org.apache.jdo.impl.model.jdo.xml
Class XMLExists

java.lang.Object
  extended byorg.apache.jdo.impl.model.jdo.xml.XMLExists

public class XMLExists
extends java.lang.Object

This class allows to check whether there is JDO metadata for a class with a given class name. There must be a class file (enhanced or not enhanced) available in the classpath of the caller.

Usage: XMLExists <options> <arguments>...
Options:
  -h       print usage message
  -v       print verbose messages and JDO metadata
  -q       do not print any output; just set the exit code
  -xml     expected to find JDO XML metadata for the specified class(es)
  -noxml   expected to find no JDO XML metadata for the specified class(es)
Arguments:
  <classname>  the fully qualified name of a class to be checked

The following sample call checks whether there is JDO XML metadata for the classes Emplyoe and Department from the com.xyz.hr package and dumps the JDOClass instances:
  java org.apache.jdo.impl.model.jdo.util.XMLExists -v com.xyz.hr.Employee com.xyz.hr.Department

Method main will exit the JVM with an exit code 1 if the test fails for at least one class. Please note, the class dumps the JDOClass if the outputLevel is set to VERBOSE (e.g. by setting the -v option). This JDOClass info does NOT include runtime metadata, even if the class file is enhanced.

Author:
Michael Bouschen

Field Summary
static int NORMAL
          Normal output.
static int QUIET
          No messages, just set the exit code.
static int VERBOSE
          Print verbose messages.
 
Constructor Summary
XMLExists()
          No arg constructor.
XMLExists(boolean xmlExpected, int outputLevel)
          Constructor taking checkXMLExists and outputLevel.
 
Method Summary
 void checkClass(java.lang.String className, java.lang.ClassLoader classLoader, org.apache.jdo.model.jdo.JDOModel jdoModel, boolean xmlExpected)
          The method checks the class with the specified class name.
static void main(java.lang.String[] args)
          The main method checks all classes specified as argument.
protected  java.util.List processArgs(java.lang.String[] args)
          Helper method to do command line argument processing.
 boolean run(java.util.List classNames)
          This method checks all classes from the specified list of class names.
 void usage()
          Print a usage message to System.err.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VERBOSE

public static final int VERBOSE
Print verbose messages.

See Also:
Constant Field Values

NORMAL

public static final int NORMAL
Normal output.

See Also:
Constant Field Values

QUIET

public static final int QUIET
No messages, just set the exit code.

See Also:
Constant Field Values
Constructor Detail

XMLExists

public XMLExists()
No arg constructor. The flags default to


XMLExists

public XMLExists(boolean xmlExpected,
                 int outputLevel)
Constructor taking checkXMLExists and outputLevel.

Method Detail

main

public static void main(java.lang.String[] args)
The main method checks all classes specified as argument. It will exit the JVM with an exit code 1 if the test fails for at least one class.

Parameters:
args - arguments which are options followed by class names.

run

public boolean run(java.util.List classNames)
This method checks all classes from the specified list of class names. It uses the current classLoader to load the classes. The method returns false if there is at least one class that fails on checking.

Parameters:
classNames - list of classes to be checked
Returns:
true if all classes are ok; false otherwise.

checkClass

public void checkClass(java.lang.String className,
                       java.lang.ClassLoader classLoader,
                       org.apache.jdo.model.jdo.JDOModel jdoModel,
                       boolean xmlExpected)
                throws java.lang.Exception
The method checks the class with the specified class name. It first loads the class using the specified class loader. If the flag xmlExpected is true it expects to get a non-null JDOClass instance. If the flag xmlExpected is false it expects to get a null JDOClass instance.

The method indicates any failure by throwing an exception. It dumps the JDOClass if the output level is VERBOSE.

Parameters:
className - the name of the class to be checked
classLoader - the class loader to be used to load the class
jdoModel - JDOModel for type info
xmlExpected - flag whether the class to be checked is expected to have JDO XML metadata or not.
Throws:
java.lang.Exception

processArgs

protected java.util.List processArgs(java.lang.String[] args)
Helper method to do command line argument processing.

Parameters:
args - the arguments passed to main.
Returns:
the list of classes to be checked.

usage

public void usage()
Print a usage message to System.err.



Copyright © 2005 Apache Software Foundation. All Rights Reserved.