ProgramixGenericLib v5.0.1

com.programix.value
Class ValueFactory

java.lang.Object
  extended by com.programix.value.ValueFactory

public class ValueFactory
extends Object

Used to create instances classes that implement the Value interface. All implementations returned are Serializable, as long as the Object passed in is also Serializable.


Field Summary
static Value NULL_INSTANCE
          A fixed, shareable Value that represents an internal value of null.
static Value ZERO_LEN_STRING_INSTANCE
          A fixed, shareable Value that represents an internal value of a zero-length String.
 
Method Summary
static Value create(BigDecimal value)
          Creates a instance encapsulating the specified value.
static Value create(byte[] data)
          Creates a instance encapsulating the specified byte[] value.
static Value create(DateTime dateTime)
          Creates a instance encapsulating the specified DateTime value.
static Value create(double value)
          Creates a new Value encapsulating the specified double value.
static Value create(int value)
          Creates a new Value encapsulating the specified int value.
static Value create(long value)
          Creates a new Value encapsulating the specified long value.
static Value create(Number value)
          Creates a instance encapsulating the specified value.
static Value create(Object value)
          Creates a instance encapsulating the specified value.
static Value create(PlainDate plainDate)
          Creates a instance encapsulating the specified PlainDate value.
static Value create(String rawString)
          Creates a instance encapsulating the specified String value.
static Value create(String rawString, String trimmedString)
          Creates a instance encapsulating the specified String value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NULL_INSTANCE

public static final Value NULL_INSTANCE
A fixed, shareable Value that represents an internal value of null. Specifically, results of calling these methods on Value are:


ZERO_LEN_STRING_INSTANCE

public static final Value ZERO_LEN_STRING_INSTANCE
A fixed, shareable Value that represents an internal value of a zero-length String. Specifically, results of calling these methods on Value are:

Method Detail

create

public static Value create(Object value)
Creates a instance encapsulating the specified value. Internally, this method will re-direct the create request to another of the create methods on ValueFactory if the type matches one of those method's parameter better. If you do know the type more specifically than Object, it is a little more efficient to call one of the other create methods directly.

Parameters:
value - the value to be encapsulated.
Returns:
the Value. NULL_INSTANCE is returned if the passed parameter is null.

create

public static Value create(String rawString)
Creates a instance encapsulating the specified String value. The "trimmed" version of the "raw" String is calculated.

Equivalent to:

 return create(rawString, null);
 

Parameters:
rawString - the String to be encapsulated.
Returns:
the Value. NULL_INSTANCE is returned if the passed parameter is null. ZERO_LEN_STRING_INSTANCE is returned if the passed parameter is a String with a length of zero.

create

public static Value create(String rawString,
                           String trimmedString)
Creates a instance encapsulating the specified String value. This method accepts the "trimmed" version of the "raw" String, if known (if not known, use the create(String rawString) method instead). For an explanation of "trimmed" and "raw", see the getString() and the getRawString() methods on Value.

Parameters:
rawString - the value to be encapsulated.
trimmedString - the rawString with leading and trailing whitespace removed, or null if the trimmed version should be calculated from rawString.
Returns:
the Value. NULL_INSTANCE is returned if the passed parameter rawString is null. ZERO_LEN_STRING_INSTANCE is returned if the passed parameter rawString is a String with a length of zero.

create

public static Value create(Number value)
Creates a instance encapsulating the specified value.

Parameters:
value - the value to be encapsulated.
Returns:
the Value. NULL_INSTANCE is returned if the passed parameter is null.

create

public static Value create(BigDecimal value)
Creates a instance encapsulating the specified value.

Parameters:
value - the value to be encapsulated.
Returns:
the Value. NULL_INSTANCE is returned if the passed parameter is null.

create

public static Value create(int value)
Creates a new Value encapsulating the specified int value.


create

public static Value create(long value)
Creates a new Value encapsulating the specified long value.


create

public static Value create(double value)
Creates a new Value encapsulating the specified double value.


create

public static Value create(DateTime dateTime)
Creates a instance encapsulating the specified DateTime value.

Parameters:
dateTime - the value to be encapsulated.
Returns:
the Value. NULL_INSTANCE is returned if the passed parameter is null.

create

public static Value create(PlainDate plainDate)
Creates a instance encapsulating the specified PlainDate value.

Parameters:
plainDate - the value to be encapsulated.
Returns:
the Value. NULL_INSTANCE is returned if the passed parameter is null.

create

public static Value create(byte[] data)
Creates a instance encapsulating the specified byte[] value.

Parameters:
data - the value to be encapsulated.
Returns:
the Value. NULL_INSTANCE is returned if the passed parameter is null.

ProgramixGenericLib v5.0.1

Copyright © 2001-2009 Programix Incorporated. All rights reserved. ProgramixGenericLib is free and is OSI Certified Open Source Software under the BSD license.