org.xins.common.types
Class List

java.lang.Object
  extended byorg.xins.common.types.Type
      extended byorg.xins.common.types.List
Direct Known Subclasses:
List, Set

public abstract class List
extends Type

Abstract base class for list types.

Since:
XINS 1.0.0
Version:
$Revision: 1.29 $ $Date: 2008/07/04 10:22:40 $
Author:
Anthony Goubard

Constructor Summary
protected List(String name, Type itemType)
          Constructs a new List object (constructor for subclasses).
 
Method Summary
abstract  ItemList createList()
          Creates a new ItemList.
protected  Object fromStringImpl(String string)
          Converts from a String to an instance of the value class for this type (implementation method).
protected  boolean isValidValueImpl(String string)
          Determines if the specified String value is considered valid for this type (implementation method).
 String toString(ItemList value)
          Converts the specified ItemList to a string.
 String toString(Object value)
          Generates a string representation of the specified value for this type.
 
Methods inherited from class org.xins.common.types.Type
checkValue, fromString, getDescription, getName, getValueClass, isValidValue, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

List

protected List(String name,
               Type itemType)
Constructs a new List object (constructor for subclasses).

Parameters:
name - the name of this type, cannot be null.
itemType - the type for the values, or null if Text should be assumed.
Method Detail

isValidValueImpl

protected final boolean isValidValueImpl(String string)
Determines if the specified String value is considered valid for this type (implementation method).

This method is called from Type.isValidValue(String). When called from that method, it is guaranteed that the argument is not null.

Overrides:
isValidValueImpl in class Type
Parameters:
string - the String value that should be checked for validity, never null.
Returns:
true if and only if the specified String value is valid, false otherwise.

fromStringImpl

protected final Object fromStringImpl(String string)
                               throws TypeValueException
Converts from a String to an instance of the value class for this type (implementation method).

This method is not required to check the validity of the specified value (since isValidValueImpl(String) should have been called before) but if it does, then it may throw a TypeValueException.

Specified by:
fromStringImpl in class Type
Parameters:
string - the string to convert to an instance of the value class, guaranteed to be not null and guaranteed to have been passed to isValidValueImpl(String) without getting an exception.
Returns:
an instance of the value class, cannot be null.
Throws:
TypeValueException - if string is considered to be an invalid value for this type.

createList

public abstract ItemList createList()
Creates a new ItemList.

Returns:
the new list created, never null.

toString

public String toString(ItemList value)
Converts the specified ItemList to a string.

Parameters:
value - the value to convert, can be null.
Returns:
the textual representation of the value, or null if and only if value == null.

toString

public final String toString(Object value)
                      throws IllegalArgumentException,
                             ClassCastException,
                             TypeValueException
Generates a string representation of the specified value for this type. The specified value must be an instance of the value class for this type (see Type.getValueClass()). Also, it may have to fall within a certain range of valid values, depending on the type.

Overrides:
toString in class Type
Parameters:
value - the value, cannot be null.
Returns:
the string representation of the specified value for this type, cannot be null.
Throws:
IllegalArgumentException - if value == null.
ClassCastException - if getValueClass().isInstance(value) == false.
TypeValueException - if the specified value is not in the allowed range.


See http://www.xins.org/.