org.sapia.archie.impl
Class MultiValueNode

java.lang.Object
  extended by org.sapia.archie.AbstractNode
      extended by org.sapia.archie.impl.MultiValueNode
All Implemented Interfaces:
Node
Direct Known Subclasses:
AttributeNode

public class MultiValueNode
extends AbstractNode

An instance of this class tolerates multiple values under the same name.

Author:
Yanick Duchesne
Copyright:
Copyright © 2002-2003 Sapia Open Source Software. All Rights Reserved.
License:
Read the license.txt file of the jar or visit the license page at the Sapia OSS web site

Field Summary
protected  java.util.Map _valueLists
           
 
Fields inherited from class org.sapia.archie.AbstractNode
_children, _fac
 
Constructor Summary
protected MultiValueNode(java.util.Map children, java.util.Map values, NodeFactory fac)
           
protected MultiValueNode(NameParser parser, java.util.Map children, java.util.Map values, NodeFactory fac)
           
 
Method Summary
 java.util.Iterator getChildren()
          Returns this instance's child nodes.
 int getChildrenCount()
          Returns the number of children that this instance contains.
 java.util.Iterator getChildrenNames()
          Returns the names of this instance's nodes.
 java.util.Iterator getEntries()
           
 java.lang.Object getValue(NamePart name)
          This method calls onSelect() and onRead() successively, before returning the a value.
 int getValueCount()
          Returns the number of values that this instance contains.
 java.util.Iterator getValueNames()
          Returns the names of this instance's values.
protected  java.lang.Object onRead(NamePart np, java.lang.Object selected)
          This method is internally called by getValue(...).
protected  java.lang.Object onSelect(java.util.List values)
          Selects a given value, from the given list, and returns it.
protected  java.lang.Object onWrite(NamePart np, java.lang.Object toBind)
          Called prior to bind the given object to the given name part.
 boolean putValue(NamePart name, java.lang.Object value, boolean overwrite)
          Put a value into this node; overwrites the existing value - if any.
 java.lang.Object removeValue(NamePart name)
          Internally removes the value that this node holds and returns it.
 
Methods inherited from class org.sapia.archie.AbstractNode
createChild, getAbsolutePath, getChild, getName, getNameParser, getParent, removeChild, setUp, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_valueLists

protected java.util.Map _valueLists
Constructor Detail

MultiValueNode

protected MultiValueNode(java.util.Map children,
                         java.util.Map values,
                         NodeFactory fac)
                  throws ProcessingException
Throws:
ProcessingException

MultiValueNode

protected MultiValueNode(NameParser parser,
                         java.util.Map children,
                         java.util.Map values,
                         NodeFactory fac)
                  throws ProcessingException
Throws:
ProcessingException
Method Detail

getValue

public java.lang.Object getValue(NamePart name)
This method calls onSelect() and onRead() successively, before returning the a value.

Returns:
an Object, or null if this node has no value.
See Also:
onSelect(List), onRead(NamePart, Object), Node.getValue(NamePart)

removeValue

public java.lang.Object removeValue(NamePart name)
Description copied from interface: Node
Internally removes the value that this node holds and returns it.

Returns:
an Object, or null if this node has no value.
See Also:
Node.removeValue(org.sapia.archie.NamePart)

getEntries

public java.util.Iterator getEntries()
Returns:
an Iterator of Entry instances, corresponding to the bindings that this instance holds.
See Also:
Node.getEntries()

putValue

public boolean putValue(NamePart name,
                        java.lang.Object value,
                        boolean overwrite)
Description copied from interface: Node
Put a value into this node; overwrites the existing value - if any.

Parameters:
name - the name under which to bind the given value.
value - an Object.
overwrite - if true, overwrites the already existing value for the given name - it such is the case.
Returns:
true if the given value was added. Returns false if overwrite is false and a value already exists for the given name.
See Also:
Node.putValue(NamePart, Object, boolean)

getValueNames

public java.util.Iterator getValueNames()
Description copied from interface: Node
Returns the names of this instance's values.

Returns:
an Iterator of NameParts.
See Also:
Node.getValueNames()

getValueCount

public int getValueCount()
Description copied from interface: Node
Returns the number of values that this instance contains.

Returns:
the number of values that this instance contains.
See Also:
Node.getValueCount()

getChildrenCount

public int getChildrenCount()
Description copied from interface: Node
Returns the number of children that this instance contains.

Specified by:
getChildrenCount in interface Node
Overrides:
getChildrenCount in class AbstractNode
Returns:
the number of children that this instance contains.
See Also:
Node.getChildrenCount()

getChildrenNames

public java.util.Iterator getChildrenNames()
Description copied from interface: Node
Returns the names of this instance's nodes.

Specified by:
getChildrenNames in interface Node
Overrides:
getChildrenNames in class AbstractNode
Returns:
an Iterator of NameParts.
See Also:
Node.getChildrenNames()

getChildren

public java.util.Iterator getChildren()
Description copied from interface: Node
Returns this instance's child nodes.

Specified by:
getChildren in interface Node
Overrides:
getChildren in class AbstractNode
Returns:
a Iterator of Nodes.
See Also:
Node.getChildren()

onSelect

protected java.lang.Object onSelect(java.util.List values)
Selects a given value, from the given list, and returns it. This template method is internally called by getValue(...).

Parameters:
values - the list of values to select from.
Returns:
an item from the given list of values.
See Also:
getValue(NamePart)

onRead

protected java.lang.Object onRead(NamePart np,
                                  java.lang.Object selected)
This method is internally called by getValue(...).

Parameters:
np - the name under which the selected object is bound.
selected - the selected object.
Returns:
the object to return to the application (the selected object, or a substitute).
See Also:
getValue(NamePart)

onWrite

protected java.lang.Object onWrite(NamePart np,
                                   java.lang.Object toBind)
Called prior to bind the given object to the given name part.

Parameters:
np - the NamePart under which the given object is to be bound.
toBind - the object to bind.
Returns:
the object to bind (can be substituted).


Copyright © 2010 Sapia OSS. All Rights Reserved.