Package org.castor.xmlctf.util
Class CTFUtils
- java.lang.Object
-
- org.castor.xmlctf.util.CTFUtils
-
public class CTFUtils extends java.lang.ObjectThis 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 Modifier and Type Field Description static java.lang.StringBOOLEANThe Java primitives.static java.lang.StringBYTEstatic java.lang.StringCHARACTERstatic java.lang.StringDOUBLEstatic java.lang.StringFLOATstatic java.lang.StringINTstatic java.lang.StringLONGstatic java.lang.StringSHORTstatic java.lang.StringSTRING
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intcompare(java.lang.String document1, java.lang.String document2)Compares two XML documents located at 2 given URLs, returning the number of differences or 0 if both documents are 'XML equivalent'.static java.lang.ClassgetClass(java.lang.String name, java.lang.ClassLoader loader)Returns the class associated with the given name.static java.lang.ObjectinstantiateObject(java.lang.String type, java.lang.String value, java.lang.ClassLoader loader)Converts the given value to a Java representation that corresponds to the given type.
-
-
-
Field Detail
-
BOOLEAN
public static final java.lang.String BOOLEAN
The Java primitives.- See Also:
- Constant Field Values
-
BYTE
public static final java.lang.String BYTE
- See Also:
- Constant Field Values
-
CHARACTER
public static final java.lang.String CHARACTER
- See Also:
- Constant Field Values
-
DOUBLE
public static final java.lang.String DOUBLE
- See Also:
- Constant Field Values
-
FLOAT
public static final java.lang.String FLOAT
- See Also:
- Constant Field Values
-
INT
public static final java.lang.String INT
- See Also:
- Constant Field Values
-
LONG
public static final java.lang.String LONG
- See Also:
- Constant Field Values
-
SHORT
public static final java.lang.String SHORT
- See Also:
- Constant Field Values
-
STRING
public static final java.lang.String STRING
- See Also:
- Constant Field Values
-
-
Method Detail
-
compare
public static int compare(java.lang.String document1, java.lang.String document2) throws java.io.IOExceptionCompares 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:
java.io.IOException- if an error occurs reading either XML document
-
getClass
public static java.lang.Class getClass(java.lang.String name, java.lang.ClassLoader loader) throws java.lang.ClassNotFoundExceptionReturns 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:
java.lang.ClassNotFoundException- if the given class cannot be loaded using the provided class loader.
-
instantiateObject
public static java.lang.Object instantiateObject(java.lang.String type, java.lang.String value, java.lang.ClassLoader loader) throws java.lang.ClassNotFoundException, MarshalExceptionConverts the given value to a Java representation that corresponds to the given type.- Parameters:
value- the value to be convertedtype- a string representation of the java type.loader- 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:
java.lang.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
-
-