Class CTFUtils

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

public class CTFUtils extends 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 Details

  • Method Details

    • compare

      public static int compare(String document1, String document2) throws 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:
      IOException - if an error occurs reading either XML document
    • 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.
      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 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:
      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