/** * Returns a string representation of the object. * * @return a string representation of the object. */ public String toString() { return super.toString() + this.internalString(); }
final Element xml ) final Argument arg = new Argument(); arg.setModelVersion( modelVersion ); arg.setName( xml.getAttributeNS( namespace, "name" ) ); arg.setIndex( Integer.valueOf( xml.getAttributeNS( namespace, "index" ) ). intValue() ); if ( type.equalsIgnoreCase( "number" ) ) arg.setType( Argument.TYPE_NUMBER ); arg.setType( Argument.TYPE_DATE ); arg.setType( Argument.TYPE_TIME ); arg.setType( Argument.TYPE_TEXT );
/** * Setter for property {@code arguments}. * * @param value the new arguments for the instance. * * @throws DuplicateArgumentException if {@code value} contains * duplicate arguments. */ public void setArguments( final Argument[] value ) { this.names.clear(); this.hashCode = 0; this.arguments = null; if ( value != null ) { for ( int i = 0; i < value.length; i++ ) { this.hashCode += value[i].hashCode(); if ( this.names.put( value[i].getName(), value[i] ) != null ) { this.names.clear(); this.hashCode = 0; throw new DuplicateArgumentException( value[i].getName() ); } } this.arguments = value; } }
/** * Creates and returns a deep copy of this object. * * @return a clone of this instance. */ public Object clone() { try { final Arguments ret = (Arguments) super.clone(); final Argument[] args = this.getArguments(); final Argument[] cloned = new Argument[ args.length ]; for ( int i = args.length - 1; i >= 0; i-- ) { cloned[i] = (Argument) args[i].clone(); } ret.setArguments( cloned ); return ret; } catch ( final CloneNotSupportedException e ) { throw new AssertionError( e ); } }
/** * Indicates whether some other object is equal to this one by comparing * the values of all properties. * * @param o the reference object with which to compare. * * @return {@code true} if this object is the same as {@code o}; * {@code false} otherwise. */ public boolean equals( final Object o ) { boolean equal = this == o; if ( !equal && o instanceof Argument ) { final Argument that = (Argument) o; equal = this.getIndex() == that.getIndex() && this.getType() == that.getType() && this.getName().equals( that.getName() ); } return equal; }
/** * Creates a string representing the properties of the instance. * * @return a string representing the properties of the instance. */ private String internalString() { final StringBuffer buf = new StringBuffer( 500 ).append( '{' ). append( this.internalString( this ) ). append( ", index=" ).append( this.index ). append( ", name=" ).append( this.name ). append( ", type=" ); if ( this.type == TYPE_NUMBER ) { buf.append( "number" ); } else if ( this.type == TYPE_DATE ) { buf.append( "date" ); } else if ( this.type == TYPE_TIME ) { buf.append( "time" ); } else if ( this.type == TYPE_TEXT ) { buf.append( "text" ); } return buf.append( '}' ).toString(); }