1 22 package org.jboss.iiop.rmi; 23 24 import org.omg.CORBA.AttributeMode ; 25 26 import java.lang.reflect.Method ; 27 28 import java.rmi.Remote ; 29 30 39 public class AttributeAnalysis 40 extends AbstractAnalysis 41 { 42 44 46 48 50 53 private AttributeAnalysis(String javaName, AttributeMode mode, 54 Method accessor, Method mutator) 55 throws RMIIIOPViolationException 56 { 57 super(Util.javaToIDLName(javaName), javaName); 58 59 this.mode = mode; 60 this.cls = accessor.getReturnType(); 61 this.accessor = accessor; 62 this.mutator = mutator; 63 64 if (accessor.getDeclaringClass().isInterface() && 66 Remote .class.isAssignableFrom(accessor.getDeclaringClass())) { 67 accessorAnalysis = new OperationAnalysis(accessor); 68 if (mutator != null) 69 mutatorAnalysis = new OperationAnalysis(mutator); 70 71 setIDLName(getIDLName()); } 73 } 74 75 76 79 AttributeAnalysis(String javaName, Method accessor) 80 throws RMIIIOPViolationException 81 { 82 this(javaName, AttributeMode.ATTR_READONLY, accessor, null); 83 } 84 85 88 AttributeAnalysis(String javaName, Method accessor, Method mutator) 89 throws RMIIIOPViolationException 90 { 91 this(javaName, AttributeMode.ATTR_NORMAL, accessor, mutator); 92 } 93 94 96 99 public AttributeMode getMode() 100 { 101 return mode; 102 } 103 104 107 public Class getCls() 108 { 109 return cls; 110 } 111 112 115 public Method getAccessor() 116 { 117 return accessor; 118 } 119 120 123 public Method getMutator() 124 { 125 return mutator; 126 } 127 128 131 public OperationAnalysis getAccessorAnalysis() 132 { 133 return accessorAnalysis; 134 } 135 136 139 public OperationAnalysis getMutatorAnalysis() 140 { 141 return mutatorAnalysis; 142 } 143 144 146 148 152 void setIDLName(String idlName) 153 { 154 super.setIDLName(idlName); 155 156 if (idlName.charAt(0) >= 0x41 && idlName.charAt(0) <= 0x5a 159 && (idlName.length() <= 1 160 || idlName.charAt(1) < 0x41 || idlName.charAt(1) > 0x5a)) { 161 idlName = 162 idlName.substring(0, 1).toLowerCase() + idlName.substring(1); 163 } 164 165 if (accessorAnalysis != null) 166 accessorAnalysis.setIDLName("_get_" + idlName); 167 if (mutatorAnalysis != null) 168 mutatorAnalysis.setIDLName("_set_" + idlName); 169 } 170 171 173 176 private AttributeMode mode; 177 178 181 private Class cls; 182 183 186 private Method accessor = null; 187 188 192 private Method mutator = null; 193 194 197 private OperationAnalysis accessorAnalysis = null; 198 199 203 private OperationAnalysis mutatorAnalysis = null; 204 205 } 206 207 | Popular Tags |