fr.obeo.acceleo.gen.template.scripts.imports.services
Class ENodeServices


public class ENodeServices
extends java.lang.Object

System services for ENode elements.


Constructor Summary
ENodeServices()
           
 
Method Summary
 fr.obeo.acceleo.gen.template.eval.ENode cast(fr.obeo.acceleo.gen.template.eval.ENode node, java.lang.String type)
          Gets all the nodes whose type is the given type.
 fr.obeo.acceleo.gen.template.eval.ENode current(fr.obeo.acceleo.gen.template.eval.ENode node)
          Returns the current node.
 fr.obeo.acceleo.gen.template.eval.ENode filter(fr.obeo.acceleo.gen.template.eval.ENode node, java.lang.String type)
          Gets all the nodes whose type is the given type.
 fr.obeo.acceleo.gen.template.eval.ENode minimize(fr.obeo.acceleo.gen.template.eval.ENode node)
          Removes all duplicated nodes.
 fr.obeo.acceleo.gen.template.eval.ENode nGet(fr.obeo.acceleo.gen.template.eval.ENode node, int index)
          Returns the child node at the given index in the current node.
 fr.obeo.acceleo.gen.template.eval.ENode nGet(fr.obeo.acceleo.gen.template.eval.ENode node, java.lang.String key)
          Gets the node for the given key in the context.
 fr.obeo.acceleo.gen.template.eval.ENode nPeek(fr.obeo.acceleo.gen.template.eval.ENode node)
          Return the last node pushed into the context, and returns an empty string.
 void nPop(fr.obeo.acceleo.gen.template.eval.ENode node)
          Pops the context, and returns an empty string.
 void nPush(fr.obeo.acceleo.gen.template.eval.ENode node)
          Pushes the current node into the context, and returns an empty string.
 void nPut(fr.obeo.acceleo.gen.template.eval.ENode node, java.lang.String key)
          Puts the current node in the context for the given key, and return an empty string.
 int nSize(fr.obeo.acceleo.gen.template.eval.ENode node)
          Returns the size of the node.
 fr.obeo.acceleo.gen.template.eval.ENode sep(fr.obeo.acceleo.gen.template.eval.ENode node, java.lang.String separator)
          Add a separator between each element of the list.
 fr.obeo.acceleo.gen.template.eval.ENode sort(fr.obeo.acceleo.gen.template.eval.ENode node)
          Sorts the node and its children.
 fr.obeo.acceleo.gen.template.eval.ENode toString(fr.obeo.acceleo.gen.template.eval.ENode node)
          Transforms the node into a string.
 fr.obeo.acceleo.gen.template.eval.ENode until(fr.obeo.acceleo.gen.template.eval.ENode node, java.lang.String link, java.lang.String type)
          Get recursively the feature value of an object.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ENodeServices

public ENodeServices()
Method Detail

cast

public fr.obeo.acceleo.gen.template.eval.ENode cast(fr.obeo.acceleo.gen.template.eval.ENode node,
                                                    java.lang.String type)
                                             throws fr.obeo.acceleo.gen.template.eval.ENodeCastException,
                                                    fr.obeo.acceleo.ecore.factories.FactoryException
Gets all the nodes whose type is the given type.

An element is kept only if it's an EObject whose type is the given type or if it isn't an EObject.

