dk.brics.xmlgraph
Class ChoiceNode

java.lang.Object
  extended by dk.brics.xmlgraph.Node
      extended by dk.brics.xmlgraph.MultiContentNode
          extended by dk.brics.xmlgraph.ChoiceNode
All Implemented Interfaces:
Serializable, Cloneable

public class ChoiceNode
extends MultiContentNode

Choice/gap node.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class dk.brics.xmlgraph.MultiContentNode
contents
 
Fields inherited from class dk.brics.xmlgraph.Node
index, origin
 
Constructor Summary
ChoiceNode(Collection<Integer> content, Origin origin)
          Constructs a new non-gap choice node.
ChoiceNode(String name, boolean open, boolean removed, Collection<Integer> content, Origin origin)
          Constructs a new gap choice node.
 
Method Summary
protected  ChoiceNode clone()
          Clones this node.
 String getName()
          Returns the gap name.
 Collection<Integer> getSortedContents()
          Returns indices of sub-nodes in order.
 boolean isGap()
          Returns true if this is a gap node.
 boolean isOpen()
          Returns true if this gap may be open.
 boolean isOptional(XMLGraph xg)
          Returns true if this node has an empty choice or is open or removed.
 boolean isRemoved()
          Returns true if this gap may be removed.
<T> T
process(NodeProcessor<T> v)
          Applies the given node processor on this node.
 void setContent(Collection<Integer> content, XMLGraph xg)
          Sets the outgoing edges.
 void setContentAndStatus(boolean open, boolean removed, Collection<Integer> content, XMLGraph xg)
          Sets the outgoing edges and gap status.
 
Methods inherited from class dk.brics.xmlgraph.MultiContentNode
getContents, setContents
 
Methods inherited from class dk.brics.xmlgraph.Node
getIndex, getOrigin, setOrigin
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChoiceNode

public ChoiceNode(Collection<Integer> content,
                  Origin origin)
Constructs a new non-gap choice node.

Parameters:
content - outgoing edges representing the possible plugs/choices
origin - source information (null if not applicable)

ChoiceNode

public ChoiceNode(String name,
                  boolean open,
                  boolean removed,
                  Collection<Integer> content,
                  Origin origin)
Constructs a new gap choice node.

Parameters:
name - gap name
open - true if maybe open gap
removed - true if maybe removed gap
content - outgoing edges representing the possible plugs/choices
origin - source information (null if not applicable)
Method Detail

clone

protected ChoiceNode clone()
Description copied from class: Node
Clones this node.

Specified by:
clone in class MultiContentNode

getName

public String getName()
Returns the gap name.

Returns:
gap name

getSortedContents

public Collection<Integer> getSortedContents()
Description copied from class: MultiContentNode
Returns indices of sub-nodes in order.

Overrides:
getSortedContents in class MultiContentNode
Returns:
ordered collection of node indices (should not be modified by caller)

isGap

public boolean isGap()
Returns true if this is a gap node.

Returns:
gap status

isOpen

public boolean isOpen()
Returns true if this gap may be open.

Returns:
open status

isOptional

public boolean isOptional(XMLGraph xg)
Returns true if this node has an empty choice or is open or removed.

Parameters:
xg - XML graph containing this node
Returns:
optional status

isRemoved

public boolean isRemoved()
Returns true if this gap may be removed.

Returns:
removed status

process

public <T> T process(NodeProcessor<T> v)
Description copied from class: Node
Applies the given node processor on this node.

Specified by:
process in class Node
Type Parameters:
T - return type
Parameters:
v - node processor
Returns:
result from processor

setContent

public void setContent(Collection<Integer> content,
                       XMLGraph xg)
Sets the outgoing edges. This operation replaces the node in the XML graph.

Parameters:
content - outgoing edges
xg - the current XML graph

setContentAndStatus

public void setContentAndStatus(boolean open,
                                boolean removed,
                                Collection<Integer> content,
                                XMLGraph xg)
Sets the outgoing edges and gap status. This operation replaces the node in the XML graph.

Parameters:
open - true if maybe open gap
removed - true if maybe removed gap
content - outgoing edges
xg - the current XML graph


Copyright © 2005-2010 Anders Møller.