org.qtitools.qti.value
Class ListValue

java.lang.Object
  extended by org.qtitools.qti.value.ListValue
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<SingleValue>, MultiValue, Value
Direct Known Subclasses:
MultipleValue, OrderedValue

public abstract class ListValue
extends java.lang.Object
implements java.lang.Cloneable, MultiValue, java.lang.Iterable<SingleValue>

Superclass for multiple and ordered containers.

This container can contain 0..N non NULL single values of the same BaseType.

This container can be multiple, ordered or NULL (if empty).

Author:
Jiri Kajaba
See Also:
Cardinality, BaseType, Serialized Form

Field Summary
protected  java.util.List<SingleValue> container
          Container for single values.
 
Constructor Summary
ListValue()
          Constructs empty (NULL) ListValue container.
ListValue(SingleValue value)
          Constructs empty (NULL) ListValue container and adds given SingleValue into it.
ListValue(SingleValue[] values)
          Constructs empty (NULL) ListValue container and adds all given SingleValues into it.
 
Method Summary
 boolean add(SingleValue value)
          Adds SingleValue into this container.
 java.lang.Object clone()
           
 boolean contains(SingleValue value)
          Returns true if this container contains given SingleValue; false otherwise.
 int count(SingleValue value)
          Returns number of occurrences of given SingleValue.
 SingleValue get(int index)
          Returns SingleValue on given index.
 java.util.List<SingleValue> getAll()
          Returns a list of SingleValues.
 BaseType getBaseType()
          Returns baseType of this value.
 int hashCode()
           
 boolean isNull()
          Returns true if this value is NULL or false otherwise.
abstract  boolean isOrdered()
          Returns true if this container is ordered; false otherwise.
 java.util.Iterator<SingleValue> iterator()
           
 boolean removeAll(SingleValue value)
          Removes all occurrences of given SingleValue from this container.
 int size()
          Returns number of values in this value.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.qtitools.qti.value.Value
getCardinality
 

Field Detail

container

protected java.util.List<SingleValue> container
Container for single values.

Constructor Detail

ListValue

public ListValue()
Constructs empty (NULL) ListValue container.


ListValue

public ListValue(SingleValue value)
Constructs empty (NULL) ListValue container and adds given SingleValue into it.

Parameters:
value - added SingleValue

ListValue

public ListValue(SingleValue[] values)
Constructs empty (NULL) ListValue container and adds all given SingleValues into it.

Parameters:
values - added SingleValues
Method Detail

iterator

public java.util.Iterator<SingleValue> iterator()
Specified by:
iterator in interface java.lang.Iterable<SingleValue>

isNull

public boolean isNull()
Description copied from interface: Value
Returns true if this value is NULL or false otherwise.

Specified by:
isNull in interface Value
Returns:
true if this value is NULL or false otherwise

getBaseType

public BaseType getBaseType()
Description copied from interface: Value
Returns baseType of this value.

If value is NULL or record cardinality returns null.

Specified by:
getBaseType in interface Value
Returns:
baseType of this value

size

public int size()
Description copied from interface: MultiValue
Returns number of values in this value.

Specified by:
size in interface MultiValue
Returns:
number of values in this value

isOrdered

public abstract boolean isOrdered()
Returns true if this container is ordered; false otherwise.

Returns:
true if this container is ordered; false otherwise

contains

public boolean contains(SingleValue value)
Returns true if this container contains given SingleValue; false otherwise.

Parameters:
value - given SingleValue
Returns:
true if this container contains given SingleValue; false otherwise

count

public int count(SingleValue value)
Returns number of occurrences of given SingleValue.

Parameters:
value - given SingleValue
Returns:
number of occurrences of given SingleValue

get

public SingleValue get(int index)
Returns SingleValue on given index.

Parameters:
index - given index
Returns:
SingleValue on given index

getAll

public java.util.List<SingleValue> getAll()
Returns a list of SingleValues.

Returns:
list of SingleValues.

add

public boolean add(SingleValue value)
            throws QTIBaseTypeException
Adds SingleValue into this container.

This container can contain only values of the same BaseType.

NULL SingleValue is ignored.

Parameters:
value - added SingleValue
Returns:
true if value was added; false otherwise
Throws:
QTIBaseTypeException - if BaseType is not same

removeAll

public boolean removeAll(SingleValue value)
Removes all occurrences of given SingleValue from this container.

Parameters:
value - given SingleValue
Returns:
true if value was removed (container contained this value); false otherwise

clone

public java.lang.Object clone()
                       throws QTIEvaluationException
Overrides:
clone in class java.lang.Object
Throws:
QTIEvaluationException

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2009. All Rights Reserved.