Sample :

  • a is an instance of class A
  • b is an instance of class B
  • c is an instance of class C
  • B extends A
  • If type equals "A" and node is a list {a, "\n", b, c}

    the result is a list {a, "\n", b}.

    Parameters:
    node - is the list
    type - is the type kept
    Returns:
    a list that contains the nodes whose type is the given type.
    Throws:
    fr.obeo.acceleo.gen.template.eval.ENodeCastException - if the given node isn't a list
    fr.obeo.acceleo.ecore.factories.FactoryException

    current

    public fr.obeo.acceleo.gen.template.eval.ENode current(fr.obeo.acceleo.gen.template.eval.ENode node)
    Returns the current node.

    Parameters:
    node - is the current node
    Returns:
    the current node

    filter

    public fr.obeo.acceleo.gen.template.eval.ENode filter(fr.obeo.acceleo.gen.template.eval.ENode node,
                                                          java.lang.String type)
                                                   throws fr.obeo.acceleo.gen.template.eval.ENodeCastException,
                                                          fr.obeo.acceleo.ecore.factories.FactoryException
    Gets all the nodes whose type is the given type.

    An element is kept only if it's an EObject whose type is the given type or if it isn't an EObject.

    Sample :

  • a is an instance of class A
  • b is an instance of class B
  • c is an instance of class C
  • B extends A
  • If type equals "A" and node is a list {a, "\n", b, c}

    the result is a list {a, "\n", b}.

    Parameters:
    node - is the list
    type - is the type kept
    Returns:
    a list that contains the nodes whose type is the given type.
    Throws:
    fr.obeo.acceleo.gen.template.eval.ENodeCastException - if the given node isn't a list
    fr.obeo.acceleo.ecore.factories.FactoryException

    minimize

    public fr.obeo.acceleo.gen.template.eval.ENode minimize(fr.obeo.acceleo.gen.template.eval.ENode node)
                                                     throws fr.obeo.acceleo.gen.template.eval.ENodeCastException
    Removes all duplicated nodes.

    Parameters:
    node - is the current node
    Returns:
    the minimized node
    Throws:
    fr.obeo.acceleo.gen.template.eval.ENodeCastException

    nGet

    public fr.obeo.acceleo.gen.template.eval.ENode nGet(fr.obeo.acceleo.gen.template.eval.ENode node,
                                                        int index)
                                                 throws fr.obeo.acceleo.gen.template.eval.ENodeCastException,
                                                        fr.obeo.acceleo.ecore.factories.FactoryException
    Returns the child node at the given index in the current node.

    Parameters:
    node - is the current node
    index - is the index of the child
    Returns:
    the child node
    Throws:
    fr.obeo.acceleo.gen.template.eval.ENodeCastException
    fr.obeo.acceleo.ecore.factories.FactoryException

    nGet

    public fr.obeo.acceleo.gen.template.eval.ENode nGet(fr.obeo.acceleo.gen.template.eval.ENode node,
                                                        java.lang.String key)
    Gets the node for the given key in the context.

    Parameters:
    node - is the current node
    key - is the key in the context
    Returns:
    the node of the context

    nPeek

    public fr.obeo.acceleo.gen.template.eval.ENode nPeek(fr.obeo.acceleo.gen.template.eval.ENode node)
    Return the last node pushed into the context, and returns an empty string.

    Parameters:
    node - is the current node
    Returns:
    an empty string

    nPop

    public void nPop(fr.obeo.acceleo.gen.template.eval.ENode node)
    Pops the context, and returns an empty string.

    Parameters:
    node - is the current node

    nPush

    public void nPush(fr.obeo.acceleo.gen.template.eval.ENode node)
    Pushes the current node into the context, and returns an empty string.

    Parameters:
    node - is the current node

    nPut

    public void nPut(fr.obeo.acceleo.gen.template.eval.ENode node,
                     java.lang.String key)
    Puts the current node in the context for the given key, and return an empty string.

    Parameters:
    node - is the current node
    key - is the key in the context

    nSize

    public int nSize(fr.obeo.acceleo.gen.template.eval.ENode node)
    Returns the size of the node.

    Parameters:
    node - is the current node
  • isEObject() : return 1
  • isList() : return getList().size()
  • isString() : return getString().length()
  • isBoolean() : return 1
  • isInt() : return 1
  • isNull() : return 0
  • Returns:
    value size

    sep

    public fr.obeo.acceleo.gen.template.eval.ENode sep(fr.obeo.acceleo.gen.template.eval.ENode node,
                                                       java.lang.String separator)
                                                throws fr.obeo.acceleo.gen.template.eval.ENodeCastException,
                                                       fr.obeo.acceleo.ecore.factories.FactoryException
    Add a separator between each element of the list. It returns the given node if it isn't a list.

    Sample :

    If separator equals "\t" and node is a list {a, b, c} the result is a list {a, "\t", b, "\t", c}.

    Parameters:
    node - is the list
    separator - is the separator
    Returns:
    a list that contains a separator between each element.
    Throws:
    fr.obeo.acceleo.gen.template.eval.ENodeCastException - if the given node isn't a list
    fr.obeo.acceleo.ecore.factories.FactoryException

    sort

    public fr.obeo.acceleo.gen.template.eval.ENode sort(fr.obeo.acceleo.gen.template.eval.ENode node)
                                                 throws fr.obeo.acceleo.gen.template.eval.ENodeCastException
    Sorts the node and its children.

    Parameters:
    node - is the current node
    Returns:
    the sorted node
    Throws:
    fr.obeo.acceleo.gen.template.eval.ENodeCastException

    toString

    public fr.obeo.acceleo.gen.template.eval.ENode toString(fr.obeo.acceleo.gen.template.eval.ENode node)
    Transforms the node into a string.

    Parameters:
    node - is the current node
    Returns:
    the string node

    until

    public fr.obeo.acceleo.gen.template.eval.ENode until(fr.obeo.acceleo.gen.template.eval.ENode node,
                                                         java.lang.String link,
                                                         java.lang.String type)
                                                  throws fr.obeo.acceleo.gen.template.eval.ENodeCastException,
                                                         fr.obeo.acceleo.ecore.factories.FactoryException
    Get recursively the feature value of an object. The recursivity is stopped when an element of the given type is found.

    The given node must be an EObject.

    Sample :

  • a is an instance of class A
  • b is an instance of class B
  • c is an instance of class C
  • a contains b
  • b contains c
  • 'container' feature is defined on a, b, and c
  • c.container returns b
  • b.container returns a
  • a.container returns null
  • until(c,"container","A") returns a

    until(b,"container","A") returns a

    until(a,"container","A") returns a

    until(b,"container","C") returns null

    Parameters:
    node - is an EObject
    link - is the feature name
    type - is the type which stops the recursivity
    Returns:
    the found object or null
    Throws:
    fr.obeo.acceleo.gen.template.eval.ENodeCastException - if the given node isn't an EObject
    fr.obeo.acceleo.ecore.factories.FactoryException