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) $
    Author:
    Keith Visco, Arnaud Blandin
    • Field Summary

      Fields 
      Modifier and Type Field Description
      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

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      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
    • 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