org.modeshape.sequencer.ddl.node
Class AstNodeFactory

java.lang.Object
  extended by org.modeshape.sequencer.ddl.node.AstNodeFactory

public class AstNodeFactory
extends Object

Utility class which provides construction, editing and assorted methods to work with AstNodes.


Constructor Summary
AstNodeFactory()
           
AstNodeFactory(ExecutionContext context)
           
 
Method Summary
 int createInt(String stringValue)
           
 AstNode getChildforNameAndType(AstNode astNode, String name, Name nodeType)
          Utility method to obtain a AstNode child of a parent AstNode with the given string name and node type.
 List<AstNode> getChildrenForType(AstNode astNode, Name nodeType)
          Utility method to obtain the children of a given node that match the given type
 boolean hasMixinType(AstNode node, Name mixinType)
          Utility method to determine if an AstNode contains a specific mixin type.
 Name name(String name)
          Constructs a Name with the given string name
 AstNode node(String name)
          Constructs an AstNode with the given string name
 AstNode node(String name, AstNode parent, Name type)
          Constructs an AstNode with the given name, type and parent node.
 AstNode node(String name, AstNode parent, Object... types)
          Constructs an AstNode with the given name, types and parent node.
 void setType(AstNode node, Name type)
          Sets the mixin type property for an AstNode
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AstNodeFactory

public AstNodeFactory(ExecutionContext context)
Parameters:
context -

AstNodeFactory

public AstNodeFactory()
Method Detail

name

public Name name(String name)
Constructs a Name with the given string name

Parameters:
name - the name to use in constructing a Name instance; may not be null
Returns:
name the Name graph property object

node

public AstNode node(String name)
Constructs an AstNode with the given string name

Parameters:
name - the name property of the node; may not be null
Returns:
the tree node

node

public AstNode node(String name,
                    AstNode parent,
                    Object... types)
Constructs an AstNode with the given name, types and parent node.

Parameters:
name - the name property of the node; may not be null
parent - the parent of the node; may not be null
types - the list of mixin types Name for the requested node; may not be null or empty
Returns:
the tree node

node

public AstNode node(String name,
                    AstNode parent,
                    Name type)
Constructs an AstNode with the given name, type and parent node.

Parameters:
name - the name property of the node; may not be null
parent - the parent of the node; may not be null
type - the mixin type Name for the requested node; may not be null
Returns:
the tree node

setType

public void setType(AstNode node,
                    Name type)
Sets the mixin type property for an AstNode

Parameters:
node - the node to set the property on; may not be null
type - the mixin type Name; may not be null

getChildrenForType

public List<AstNode> getChildrenForType(AstNode astNode,
                                        Name nodeType)
Utility method to obtain the children of a given node that match the given type

Parameters:
astNode - the parent node; may not be null
nodeType - the type property of the target child node; may not be null
Returns:
the list of typed nodes (may be empty)

getChildforNameAndType

public AstNode getChildforNameAndType(AstNode astNode,
                                      String name,
                                      Name nodeType)
Utility method to obtain a AstNode child of a parent AstNode with the given string name and node type.

Parameters:
astNode - the parent node; may not be null
name - the name property of the node; may not be null
nodeType - the type property of the target child node; may not be null
Returns:
the matched child (may be null)

hasMixinType

public boolean hasMixinType(AstNode node,
                            Name mixinType)
Utility method to determine if an AstNode contains a specific mixin type.

Parameters:
node - the AstNode
mixinType - the target mixin type Name; may not be null;
Returns:
true if the mixinType exists for this node

createInt

public int createInt(String stringValue)


Copyright © 2008-2010 JBoss, a division of Red Hat. All Rights Reserved.