Package org.castor.xmlctf.util
Class CTFUtils
java.lang.Object
org.castor.xmlctf.util.CTFUtils
This class contains utility methods needed by the CTF.
- Version:
- $Revision: 6787 $ $Date: 2005-03-05 06:42:06 -0700 (Sat, 05 Mar 2005) $
- Author:
- Keith Visco, Arnaud Blandin
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic intCompares two XML documents located at 2 given URLs, returning the number of differences or 0 if both documents are 'XML equivalent'.static ClassgetClass(String name, ClassLoader loader) Returns the class associated with the given name.static ObjectinstantiateObject(String type, String value, ClassLoader loader) Converts the given value to a Java representation that corresponds to the given type.
-
Field Details
-
BOOLEAN
The Java primitives.- See Also:
-
BYTE
- See Also:
-
CHARACTER
- See Also:
-
DOUBLE
- See Also:
-
FLOAT
- See Also:
-
INT
- See Also:
-
LONG
- See Also:
-
SHORT
- See Also:
-
STRING
- See Also:
-
-
Method Details
-
compare
Compares two XML documents located at 2 given URLs, returning the number of differences or 0 if both documents are 'XML equivalent'.- Parameters:
document1- the URL of the first XML document.document2- the URL of the second XML document.- Returns:
- an int indicating the number of differences or 0 if both documents are 'XML equivalent'.
- Throws:
IOException- if an error occurs reading either XML document
-
getClass
Returns the class associated with the given name.- Parameters:
name- the fully qualified name of the class to return. Primitives are handled through their name and not their class name. For instance 'boolean' should be used instead of 'java.lang.Boolean.TYPE'.loader- the ClassLoader to use if the class needs to be loaded- Returns:
- the class associated with given name.
- Throws:
ClassNotFoundException- if the given class cannot be loaded using the provided class loader.
-
instantiateObject
public static Object instantiateObject(String type, String value, ClassLoader loader) throws ClassNotFoundException, MarshalException Converts the given value to a Java representation that corresponds to the given type.- Parameters:
type- a string representation of the java type.value- the value to be convertedloader- an optional ClassLoader used in case we need to use the Unmarshaller to retrieve a complex java object.- Returns:
- an java object that corresponds to the given value converted to a java type according to the type passed as parameter.
- Throws:
ClassNotFoundException- if the type is not a recognized primitive type and the class loader provided cannot load the typeMarshalException- if the type is not a recognized primitive type and no Marshaller can be found for that type
-