1 package org.apache.ojb.broker.metadata; 2 3 17 18 import org.apache.commons.lang.builder.ToStringBuilder; 19 import org.apache.commons.lang.builder.ToStringStyle; 20 import java.io.Serializable ; 21 import java.util.Iterator ; 22 23 34 public class UpdateProcedureDescriptor 35 extends ProcedureDescriptor 36 implements Serializable , XmlCapable 37 { 38 private static final long serialVersionUID = 1319547080310130251L; 39 40 45 private boolean includeAllFields; 46 47 51 public UpdateProcedureDescriptor( 52 ClassDescriptor classDescriptor, 53 String name, 54 boolean includeAllFields) 55 { 56 super(classDescriptor, name); 57 if (includeAllFields) 58 { 59 this.addArguments(this.getClassDescriptor().getFieldDescriptions()); 60 } 61 this.includeAllFields = includeAllFields; 62 } 63 64 72 public boolean getIncludeAllFields() 73 { 74 return this.includeAllFields; 75 } 76 77 84 public final void addArgument(ArgumentDescriptor argument) 85 { 86 if (!this.getIncludeAllFields()) 87 { 88 super.addArgument(argument); 89 } 90 } 91 92 95 public String toXML() 96 { 97 RepositoryTags tags = RepositoryTags.getInstance(); 98 String eol = System.getProperty("line.separator"); 99 100 StringBuffer result = new StringBuffer (1024); 102 result.append(eol); 103 result.append(" "); 104 105 result.append(" "); 107 result.append(tags.getOpeningTagNonClosingById(UPDATE_PROCEDURE)); 108 result.append(" "); 109 result.append(tags.getAttribute(NAME, this.getName()) ); 110 if (this.hasReturnValue()) 111 { 112 result.append(" "); 113 result.append(tags.getAttribute(RETURN_FIELD_REF, this.getReturnValueFieldRefName()) ); 114 } 115 result.append(" "); 116 result.append(tags.getAttribute(INCLUDE_ALL_FIELDS, String.valueOf(this.getIncludeAllFields())) ); 117 result.append(">"); 118 result.append(eol); 119 120 if (!this.getIncludeAllFields()) 122 { 123 Iterator args = this.getArguments().iterator(); 124 while (args.hasNext()) 125 { 126 result.append(((ArgumentDescriptor) args.next()).toXML()); 127 } 128 } 129 130 result.append(" "); 132 result.append(tags.getClosingTagById(UPDATE_PROCEDURE)); 133 result.append(eol); 134 return result.toString(); 135 } 136 137 143 public String toString() 144 { 145 ToStringBuilder buf = new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE); 146 buf.append("name", this.getName()); 147 buf.append("includeAllFields", this.getIncludeAllFields()); 148 if (this.hasReturnValue()) 149 { 150 buf.append("returnFieldRefName", this.getReturnValueFieldRefName()); 151 } 152 return buf.toString(); 153 } 154 } 155 | Popular Tags |