org.drools.eclipse.editors.completion
Class DSLTree

java.lang.Object
  extended by org.drools.eclipse.editors.completion.DSLTree

public class DSLTree
extends Object


Field Summary
static String separator
           
static String tab
           
 
Constructor Summary
DSLTree()
           
 
Method Summary
 void addChildToList(Node n, String prefix, ArrayList list)
          method will prepend the parent text to the child and generate the possible combinations in text format.
 void addObjToNLMap(String objname, String nl)
           
 void addTokens(String[] tokens, Node rootNode)
          method adds the token to root
 void addTokens(String metadata, StringTokenizer tokens)
          The method is different than addTokens(StringTokenizer). this method expects additional metadata.
 void buildTree(org.drools.lang.dsl.DSLMapping mapping)
           
 void buildTree(Reader dslcontents)
          the method uses the DSLAdapter to get the contents of the DSL mapping file.
 void buildTree(String dslFile)
          the method will take the dsl file and build a DSLTree using the Node class.
protected  BufferedReader createBufferedReader(Reader reader)
          Create a buffered reader for the reader created by the DSLAdapater
 Node[] getChildren(String obj, String text)
          the method expects the caller to pass the object
 ArrayList getChildrenList(String obj, String text, boolean addChildren, boolean firstLine)
           
 Node[] getConditionChildren(String text)
          the method will tokenize the text and try to find the node that matches and return the children. the method will traverse down the network as far as it can and return the children at that level.
 ArrayList getConditionChildrenList(String text, boolean addChildren)
          for convienance, the method will return a list of strings that are children of the last node found.
 Node[] getConsequenceChildren(String text)
          the method will tokenize the text and try to find the node that matches and return the children. the method will traverse down the network as far as it can and return the children at that level.
 ArrayList getConsequenceChildrenList(String text, boolean addChildren)
          for convienance, the method will return a list of strings that are children of the last node found.
 Node getCurrent()
           
 Node getLast()
           
protected  String getObjMetadata(String text)
          Method will return just the object metadata
protected  org.drools.lang.dsl.DSLMappingEntry.Section getSection(String text)
           
 boolean isEmpty()
          if the DSL mapping hasn't been loaded, the method will return true.
protected  BufferedReader openDSLFile(String filename)
          method will create a BufferedReader to read the file.
protected  void parseFile(BufferedReader reader)
          method will use the BufferedReader to read the contents of the file.
protected  void printNode(Node n)
          method will print the node and then iterate over the children
protected  void printTabs(int count)
          Method will print n number of tabs
 void printTree()
          The method will print the DSLTree to System.out in text format.
 void setCurrent(Node current)
           
 void setLast(Node last)
           
protected  String stripHeadingAndCode(String text)
          method will strip out the when, then, * at the beginning of each line and the mapped drl expression
protected  String stripObjMetadata(String text)
          method will strip the metadata from the text string
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

separator

public static final String separator
See Also:
Constant Field Values

tab

public static final String tab
See Also:
Constant Field Values
Constructor Detail

DSLTree

public DSLTree()
Method Detail

buildTree

public void buildTree(String dslFile)
the method will take the dsl file and build a DSLTree using the Node class.

Parameters:
dslFile -

buildTree

public void buildTree(Reader dslcontents)
the method uses the DSLAdapter to get the contents of the DSL mapping file.

Parameters:
dslcontents -

openDSLFile

protected BufferedReader openDSLFile(String filename)
method will create a BufferedReader to read the file.

Parameters:
filename -
Returns:

createBufferedReader

protected BufferedReader createBufferedReader(Reader reader)
Create a buffered reader for the reader created by the DSLAdapater

Parameters:
reader -
Returns:

isEmpty

public boolean isEmpty()
if the DSL mapping hasn't been loaded, the method will return true. If the DSL mapping has been loaded, the method returns false.

Returns:

parseFile

protected void parseFile(BufferedReader reader)
method will use the BufferedReader to read the contents of the file. It calls other methods to parse the line and build the tree.

Parameters:
reader -

buildTree

public void buildTree(org.drools.lang.dsl.DSLMapping mapping)

addObjToNLMap

public void addObjToNLMap(String objname,
                          String nl)

getSection

protected org.drools.lang.dsl.DSLMappingEntry.Section getSection(String text)

stripHeadingAndCode

protected String stripHeadingAndCode(String text)
method will strip out the when, then, * at the beginning of each line and the mapped drl expression

Parameters:
text -
Returns:

getObjMetadata

protected String getObjMetadata(String text)
Method will return just the object metadata

Parameters:
text -
Returns:

stripObjMetadata

protected String stripObjMetadata(String text)
method will strip the metadata from the text string

Parameters:
text -
Returns:

addTokens

public void addTokens(String metadata,
                      StringTokenizer tokens)
The method is different than addTokens(StringTokenizer). this method expects additional metadata. It expects to get an object name or "*" meaning all. If the metadata is a wildcard all, it will add the tokens to all the top level nodes that are immediate child of root.

Parameters:
metadata -
tokens -

addTokens

public void addTokens(String[] tokens,
                      Node rootNode)
method adds the token to root

Parameters:
tokens -

getConditionChildren

public Node[] getConditionChildren(String text)
the method will tokenize the text and try to find the node that matches and return the children. the method will traverse down the network as far as it can and return the children at that level.

Parameters:
text -
Returns:

getConsequenceChildren

public Node[] getConsequenceChildren(String text)
the method will tokenize the text and try to find the node that matches and return the children. the method will traverse down the network as far as it can and return the children at that level.

Parameters:
text -
Returns:

getChildren

public Node[] getChildren(String obj,
                          String text)
the method expects the caller to pass the object

Parameters:
obj -
text -
Returns:

getConditionChildrenList

public ArrayList getConditionChildrenList(String text,
                                          boolean addChildren)
for convienance, the method will return a list of strings that are children of the last node found. If the editor wants to generate the children strings, call the method with true

Parameters:
text -
Returns:

getConsequenceChildrenList

public ArrayList getConsequenceChildrenList(String text,
                                            boolean addChildren)
for convienance, the method will return a list of strings that are children of the last node found. If the editor wants to generate the children strings, call the method with true

Parameters:
text -
Returns:

getChildrenList

public ArrayList getChildrenList(String obj,
                                 String text,
                                 boolean addChildren,
                                 boolean firstLine)
Parameters:
obj -
text -
addChildren -
Returns:

addChildToList

public void addChildToList(Node n,
                           String prefix,
                           ArrayList list)
method will prepend the parent text to the child and generate the possible combinations in text format.

Parameters:
n -
prefix -
list -

getCurrent

public Node getCurrent()

setCurrent

public void setCurrent(Node current)

getLast

public Node getLast()

setLast

public void setLast(Node last)

printTree

public void printTree()
The method will print the DSLTree to System.out in text format.


printNode

protected void printNode(Node n)
method will print the node and then iterate over the children

Parameters:
n -

printTabs

protected void printTabs(int count)
Method will print n number of tabs

Parameters:
count -


Copyright © 2001-2012 JBoss by Red Hat. All Rights Reserved.