Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 


org.eclipse.jet
Class XPathContextExtender

java.lang.Object
  extended by 
org.eclipse.jet.XPathContextExtender
All Implemented Interfaces:
XPathVariableResolver

public final class XPathContextExtender
extends java.lang.Object
implements XPathVariableResolver

Context Extender that understands XPath processing.


Constructor Summary
XPathContextExtender ( JET2Context context)
          Deprecated. Use getInstance(JET2Context). This method will be made private in the near future.
 
Method Summary
 void addCustomFunctions ( XPathFunctionMetaData[] functionData)
          Add the passed list of XPath function definitions to the XPath processor.
 java.lang.Object addElement (java.lang.Object parent, java.lang.String name)
           
 java.lang.Object addTextElement (java.lang.Object parentElement, java.lang.String name, java.lang.String bodyContent)
          Create a new text (simple) element whose content is set to bodyContent.
 java.lang.Object addTextElement (java.lang.Object parentElement, java.lang.String name, java.lang.String bodyContent, boolean asCData)
          Create a new text (simple) element whose content is set to bodyContent.
 java.lang.Object copyElement (java.lang.Object srcElement, java.lang.Object tgtParent, java.lang.String name, boolean recursive)
          Copy srcElement as a new element with the specified name under tgtParent.
protected  java.lang.Object createExtendedData ( JET2Context context)
           
 java.lang.Object currentXPathContextObject ()
          Return the current XPath context object.
 java.lang.Object getAttributeValue (java.lang.Object element, java.lang.String attributeName)
          Return the value of the named attribute on the passed element.
 java.lang.String getContent (java.lang.Object object)
          Return the string value of the passed object.
static  XPathContextExtender getInstance ( JET2Context context)
          Factory method for XPathContextExtenders
 java.lang.Object popXPathContextObject ()
          Restore the previous XPath context object.
 void pushXPathContextObject (java.lang.Object contextObject)
          Push a new XPath context object.
 void removeAttribute (java.lang.Object element, java.lang.String attributeName)
          Remove the named attribute from the specified element.
 void removeElement (java.lang.Object element)
           
 java.lang.Object[] resolve (java.lang.Object xpathContextObject, java.lang.String selectXPath)
          Resolve an XPath expression into an array of Objects.
 java.lang.Object[] resolve (java.lang.String selectXPath)
          Resolve an XPath expression into an array of Objects.
 java.lang.Object resolveAsObject (java.lang.Object contextObject, java.lang.String selectXPath)
          Resolve the XPath expression, returning an object.
 java.lang.Object resolveAsObject (java.lang.String selectXPath)
          Resolve the XPath expression, returning an object.
 java.lang.String resolveAsString (java.lang.Object xpathContextObject, java.lang.String selectXPath)
          Resolve the given XPath expression as a string value.
 java.lang.String resolveAsString (java.lang.String selectXPath)
          Resolve the given XPath expression as a string value.
 java.lang.String resolveDynamic (java.lang.String value)
          Resolve dynamic XPath expressions {...} within the pass value
static java.lang.String resolveDynamic (java.lang.String value, JET2Context context)
           
 java.lang.Object resolveSingle (java.lang.Object xpathContextObject, java.lang.String selectXPath)
          Resolve an XPath expression to a single object.
 java.lang.Object resolveSingle (java.lang.String selectXPath)
          Resolve an XPath expression to a single object.
 boolean resolveTest (java.lang.Object xpathContext, java.lang.String testXPath)
          Resolve an xpath expression as a boolean result according to the XPath rules.
 boolean resolveTest (java.lang.String textXPath)
          Resolve an xpath expression as a boolean result according to the XPath rules.
 java.lang.Object resolveVariable (java.lang.String name)
           
 boolean setAttribute (java.lang.Object element, java.lang.String name, java.lang.String bodyContent)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XPathContextExtender

public XPathContextExtender(
JET2Context context)
Deprecated. Use getInstance(JET2Context). This method will be made private in the near future.

Parameters:
context -
Method Detail

getInstance

public static 
XPathContextExtender getInstance(
JET2Context context)
Factory method for XPathContextExtenders

Parameters:
context - the JET2Context that is extended
Returns:
an XPathContextExtender

createExtendedData

protected java.lang.Object createExtendedData(
JET2Context context)

resolveVariable

public java.lang.Object resolveVariable(java.lang.String name)
Specified by:
resolveVariable in interface XPathVariableResolver

resolveAsString

public java.lang.String resolveAsString(java.lang.Object xpathContextObject,
                                        java.lang.String selectXPath)
                                 throws 
JET2TagException
Resolve the given XPath expression as a string value. Note that if the XPath expression returns an empty Node set, this method returns null

