org.castor.xmlctf.util
Class CTFUtils

java.lang.Object
  extended by org.castor.xmlctf.util.CTFUtils

public class CTFUtils
extends java.lang.Object

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
static java.lang.String BOOLEAN
          The Java primitives.
static java.lang.String BYTE
           
static java.lang.String CHARACTER
           
static java.lang.String DOUBLE
           
static java.lang.String FLOAT
           
static java.lang.String INT
           
static java.lang.String LONG
           
static java.lang.String SHORT
           
static java.lang.String STRING
           
 
Method Summary
static int compare(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.Class getClass(java.lang.String name, java.lang.ClassLoader loader)
          Returns the class associated with the given name.
static java.lang.Object instantiateObject(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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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.IOException
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:
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.ClassNotFoundException
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:
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,
                                                 MarshalException
Converts the given value to a Java representation that corresponds to the given type.

Parameters:
value - the value to be converted
type - 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 type
MarshalException - if the type is not a recognized primitive type and no Marshaller can be found for that type


Intalio Inc. (C) 1999-2008. All rights reserved http://www.intalio.com