Methods Summary |
---|
public void | addClass(ClassControl cc)Add the class to the class mapping table. Check that it does
not conflict with earlier settings.
String className = cc.className();
ClassControl existCC = getClass(className);
if (existCC != null) {
if (!existCC.source().sameAs(cc.source())) {
//@olsen: support for I18N
error(getI18N("enhancer.class_already_entered",//NOI18N
cc.userClassName(),
cc.sourceName(),
existCC.sourceName()));
return;
}
// the two files are from the same source - select the higher
// level of persistence capability and discard the other
if (cc.persistType() == ClassControl.PersistUnknown ||
existCC.persistType() == ClassControl.PersistCapable ||
(existCC.persistType() == ClassControl.PersistAware &&
cc.persistType() != ClassControl.PersistCapable))
return;
}
if (existCC == null && cc.sourceName() != null)
message("adding class " + cc.userClassName() +//NOI18N
" from " + cc.sourceName());//NOI18N
classMap.put(className, cc);
|
public boolean | canFindClass(java.lang.String className)Look for the specified class in the class map. If not there,
use the class path to find the class. If still not found,
return false.
return findClass(className) != null;
|
private boolean | classWarningsSuppressed(java.lang.String classname)Check whether the named class should have warnings suppressed.
return classSuppressions.get(classname) != null;
|
public java.util.ArrayList | collectClasses(int persistType)Return a ArrayList of ClassControl objects which have the specified
persistence type
ArrayList v = new ArrayList();
for (Iterator e = classMap.values().iterator(); e.hasNext();) {
ClassControl cc = (ClassControl)e.next();
if (cc.persistType() == persistType)
v.add(cc);
}
return v;
|
public java.util.ArrayList | collectClasses()Return an ArrayList of the ClassControls in classMap.
This is useful in that it provides a stable base for enumeration.
ArrayList v = new ArrayList();
for (Iterator e = classMap.values().iterator(); e.hasNext(); )
v.add(e.next());
return v;
|
public java.io.File | destinationDirectory()
return destinationDirectory;
|
public boolean | doInitializerOptimization()
return disableInitializerAnnotationSuppression == false;
|
public boolean | doThisOptimization()
return disableThisHookHoisting == false;
|
public boolean | doTimingStatistics()
return timingOption;
|
public void | error(java.lang.String error)
errorsEncountered++;
//@olsen: support for I18N
//@olsen: redirected output
//System.out.print("Error: ");
//System.out.println(err);
err.println(lastErrorMessage = getI18N("enhancer.enumerated_error",
errorsEncountered,
error));
|
public int | errorCount()
return errorsEncountered;
|
public void | excludeDestinationDirectory()Update the class path to remove the destination directory if it
is found in the class path.
if (destinationDirectory != null)
classPathOption.remove(destinationDirectory);
|
private boolean | fieldWarningsSuppressed(java.lang.String classname, java.lang.String fieldName)Check whether the named field in the named class should have
warnings suppressed.
return fieldSuppressions.get(classname + "." + fieldName) != null;//NOI18N
|
public ClassControl | findClass(java.lang.String className)Look for the specified class in the class map. If not there,
use the class path to find the class. If still not found,
return false.
ClassControl cc = (ClassControl) classMap.get(className);
if ((cc == null) && (missingClasses.get(className) == null)) {
// Not already known - try looking up in class path
cc = lookupClass(className);
if (cc != null) {
message("Reading class " + cc.userClassName() +//NOI18N
" from " + cc.sourceName());//NOI18N
classMap.put(className, cc);
} else {
missingClasses.put(className, className);
}
}
return cc;
|
public boolean | forceOverwrite()
return forceOverwriteOption;
|
public ClassControl | getClass(java.lang.String className)Look for the specified class in the class map. No other class
lookup is performed. Use this only if you are certain that the
class will have been found.
return (ClassControl)classMap.get(className);
|
public java.util.Iterator | getClasses()
return classMap.values().iterator();
|
public java.io.PrintWriter | getErrorWriter()
return err;
|
public com.sun.jdo.api.persistence.enhancer.meta.JDOMetaData | getJDOMetaData()Is the class a well known persistent capable class? These are
normally the java primitives.
return jdoMetaData;
|
public final java.lang.String | getLastErrorMessage()
return this.lastErrorMessage;
|
public java.io.PrintWriter | getOutputWriter()
return out;
|
public boolean | isVerbose()
return this.verboseOption;
|
public ClassControl | lookupClass(java.lang.String className)Look up the specified class in the class search path. Callers
should normally consult the classmap prior to calling this function.
The class is not entered into the classmap
ClassFileSource source = classPathOption.findClass(className);
while (true) {
if (source == null)
return null;
//@olsen: cosmetics
try {
ClassControl cc = new ClassControl(source, this);
if (cc.className() != null &&
cc.className().equals(className))
return cc;
} catch (ClassFormatError e) {
}
// Try to find an alternate source for the class
source = source.nextSource(className);
}
|
public com.sun.jdo.api.persistence.enhancer.util.ClassFileSource | lookupDestClass(java.lang.String className)Look for a class source using the destination directory as a
root directory for the lookup which represents the annotated output
for the class specified. Return null if not found.
if (destClassPath == null && destinationDirectory != null)
destClassPath = new ClassPath(destinationDirectory.getPath());
return (destClassPath == null
? null : destClassPath.findClass(className));
|
public void | message(java.lang.String mess)
if (verboseOption) {
//@olsen: redirected output
//System.out.println(mess);
out.println("JDO ENHANCER: " + mess);//NOI18N
}
|
public void | messageNL(java.lang.String mess)
if (verboseOption) {
//@olsen: redirected output
//System.out.println(mess);
out.println();
out.println("JDO ENHANCER: " + mess);//NOI18N
}
|
public void | moveDestinationDirectoryToEnd()Update the class path to move the destination directory to the
end of the class path if it is found in the class path.
if (destinationDirectory != null &&
classPathOption.remove(destinationDirectory))
classPathOption.append(destinationDirectory);
|
public void | reset()Reset the environment.
/*
jdoMetaData = null;
verboseOption = false;
quietOption = false;
dumpLevel = 0;
disableThisHookHoisting = false;
disableInitializerAnnotationSuppression = false;
disableArrayHookCaching = false;
disableArrayElementFetch = false;
noWriteOption = false;
forceOverwriteOption = false;
updateInPlaceOption = false;
classPathOption = null;
destinationDirectory = null;
destClassPath = null;
renamedMap.clear();
translations.clear();
*/
errorsEncountered = 0;
classMap.clear();
missingClasses.clear();
fieldSuppressions.clear();
classSuppressions.clear();
|
public void | setDestinationDirectory(java.lang.String dir)
final File dest = new File(dir);
if (destinationDirectory != null) {
//@olsen: support for I18N
error(getI18N("destination_directory_already_set",//NOI18N
dir,
destinationDirectory.getPath()));
return;
}
if (!dest.isDirectory()) {
error(getI18N("enhancer.destination_directory_not_exist",//NOI18N
dir));
return;
}
destinationDirectory = dest;
|
public void | setDoTimingStatistics(boolean dontOpt)
// public accessors
timingOption = dontOpt;
|
public void | setErrorWriter(java.io.PrintWriter err)
this.err = err;
|
public void | setForceOverwrite(boolean forceOverwrite)
forceOverwriteOption = forceOverwrite;
|
public void | setJDOMetaData(com.sun.jdo.api.persistence.enhancer.meta.JDOMetaData jdoMetaData)
this.jdoMetaData = jdoMetaData;
|
public void | setNoInitializerOptimization(boolean dontOpt)
disableInitializerAnnotationSuppression = dontOpt;
|
public void | setNoOptimization(boolean dontOpt)
//@olsen: disabled feature
/*
disableArrayHookCaching = dontOpt;
*/
disableThisHookHoisting = dontOpt;
disableInitializerAnnotationSuppression = dontOpt;
//@olsen: disabled feature
/*
disableArrayElementFetch = dontOpt;
*/
|
public void | setNoThisOptimization(boolean dontOpt)
disableThisHookHoisting = dontOpt;
|
public void | setNoWrite(boolean dontWrite)
noWriteOption = dontWrite;
|
public void | setOutputWriter(java.io.PrintWriter out)
this.out = out;
|
public void | setQuiet(boolean beQuiet)
quietOption = beQuiet;
|
public void | setVerbose(boolean beVerbose)
verboseOption = beVerbose;
|
public void | suppressClassWarnings(java.lang.String className)Add a suppression entry for a class
classSuppressions.put(className, className);
|
public void | suppressFieldWarnings(java.lang.String fullFieldName)Add a suppression entry for a field of a class
fieldSuppressions.put(fullFieldName, fullFieldName);
|
public boolean | updateInPlace()
return updateInPlaceOption;
|
static java.lang.String | validVMPackage(java.lang.String pkg)Convert a user package name to a VM package name.
If the package name isn't valid, return null instead.
StringBuffer buf = new StringBuffer();
int i=0;
while (i<pkg.length()) {
if (i != 0) {
// each package component must be preceded by a '.'
if (pkg.charAt(i) != '.")
return null;
// translate '.' to '/'
buf.append("/");//NOI18N
// there must be more characters for the next package component
i++;
if (i == pkg.length())
return null;
}
if (!Character.isJavaIdentifierStart(pkg.charAt(i)))
return null;
buf.append(pkg.charAt(i++));
while (i < pkg.length() &&
Character.isJavaIdentifierPart(pkg.charAt(i)))
buf.append(pkg.charAt(i++));
}
return buf.toString();
|
public void | warning(java.lang.String warn)
if (!quietOption) {
//@olsen: support for I18N
//@olsen: redirected output
//System.out.print("Warning: ");
//System.out.println(warn);
out.println(getI18N("enhancer.warning", warn));//NOI18N
}
|
public void | warning(java.lang.String warn, java.lang.String classname)
if (!quietOption &&
!classWarningsSuppressed(classname)) {
//@olsen: support for I18N
//@olsen: redirected output
//System.out.print("Warning: ");
//System.out.println(warn);
out.println(getI18N("enhancer.warning", warn));//NOI18N
}
|
public void | warning(java.lang.String warn, java.lang.String classname, java.lang.String fieldname)
if (!quietOption &&
!classWarningsSuppressed(classname) &&
!fieldWarningsSuppressed(classname, fieldname)) {
//@olsen: support for I18N
//@olsen: redirected output
//System.out.print("Warning: ");
//System.out.println(warn);
out.print(getI18N("enhancer.warning", warn));//NOI18N
}
|
public boolean | writeClasses()Expected dump levels are 0, 1, 2, 3
dump level 0 is always on.
return (noWriteOption == false && errorsEncountered == 0);
|