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

java.lang.Object
  extended by fr.obeo.acceleo.gen.template.scripts.imports.services.ENodeServices

public class ENodeServices
extends java.lang.Object

System services for ENode elements.

Author:
www.obeo.fr

Constructor Summary
ENodeServices(fr.obeo.acceleo.gen.template.scripts.IScript script)
          Constructor.
 
Method Summary
 fr.obeo.acceleo.gen.template.eval.ENode adapt(fr.obeo.acceleo.gen.template.eval.ENode node, java.lang.String type)
          Returns the adaptive value for the given type short name.
 fr.obeo.acceleo.gen.template.eval.ENode cast(fr.obeo.acceleo.gen.template.eval.ENode node, java.lang.String type)
          Deprecated.  
 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 current(fr.obeo.acceleo.gen.template.eval.ENode node, fr.obeo.acceleo.gen.template.eval.ENode arg)
          Returns the current node.
 fr.obeo.acceleo.gen.template.eval.ENode debug(fr.obeo.acceleo.gen.template.eval.ENode node)
          It prints 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)
          Deprecated.  
 boolean nContains(fr.obeo.acceleo.gen.template.eval.ENode node, fr.obeo.acceleo.gen.template.eval.ENode element)
          Returns true if this list contains the specified element.
 fr.obeo.acceleo.gen.template.eval.ENode nFirst(fr.obeo.acceleo.gen.template.eval.ENode node)
          Returns the first child of the current node.
 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, int begin, int end)
          Returns the children in the given range.
 fr.obeo.acceleo.gen.template.eval.ENode nLast(fr.obeo.acceleo.gen.template.eval.ENode node)
          Returns the last child of the current node.
 fr.obeo.acceleo.gen.template.eval.ENode nMinimize(fr.obeo.acceleo.gen.template.eval.ENode node)
          Removes all duplicated nodes.
 fr.obeo.acceleo.gen.template.eval.ENode nReverse(fr.obeo.acceleo.gen.template.eval.ENode node)
          Reverses the order of the elements of the specified node.
 int nSize(fr.obeo.acceleo.gen.template.eval.ENode node)
          Returns the size of the node.
 fr.obeo.acceleo.gen.template.eval.ENode nSort(fr.obeo.acceleo.gen.template.eval.ENode node)
          Sorts the node and its children.
 fr.obeo.acceleo.gen.template.eval.ENode nSort(fr.obeo.acceleo.gen.template.eval.ENode current, java.lang.String call)
          Sorts the node and its children.
 fr.obeo.acceleo.gen.template.eval.ENode reverse(fr.obeo.acceleo.gen.template.eval.ENode node)
          Deprecated.  
 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 sepStr(fr.obeo.acceleo.gen.template.eval.ENode node, java.lang.String separator)
          Deprecated.  
 fr.obeo.acceleo.gen.template.eval.ENode sort(fr.obeo.acceleo.gen.template.eval.ENode node)
          Deprecated.  
 fr.obeo.acceleo.gen.template.eval.ENode sort(fr.obeo.acceleo.gen.template.eval.ENode current, java.lang.String call)
          Deprecated.  
 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 trace(fr.obeo.acceleo.gen.template.eval.ENode node)
          It prints current node.
 fr.obeo.acceleo.gen.template.eval.ENode trace(fr.obeo.acceleo.gen.template.eval.ENode node, java.lang.String template)
          It prints current node.
 fr.obeo.acceleo.gen.template.eval.ENode until(fr.obeo.acceleo.gen.template.eval.ENode node, java.lang.String link, java.lang.String type)
          Deprecated.  
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ENodeServices

public ENodeServices(fr.obeo.acceleo.gen.template.scripts.IScript script)
Constructor.

