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 DeleteProcedureDescriptor extends ProcedureDescriptor 35 implements Serializable , XmlCapable 36 { 37 private static final long serialVersionUID = -1265854095889157172L; 38 44 private boolean includePkFieldsOnly; 45 46 48 51 public DeleteProcedureDescriptor(ClassDescriptor classDescriptor, 52 String name, boolean includePkFieldsOnly) 53 { 54 super(classDescriptor, name); 55 if (includePkFieldsOnly) 56 { 57 addArguments(getClassDescriptor().getPkFields()); 58 addArguments(getClassDescriptor().getLockingFields()); 59 } 60 this.includePkFieldsOnly = includePkFieldsOnly; 61 } 62 63 72 public boolean getIncludePkFieldsOnly() 73 { 74 return this.includePkFieldsOnly; 75 } 76 77 85 public final void addArgument(ArgumentDescriptor argument) 86 { 87 if (!this.getIncludePkFieldsOnly()) 88 { 89 super.addArgument(argument); 90 } 91 } 92 93 96 public String toXML() 97 { 98 RepositoryTags tags = RepositoryTags.getInstance(); 99 String eol = System.getProperty( "line.separator" ); 100 101 StringBuffer result = new StringBuffer ( 1024 ); 103 result.append( eol ); 104 result.append( " " ); 105 106 result.append( " " ); 108 result.append( tags.getOpeningTagNonClosingById( DELETE_PROCEDURE ) ); 109 result.append( " " ); 110 result.append( tags.getAttribute( NAME, this.getName() ) ); 111 if( this.hasReturnValue() ) 112 { 113 result.append( " " ); 114 result.append( tags.getAttribute( RETURN_FIELD_REF, this.getReturnValueFieldRefName() ) ); 115 } 116 result.append( " " ); 117 result.append( tags.getAttribute( INCLUDE_PK_FIELDS_ONLY, String.valueOf( this.getIncludePkFieldsOnly() ) ) ); 118 result.append( ">" ); 119 result.append( eol ); 120 121 if( !this.getIncludePkFieldsOnly() ) 123 { 124 Iterator args = this.getArguments().iterator(); 125 while( args.hasNext() ) 126 { 127 result.append( ( ( ArgumentDescriptor ) args.next() ).toXML() ); 128 } 129 } 130 131 result.append( " " ); 133 result.append( tags.getClosingTagById( DELETE_PROCEDURE ) ); 134 result.append( eol ); 135 return result.toString(); 136 } 137 138 144 public String toString() 145 { 146 ToStringBuilder buf = new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE); 147 buf.append("name", this.getName()); 148 buf.append("includePkFieldsOnly", this.getIncludePkFieldsOnly()); 149 if (this.hasReturnValue()) 150 { 151 buf.append("returnFieldRefName", this.getReturnValueFieldRefName()); 152 } 153 return buf.toString(); 154 } 155 } 156 | Popular Tags |