Parameters:
xpathContextObject - the xpath context
selectXPath - the XPath expression
Returns:
the string value of the XPath expression, or null if the expression resulted in an empty node set.
Throws:
JET2TagException - if an error occurs during expression evaluation

resolveAsString

public java.lang.String resolveAsString(java.lang.String selectXPath)
                                 throws 
JET2TagException
Resolve the given XPath expression as a string value. Note that if the XPath expression returns an empty Node set, this method returns null. This is a convenience implementation of:
 resolveAsString(currentXPathContextObject(), selectXPath)
 

Parameters:
selectXPath - the XPath expression
Returns:
the string value of the XPath expression, or null if the expression resulted in an empty node set.
Throws:
JET2TagException - if an error occurs during expression evaluation
Since:
1.0
See Also:
resolveAsString(Object, String)

resolveSingle

public java.lang.Object resolveSingle(java.lang.Object xpathContextObject,
                                      java.lang.String selectXPath)
                               throws 
JET2TagException
Resolve an XPath expression to a single object. If the Xpath expression returns a collection, then return the first element in the collection, or null if that colleciton is empty. Otherwise, the result of the XPath expression is returned.

Parameters:
xpathContextObject - the context object used to resolve relative XPath expressions
selectXPath - the Xpath expression
Returns:
an Object or null
Throws:
JET2TagException - if an XPath error occurs.

resolveSingle

public java.lang.Object resolveSingle(java.lang.String selectXPath)
                               throws 
JET2TagException
Resolve an XPath expression to a single object. This is a convenience implementation of:
 resolveSingle(currentXPathContextObject(), selectXPath)
 

Parameters:
selectXPath - the Xpath expression
Returns:
an Object or null
Throws:
JET2TagException - if an XPath error occurs.
Since:
1.0
See Also:
resolveSingle(Object, String)

currentXPathContextObject

