Coverage Report - org.apache.commons.clazz.reflect.common.ReflectedListProperty
 
Classes in this File Line Coverage Branch Coverage Complexity
ReflectedListProperty
0%
0/69
0%
0/22
1.5
 
 1  
 /*
 2  
  * Copyright 2002-2004 The Apache Software Foundation
 3  
  *
 4  
  * Licensed under the Apache License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  *     http://www.apache.org/licenses/LICENSE-2.0
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package org.apache.commons.clazz.reflect.common;
 17  
 
 18  
 import java.lang.reflect.Method;
 19  
 
 20  
 import org.apache.commons.clazz.Clazz;
 21  
 
 22  
 /**
 23  
  * 
 24  
  * @author <a href="mailto:dmitri@apache.org">Dmitri Plotnikov</a>
 25  
  * @version $Id: ReflectedListProperty.java 155436 2005-02-26 13:17:48Z dirkv $
 26  
  */
 27  
 public class ReflectedListProperty extends ReflectedAccessorPairProperty {
 28  
 
 29  
     private Class contentType;
 30  
     private Method sizeMethod;
 31  
     private Method getMethod;
 32  
     private Method addMethod;
 33  
     private Method addIndexedMethod;
 34  
     private Method setMethod;
 35  
     private Method removeMethod;
 36  
     private Method removeIndexedMethod;
 37  
     
 38  
     /**
 39  
      * Constructor for ReflectedListProperty.
 40  
      * @param declaringClazz
 41  
      * @param name
 42  
      */
 43  
     public ReflectedListProperty(Clazz declaringClazz, String name) {
 44  0
         super(declaringClazz, name);
 45  0
     }
 46  
     
 47  
     /**
 48  
      * @see org.apache.commons.clazz.ClazzProperty#isCollection()
 49  
      */
 50  
     public boolean isCollection() {
 51  0
         return true;
 52  
     }
 53  
 
 54  
     /**
 55  
      * Returns the contentType.
 56  
      * @return Class
 57  
      */
 58  
     public Class getContentType() {
 59  0
         return contentType;
 60  
     }
 61  
 
 62  
     /**
 63  
      * Sets the contentType.
 64  
      * @param contentType The contentType to set
 65  
      */
 66  
     public void setContentType(Class valueType) {
 67  0
         this.contentType = valueType;
 68  0
     }
 69  
     
 70  
     /**
 71  
      * Returns the getMethod.
 72  
      * @return Method
 73  
      */
 74  
     public Method getGetMethod() {
 75  0
         return getMethod;
 76  
     }
 77  
 
 78  
     /**
 79  
      * Sets the getMethod.
 80  
      * @param getMethod The getMethod to set
 81  
      */
 82  
     public void setGetMethod(Method getMethod) {
 83  0
         this.getMethod = getMethod;
 84  0
     }
 85  
     
 86  
    /**
 87  
      * Returns the setMethod.
 88  
      * @return Method
 89  
      */
 90  
     public Method getSetMethod() {
 91  0
         return setMethod;
 92  
     }
 93  
 
 94  
     /**
 95  
      * Sets the setMethod.
 96  
      * @param setMethod The setMethod to set
 97  
      */
 98  
     public void setSetMethod(Method setMethod) {
 99  0
         this.setMethod = setMethod;
 100  0
     }
 101  
 
 102  
     /**
 103  
      * Returns the addMethod.
 104  
      * @return Method
 105  
      */
 106  
     public Method getAddMethod() {
 107  0
         return addMethod;
 108  
     }
 109  
 
 110  
     /**
 111  
      * Sets the addMethod.
 112  
      * @param addMethod The addMethod to set
 113  
      */
 114  
     public void setAddMethod(Method addMethod) {
 115  0
         this.addMethod = addMethod;
 116  0
     }
 117  
 
 118  
     /**
 119  
      * Returns the addIndexedMethod.
 120  
      * @return Method
 121  
      */
 122  
     public Method getAddIndexedMethod() {
 123  0
         return addIndexedMethod;
 124  
     }
 125  
 
 126  
     /**
 127  
      * Sets the addIndexedMethod.
 128  
      * @param addIndexedMethod The addIndexedMethod to set
 129  
      */
 130  
     public void setAddIndexedMethod(Method addIndexedMethod) {
 131  0
         this.addIndexedMethod = addIndexedMethod;
 132  0
     }
 133  
 
 134  
     /**
 135  
      * Returns the removeMethod.
 136  
      * @return Method
 137  
      */
 138  
     public Method getRemoveMethod() {
 139  0
         return removeMethod;
 140  
     }
 141  
 
 142  
     /**
 143  
      * Sets the removeMethod.
 144  
      * @param removeMethod The removeMethod to set
 145  
      */
 146  
     public void setRemoveMethod(Method removeMethod) {
 147  0
         this.removeMethod = removeMethod;
 148  0
     }
 149  
 
 150  
     /**
 151  
      * Returns the removeIndexedMethod.
 152  
      * @return Method
 153  
      */
 154  
     public Method getRemoveIndexedMethod() {
 155  0
         return removeIndexedMethod;
 156  
     }
 157  
 
 158  
     /**
 159  
      * Sets the removeIndexedMethod.
 160  
      * @param removeIndexedMethod The removeIndexedMethod to set
 161  
      */
 162  
     public void setRemoveIndexedMethod(Method removeIndexedMethod) {
 163  0
         this.removeIndexedMethod = removeIndexedMethod;
 164  0
     }
 165  
 
 166  
     /**
 167  
      * Returns the sizeMethod.
 168  
      * @return Method
 169  
      */
 170  
     public Method getSizeMethod() {
 171  0
         return sizeMethod;
 172  
     }
 173  
 
 174  
     /**
 175  
      * Sets the sizeMethod.
 176  
      * @param sizeMethod The sizeMethod to set
 177  
      */
 178  
     public void setSizeMethod(Method sizeMethod) {
 179  0
         this.sizeMethod = sizeMethod;
 180  0
     }
 181  
 
 182  
     public String toString() {
 183  0
         StringBuffer buffer = new StringBuffer("[ReflectedListProperty ");
 184  0
         if (getType() != null) {
 185  0
             buffer.append(getType().getName());
 186  0
             buffer.append(" ");
 187  
         }
 188  0
         if (getContentType() != null) {
 189  0
             buffer.append("[content: ");
 190  0
             buffer.append(getContentType().getName());
 191  0
             buffer.append("] ");
 192  
         }
 193  0
         buffer.append(getName());
 194  0
         if (getReadMethod() != null) {
 195  0
             buffer.append("\n   [read method]      ");
 196  0
             buffer.append(getReadMethod());            
 197  
         }
 198  0
         if (getWriteMethod() != null) {
 199  0
             buffer.append("\n   [write method]     ");
 200  0
             buffer.append(getWriteMethod());            
 201  
         }
 202  0
         if (getGetMethod() != null) {
 203  0
             buffer.append("\n   [get method]       ");
 204  0
             buffer.append(getGetMethod());            
 205  
         }
 206  0
         if (getSetMethod() != null) {
 207  0
             buffer.append("\n   [set method]       ");
 208  0
             buffer.append(getSetMethod());            
 209  
         }
 210  0
         if (getAddMethod() != null) {
 211  0
             buffer.append("\n   [add method]       ");
 212  0
             buffer.append(getAddMethod());            
 213  
         }
 214  0
         if (getAddIndexedMethod() != null) {
 215  0
             buffer.append("\n   [add(i) method]    ");
 216  0
             buffer.append(getAddIndexedMethod());            
 217  
         }
 218  0
         if (getRemoveMethod() != null) {
 219  0
             buffer.append("\n   [remove method]    ");
 220  0
             buffer.append(getRemoveMethod());            
 221  
         }
 222  0
         if (getRemoveIndexedMethod() != null) {
 223  0
             buffer.append("\n   [remove(i) method] ");
 224  0
             buffer.append(getRemoveIndexedMethod());
 225  
         }
 226  0
         if (getSizeMethod() != null) {
 227  0
             buffer.append("\n   [size method]      ");
 228  0
             buffer.append(getSizeMethod());            
 229  
         }
 230  0
         buffer.append("]");
 231  0
         return buffer.toString();
 232  
     }
 233  
     /**
 234  
      * @see org.apache.commons.clazz.ClazzProperty#get(java.lang.Object)
 235  
      */
 236  
     public Object get(Object instance) {
 237  0
         return new ReflectedList(instance, this);
 238  
     }
 239  
     
 240  
     public Object getList(Object instance) {
 241  0
         return super.get(instance);
 242  
     }
 243  
 
 244  
     /**
 245  
      * @see org.apache.commons.clazz.ClazzProperty#set(Object, Object)
 246  
      */
 247  
     public void set(Object instance, Object value) {
 248  0
         super.set(instance, value);
 249  0
     }
 250  
 }