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 InsertProcedureDescriptor 35 extends ProcedureDescriptor 36 implements Serializable , XmlCapable 37 { 38 private static final long serialVersionUID = -3808311052971075269L; 39 44 private boolean includeAllFields; 45 46 50 public InsertProcedureDescriptor( 51 ClassDescriptor classDescriptor, 52 String name, 53 boolean includeAllFields) 54 { 55 super(classDescriptor, name); 56 if (includeAllFields) 57 { 58 this.addArguments(this.getClassDescriptor().getFieldDescriptions()); 59 } 60 this.includeAllFields = includeAllFields; 61 } 62 63 71 public boolean getIncludeAllFields() 72 { 73 return this.includeAllFields; 74 } 75 76 83 public final void addArgument(ArgumentDescriptor argument) 84 { 85 if (!this.getIncludeAllFields()) 86 { 87 super.addArgument(argument); 88 } 89 } 90 91 94 public String toXML() 95 { 96 RepositoryTags tags = RepositoryTags.getInstance(); 97 String eol = System.getProperty( "line.separator" ); 98 99 StringBuffer result = new StringBuffer ( 1024 ); 101 result.append( eol ); 102 result.append( " " ); 103 104 result.append( " " ); 106 result.append( tags.getOpeningTagNonClosingById( INSERT_PROCEDURE ) ); 107 result.append( " " ); 108 result.append( tags.getAttribute( NAME, this.getName() ) ); 109 if( this.hasReturnValue() ) 110 { 111 result.append( " " ); 112 result.append( tags.getAttribute( RETURN_FIELD_REF, this.getReturnValueFieldRefName() ) ); 113 } 114 result.append( " " ); 115 result.append( tags.getAttribute( INCLUDE_ALL_FIELDS, String.valueOf( this.getIncludeAllFields() ) ) ); 116 result.append( ">" ); 117 result.append( eol ); 118 119 if( !this.getIncludeAllFields() ) 121 { 122 Iterator args = this.getArguments().iterator(); 123 while( args.hasNext() ) 124 { 125 result.append( ( ( ArgumentDescriptor ) args.next() ).toXML() ); 126 } 127 } 128 129 result.append( " " ); 131 result.append( tags.getClosingTagById( INSERT_PROCEDURE ) ); 132 result.append( eol ); 133 return result.toString(); 134 } 135 136 142 public String toString() 143 { 144 ToStringBuilder buf = new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE); 145 buf.append("name", this.getName()); 146 buf.append("includeAllFields", this.getIncludeAllFields()); 147 if (this.hasReturnValue()) 148 { 149 buf.append("returnFieldRefName", this.getReturnValueFieldRefName()); 150 } 151 return buf.toString(); 152 } 153 } 154 | Popular Tags |