org.castor.xmlctf.util

Class 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) $
Authors:
Keith Visco
Arnaud Blandin

Field Summary

static String
BOOLEAN
The Java primitives.
static String
BYTE
static String
CHARACTER
static String
DOUBLE
static String
FLOAT
static String
INT
static String
LONG
static String
SHORT
static String
STRING

Method Summary

static int
compare(String document1, 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 Class
getClass(String name, ClassLoader loader)
Returns the class associated with the given name.
static Object
instantiateObject(String type, String value, ClassLoader loader)
Converts the given value to a Java representation that corresponds to the given type.

Field Details

BOOLEAN

public static final String BOOLEAN
The Java primitives.

BYTE

public static final String BYTE

CHARACTER

public static final String CHARACTER

DOUBLE

public static final String DOUBLE

FLOAT

public static final String FLOAT

INT

public static final String INT

LONG

public static final String LONG

SHORT

public static final String SHORT

STRING

public static final String STRING

Method Details

compare

public static int compare(String document1,
                          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'.

getClass

public static Class getClass(String name,
                             ClassLoader loader)
            throws 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.

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 converted
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:
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