com.novell.xsl.extensions
Class JavaObject

java.lang.Object
  extended bycom.novell.xsl.extensions.JavaObject
All Implemented Interfaces:
ExpressionValue

public class JavaObject
extends Object
implements ExpressionValue

A wrapper class for a generic java Object, permitting the Object to be used in XPath expressions.


Field Summary
 
Fields inherited from interface com.novell.xml.xpath.ExpressionValue
BOOLEAN, EXTENDED, NATIVE, NODE_SET, NUMBER, STRING
 
Constructor Summary
JavaObject()
          Construct a null JavaObject
JavaObject(Object object)
          Construct a JavaObject that wraps the passed object.
 
Method Summary
 void castFrom(Object type)
          Convert from a different type of expression value to the type of the class implementing the ExpressionValue interface.
 void dump(PrintWriter writer)
          Output a human-readable form for the value
static Class getArgType()
          Return the Class object for objects of this type.
 boolean getBooleanValue()
          Return boolean value of expression value (will convert to boolean if value is not of type boolean)
 Object getNativeValue()
          return the underlying native value (java.lang.Boolean, java.lang.Double, etc.)
 NodeSet getNodeSetValue()
          Return node-set value of this ExpressionValue.
 double getNumberValue()
          Return numeric value of ExpressionValue.
 Object getObject()
          Return the underlying java Object
 String getStringValue()
          Return string value of this ExpressionValue.
 int getValueType()
          Return type of expression value
 Class getWrappedType()
          Return the Class of the wrapped object This will not be valid if either object is null, or set wrapped type has not been called.
 void setWrappedType(Class wrappedType)
          Set the wrapped object Class, if there is no current wrapped object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JavaObject

public JavaObject(Object object)
Construct a JavaObject that wraps the passed object.

Parameters:
object - The object to wrap.

JavaObject

public JavaObject()
Construct a null JavaObject

Method Detail

getArgType

public static Class getArgType()
Return the Class object for objects of this type. This is used for FunctionSignature objects.

Returns:
The Class object corresponding to BooleanValue

getObject

public Object getObject()
Return the underlying java Object

Returns:
The java Object associated with this JavaObject object (object...object...object)

getWrappedType

public Class getWrappedType()
Return the Class of the wrapped object This will not be valid if either object is null, or set wrapped type has not been called. This is primarily designed for parameter type matching for extension functions

Returns:
The Class of the wrapped object

setWrappedType

public void setWrappedType(Class wrappedType)
Set the wrapped object Class, if there is no current wrapped object. This is primarily designed for parameter type matching for extension functions

Parameters:
wrappedType - The Class of the intended wrapped object

getValueType

public int getValueType()
Return type of expression value

Specified by:
getValueType in interface ExpressionValue
Returns:
ExpressionValue.BOOLEAN, ExpressionValue.NUMBER, etc.

castFrom

public void castFrom(Object type)
              throws XPathConversionException
Convert from a different type of expression value to the type of the class implementing the ExpressionValue interface. This is used primarily for converting parameters for function calls. The XPath basic types (Boolean, Number, String, Node-set) use the required methods of ExpressionValue to perform this function. Extended types must implement this according to their language definitions.

Specified by:
castFrom in interface ExpressionValue
Parameters:
type - The object to convert from.
Throws:
XPathConversionException

getBooleanValue

public boolean getBooleanValue()
                        throws XPathConversionException
Return boolean value of expression value (will convert to boolean if value is not of type boolean)

Specified by:
getBooleanValue in interface ExpressionValue
Returns:
true or false
Throws:
XPathConversionException

getNumberValue

public double getNumberValue()
                      throws XPathConversionException
Return numeric value of ExpressionValue. Will convert to a number if value is not of NUMBER type

Specified by:
getNumberValue in interface ExpressionValue
Returns:
numeric value
Throws:
XPathConversionException

getStringValue

public String getStringValue()
Return string value of this ExpressionValue. Will convert to a string if underlying type is not string.

Specified by:
getStringValue in interface ExpressionValue
Returns:
String value of ExpressionValue

getNodeSetValue

public NodeSet getNodeSetValue()
                        throws XPathConversionException
Return node-set value of this ExpressionValue. Will NOT convert an underlying type to a node-set.

Specified by:
getNodeSetValue in interface ExpressionValue
Throws:
XPathConversionException

getNativeValue

public Object getNativeValue()
return the underlying native value (java.lang.Boolean, java.lang.Double, etc.)

Specified by:
getNativeValue in interface ExpressionValue
Returns:
The native java class that is the value

dump

public void dump(PrintWriter writer)
Output a human-readable form for the value

Specified by:
dump in interface ExpressionValue
Parameters:
writer - Output device