Parameters:
script - is the script
Method Detail

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

    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
    Deprecated. 

    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

    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.ecore.factories.FactoryException
    fr.obeo.acceleo.gen.template.eval.ENodeCastException

    sepStr

    public fr.obeo.acceleo.gen.template.eval.ENode sepStr(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
    Deprecated. 

    Add a separator between each element of the list and serialize the list. It returns node.toString() if it isn't a list.

    Sample :

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

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

    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
    Deprecated. 

    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

    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

    current

    public fr.obeo.acceleo.gen.template.eval.ENode current(fr.obeo.acceleo.gen.template.eval.ENode node,
                                                           fr.obeo.acceleo.gen.template.eval.ENode arg)
                                                    throws fr.obeo.acceleo.gen.template.eval.ENodeCastException
    Returns the current node.

    Parameters:
    node - is the current node
    level - is the level in the parent hierarchy
    Returns:
    the current 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

    adapt

    public fr.obeo.acceleo.gen.template.eval.ENode adapt(fr.obeo.acceleo.gen.template.eval.ENode node,
                                                         java.lang.String type)
                                                  throws fr.obeo.acceleo.gen.template.eval.ENodeCastException
    Returns the adaptive value for the given type short name.

    Parameters:
    node - is the node
    type - is the type name : "EObject", "ENodeList", "String", "boolean", "int", "double", "List", "ENode"
    Returns:
    the adaptive value
    Throws:
    fr.obeo.acceleo.gen.template.eval.ENodeCastException

    debug

    public fr.obeo.acceleo.gen.template.eval.ENode debug(fr.obeo.acceleo.gen.template.eval.ENode node)
    It prints current node.

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

    trace

    public fr.obeo.acceleo.gen.template.eval.ENode trace(fr.obeo.acceleo.gen.template.eval.ENode node)
    It prints current node.

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

    trace

    public fr.obeo.acceleo.gen.template.eval.ENode trace(fr.obeo.acceleo.gen.template.eval.ENode node,
                                                         java.lang.String template)
    It prints current node.

    Parameters:
    node - is the current node
    template - is the template to evaluate for each node
    Returns:
    the current node

    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

    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,
                                                        int begin,
                                                        int end)
                                                 throws fr.obeo.acceleo.gen.template.eval.ENodeCastException,
                                                        fr.obeo.acceleo.ecore.factories.FactoryException
    Returns the children in the given range.

    Parameters:
    node - is the current node
    begin - is the beginning index
    begin - is the ending index
    Returns:
    the children in the given range
    Throws:
    fr.obeo.acceleo.gen.template.eval.ENodeCastException
    fr.obeo.acceleo.ecore.factories.FactoryException

    nFirst

    public fr.obeo.acceleo.gen.template.eval.ENode nFirst(fr.obeo.acceleo.gen.template.eval.ENode node)
                                                   throws fr.obeo.acceleo.gen.template.eval.ENodeCastException,
                                                          fr.obeo.acceleo.ecore.factories.FactoryException
    Returns the first child of the current node.

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

    nLast

    public fr.obeo.acceleo.gen.template.eval.ENode nLast(fr.obeo.acceleo.gen.template.eval.ENode node)
                                                  throws fr.obeo.acceleo.gen.template.eval.ENodeCastException,
                                                         fr.obeo.acceleo.ecore.factories.FactoryException
    Returns the last child of the current node.

    Parameters:
    node - is the current node
    Returns:
    the last child node
    Throws:
    fr.obeo.acceleo.gen.template.eval.ENodeCastException
    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
    Deprecated. 

    Removes all duplicated nodes.

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

    nMinimize

    public fr.obeo.acceleo.gen.template.eval.ENode nMinimize(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

    reverse

    public fr.obeo.acceleo.gen.template.eval.ENode reverse(fr.obeo.acceleo.gen.template.eval.ENode node)
                                                    throws fr.obeo.acceleo.gen.template.eval.ENodeCastException,
                                                           fr.obeo.acceleo.ecore.factories.FactoryException
    Deprecated. 

    Reverses the order of the elements of the specified node.

    Parameters:
    node - is the node whose elements are to be reversed
    Returns:
    the new node
    Throws:
    fr.obeo.acceleo.gen.template.eval.ENodeCastException
    fr.obeo.acceleo.ecore.factories.FactoryException

    nReverse

    public fr.obeo.acceleo.gen.template.eval.ENode nReverse(fr.obeo.acceleo.gen.template.eval.ENode node)
                                                     throws fr.obeo.acceleo.gen.template.eval.ENodeCastException,
                                                            fr.obeo.acceleo.ecore.factories.FactoryException
    Reverses the order of the elements of the specified node.

    Parameters:
    node - is the node whose elements are to be reversed
    Returns:
    the new node
    Throws:
    fr.obeo.acceleo.gen.template.eval.ENodeCastException
    fr.obeo.acceleo.ecore.factories.FactoryException

    nContains

    public boolean nContains(fr.obeo.acceleo.gen.template.eval.ENode node,
                             fr.obeo.acceleo.gen.template.eval.ENode element)
                      throws fr.obeo.acceleo.gen.template.eval.ENodeCastException
    Returns true if this list contains the specified element.

    More formally, returns true if and only if this list contains at least

    one element e such that (o==null ? e==null : o.equals(e)).

    Parameters:
    node - is the current node
    element - is element whose presence in this list is to be tested
    Returns:
    true if this list contains the specified element
    Throws:
    fr.obeo.acceleo.gen.template.eval.ENodeCastException

    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
    Deprecated. 

    Sorts the node and its children.

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

    nSort

    public fr.obeo.acceleo.gen.template.eval.ENode nSort(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

    sort

    public fr.obeo.acceleo.gen.template.eval.ENode sort(fr.obeo.acceleo.gen.template.eval.ENode current,
                                                        java.lang.String call)
                                                 throws fr.obeo.acceleo.gen.template.eval.ENodeCastException
    Deprecated. 

    Sorts the node and its children.

    Parameters:
    current - is the current node of generation
    call - is the expression to evaluate for each node
    Returns:
    the sorted node
    Throws:
    fr.obeo.acceleo.gen.template.eval.ENodeCastException

    nSort

    public fr.obeo.acceleo.gen.template.eval.ENode nSort(fr.obeo.acceleo.gen.template.eval.ENode current,
                                                         java.lang.String call)
                                                  throws fr.obeo.acceleo.gen.template.eval.ENodeCastException
    Sorts the node and its children.

    Parameters:
    current - is the current node of generation
    call - is the expression to evaluate for each node
    Returns:
    the sorted node
    Throws:
    fr.obeo.acceleo.gen.template.eval.ENodeCastException