org.eclipse.emf.codegen.merge.java.facade
Class FacadeHelper

java.lang.Object
  extended byorg.eclipse.emf.codegen.merge.java.facade.FacadeHelper
Direct Known Subclasses:
ASTFacadeHelper, JDOMFacadeHelper

public abstract class FacadeHelper
extends Object


Field Summary
protected static String CLASS_PREFIX
           
protected  JControlModel controlModel
           
protected  Map objectToNodeMap
           
 
Constructor Summary
FacadeHelper()
           
 
Method Summary
 boolean addChild(JNode node, JNode child)
          Adds the given un-parented node (document fragment) as the last child of the specified node.
 String applyFormatRules(String value)
          Formats the specified string using the CodeGenUtil.convertFormat(String, boolean, String) method.
abstract  JNode cloneNode(Object context, JNode node)
          Clones the specified node, returning an object that is related to the given context.
 JNode convertToNode(Object object)
           
abstract  JCompilationUnit createCompilationUnit(String name, String content)
           
protected abstract  JNode doConvertToNode(Object object)
           
 List getChildren(JNode node, Class cls)
          Returns a list with the children of the specified node that are instances of the given class.
 String getClassPrefix()
           
 JCompilationUnit getCompilationUnit(JNode node)
          Returns the compilation unit of the specified node.
abstract  Object getContext(JNode node)
          Returns the context of a node.
 JControlModel getControlModel()
           
 JNode getFirstChild(JNode node)
          Returns the first child of the specified node.
 JType getMainType(JCompilationUnit compilationUnit)
          Returns the first public type in of a compilation unit.
 JNode getNext(JNode node)
          Returns the sibling node immediately following the specified node.
protected  Map getObjectToNodeMap()
           
 JPackage getPackage(JNode node)
          Returns the package of the specified node.
 JNode getPrevious(JNode node)
          Returns the sibling node immediately preceding the specified node.
 JNode getSibiling(JNode node, int pos)
          Returns the sibiling of the specified node that is located in a specific position relative to the node.
 boolean insertSibling(JNode node, JNode sibiling, boolean before)
          Inserts the given un-parented node as a sibling of the specofoed node, immediately before or after it.
 boolean remove(JNode node)
          Separates the specified node from its parent and siblings, maintaining any ties that this node has to the underlying document fragment.
 void reset()
           
 void setControlModel(JControlModel controlModel)
          Sets this facade helper's control model.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_PREFIX

protected static final String CLASS_PREFIX
See Also:
Constant Field Values

controlModel

protected JControlModel controlModel

objectToNodeMap

protected Map objectToNodeMap
Constructor Detail

FacadeHelper

public FacadeHelper()
Method Detail

reset

public void reset()

getObjectToNodeMap

protected Map getObjectToNodeMap()

getClassPrefix

public String getClassPrefix()

setControlModel

public void setControlModel(JControlModel controlModel)
                     throws IllegalArgumentException
Sets this facade helper's control model.

Parameters:
controlModel -
Throws:
IllegalArgumentException - if the control model's facade helper is different than this facade helper.

getControlModel

public JControlModel getControlModel()

convertToNode

public JNode convertToNode(Object object)

cloneNode

public abstract JNode cloneNode(Object context,
                                JNode node)
Clones the specified node, returning an object that is related to the given context. On some implementations the context may be null.

Parameters:
context -
node -
Returns:
a cloned version of the specified node

getContext

public abstract Object getContext(JNode node)
Returns the context of a node. The context is usually an object that would be used to create a child or sibiling of the node.

Returns:
the context of a node.

createCompilationUnit

public abstract JCompilationUnit createCompilationUnit(String name,
                                                       String content)

doConvertToNode

protected abstract JNode doConvertToNode(Object object)

getCompilationUnit

public JCompilationUnit getCompilationUnit(JNode node)
Returns the compilation unit of the specified node.

Parameters:
node -
Returns:
the JCompilationUnit of a JNode or null.

getPackage

public JPackage getPackage(JNode node)
Returns the package of the specified node.

Parameters:
node -
Returns:
the JPackage of a JNode or null

getMainType

public JType getMainType(JCompilationUnit compilationUnit)
Returns the first public type in of a compilation unit.

Parameters:
compilationUnit -
Returns:
the first public type of a compilation unti

getChildren

public List getChildren(JNode node,
                        Class cls)
Returns a list with the children of the specified node that are instances of the given class. The list should be an unmodifiable list if it doesn't support changes.

Parameters:
node -
Returns:
the list of children of a JNode

getFirstChild

public JNode getFirstChild(JNode node)
Returns the first child of the specified node. Children appear in the order in which they exist in the source code.

Parameters:
node -
Returns:
the first child, or null if this node has no children
See Also:
#getChildren()

getPrevious

public JNode getPrevious(JNode node)
Returns the sibling node immediately preceding the specified node.

Parameters:
node -
Returns:
the previous node, or null if there is no preceding node

getNext

public JNode getNext(JNode node)
Returns the sibling node immediately following the specified node.

Parameters:
node -
Returns:
the next node, or null if there is no following node

getSibiling

public JNode getSibiling(JNode node,
                         int pos)
Returns the sibiling of the specified node that is located in a specific position relative to the node.

Parameters:
node -
Returns:
the sibiling, or null if this node has no children
See Also:
#getChildren()

addChild

public boolean addChild(JNode node,
                        JNode child)
Adds the given un-parented node (document fragment) as the last child of the specified node.

Parameters:
node - the parent of the child to be added
child - the new child node
Returns:
whether the opearation was succesful.
See Also:
#insertSibling(JNode, JNode), remove(JNode)

insertSibling

public boolean insertSibling(JNode node,
                             JNode sibiling,
                             boolean before)
Inserts the given un-parented node as a sibling of the specofoed node, immediately before or after it.

Parameters:
node - the node that will be after the new sibiling
before - whether the sibiling should be added before the node
See Also:
addChild(JNode, JNode), remove(JNode)

remove

public boolean remove(JNode node)
Separates the specified node from its parent and siblings, maintaining any ties that this node has to the underlying document fragment. A document fragment that is removed from its host document may still be dependent on that host document until it is inserted into a different document. Removing a root node has no effect.

Parameters:
node - the node to be removed
Returns:
whether the operation was succesful.
See Also:
addChild(JNode, JNode), #insertSibling(JNode, JNode)

applyFormatRules

public String applyFormatRules(String value)
Formats the specified string using the CodeGenUtil.convertFormat(String, boolean, String) method.

Parameters:
value -
Returns:
the formatted String.

Copyright 2001-2006 IBM Corporation and others.
All Rights Reserved.