1 package org.apache.ojb.broker.metadata; 2 3 17 18 import java.io.Serializable ; 19 import java.util.ArrayList ; 20 import java.util.Collection ; 21 import java.util.Iterator ; 22 23 34 public abstract class ProcedureDescriptor extends DescriptorBase implements Serializable 35 { 36 private static final long serialVersionUID = -8228331122289787173L; 37 41 private String name; 42 43 47 private FieldDescriptor returnValueFieldRef; 48 49 53 private ClassDescriptor classDescriptor; 54 55 59 private ArrayList arguments = new ArrayList (); 60 61 65 public ProcedureDescriptor(ClassDescriptor classDescriptor, String name) 66 { 67 this.classDescriptor = classDescriptor; 68 this.name = name; 69 } 70 71 77 public final String getName() 78 { 79 return this.name; 80 } 81 82 90 public final void setReturnValueFieldRef(String fieldName) 91 { 92 this.returnValueFieldRef = this.getClassDescriptor().getFieldDescriptorByName(fieldName); 93 } 94 95 103 public final void setReturnValueFieldRef(FieldDescriptor fieldDescriptor) 104 { 105 this.returnValueFieldRef = fieldDescriptor; 106 } 107 108 115 public final FieldDescriptor getReturnValueFieldRef() 116 { 117 return this.returnValueFieldRef; 118 } 119 120 127 public final boolean hasReturnValue() 128 { 129 return (this.returnValueFieldRef != null); 130 } 131 132 139 public final boolean hasReturnValues() 140 { 141 if (this.hasReturnValue()) 142 { 143 return true; 144 } 145 else 146 { 147 Iterator iter = this.getArguments().iterator(); 153 while (iter.hasNext()) 154 { 155 ArgumentDescriptor arg = (ArgumentDescriptor) iter.next(); 156 if (arg.getIsReturnedByProcedure()) 157 { 158 return true; 159 } 160 } 161 } 162 return false; 163 } 164 165 172 public final String getReturnValueFieldRefName() 173 { 174 if (this.returnValueFieldRef == null) 175 { 176 return null; 177 } 178 else 179 { 180 return this.returnValueFieldRef.getAttributeName(); 181 } 182 } 183 184 190 public final ClassDescriptor getClassDescriptor() 191 { 192 return this.classDescriptor; 193 } 194 195 198 public abstract String toXML(); 199 200 204 protected void addArgument(ArgumentDescriptor argument) 205 { 206 this.arguments.add(argument); 207 } 208 209 213 protected void addArguments(FieldDescriptor field[]) 214 { 215 for (int i = 0; i < field.length; i++) 216 { 217 ArgumentDescriptor arg = new ArgumentDescriptor(this); 218 arg.setValue(field[i].getAttributeName(), false); 219 this.addArgument(arg); 220 } 221 } 222 223 227 public final Collection getArguments() 228 { 229 return this.arguments; 230 } 231 232 240 public final int getArgumentCount() 241 { 242 return this.arguments.size(); 243 } 244 } 245 | Popular Tags |