com.waveset.expression
Class ExParser

java.lang.Object
  extended bycom.waveset.expression.ExParser

public abstract class ExParser
extends java.lang.Object

A class that provides a set of static methods for parsing the XML representation of expressions into ExNode trees.

We used to require that all ExNode trees be rooted in an environment, but that restriction has been removed. You can still use the ExEnvironment and its parsing methods, but often it is more convenient just to maintain your own independent node trees.

One advantage of using the ExEnvironment, is that global definitions like can be discovered by disconnected expression fragments.


Field Summary
static java.lang.String code_id
           
static java.lang.String WRAPPER_ELEMENT
           
 
Constructor Summary
ExParser()
           
 
Method Summary
static ExNode parse(org.w3c.dom.Element el)
          Parse an XML element expected to be the root of an expression tree, and return the ExNode that is the root of that tree.
static ExNode parse(org.w3c.dom.Element el, boolean raiseError)
           
static ExNode parse(java.lang.String xml, boolean validate)
          Parse a string into a node tree.
static java.lang.Object parseAnything(org.w3c.dom.Element el)
          Conveinence method for objects that support both expressions and static objects, but have different representations for them.
protected static ExNode[] parseChildren(org.w3c.dom.Node domnode, boolean allowText)
          Parse the children of an element into an array.
protected static void parseChildren(org.w3c.dom.Node domnode, boolean allowText, java.util.List nodes)
          Parse the children of an element building a list of nodes.
protected static ExNode[] parseChildren(org.w3c.dom.Node domnode, ExNode first, boolean allowText)
          Parse the children of an element into an array, including a previously created element at the front.
protected static ExNode parseElement(org.w3c.dom.Element el, boolean raiseError)
          Parses one XML element into its corresponding ExNode object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

code_id

public static final java.lang.String code_id
See Also:
Constant Field Values

WRAPPER_ELEMENT

public static final java.lang.String WRAPPER_ELEMENT
See Also:
Constant Field Values
Constructor Detail

ExParser

public ExParser()
Method Detail

parse

public static ExNode parse(java.lang.String xml,
                           boolean validate)
                    throws WavesetException
Parse a string into a node tree.

Throws:
WavesetException

parse

public static ExNode parse(org.w3c.dom.Element el)
                    throws WavesetException
Parse an XML element expected to be the root of an expression tree, and return the ExNode that is the root of that tree.

Throws:
WavesetException

parse

public static ExNode parse(org.w3c.dom.Element el,
                           boolean raiseError)
                    throws WavesetException
Throws:
WavesetException

parseAnything

public static java.lang.Object parseAnything(org.w3c.dom.Element el)
                                      throws WavesetException
Conveinence method for objects that support both expressions and static objects, but have different representations for them. parseElement will promote any objects it finds into ExValueNodes, here we demote them back to ordinary objects. Classes that use this should consider just representing static values as an ExValueNode.

Throws:
WavesetException

parseElement

protected static ExNode parseElement(org.w3c.dom.Element el,
                                     boolean raiseError)
                              throws WavesetException
Parses one XML element into its corresponding ExNode object. This may recurse and build up a comlex node tree. Returns null if this element does not represent an XPRSES or XML object expression.

Throws:
WavesetException

parseChildren

protected static ExNode[] parseChildren(org.w3c.dom.Node domnode,
                                        boolean allowText)
                                 throws WavesetException
Parse the children of an element into an array.

Throws:
WavesetException

parseChildren

protected static ExNode[] parseChildren(org.w3c.dom.Node domnode,
                                        ExNode first,
                                        boolean allowText)
                                 throws WavesetException
Parse the children of an element into an array, including a previously created element at the front. UPDATE: The ability to pass in the first node was originally used by dolist to insert an implicit for the iteration variable, this is no longer used.

Throws:
WavesetException

parseChildren

protected static void parseChildren(org.w3c.dom.Node domnode,
                                    boolean allowText,
                                    java.util.List nodes)
                             throws WavesetException
Parse the children of an element building a list of nodes. Optionally allow literal text to be converted to ExValueNode objects. NOTE WELL: have to trim whitespace and collapse adjacent text nodes when parsing text. If not, when the resulting node tree gets serialized, extra newlines will be added around the interior nodes, when this is parsed again, we find more newline "text" and add more string constants, not only does this break calculated s, but if you keep round-tripping this it will continue to grow This seems to be necessary only for newlines, if there are just trailing spaces, the XML parser seems to be free to remove them, is this the "insignificant whitespace" issue? I thought XML avoided that...Either way, unless we can keep the parser from doing that, there seems to be no way to have mixed content with spaces around elements. This is relatively obscure, but I could imagine it happening with more often than .

Throws:
WavesetException