public java.lang.Object currentXPathContextObject()
Return the current XPath context object. If no context object has been specified via { pushXPathContextObject(Object), then value of JET2Context.getSource() is returned

Returns:
the XPath context object

pushXPathContextObject

public void pushXPathContextObject(java.lang.Object contextObject)
Push a new XPath context object. The XPath context object is used to resolve relative XPath expressions.

Parameters:
contextObject - the object that will be the new XPath context object
Since:
1.0
See Also:
currentXPathContextObject(), popXPathContextObject()

popXPathContextObject

public java.lang.Object popXPathContextObject()
Restore the previous XPath context object.

Returns:
the XPath context object that was just removed
Throws:
java.util.EmptyStackException - if there is no prior XPath context to restore.
Since:
1.0
See Also:
currentXPathContextObject(), pushXPathContextObject(Object)

resolve

public java.lang.Object[] resolve(java.lang.Object xpathContextObject,
                                  java.lang.String selectXPath)
                           throws 
JET2TagException
Resolve an XPath expression into an array of Objects.

Parameters:
xpathContextObject - the context object for relative Xpath expressions
selectXPath - the XPath expression
Returns:
a possibly empty array of objects resolved by the expression
Throws:
JET2TagException - if an error in the XPath expression occurs

resolve

public java.lang.Object[] resolve(java.lang.String selectXPath)
                           throws 
JET2TagException
Resolve an XPath expression into an array of Objects. This method is a convenience implementation of:
 resolve(currentXPathContextObject(), selectXPath)
 

Parameters:
selectXPath - selectXPath the XPath expression
Returns:
a possibly empty array of objects resolved by the expression
Throws:
JET2TagException - if an error in the XPath expression occurs
Since:
1.0

resolveTest

public boolean resolveTest(java.lang.Object xpathContext,
                           java.lang.String testXPath)
                    throws 
JET2TagException
Resolve an xpath expression as a boolean result according to the XPath rules.

See the documentation of the XPath boolean function for complete details on how XPath results are converted to boolean values.

Parameters:
xpathContext - the XPath context object
testXPath - the XPath expression
Returns:
true or false
Throws:
JET2TagException - if an error occurs in evaluating the expression.

resolveTest

public boolean resolveTest(java.lang.String textXPath)
                    throws 
JET2TagException
Resolve an xpath expression as a boolean result according to the XPath rules. This method is a convenience implementation of:
 resolveTest(currentXPathContextObject(), textXPath)
 

Parameters:
testXPath - the XPath expression
Returns:
true or false
Throws:
JET2TagException - if an error occurs in evaluating the expression.
Since:
1.0
See Also:
resolveTest(Object, String)

setAttribute

public boolean setAttribute(java.lang.Object element,
                            java.lang.String name,
                            java.lang.String bodyContent)
                     throws 
JET2TagException
Throws:
JET2TagException

resolveDynamic

public java.lang.String resolveDynamic(java.lang.String value)
                                throws 
JET2TagException
Resolve dynamic XPath expressions {...} within the pass value

Parameters:
value - a string containing zero or more dynamic xpath expressions
Returns:
the string with all dynamic xpath expressions resolved
Throws:
JET2TagException - if an Xpath evaluation error occurs

resolveDynamic

public static java.lang.String resolveDynamic(java.lang.String value,
                                              
JET2Context context)
                                       throws 
JET2TagException
Throws:
JET2TagException

addElement

public java.lang.Object addElement(java.lang.Object parent,
                                   java.lang.String name)
                            throws 
JET2TagException
Throws:
JET2TagException

removeElement

public void removeElement(java.lang.Object element)
                   throws 
JET2TagException
Throws:
JET2TagException

copyElement

public java.lang.Object copyElement(java.lang.Object srcElement,
                                    java.lang.Object tgtParent,
                                    java.lang.String name,
                                    boolean recursive)
                             throws 
JET2TagException
Copy srcElement as a new element with the specified name under tgtParent. If recursive is true, then all the contained children of srcElement are copied, otherwise, only the element and its attributes are copied.

Parameters:
srcElement - the element to copy
tgtParent - the parent element that will contain the copy
name - the name of the copied element
recursive - true if contained chidren are to be copied, too.
Returns:
the newly copied element
Throws:
JET2TagException - an error occurs

addTextElement

public java.lang.Object addTextElement(java.lang.Object parentElement,
                                       java.lang.String name,
                                       java.lang.String bodyContent)
                                throws 
JET2TagException
Create a new text (simple) element whose content is set to bodyContent.

Parameters:
parentElement - the parent of the new element.
name - the name of the new element.
bodyContent - the content.
Returns:
the new Element.
Throws:
JET2TagException - if the element cannot be added.

addTextElement

public java.lang.Object addTextElement(java.lang.Object parentElement,
                                       java.lang.String name,
                                       java.lang.String bodyContent,
                                       boolean asCData)
                                throws 
JET2TagException
Create a new text (simple) element whose content is set to bodyContent.

Parameters:
parentElement - the parent of the new element.
name - the name of the new element.
bodyContent - the content.
asCData - if true, create the element as a CDATA section, of possible
Returns:
the new element.
Throws:
JET2TagException - if the element cannot be added.

resolveAsObject

public java.lang.Object resolveAsObject(java.lang.Object contextObject,
                                        java.lang.String selectXPath)
                                 throws 
JET2TagException
Resolve the XPath expression, returning an object. Unlike the other resolve methods, this method performs no type conversions on the XPath results.

Parameters:
contextObject - the context object to which the XPath expression is relative.
selectXPath - the XPath expression
Returns:
the result of the expression evaluation.
Throws:
JET2TagException - if an error occurs.

resolveAsObject

public java.lang.Object resolveAsObject(java.lang.String selectXPath)
                                 throws 
JET2TagException
Resolve the XPath expression, returning an object. Unlike the other resolve methods, this method performs no type conversions on the XPath results. This is a convenience implementation of:
 resolveAsObject(currentXPathContextObject(), selectXPath);
 

Parameters:
selectXPath - the XPath expression
Returns:
the result of the expression evaluation.
Throws:
JET2TagException - if an error occurs.
Since:
1.0
See Also:
resolveAsObject(Object, String)

getAttributeValue

public java.lang.Object getAttributeValue(java.lang.Object element,
                                          java.lang.String attributeName)
                                   throws 
JET2TagException
Return the value of the named attribute on the passed element.

Parameters:
element - the element containing the attribute
attributeName - the attribute name
Returns:
the attribute value
Throws:
JET2TagException

removeAttribute

public void removeAttribute(java.lang.Object element,
                            java.lang.String attributeName)
                     throws 
JET2TagException
Remove the named attribute from the specified element.

Parameters:
element - the element containing the attribute
attributeName - the attribute to remove
Throws:
JET2TagException - if the attribute cannot be removed (because it is required), or if element is not a recognized element.

getContent

public java.lang.String getContent(java.lang.Object object)
                            throws 
JET2TagException
Return the string value of the passed object. This equivalent to calling the XPath string() function on the passed object.

Parameters:
object - the object to examine.
Returns:
the string value.
Throws:
JET2TagException - if an error occurs.

addCustomFunctions

public void addCustomFunctions(
XPathFunctionMetaData[] functionData)
Add the passed list of XPath function definitions to the XPath processor.

Parameters:
functionData - possible empty array of XPathFunctionMetaData instances.

Copyright 2006 IBM Corporation and others.
All Rights Reserved.


 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire