Coverage report

  %line %branch
org.apache.jetspeed.om.page.proxy.LinkProxy
0% 
0% 

 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one or more
 3  
  * contributor license agreements.  See the NOTICE file distributed with
 4  
  * this work for additional information regarding copyright ownership.
 5  
  * The ASF licenses this file to You under the Apache License, Version 2.0
 6  
  * (the "License"); you may not use this file except in compliance with
 7  
  * the License.  You may obtain a copy of the License at
 8  
  * 
 9  
  *      http://www.apache.org/licenses/LICENSE-2.0
 10  
  * 
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 package org.apache.jetspeed.om.page.proxy;
 18  
 
 19  
 import java.lang.reflect.InvocationHandler;
 20  
 import java.lang.reflect.Method;
 21  
 import java.lang.reflect.Proxy;
 22  
 
 23  
 import org.apache.jetspeed.om.folder.Folder;
 24  
 import org.apache.jetspeed.om.page.Link;
 25  
 import org.apache.jetspeed.page.document.proxy.NodeProxy;
 26  
 import org.apache.jetspeed.portalsite.view.SiteView;
 27  
 
 28  
 /**
 29  
  * This class proxies PSML Link instances to create a logical view
 30  
  * of site content using the Dynamic Proxy pattern.
 31  
  * 
 32  
  * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
 33  
  * @version $Id: LinkProxy.java 517121 2007-03-12 07:45:49Z ate $
 34  
  */
 35  
 public class LinkProxy extends NodeProxy implements InvocationHandler
 36  
 {
 37  
     /**
 38  
      * link - proxy delegate link instance
 39  
      */
 40  
     private Link link;
 41  
 
 42  
     /**
 43  
      * newInstance - creates a new proxy instance that implements the Link interface
 44  
      *
 45  
      * @param view site view owner of this proxy
 46  
      * @param locatorName name of profile locator associated
 47  
      *                    with the proxy delegate
 48  
      * @param parentFolder view parent proxy folder
 49  
      * @param link proxy delegate
 50  
      */
 51  
     public static Link newInstance(SiteView view, String locatorName, Folder parentFolder, Link link)
 52  
     {
 53  0
         return (Link)Proxy.newProxyInstance(link.getClass().getClassLoader(), new Class[]{Link.class}, class="keyword">new LinkProxy(view, locatorName, parentFolder, link));
 54  
     }
 55  
 
 56  
     /**
 57  
      * LinkProxy - private constructor used by newInstance()
 58  
      *
 59  
      * @param view site view owner of this proxy
 60  
      * @param locatorName name of profile locator associated
 61  
      *                    with the proxy delegate
 62  
      * @param parentFolder view parent proxy folder
 63  
      * @param link proxy delegate
 64  
      */
 65  
     private LinkProxy(SiteView view, String locatorName, Folder parentFolder, Link link)
 66  
     {
 67  0
         super(view, locatorName, parentFolder, link.getName(), link.isHidden());
 68  0
         this.link = link;
 69  0
     }
 70  
     
 71  
     /**
 72  
      * invoke - method invocation dispatch for this proxy, (defaults to
 73  
      *          invocation of delegate unless method is implemented in this
 74  
      *          proxy handler or should be hidden/stubbed)
 75  
      *
 76  
      * @param proxy instance invoked against
 77  
      * @param method Link interface method invoked
 78  
      * @param args method arguments
 79  
      * @throws Throwable
 80  
      */
 81  
     public Object invoke(Object proxy, Method m, Object [] args) throws Throwable
 82  
     {
 83  
         // proxy implementation method dispatch
 84  0
         if (m.equals(GET_PARENT_METHOD))
 85  
         {
 86  0
             return getParent();
 87  
         }
 88  0
         else if (m.equals(GET_PATH_METHOD))
 89  
         {
 90  0
             return getPath();
 91  
         }
 92  0
         else if (m.equals(EQUALS_METHOD))
 93  
         {
 94  0
             return new Boolean(equals(args[0]));
 95  
         }
 96  0
         else if (m.equals(HASH_CODE_METHOD))
 97  
         {
 98  0
             return new Integer(hashCode());
 99  
         }
 100  0
         else if (m.equals(IS_HIDDEN_METHOD))
 101  
         {
 102  0
             return new Boolean(isHidden());
 103  
         }
 104  0
         else if (m.equals(TO_STRING_METHOD))
 105  
         {
 106  0
             return toString();
 107  
         }
 108  
     
 109  
         // proxy suppression of not implemented or mutable methods
 110  0
         if (m.getName().startsWith("set"))
 111  
         {
 112  0
             throw new RuntimeException("Link instance is immutable from proxy.");
 113  
         }
 114  
 
 115  
         // attempt to invoke method on delegate Link instance
 116  0
         return m.invoke(link, args);
 117  
     }
 118  
 
 119  
     /**
 120  
      * getLink - get proxy delegate link instance
 121  
      *
 122  
      * @return delegate link
 123  
      */
 124  
     public Link getLink()
 125  
     {
 126  0
         return link;
 127  
     }
 128  
 }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.