private ValueInterface getValueCopy() { if ( value == null ) { return null; } return (ValueInterface) value.clone(); }
/** * Get the length of this Value. * * @return the length of this Value. */ public int getLength() { if ( value == null ) { return -1; } return value.getLength(); }
/** * get the precision of this Value * * @return the precision of this Value. */ public int getPrecision() { if ( value == null ) { return -1; } return value.getPrecision(); }
/** * Get the Serializable of this Value. If the Value is not of type Serializable, it returns null. * * @return the Serializable of this Value. */ public Serializable getSerializable() { if ( value == null || isNull() || value.getType() != VALUE_TYPE_SERIALIZABLE ) { return null; } return value.getSerializable(); }
switch ( valType ) { case VALUE_TYPE_NUMBER: value = new ValueNumber( value.getNumber() ); break; case VALUE_TYPE_STRING: value = new ValueString( value.getString() ); break; case VALUE_TYPE_DATE: value = new ValueDate( value.getDate() ); break; case VALUE_TYPE_BOOLEAN: value = new ValueBoolean( value.getBoolean() ); break; case VALUE_TYPE_INTEGER: value = new ValueInteger( value.getInteger() ); break; case VALUE_TYPE_BIGNUMBER: value = new ValueBigNumber( value.getBigNumber() ); break; case VALUE_TYPE_BINARY: value = new ValueBinary( value.getBytes() ); break; default:
if ( value.getLength() < 1 ) { if ( isNull() ) { retval = Const.NULL_NUMBER; retval = form.format( value.getNumber() ); Const.rightPad( ret, value.getLength() ); retval = ret.toString(); } else { if ( value.getNumber() >= 0 ) { fmt.append( ' ' ); // to compensate for minus sign. if ( value.getPrecision() < 0 ) { // Default: two decimals for ( i = 0; i < value.getLength(); i++ ) { fmt.append( '0' ); for ( i = 0; i <= value.getLength(); i++ ) { fmt.append( '0' ); // all zeroes. int pos = value.getLength() - value.getPrecision() + 1 - ( value.getNumber() < 0 ? 1 : 0 ); if ( pos >= 0 && pos < fmt.length() ) { value.getLength() - value.getPrecision() + 1 - ( value.getNumber() < 0 ? 1 : 0 ), '.' ); retval = form.format( value.getNumber() ); retval = Const.NULL_NUMBER;
/** * Converts a BigNumber value to a String, optionally padding the result to the specified length. * * @param pad * true if you want to pad the resulting string to length. * @return a String optionally padded to the specified length. */ private String toStringBigNumber() { if ( value == null ) { return null; } String retval; if ( isNull() ) { retval = Const.NULL_BIGNUMBER; } else { if ( value.getBigNumber() == null ) { retval = null; } else { retval = value.getString(); // Localise . to , if ( Const.DEFAULT_DECIMAL_SEPARATOR != '.' ) { retval = retval.replace( '.', Const.DEFAULT_DECIMAL_SEPARATOR ); } } } return retval; }
if ( value.getLength() <= 0 ) { if ( isNull() || value.getString() == null ) { retval = Const.NULL_STRING; } else { retval = value.getString(); StringBuilder ret = null; if ( isNull() || value.getString() == null ) { ret = new StringBuilder( Const.NULL_STRING ); } else { ret = new StringBuilder( value.getString() ); int length = value.getLength(); if ( length > 16384 ) { length = 16384; // otherwise we get OUT OF MEMORY errors for CLOBS. if ( isNull() || value.getString() == null ) { retval = Const.NULL_STRING; } else { retval = value.getString();
/** * Returns a String representing the binary value. * * @return a String representing the binary value. */ private String toStringBinary() { String retval; if ( value == null ) { return null; } if ( isNull() || value.getBytes() == null ) { retval = Const.NULL_BINARY; } else { retval = new String( value.getBytes() ); } return retval; }
/** * Get the Date of this Value. If the Value is not of type DATE, a conversion is done first. * * @return the Date of this Value. */ public Date getDate() { if ( value == null || isNull() ) { return null; } return value.getDate(); }
/** * Get the long integer representation of this value. If the Value is not of type INTEGER, it will be converted: * <p> * String: try to convert to a long value, 0L if it didn't work. * <p> * Number: round the double value and return the resulting long integer. * <p> * Date: return the number of miliseconds after <code>1970:01:01 00:00:00</code> * <p> * Date: always false. * * @return the long integer representation of this value. */ public long getInteger() { if ( value == null || isNull() ) { return 0L; } return value.getInteger(); }
/** * Get the boolean value of this Value. If the Value is not of type BOOLEAN, it will be converted. * <p> * Strings: "YES", "Y", "TRUE" (case insensitive) to true, the rest false * <p> * Number: 0.0 is false, the rest is true. * <p> * Integer: 0 is false, the rest is true. * <p> * Date: always false. * * @return the boolean representation of this Value. */ public boolean getBoolean() { if ( value == null || isNull() ) { return false; } return value.getBoolean(); }
/** * Get the double precision floating point number of this Value. If the value is not of type NUMBER, a conversion is * done first. * * @return the double precision floating point number of this Value. */ public double getNumber() { if ( value == null || isNull() ) { return 0.0; } return value.getNumber(); }
/** * Get the BigDecimal number of this Value. If the value is not of type BIG_NUMBER, a conversion is done first. * * @return the double precision floating point number of this Value. */ public BigDecimal getBigNumber() { if ( value == null || isNull() ) { return null; } return value.getBigNumber(); }
public byte[] getBytes() { if ( value == null || isNull() ) { return null; } return value.getBytes(); }
/** * Converts a Date value to a String. The date has format: <code>yyyy/MM/dd HH:mm:ss.SSS</code> * * @return a String representing the Date Value. */ private String toStringDate() { String retval; if ( value == null ) { return null; } SimpleDateFormat df = new SimpleDateFormat( "yyyy/MM/dd HH:mm:ss.SSS", Locale.US ); if ( isNull() || value.getDate() == null ) { retval = Const.NULL_DATE; } else { retval = df.format( value.getDate() ).toString(); } /* * This code was removed as TYPE_VALUE_DATE does not know "length", so this could never be called anyway else { * StringBuffer ret; if (isNull() || value.getDate()==null) ret=new StringBuffer(Const.NULL_DATE); else ret=new * StringBuffer(df.format(value.getDate()).toString()); Const.rightPad(ret, getLength()<=10?10:getLength()); * retval=ret.toString(); } */ return retval; }
} else { DecimalFormat form = new DecimalFormat( " ###############0;-###############0" ); retval = form.format( value.getInteger() ); DecimalFormat form; if ( value.getInteger() >= 0 ) { fmt.append( ' ' ); // to compensate for minus sign. retval = form.format( value.getInteger() ); } else { retval = Long.toString( value.getInteger() );
/** * Returns a String representing the boolean value. It will be either "true" or "false". * * @return a String representing the boolean value. */ private String toStringBoolean() { // Code was removed from this method as ValueBoolean // did not store length, so some parts could never be // called. String retval; if ( value == null ) { return null; } if ( isNull() ) { retval = Const.NULL_BOOLEAN; } else { retval = value.getBoolean() ? "true" : "false"; } return retval; }
@Override public Object clone() { Value retval = null; try { retval = (Value) super.clone(); if ( value != null ) { retval.value = (ValueInterface) value.clone(); } } catch ( CloneNotSupportedException e ) { retval = null; } return retval; }