You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@depot.apache.org by ni...@apache.org on 2004/07/30 23:46:02 UTC
svn commit: rev 31007 - in incubator/depot/trunk/version/src/java/org/apache/depot/version: . ant ant/constraint ant/environment ant/stamp context discovery/loading generation/source impl impl/data specification/formatting specification/formatting/format taglib tool
Author: nickchalko
Date: Fri Jul 30 16:46:01 2004
New Revision: 31007
Modified:
incubator/depot/trunk/version/src/java/org/apache/depot/version/VersionRuntime.java
incubator/depot/trunk/version/src/java/org/apache/depot/version/ant/AntInterface.java
incubator/depot/trunk/version/src/java/org/apache/depot/version/ant/AntTask.java
incubator/depot/trunk/version/src/java/org/apache/depot/version/ant/constraint/ConstraintCheckTask.java
incubator/depot/trunk/version/src/java/org/apache/depot/version/ant/constraint/ConstraintInformationSet.java
incubator/depot/trunk/version/src/java/org/apache/depot/version/ant/environment/EnvironmentCheckTask.java
incubator/depot/trunk/version/src/java/org/apache/depot/version/ant/environment/EnvironmentTask.java
incubator/depot/trunk/version/src/java/org/apache/depot/version/ant/stamp/VersionGeneratorTask.java
incubator/depot/trunk/version/src/java/org/apache/depot/version/ant/stamp/VersionMarkerGeneratorTask.java
incubator/depot/trunk/version/src/java/org/apache/depot/version/context/Resolver.java
incubator/depot/trunk/version/src/java/org/apache/depot/version/context/VersionContextStore.java
incubator/depot/trunk/version/src/java/org/apache/depot/version/discovery/loading/FilenameVersionLoadContext.java
incubator/depot/trunk/version/src/java/org/apache/depot/version/discovery/loading/PackageVersionLoadContext.java
incubator/depot/trunk/version/src/java/org/apache/depot/version/discovery/loading/StampVersionLoadContext.java
incubator/depot/trunk/version/src/java/org/apache/depot/version/generation/source/AbstractVersionMarkerClassGenerator.java
incubator/depot/trunk/version/src/java/org/apache/depot/version/impl/ApacheVersion.java
incubator/depot/trunk/version/src/java/org/apache/depot/version/impl/ApacheVersionMarker.java
incubator/depot/trunk/version/src/java/org/apache/depot/version/impl/data/VersionData.java
incubator/depot/trunk/version/src/java/org/apache/depot/version/impl/data/VersionDataComparator.java
incubator/depot/trunk/version/src/java/org/apache/depot/version/specification/formatting/VersionFormat.java
incubator/depot/trunk/version/src/java/org/apache/depot/version/specification/formatting/format/VersionFormatImpl.java
incubator/depot/trunk/version/src/java/org/apache/depot/version/taglib/VersionEnvironmentTag.java
incubator/depot/trunk/version/src/java/org/apache/depot/version/tool/VersionToolImpl.java
Log:
Cleanup.
Modified: incubator/depot/trunk/version/src/java/org/apache/depot/version/VersionRuntime.java
==============================================================================
--- incubator/depot/trunk/version/src/java/org/apache/depot/version/VersionRuntime.java (original)
+++ incubator/depot/trunk/version/src/java/org/apache/depot/version/VersionRuntime.java Fri Jul 30 16:46:01 2004
@@ -104,7 +104,7 @@
* @param writer --- the PrintWriter to print to
* @throws VersionException
*/
- public void printEnvironment(PrintWriter writer) throws VersionException {
+ public void printEnvironment(PrintWriter writer) {
printEnvironment(writer, false);
}
@@ -117,7 +117,7 @@
* @throws VersionException
*/
public void printEnvironment(PrintWriter writer, boolean verbose)
- throws VersionException {
+ {
DebugUtils.dump(writer, verbose, m_context.getEnvironment());
}
@@ -214,7 +214,7 @@
* @param verbose --- true for verbose
* @throws VersionException
*/
- public void writeEnvironment(PrintWriter writer) throws VersionException {
+ public void writeEnvironment(PrintWriter writer) {
DOMUtils.serialize(
writer,
DOMUtils.produceDOM(m_context.getEnvironment()));
@@ -229,7 +229,7 @@
* @see VersionEnvironment
* @throws VersionException
*/
- public VersionEnvironment getEnvironment() throws VersionException {
+ public VersionEnvironment getEnvironment() {
return m_context.getEnvironment();
}
@@ -242,7 +242,7 @@
* @see ConstraintResultSet
* @throws VersionException
*/
- public ConstraintResultSet checkEnvironment() throws VersionException {
+ public ConstraintResultSet checkEnvironment() {
//:TODO: Maybe just get constraints
VersionEnvironment env = getEnvironment();
@@ -258,7 +258,7 @@
* @see ConstraintResultSet
* @throws VersionException
*/
- public AnnotationScratchpad reviewEnvironment() throws VersionException {
+ public AnnotationScratchpad reviewEnvironment() {
//:TODO: Maybe just get constraints
VersionEnvironment env = getEnvironment();
Modified: incubator/depot/trunk/version/src/java/org/apache/depot/version/ant/AntInterface.java
==============================================================================
--- incubator/depot/trunk/version/src/java/org/apache/depot/version/ant/AntInterface.java (original)
+++ incubator/depot/trunk/version/src/java/org/apache/depot/version/ant/AntInterface.java Fri Jul 30 16:46:01 2004
@@ -118,9 +118,9 @@
if( m_component instanceof Task ) {
Task task = (Task) m_component;
return task.getLocation();
- } else {
- return Location.UNKNOWN_LOCATION;
- }
+ }
+ return Location.UNKNOWN_LOCATION;
+
}
public void log(String message, int level) {
Modified: incubator/depot/trunk/version/src/java/org/apache/depot/version/ant/AntTask.java
==============================================================================
--- incubator/depot/trunk/version/src/java/org/apache/depot/version/ant/AntTask.java (original)
+++ incubator/depot/trunk/version/src/java/org/apache/depot/version/ant/AntTask.java Fri Jul 30 16:46:01 2004
@@ -16,9 +16,9 @@
package org.apache.depot.version.ant;
+import org.apache.depot.common.ant.util.AntLogListener;
import org.apache.depot.common.log.Logger;
import org.apache.depot.common.util.note.AnnotationScratchpad;
-import org.apache.depot.common.ant.util.AntLogListener;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
Modified: incubator/depot/trunk/version/src/java/org/apache/depot/version/ant/constraint/ConstraintCheckTask.java
==============================================================================
--- incubator/depot/trunk/version/src/java/org/apache/depot/version/ant/constraint/ConstraintCheckTask.java (original)
+++ incubator/depot/trunk/version/src/java/org/apache/depot/version/ant/constraint/ConstraintCheckTask.java Fri Jul 30 16:46:01 2004
@@ -33,59 +33,51 @@
* @author arb_jack@users.sourceforge.net
*/
public class ConstraintCheckTask extends AntTask {
- private ArrayList m_information = null;
+ private ArrayList m_information = null;
- /**
- * Constructor for ConstraintEvaluatorTask.
- */
- public ConstraintCheckTask() {
- m_information = new ArrayList();
- }
-
- public void performExecute() throws org.apache.tools.ant.BuildException {
- try {
- VersionContext context = VersionContextStore.getContext();
-
- for (Iterator i = m_information.iterator(); i.hasNext();) {
- ConstraintInformationSet infoSet =
- (ConstraintInformationSet) i.next();
-
- ArrayList constraints = infoSet.getConstraints();
-
- for (Iterator ii = constraints.iterator(); ii.hasNext();) {
- IContextConstraint constraint = (IContextConstraint) ii.next();
-
- //System.out.println("Constraint: " + constraint);
-
- ConstraintResult result = constraint.check(context);
- ConstraintConclusion conclusion = result.getConclusion();
-
- if (!ConstraintConclusion.isSatisfied(conclusion)) {
-
- if (ConstraintConclusion.isCertain(conclusion))
- throw new BuildException(
- "Constraint NOT satisfied: " + result,
- getLocation());
- else
- log(
- "Constraint *suspected* NOT satisfied: "
- + result,
- Project.MSG_WARN);
- }
- }
- }
- }
- catch (BuildException be) {
- throw be;
- }
- catch (VersionException ve) {
- throw new BuildException("Constraint processing failed: ", ve);
- }
- }
-
- public ConstraintInformationSet createConstraintSet() {
- ConstraintInformationSet info = new ConstraintInformationSet(this);
- m_information.add(info);
- return info;
- }
-}
+ /**
+ * Constructor for ConstraintEvaluatorTask.
+ */
+ public ConstraintCheckTask() {
+ m_information = new ArrayList();
+ }
+
+ public void performExecute() throws org.apache.tools.ant.BuildException {
+ try {
+ VersionContext context = VersionContextStore.getContext();
+
+ for (Iterator i = m_information.iterator(); i.hasNext();) {
+ ConstraintInformationSet infoSet = (ConstraintInformationSet) i.next();
+
+ ArrayList constraints = infoSet.getConstraints();
+
+ for (Iterator ii = constraints.iterator(); ii.hasNext();) {
+ IContextConstraint constraint = (IContextConstraint) ii.next();
+
+ //System.out.println("Constraint: " + constraint);
+
+ ConstraintResult result = constraint.check(context);
+ ConstraintConclusion conclusion = result.getConclusion();
+
+ if (!ConstraintConclusion.isSatisfied(conclusion)) {
+
+ if (ConstraintConclusion.isCertain(conclusion)) {
+ throw new BuildException("Constraint NOT satisfied: " + result, getLocation());
+ }
+ log("Constraint *suspected* NOT satisfied: " + result, Project.MSG_WARN);
+ }
+ }
+ }
+ } catch (BuildException be) {
+ throw be;
+ } catch (VersionException ve) {
+ throw new BuildException("Constraint processing failed: ", ve);
+ }
+ }
+
+ public ConstraintInformationSet createConstraintSet() {
+ ConstraintInformationSet info = new ConstraintInformationSet(this);
+ m_information.add(info);
+ return info;
+ }
+}
\ No newline at end of file
Modified: incubator/depot/trunk/version/src/java/org/apache/depot/version/ant/constraint/ConstraintInformationSet.java
==============================================================================
--- incubator/depot/trunk/version/src/java/org/apache/depot/version/ant/constraint/ConstraintInformationSet.java (original)
+++ incubator/depot/trunk/version/src/java/org/apache/depot/version/ant/constraint/ConstraintInformationSet.java Fri Jul 30 16:46:01 2004
@@ -170,7 +170,7 @@
Object info = i.next();
if (info instanceof IContextConstraint) {
- constraints.add((IContextConstraint) info);
+ constraints.add( info);
}
else if (info instanceof ConstraintInformation) {
ConstraintInformation cinfo = (ConstraintInformation) info;
Modified: incubator/depot/trunk/version/src/java/org/apache/depot/version/ant/environment/EnvironmentCheckTask.java
==============================================================================
--- incubator/depot/trunk/version/src/java/org/apache/depot/version/ant/environment/EnvironmentCheckTask.java (original)
+++ incubator/depot/trunk/version/src/java/org/apache/depot/version/ant/environment/EnvironmentCheckTask.java Fri Jul 30 16:46:01 2004
@@ -33,109 +33,95 @@
* @author arb_jack@users.sourceforge.net
*/
public class EnvironmentCheckTask extends AntTask {
- private boolean m_haltOnFailure = true;
- private File m_environment = new File(EnvironmentTask.DEFAULT_OUTPUT);
+ private boolean m_haltOnFailure = true;
+ private File m_environment = new File(EnvironmentTask.DEFAULT_OUTPUT);
- /**
- * Constructor for EnvironmentCheckTask.
- */
- public EnvironmentCheckTask() {
- }
-
- public void performExecute() throws org.apache.tools.ant.BuildException {
- try {
- VersionRuntime runtime = VersionRuntime.getRuntime();
-
- //
- // Compare against environment
- //
- if (m_environment.exists()) {
- AnnotationScratchpad comparison =
- runtime.compareEnvironment(m_environment.getAbsolutePath());
-
- logScratchpad(comparison);
-
- if (comparison.hasErrors())
- throw new BuildException(
- "Failed environment comparison",
- getLocation());
- }
-
- //
- // Review environment
- //
- AnnotationScratchpad review = runtime.reviewEnvironment();
- m_ant.logScratchpad(review);
-
- //
- // Check environment
- //
- ConstraintResultSet resultSet = runtime.checkEnvironment();
-
- if (null != resultSet)
- m_ant.logResultSet(resultSet);
-
- //
- // Check errors, see if any are certain failures...
- //
-
- if (resultSet.hasErrors() && m_haltOnFailure) {
- for (Iterator i = resultSet.errorIterator(); i.hasNext();) {
- ConstraintResult result = (ConstraintResult) i.next();
-
- ConstraintConclusion conclusion = result.getConclusion();
-
- if (!ConstraintConclusion.isSatisfied(conclusion)) {
-
- if (ConstraintConclusion.isCertain(conclusion))
- throw new BuildException(
- "Constraint NOT satisfied: " + result,
- getLocation());
- else
- log(
- "Constraint *suspected* NOT satisfied: "
- + result,
- Project.MSG_WARN);
- }
- }
- }
-
- }
- catch (BuildException be) {
- throw be;
- }
- catch (VersionException ve) {
- throw new BuildException(
- "Environment processing failed: ",
- ve,
- getLocation());
- }
- }
- /**
- * @return
- */
- public boolean isHaltOnFailure() {
- return m_haltOnFailure;
- }
-
- /**
- * @param b
- */
- public void setHaltOnFailure(boolean b) {
- m_haltOnFailure = b;
- }
- /**
- * @return
- */
- public File getEnvironment() {
- return m_environment;
- }
-
- /**
- * @param file
- */
- public void setEnvironment(File file) {
- m_environment = file;
- }
+ /**
+ * Constructor for EnvironmentCheckTask.
+ */
+ public EnvironmentCheckTask() {
+ }
+
+ public void performExecute() throws org.apache.tools.ant.BuildException {
+ try {
+ VersionRuntime runtime = VersionRuntime.getRuntime();
+
+ //
+ // Compare against environment
+ //
+ if (m_environment.exists()) {
+ AnnotationScratchpad comparison = runtime.compareEnvironment(m_environment.getAbsolutePath());
+
+ logScratchpad(comparison);
+
+ if (comparison.hasErrors()) throw new BuildException("Failed environment comparison", getLocation());
+ }
+
+ //
+ // Review environment
+ //
+ AnnotationScratchpad review = runtime.reviewEnvironment();
+ m_ant.logScratchpad(review);
+
+ //
+ // Check environment
+ //
+ ConstraintResultSet resultSet = runtime.checkEnvironment();
+
+ if (null != resultSet) m_ant.logResultSet(resultSet);
+
+ //
+ // Check errors, see if any are certain failures...
+ //
+
+ if (resultSet.hasErrors() && m_haltOnFailure) {
+ for (Iterator i = resultSet.errorIterator(); i.hasNext();) {
+ ConstraintResult result = (ConstraintResult) i.next();
+
+ ConstraintConclusion conclusion = result.getConclusion();
+
+ if (!ConstraintConclusion.isSatisfied(conclusion)) {
+
+ if (ConstraintConclusion.isCertain(conclusion)) {
+ throw new BuildException("Constraint NOT satisfied: " + result, getLocation());
+ }
+
+ log("Constraint *suspected* NOT satisfied: " + result, Project.MSG_WARN);
+ }
+ }
+ }
+
+ } catch (BuildException be) {
+ throw be;
+ } catch (VersionException ve) {
+ throw new BuildException("Environment processing failed: ", ve, getLocation());
+ }
+ }
+ /**
+ * @return
+ */
+ public boolean isHaltOnFailure() {
+ return m_haltOnFailure;
+ }
+
+ /**
+ * @param b
+ */
+ public void setHaltOnFailure(boolean b) {
+ m_haltOnFailure = b;
+ }
+ /**
+ * @return
+ */
+ public File getEnvironment() {
+ return m_environment;
+ }
+
+ /**
+ * @param file
+ */
+ public void setEnvironment(File file) {
+ m_environment = file;
+ }
-}
+}
\ No newline at end of file
Modified: incubator/depot/trunk/version/src/java/org/apache/depot/version/ant/environment/EnvironmentTask.java
==============================================================================
--- incubator/depot/trunk/version/src/java/org/apache/depot/version/ant/environment/EnvironmentTask.java (original)
+++ incubator/depot/trunk/version/src/java/org/apache/depot/version/ant/environment/EnvironmentTask.java Fri Jul 30 16:46:01 2004
@@ -27,7 +27,6 @@
import org.apache.depot.common.util.classpath.PathSet;
import org.apache.depot.common.util.debug.DebugUtils;
import org.apache.depot.common.util.dom.DOMUtils;
-import org.apache.depot.version.VersionException;
import org.apache.depot.version.VersionMarker;
import org.apache.depot.version.VersionRuntime;
import org.apache.depot.version.ant.AntTask;
@@ -94,12 +93,7 @@
ioe,
getLocation());
}
- catch (VersionException ve) {
- throw new BuildException(
- "Environment processing failed: ",
- ve,
- getLocation());
- }
+
}
private void generateLog(VersionEnvironment env) {
@@ -159,7 +153,7 @@
boolean evenNotOdd = true;
for (Iterator i = versions.iterator();
i.hasNext();) {
- Object entry = (Object) i.next();
+ Object entry = i.next();
if (entry instanceof VersionInformation) {
VersionInformation info = (VersionInformation) entry;
VersionLoadContext context = info.getLoadContext();
@@ -203,7 +197,7 @@
for (Iterator i = extensions.iterator();
i.hasNext();
) {
- Object entry = (Object) i.next();
+ Object entry = i.next();
if (entry instanceof VirtualMachineExtensionInformation) {
VirtualMachineExtensionInformation extensionInfo =
(VirtualMachineExtensionInformation) entry;
Modified: incubator/depot/trunk/version/src/java/org/apache/depot/version/ant/stamp/VersionGeneratorTask.java
==============================================================================
--- incubator/depot/trunk/version/src/java/org/apache/depot/version/ant/stamp/VersionGeneratorTask.java (original)
+++ incubator/depot/trunk/version/src/java/org/apache/depot/version/ant/stamp/VersionGeneratorTask.java Fri Jul 30 16:46:01 2004
@@ -19,19 +19,12 @@
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
-import java.io.PrintWriter;
import java.io.Writer;
-import java.util.ArrayList;
-import java.util.List;
import org.apache.depot.version.VersionMarker;
import org.apache.depot.version.ant.ClassGeneratorTask;
import org.apache.depot.version.generation.VersionSourceGenerator;
-import org.apache.depot.version.generation.source.ClassGenerator;
-import org.apache.depot.version.generation.source.DependentVersionMarkerClassGenerator;
-import org.apache.depot.version.generation.source.StandaloneVersionMarkerClassGenerator;
import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Project;
/**
* Generate Version class.
@@ -41,13 +34,10 @@
*/
public class VersionGeneratorTask extends ClassGeneratorTask {
- private java.util.Date m_date = new java.util.Date();
private boolean m_debug = false;
- private boolean m_dependent = false;
- private final List m_attributeList = new ArrayList();
public VersionGeneratorTask() {
super();
@@ -104,15 +94,6 @@
return fw;
}
- /**
- * Set the generated file's dependency (standalone or dependen upon k-v)..
- *
- * @param newDependent
- * boolean
- */
- public void setDependent(boolean newDependent) {
- m_dependent = newDependent;
- }
/**
* Set the generated file's debug field..
Modified: incubator/depot/trunk/version/src/java/org/apache/depot/version/ant/stamp/VersionMarkerGeneratorTask.java
==============================================================================
--- incubator/depot/trunk/version/src/java/org/apache/depot/version/ant/stamp/VersionMarkerGeneratorTask.java (original)
+++ incubator/depot/trunk/version/src/java/org/apache/depot/version/ant/stamp/VersionMarkerGeneratorTask.java Fri Jul 30 16:46:01 2004
@@ -29,79 +29,71 @@
/**
* Generate Version class.
+ *
* @author: $Author: arb_jack $
* @version: $Revision: 1.5 $
*/
public class VersionMarkerGeneratorTask extends ClassGeneratorTask {
- private java.util.Date m_date = new java.util.Date();
- private boolean m_debug = false;
- private boolean m_dependent = false;
-
- private final List m_attributeList = new ArrayList();
-
- public VersionMarkerGeneratorTask() {
- super();
- }
- /**
- * ant entry point: Creates the build version java file.
- */
- public void performExecute() throws org.apache.tools.ant.BuildException {
- try {
- VersionMarker versionMarker = getVersionMarker();
-
- String packageName = versionMarker.getId() + ".version";
-
- if ( m_dependent )
- log("Dependent classes are *strongly* discouraged since they tightly bind results to apache-version classes. Tight coupling promotes Jar-Hell.", Project.MSG_WARN);
-
- ClassGenerator generator =
- m_dependent
- ? (ClassGenerator) new DependentVersionMarkerClassGenerator(
- getDest(),
- packageName,
- "Version",
- versionMarker)
- : (ClassGenerator) new StandaloneVersionMarkerClassGenerator(
- getDest(),
- packageName,
- "Version",
- versionMarker);
-
- validate(generator);
-
- generator.createClass();
-
- log(
- "Created class "
- + generator.getFullClassName()
- + " into "
- + generator.getFile(),
- Project.MSG_INFO);
- }
- catch (Exception e) {
- if (e instanceof BuildException)
- throw (BuildException) e;
- else
- throw new BuildException(e, getLocation());
- }
- }
-
- /**
- * Set the generated file's dependency (standalone or dependen upon k-v)..
- *
- * @param newDependent boolean
- */
- public void setDependent(boolean newDependent) {
- m_dependent = newDependent;
- }
-
- /**
- * Set the generated file's debug field..
- *
- * @param newDebug boolean
- */
- public void setDebug(boolean newDebug) {
- m_debug = newDebug;
- }
-}
+ private java.util.Date m_date = new java.util.Date();
+ private boolean m_debug = false;
+ private boolean m_dependent = false;
+
+ private final List m_attributeList = new ArrayList();
+
+ public VersionMarkerGeneratorTask() {
+ super();
+ }
+ /**
+ * ant entry point: Creates the build version java file.
+ */
+ public void performExecute() throws org.apache.tools.ant.BuildException {
+ try {
+ VersionMarker versionMarker = getVersionMarker();
+
+ String packageName = versionMarker.getId() + ".version";
+
+ if (m_dependent)
+ log(
+ "Dependent classes are *strongly* discouraged since they tightly bind results to apache-version classes. Tight coupling promotes Jar-Hell.",
+ Project.MSG_WARN);
+
+ ClassGenerator generator = m_dependent
+ ? (ClassGenerator) new DependentVersionMarkerClassGenerator(getDest(), packageName, "Version",
+ versionMarker)
+ : (ClassGenerator) new StandaloneVersionMarkerClassGenerator(getDest(), packageName, "Version",
+ versionMarker);
+
+ validate(generator);
+
+ generator.createClass();
+
+ log("Created class " + generator.getFullClassName() + " into " + generator.getFile(), Project.MSG_INFO);
+ } catch (BuildException e) {
+ throw e;
+ } catch (Exception e) {
+
+ throw new BuildException(e, getLocation());
+ }
+ }
+
+ /**
+ * Set the generated file's dependency (standalone or dependen upon k-v)..
+ *
+ * @param newDependent
+ * boolean
+ */
+ public void setDependent(boolean newDependent) {
+ m_dependent = newDependent;
+ }
+
+ /**
+ * Set the generated file's debug field..
+ *
+ * @param newDebug
+ * boolean
+ */
+ public void setDebug(boolean newDebug) {
+ m_debug = newDebug;
+ }
+}
\ No newline at end of file
Modified: incubator/depot/trunk/version/src/java/org/apache/depot/version/context/Resolver.java
==============================================================================
--- incubator/depot/trunk/version/src/java/org/apache/depot/version/context/Resolver.java (original)
+++ incubator/depot/trunk/version/src/java/org/apache/depot/version/context/Resolver.java Fri Jul 30 16:46:01 2004
@@ -51,15 +51,14 @@
}
public VersionInformation resolve(
- Object versionMarker)
- throws VersionException {
+ Object versionMarker) {
Logger.getLogger().debug("Resolve Object: " + versionMarker);
return resolve(versionMarker.getClass());
}
public VersionInformation resolve(
Class identifierClass)
- throws VersionException {
+ {
VersionInformation candidateInfo = null;
Modified: incubator/depot/trunk/version/src/java/org/apache/depot/version/context/VersionContextStore.java
==============================================================================
--- incubator/depot/trunk/version/src/java/org/apache/depot/version/context/VersionContextStore.java (original)
+++ incubator/depot/trunk/version/src/java/org/apache/depot/version/context/VersionContextStore.java Fri Jul 30 16:46:01 2004
@@ -120,7 +120,7 @@
out.println("(");
for (Iterator i = l_store.keySet().iterator(); i.hasNext();) {
- Object loader = (Object) i.next();
+ Object loader = i.next();
VersionContext context = (VersionContext) l_store.get(loader);
out.println("\t" + loader.toString());
context.dump(out, depth + 1, verbose);
Modified: incubator/depot/trunk/version/src/java/org/apache/depot/version/discovery/loading/FilenameVersionLoadContext.java
==============================================================================
--- incubator/depot/trunk/version/src/java/org/apache/depot/version/discovery/loading/FilenameVersionLoadContext.java (original)
+++ incubator/depot/trunk/version/src/java/org/apache/depot/version/discovery/loading/FilenameVersionLoadContext.java Fri Jul 30 16:46:01 2004
@@ -20,7 +20,6 @@
import java.io.PrintWriter;
import org.apache.depot.common.util.debug.DebugUtils;
-import org.apache.depot.version.VersionException;
import org.apache.depot.version.VersionMarker;
import org.apache.depot.version.impl.VersionIdentifier;
@@ -39,7 +38,7 @@
VersionIdentifier identifier,
VersionMarker versionMarker,
File file)
- throws VersionException {
+ {
super(loadType, identifier, versionMarker);
m_file = file;
Modified: incubator/depot/trunk/version/src/java/org/apache/depot/version/discovery/loading/PackageVersionLoadContext.java
==============================================================================
--- incubator/depot/trunk/version/src/java/org/apache/depot/version/discovery/loading/PackageVersionLoadContext.java (original)
+++ incubator/depot/trunk/version/src/java/org/apache/depot/version/discovery/loading/PackageVersionLoadContext.java Fri Jul 30 16:46:01 2004
@@ -19,7 +19,6 @@
import java.io.PrintWriter;
import org.apache.depot.common.util.debug.DebugUtils;
-import org.apache.depot.version.VersionException;
import org.apache.depot.version.VersionMarker;
import org.apache.depot.version.impl.VersionIdentifier;
@@ -37,7 +36,7 @@
VersionIdentifier identifier,
VersionMarker versionMarker,
Package packageMetadata)
- throws VersionException {
+ {
super(LoadType.PACKAGE, identifier, versionMarker);
m_packageMetadata = packageMetadata;
Modified: incubator/depot/trunk/version/src/java/org/apache/depot/version/discovery/loading/StampVersionLoadContext.java
==============================================================================
--- incubator/depot/trunk/version/src/java/org/apache/depot/version/discovery/loading/StampVersionLoadContext.java (original)
+++ incubator/depot/trunk/version/src/java/org/apache/depot/version/discovery/loading/StampVersionLoadContext.java Fri Jul 30 16:46:01 2004
@@ -18,7 +18,6 @@
import java.io.PrintWriter;
-import org.apache.depot.version.VersionException;
import org.apache.depot.version.impl.VersionIdentifier;
import org.apache.depot.version.interfacing.ApacheVersionMarkerInterfaceProxy;
import org.apache.depot.version.interfacing.PseudoInterface;
@@ -39,7 +38,7 @@
VersionIdentifier identifier,
ApacheVersionMarkerInterfaceProxy dataProxy,
PseudoInterface pseudoInterface,
- Object instance) throws VersionException {
+ Object instance) {
super(LoadType.INTROSPECTION,
identifier,
null//:TODO: Hack, filled later see HACK-DELAY-MARKER
Modified: incubator/depot/trunk/version/src/java/org/apache/depot/version/generation/source/AbstractVersionMarkerClassGenerator.java
==============================================================================
--- incubator/depot/trunk/version/src/java/org/apache/depot/version/generation/source/AbstractVersionMarkerClassGenerator.java (original)
+++ incubator/depot/trunk/version/src/java/org/apache/depot/version/generation/source/AbstractVersionMarkerClassGenerator.java Fri Jul 30 16:46:01 2004
@@ -17,7 +17,6 @@
package org.apache.depot.version.generation.source;
import java.io.File;
-import java.net.UnknownHostException;
import java.util.Date;
import java.util.Iterator;
import java.util.Map;
@@ -32,192 +31,170 @@
import org.apache.depot.version.interfacing.ApacheVersionMarkerInterfaceProxy;
/**
- * Generate Version class.
- * Version class contain information about a specific build/release:
+ * Generate Version class. Version class contain information about a specific build/release:
+ *
* @author: $Author$
* @version: $Revision: 1.4 $
*/
-public abstract class AbstractVersionMarkerClassGenerator
- extends ClassGenerator {
+public abstract class AbstractVersionMarkerClassGenerator extends ClassGenerator {
- protected VersionMarker m_versionMarker = null;
- protected CompoundVersion m_compoundVersion = null;
+ protected VersionMarker m_versionMarker = null;
+ protected CompoundVersion m_compoundVersion = null;
- /**
- * Constructor for VersionClassGenerator.
- * @param destinationDirectory
- * @param packageName
- * @param className
- */
- public AbstractVersionMarkerClassGenerator(
- File destinationDirectory,
- String packageName,
- String className,
- VersionMarker versionMarker) {
- super(destinationDirectory, packageName, className);
-
- m_versionMarker = versionMarker;
- m_compoundVersion = (CompoundVersion) m_versionMarker.getVersion();
- }
-
- /**
- * Creates the java source file.
- */
- public void createClass() throws Exception {
- ApacheVersionMarkerInterfaceProxy proxy =
- //:TODO: cast hack hack hack
- new ApacheVersionMarkerInterfaceProxy(
- (ApacheVersionMarker) m_versionMarker);
-
- IndentWriter out = openIndentWriter();
-
- printFileHeader(out);
- printPackage(out);
-
- out.println();
- if (hasAttributes(proxy)) {
- out.println("import java.util.Map;");
- out.println("import java.util.HashMap;");
- out.println();
- }
-
- out.println("/**");
- out.println(" *");
- out.println(
- " * A autogenerated Version class for \""
- + m_versionMarker.getId()
- + "\".");
-
- out.println(" *");
- out.println(" *");
- out.println(
- " * @author "
- + this.getClass().getName()
- + " "
- + VersionImplementationConstants.VERSION_FORMAT_VERSION);
- //out.println(" * @author " + getUser()); :TODO:
- out.println(
- " * @version "
- + m_compoundVersion.getMajor()
- + "."
- + m_compoundVersion.getMinor()
- + "."
- + m_compoundVersion.getPoint()
- + ", generated on "
- + new java.util.Date());
- out.println(" */");
-
- createClass(out, proxy);
-
- out.close();
- }
-
- protected abstract void createClass(
- IndentWriter out,
- ApacheVersionMarkerInterfaceProxy proxy)
- throws Exception;
-
- protected void printPartConstructor(IndentWriter out) {
- out.println("super(");
- out.indent();
-
- out.println("\"" + m_versionMarker.getId() + "\",");
- out.println("new "+ApacheVersion.class.getName()+"(");
- out.indent();
- out.println(m_compoundVersion.getMajor() + ",");
- out.println(m_compoundVersion.getMinor() + ",");
- out.println(
- ReleaseLevel.class.getPackage().getName()+"."
- + ReleaseLevel
- .getFromStringFailSafe(m_compoundVersion.getReleaseLevel())
- .getSourceCodeName()
- + ",");
- out.println(m_compoundVersion.getReleaseQualifier() + ",");
- out.println(m_compoundVersion.getPoint() + ",");
- out.println(m_compoundVersion.getBuildNumber());
- out.println(")");
- out.undent();
- out.println(");");
-
- out.undent();
- }
-
- protected void printVersionConstructor(IndentWriter out)
- throws UnknownHostException {
- out.println("super(");
- out.indent();
- out.println("\"" + m_versionMarker.getId() + "\",");
- out.println("\"" + m_versionMarker.getVersion() + "\"");
- out.println(");");
-
- out.undent();
- }
-
- protected void printAttributes(IndentWriter out) {
- Map attributes = m_versionMarker.getAttributes();
- if (null != attributes) {
- out.println();
- out.println("Map attributes = new HashMap();");
- out.println();
-
- for (Iterator i = attributes.keySet().iterator(); i.hasNext();) {
- Object key = i.next();
- Object value = attributes.get(key);
-
- if (value instanceof Date)
- out.println(
- "attributes.put(\""
- + key.toString()
- + "\","
- + "new java.util.Date("
- + Long.toString(((Date) value).getTime())
- + "L)"
- + ");");
- else
- out.println(
- "attributes.put(\""
- + key.toString()
- + "\",\""
- + value.toString()
- + "\");");
- }
- out.println();
- out.println("try { ");
- out.println("importProperties(attributes);");
- out.println(" } catch ( Exception e ) {");
- out.println("}");
- }
- }
-
- /**
- * Gets the host the program is run on.
- *
- * @return java.lang.String
- */
- public java.lang.String getLocalHost()
- throws java.net.UnknownHostException {
- return java.net.InetAddress.getLocalHost().toString();
- }
-
- /**
- * The source id from the version control software of both this and the parent class.
- * @return java.lang.String
- */
- public String getCVSHeader() {
- return "$Id$ ";
- }
-
- /**
- * Gets the version.
- * @return java.lang.String
- */
- public String getCVSVersion() {
- return "LastChangedRevision: 1.4 $";
- }
-
- protected boolean hasAttributes(ApacheVersionMarkerInterfaceProxy proxy) {
- return (
- (null != proxy.getAttributes())
- && !proxy.getAttributes().isEmpty());
- }
-}
+ /**
+ * Constructor for VersionClassGenerator.
+ *
+ * @param destinationDirectory
+ * @param packageName
+ * @param className
+ */
+ public AbstractVersionMarkerClassGenerator(File destinationDirectory, String packageName, String className,
+ VersionMarker versionMarker) {
+ super(destinationDirectory, packageName, className);
+
+ m_versionMarker = versionMarker;
+ m_compoundVersion = (CompoundVersion) m_versionMarker.getVersion();
+ }
+
+ /**
+ * Creates the java source file.
+ */
+ public void createClass() throws Exception {
+ ApacheVersionMarkerInterfaceProxy proxy =
+ //:TODO: cast hack hack hack
+ new ApacheVersionMarkerInterfaceProxy((ApacheVersionMarker) m_versionMarker);
+
+ IndentWriter out = openIndentWriter();
+
+ printFileHeader(out);
+ printPackage(out);
+
+ out.println();
+ if (hasAttributes(proxy)) {
+ out.println("import java.util.Map;");
+ out.println("import java.util.HashMap;");
+ out.println();
+ }
+
+ out.println("/**");
+ out.println(" *");
+ out.println(" * A autogenerated Version class for \"" + m_versionMarker.getId() + "\".");
+
+ out.println(" *");
+ out.println(" *");
+ out.println(" * @author "
+ + this.getClass().getName()
+ + " "
+ + VersionImplementationConstants.VERSION_FORMAT_VERSION);
+ //out.println(" * @author " + getUser()); :TODO:
+ out.println(" * @version "
+ + m_compoundVersion.getMajor()
+ + "."
+ + m_compoundVersion.getMinor()
+ + "."
+ + m_compoundVersion.getPoint()
+ + ", generated on "
+ + new java.util.Date());
+ out.println(" */");
+
+ createClass(out, proxy);
+
+ out.close();
+ }
+
+ protected abstract void createClass(IndentWriter out, ApacheVersionMarkerInterfaceProxy proxy) throws Exception;
+
+ protected void printPartConstructor(IndentWriter out) {
+ out.println("super(");
+ out.indent();
+
+ out.println("\"" + m_versionMarker.getId() + "\",");
+ out.println("new " + ApacheVersion.class.getName() + "(");
+ out.indent();
+ out.println(m_compoundVersion.getMajor() + ",");
+ out.println(m_compoundVersion.getMinor() + ",");
+ out.println(ReleaseLevel.class.getPackage().getName()
+ + "."
+ + ReleaseLevel.getFromStringFailSafe(m_compoundVersion.getReleaseLevel()).getSourceCodeName()
+ + ",");
+ out.println(m_compoundVersion.getReleaseQualifier() + ",");
+ out.println(m_compoundVersion.getPoint() + ",");
+ out.println(m_compoundVersion.getBuildNumber());
+ out.println(")");
+ out.undent();
+ out.println(");");
+
+ out.undent();
+ }
+
+ protected void printVersionConstructor(IndentWriter out) {
+ out.println("super(");
+ out.indent();
+ out.println("\"" + m_versionMarker.getId() + "\",");
+ out.println("\"" + m_versionMarker.getVersion() + "\"");
+ out.println(");");
+
+ out.undent();
+ }
+
+ protected void printAttributes(IndentWriter out) {
+ Map attributes = m_versionMarker.getAttributes();
+ if (null != attributes) {
+ out.println();
+ out.println("Map attributes = new HashMap();");
+ out.println();
+
+ for (Iterator i = attributes.keySet().iterator(); i.hasNext();) {
+ Object key = i.next();
+ Object value = attributes.get(key);
+
+ if (value instanceof Date)
+ out.println("attributes.put(\""
+ + key.toString()
+ + "\","
+ + "new java.util.Date("
+ + Long.toString(((Date) value).getTime())
+ + "L)"
+ + ");");
+ else
+ out.println("attributes.put(\"" + key.toString() + "\",\"" + value.toString() + "\");");
+ }
+ out.println();
+ out.println("try { ");
+ out.println("importProperties(attributes);");
+ out.println(" } catch ( Exception e ) {");
+ out.println("}");
+ }
+ }
+
+ /**
+ * Gets the host the program is run on.
+ *
+ * @return java.lang.String
+ */
+ public java.lang.String getLocalHost() throws java.net.UnknownHostException {
+ return java.net.InetAddress.getLocalHost().toString();
+ }
+
+ /**
+ * The source id from the version control software of both this and the parent class.
+ *
+ * @return java.lang.String
+ */
+ public String getCVSHeader() {
+ return "$Id$ ";
+ }
+
+ /**
+ * Gets the version.
+ *
+ * @return java.lang.String
+ */
+ public String getCVSVersion() {
+ return "LastChangedRevision: 1.4 $";
+ }
+
+ protected boolean hasAttributes(ApacheVersionMarkerInterfaceProxy proxy) {
+ return ((null != proxy.getAttributes()) && !proxy.getAttributes().isEmpty());
+ }
+}
\ No newline at end of file
Modified: incubator/depot/trunk/version/src/java/org/apache/depot/version/impl/ApacheVersion.java
==============================================================================
--- incubator/depot/trunk/version/src/java/org/apache/depot/version/impl/ApacheVersion.java (original)
+++ incubator/depot/trunk/version/src/java/org/apache/depot/version/impl/ApacheVersion.java Fri Jul 30 16:46:01 2004
@@ -120,7 +120,7 @@
* Construct a standard version
*/
public ApacheVersion(int major,int minor,ReleaseLevel releaseLevel, int releaseQualifier,
- int point, int buildNumber, Date buildDate) throws VersionException {
+ int point, int buildNumber, Date buildDate) {
m_specification =
VersionSpecificationFactory.createDefaultVersionSpecification();
m_data =
Modified: incubator/depot/trunk/version/src/java/org/apache/depot/version/impl/ApacheVersionMarker.java
==============================================================================
--- incubator/depot/trunk/version/src/java/org/apache/depot/version/impl/ApacheVersionMarker.java (original)
+++ incubator/depot/trunk/version/src/java/org/apache/depot/version/impl/ApacheVersionMarker.java Fri Jul 30 16:46:01 2004
@@ -47,605 +47,536 @@
/**
* @author arb_jack@users.apache.org
*/
-public class ApacheVersionMarker
- implements VersionMarker, Dumpable, DOMProducer, DOMConsumer {
+public class ApacheVersionMarker implements VersionMarker, Dumpable, DOMProducer, DOMConsumer {
- public final static String VERSION_MARKER_TAG = "versionMarker";
- public final static String VERSION_ID_ATTRIBUTE = "versionId";
-
- private static final Map l_parts = new HashMap();
- static {
- l_parts.put(ApacheVersion.VERSION_TAG, ApacheVersion.class);
- }
-
- private VersionIdentifier m_identifier;
- private ApacheVersion m_version;
- public final static VersionFormat FORMAT = new ApacheVersionFormat();
-
- /** Extended Optional Settings... */
- //:TODO: final on these two?
- private Map m_attributes = null;
- private List m_annotations = null;
-
- /**
- * Constructor for Version.
- * @param other
- */
- public ApacheVersionMarker(ApacheVersionMarker other) {
- super();
-
- m_identifier = other.m_identifier;
- m_version = other.m_version;
-
- validate();
- }
-
- public ApacheVersionMarker(String identifier, ApacheVersion version) {
- m_identifier = new VersionIdentifier(identifier);
- m_version = version;
- validate();
- }
-
- public ApacheVersionMarker(String identifier, CompoundVersion version) throws VersionException {
- m_identifier = new VersionIdentifier(identifier);
- m_version = new ApacheVersion(version);
- validate();
- }
-
- /**
- * Constructor for Version.
- * @param other
- */
- public ApacheVersionMarker(String identifier) {
- super();
-
- m_identifier = new VersionIdentifier(identifier);
- m_version = new ApacheVersion();
- validate();
- }
-
- /**
- * Constructor for Version.
- * @param other
- */
- public ApacheVersionMarker(VersionIdentifier identifier, Date date) {
- super();
-
- m_identifier = identifier;
- m_version = new ApacheVersion(date);
- validate();
- }
-
- /**
- * Constructor for Version.
- * @param other
- */
- public ApacheVersionMarker(String identifier, Date date) {
- this(new VersionIdentifier(identifier), date);
- }
-
-
- /**
- * Constructor for Version.
- * @param other
- */
- public ApacheVersionMarker(String id, String data)
- throws VersionException {
- this(
- VersionImporter.importApacheVersionMarker(
- VersionIdentifier.importVersionIdentifier(id),
- data));
- }
-
- /**
- * Constructor for Version.
- * @param other
- */
- public ApacheVersionMarker(VersionIdentifier id, String data)
- throws VersionException {
- this(VersionImporter.importApacheVersionMarker(id, data));
- }
-
- /**
- * Constructor for Version.
- * @param other
- */
- public ApacheVersionMarker(VersionIdentifier id, Version version)
- throws VersionException {
- m_identifier = id;
- m_version = ApacheVersion.fromVersion(version);
- validate();
- }
-
- /**
- * Constructor for ApacheVersion.
- * @param other
- */
- public ApacheVersionMarker(VersionIdentifier id, ApacheVersion version){
- m_identifier = id;
- m_version = version;
- validate();
- }
-
- /**
- * Constructor for Version.
- * @param other
- */
- public ApacheVersionMarker(
- String id,
- VersionSpecification specification,
- String data)
- throws VersionException {
- this(
- VersionImporter.importApacheVersionMarker(
- VersionIdentifier.importVersionIdentifier(id),
- specification,
- data));
- }
-
- public ApacheVersionMarker(String id,int major,int minor,ReleaseLevel releaseLevel,int buildNumber)
- {
- this(VersionIdentifier.importVersionIdentifier(id),
- new ApacheVersion(major,minor,releaseLevel,buildNumber));
- }
-
- /**
- * Constructor for Version.
- * @param other
- */
- public ApacheVersionMarker(
- String id,
- VersionSpecification specification,
- String data,
- Map properties)
- throws VersionFormatException, VersionException {
- this(
- VersionImporter.importApacheVersionMarker(
- id,
- specification,
- data));
- importProperties(properties);
- validate();
- }
-
- /**
- * Constructor for Version.
- * @param other
- */
- public ApacheVersionMarker(
- String id,
- Map properties)
- throws VersionFormatException, VersionException {
- this(id);
- importProperties(properties);
- validate();
- }
-
- /**
- * Constructor for Version.
- * @param other
- */
- public ApacheVersionMarker(
- String id,
- VersionSpecification specification,
- String data,
- Map attributes,
- List annotations)
- throws VersionFormatException, VersionException {
- this(
- new VersionIdentifier(id),
- specification,
- data,
- attributes,
- annotations);
- }
-
- /**
- * Constructor for Version.
- * @param other
- */
- public ApacheVersionMarker(
- VersionIdentifier id,
- VersionSpecification specification,
- String data,
- Map attributes,
- List annotations)
- throws VersionFormatException, VersionException {
- this(
- VersionImporter.importApacheVersionMarker(
- id,
- specification,
- data));
-
- importProperties(attributes);
-
- m_attributes = attributes;
- m_annotations = annotations;
- validate();
- }
-
-
- /**
- * Constructor for Version.
- * @param other
- */
- public ApacheVersionMarker(
- VersionIdentifier id,
- Version version,
- Map attributes,
- List annotations)
- throws VersionFormatException, VersionException {
- this(id, version);
-
- // :TODO: Ensure importProperties does return the
- // ununsed ones
- m_attributes = importProperties(attributes);
- m_annotations = annotations;
- validate();
- }
-
- /**
- * Constructor for Version.
- * @param other
- */
- public ApacheVersionMarker(
- String id,
- Version version,
- Map attributes,
- List annotations)
- throws VersionFormatException, VersionException {
- this(new VersionIdentifier(id), version);
-
- importProperties(attributes);
-
- m_attributes = attributes;
- m_annotations = annotations;
- validate();
- }
-
- /**
- * @param string
- * @param version
- * @param attributes
- * @param m_annotationList
- * @param date
- */
- public ApacheVersionMarker(
- String id,
- Version version,
- HashMap attributes,
- List annotationList,
- Date date)
- throws VersionFormatException, VersionException {
- this(id, version, attributes, annotationList);
- m_version.setBuildDate(date);
- }
-
- /**
- * Constructor for Version.
- * @param other
- */
- public ApacheVersionMarker(String id, String data, Map properties)
- throws VersionFormatException, VersionException {
- this(VersionImporter.importApacheVersionMarker(id, data));
- importProperties(properties);
- validate();
- }
-
- public Map importProperties(Map properties) throws VersionException {
- return m_version.importProperties(properties);
- }
-
-
- public String getId() {
- return m_identifier.toString();
- }
-
- /**
- * Returns the identifier.
- * @return VersionIdentifier
- */
- public VersionIdentifier getIdentifier() {
- return m_identifier;
- }
-
- public Version getVersion() {
- return m_version;
- }
-
- public ApacheVersion getApacheVersion() {
- return m_version;
- }
-
- // :TODO: Nick, let me complete 'MASK' in format first
- // :TODO: Nick, this really a description?
- // Please let me complete 'MASK' in format first
- public String getLongVersion() {
- return FORMAT.toVersionString(this.m_version.getData());
- }
-
- // Please let me complete 'MASK' in format first
- public String getShortVersion() {
- return getVersion().toString();
- }
-
- public int hashCode() {
- int hashCode = 0;
-
- if (null != m_identifier)
- hashCode = m_identifier.hashCode();
-
- if (null != m_version)
- hashCode += m_version.hashCode();
-
- return hashCode;
- }
-
- public boolean equals(Object other) {
- boolean equal = false;
-
- if (other instanceof ApacheVersionMarker) {
- ApacheVersionMarker otherVersionMarker =
- (ApacheVersionMarker) other;
-
- equal = otherVersionMarker.m_identifier.equals(m_identifier);
-
- if (equal)
- equal = otherVersionMarker.m_version.equals(m_version);
- }
- else
- throw new IllegalArgumentException(
- "Not a ApacheVersionMarker: "
- + other.getClass()
- + " : "
- + other.toString());
-
- return equal;
- }
-
- public int compareTo(Object other) {
- int comparison = -1;
-
- if (other instanceof ApacheVersionMarker) {
- ApacheVersionMarker otherVersionMarker =
- (ApacheVersionMarker) other;
-
- comparison =
- otherVersionMarker.m_identifier.compareTo(m_identifier);
-
- if (0 == comparison)
- comparison = otherVersionMarker.m_version.compareTo(m_version);
- }
- else
- throw new IllegalArgumentException(
- "Not a ApacheVersionMarker: "
- + other.getClass()
- + " : "
- + other.toString());
-
- return comparison;
- }
-
- public String toString() {
-
- String v = FORMAT.toVersionString(m_version.getData());
- return m_identifier + " version " + v;
- }
-
- public void dump(PrintWriter out, int depth, boolean verbose) {
- final String indent = DebugUtils.getIndent(depth);
-
- if (verbose) {
-
- if (null != m_identifier)
- m_identifier.dump(out, depth + 1, verbose);
-
- if (null != m_version)
- m_version.dump(out, depth + 1, verbose);
-
- if (null != m_annotations) {
- for (Iterator ai = m_annotations.iterator(); ai.hasNext();) {
- Object note = ai.next();
- out.println(" - " + note.toString());
- }
- }
-
- if (null != m_attributes) {
- for (Iterator ai = m_attributes.keySet().iterator();
- ai.hasNext();
- ) {
- Object key = ai.next();
- Object value = m_attributes.get(key);
-
- out.println(" - " + key + " -> [" + value.toString() + "]");
- }
- }
- }
- else {
- out.print(indent);
- out.print(m_identifier.toString());
- out.print(" : ");
- out.println(m_version.toString());
-
- if (null != m_attributes) {
- out.print(indent);
- out.print("Attributes :");
- out.println(m_attributes);
- }
-
- if (null != m_annotations) {
- out.print(indent);
- out.print("Annotations :");
- out.println(m_annotations);
- }
- }
- }
-
- /**
- * Returns the attributes.
- * @return Map
- */
- public Map getAttributes() {
- return m_attributes;
- }
-
- /**
- * Sets the attributes.
- * @param attributes The attributes to set
- */
- public void setAttributes(Map attributes) {
- m_attributes = attributes;
- }
-
- public void setAttribute(String key, Object value) {
- if (null == m_attributes)
- m_attributes = new HashMap();
-
- m_attributes.put(key, value);
- }
-
- public Object getAttribute(String key) {
- Object value = null;
-
- if (null != m_attributes)
- value = m_attributes.get(key);
-
- return value;
- }
-
- public String getAttributeAsString(String key) {
- Object value = null;
-
- if (null != m_attributes)
- value = m_attributes.get(key);
-
- return ((null != value) ? value.toString() : null);
- }
-
- public void addAnnotation(Object note) {
- if (null == m_annotations)
- m_annotations = new ArrayList();
-
- m_annotations.add(note);
- }
-
- /**
- * Returns the annotations.
- * @return List
- */
- public List getAnnotations() {
- return m_annotations;
- }
-
- /**
- * Sets the annotations.
- * @param annotations The annotations to set
- */
- public void setAnnotations(List annotations) {
- m_annotations = annotations;
- }
-
- private void validate() {
- if (null == m_identifier)
- throw new IllegalArgumentException("Invalid (null) identifier");
- else
- m_identifier.validate();
-
- if (null == m_version)
- throw new IllegalArgumentException("Invalid (null) version");
- else
- m_version.validate();
- }
-
- public void produceDOM(Document document, Element element) {
-
- //
- // Import XML as 'smart'
- //
- Element v = document.createElement(VERSION_MARKER_TAG);
- DOMUtils.appendChild(document, element, v);
-
- Attr a = document.createAttribute(VERSION_ID_ATTRIBUTE);
- a.setNodeValue(getId());
- v.setAttributeNode(a);
-
- if (m_version instanceof ApacheVersion) {
-
- DOMUtils.produceDOM(document, v, (ApacheVersion) m_version);
- }
- else if (m_version instanceof CompoundVersion) {
- //:TODO: Need DOMHelper? Need CompoundVersionHelper?
- DOMUtils.produceDOM(document, v, (CompoundVersion) m_version);
- }
- else
- DOMUtils.produceDOM(document, v, (Version) m_version);
- }
-
- /**
- * The Date this version was Built.
- * @return the Date the version was Built
- */
- public Date getBuildDate() {
- return (Date) m_attributes.get(VersionConstants.BUILD_DATETIME);
- }
-
- //
- // XML handling
- //
-
- public ApacheVersionMarker(Element element) throws DepotException {
- //
- // Any attributes we need?
- //
- if (element.getNodeName().equals(VERSION_MARKER_TAG)) {
- DOMUtils.consumeDOMSubElements(this, l_parts, element);
- }
- // Identifier...
- m_identifier =
- new VersionIdentifier(element.getAttribute(VERSION_ID_ATTRIBUTE));
- }
-
- public void consumeDOMElement(String tag, Element element) {
- }
- public void consumeDOMObject(String tag, Object object) {
- if (object instanceof ApacheVersion)
- m_version = (ApacheVersion) object;
- }
-
- public static ApacheVersionMarker getTestVersionMarker(String identifier) {
- return new TestApacheVersionMarker(identifier);
- }
-
- public static ApacheVersionMarker getTestVersionMarker(VersionIdentifier identifier) {
- return new TestApacheVersionMarker(identifier);
- }
-
- public static ApacheVersionMarker getTestVersionMarker(String identifier,int major, int minor) {
- return new TestApacheVersionMarker(identifier,major,minor);
- }
-
- public static ApacheVersionMarker getTestVersionMarker(VersionIdentifier identifier,int major, int minor) {
- return new TestApacheVersionMarker(identifier,major,minor);
- }
+ public final static String VERSION_MARKER_TAG = "versionMarker";
+ public final static String VERSION_ID_ATTRIBUTE = "versionId";
+
+ private static final Map l_parts = new HashMap();
+ static {
+ l_parts.put(ApacheVersion.VERSION_TAG, ApacheVersion.class);
+ }
+
+ private VersionIdentifier m_identifier;
+ private ApacheVersion m_version;
+ public final static VersionFormat FORMAT = new ApacheVersionFormat();
+
+ /** Extended Optional Settings... */
+ //:TODO: final on these two?
+ private Map m_attributes = null;
+ private List m_annotations = null;
+
+ /**
+ * Constructor for Version.
+ *
+ * @param other
+ */
+ public ApacheVersionMarker(ApacheVersionMarker other) {
+ super();
+
+ m_identifier = other.m_identifier;
+ m_version = other.m_version;
+
+ validate();
+ }
+
+ public ApacheVersionMarker(String identifier, ApacheVersion version) {
+ m_identifier = new VersionIdentifier(identifier);
+ m_version = version;
+ validate();
+ }
+
+ public ApacheVersionMarker(String identifier, CompoundVersion version) throws VersionException {
+ m_identifier = new VersionIdentifier(identifier);
+ m_version = new ApacheVersion(version);
+ validate();
+ }
+
+ /**
+ * Constructor for Version.
+ *
+ * @param other
+ */
+ public ApacheVersionMarker(String identifier) {
+ super();
+
+ m_identifier = new VersionIdentifier(identifier);
+ m_version = new ApacheVersion();
+ validate();
+ }
+
+ /**
+ * Constructor for Version.
+ *
+ * @param other
+ */
+ public ApacheVersionMarker(VersionIdentifier identifier, Date date) {
+ super();
+
+ m_identifier = identifier;
+ m_version = new ApacheVersion(date);
+ validate();
+ }
+
+ /**
+ * Constructor for Version.
+ *
+ * @param other
+ */
+ public ApacheVersionMarker(String identifier, Date date) {
+ this(new VersionIdentifier(identifier), date);
+ }
+
+ /**
+ * Constructor for Version.
+ *
+ * @param other
+ */
+ public ApacheVersionMarker(String id, String data) throws VersionException {
+ this(VersionImporter.importApacheVersionMarker(VersionIdentifier.importVersionIdentifier(id), data));
+ }
+
+ /**
+ * Constructor for Version.
+ *
+ * @param other
+ */
+ public ApacheVersionMarker(VersionIdentifier id, String data) throws VersionException {
+ this(VersionImporter.importApacheVersionMarker(id, data));
+ }
+
+ /**
+ * Constructor for Version.
+ *
+ * @param other
+ */
+ public ApacheVersionMarker(VersionIdentifier id, Version version) throws VersionException {
+ m_identifier = id;
+ m_version = ApacheVersion.fromVersion(version);
+ validate();
+ }
+
+ /**
+ * Constructor for ApacheVersion.
+ *
+ * @param other
+ */
+ public ApacheVersionMarker(VersionIdentifier id, ApacheVersion version) {
+ m_identifier = id;
+ m_version = version;
+ validate();
+ }
+
+ /**
+ * Constructor for Version.
+ *
+ * @param other
+ */
+ public ApacheVersionMarker(String id, VersionSpecification specification, String data) throws VersionException {
+ this(VersionImporter.importApacheVersionMarker(
+ VersionIdentifier.importVersionIdentifier(id),
+ specification,
+ data));
+ }
+
+ public ApacheVersionMarker(String id, int major, int minor, ReleaseLevel releaseLevel, int buildNumber) {
+ this(VersionIdentifier.importVersionIdentifier(id), new ApacheVersion(major, minor, releaseLevel, buildNumber));
+ }
+
+ /**
+ * Constructor for Version.
+ *
+ * @param other
+ */
+ public ApacheVersionMarker(String id, VersionSpecification specification, String data, Map properties)
+ throws VersionFormatException, VersionException {
+ this(VersionImporter.importApacheVersionMarker(id, specification, data));
+ importProperties(properties);
+ validate();
+ }
+
+ /**
+ * Constructor for Version.
+ *
+ * @param other
+ */
+ public ApacheVersionMarker(String id, Map properties) throws VersionFormatException, VersionException {
+ this(id);
+ importProperties(properties);
+ validate();
+ }
+
+ /**
+ * Constructor for Version.
+ *
+ * @param other
+ */
+ public ApacheVersionMarker(String id, VersionSpecification specification, String data, Map attributes,
+ List annotations) throws VersionFormatException, VersionException {
+ this(new VersionIdentifier(id), specification, data, attributes, annotations);
+ }
+
+ /**
+ * Constructor for Version.
+ *
+ * @param other
+ */
+ public ApacheVersionMarker(VersionIdentifier id, VersionSpecification specification, String data, Map attributes,
+ List annotations) throws VersionFormatException, VersionException {
+ this(VersionImporter.importApacheVersionMarker(id, specification, data));
+
+ importProperties(attributes);
+
+ m_attributes = attributes;
+ m_annotations = annotations;
+ validate();
+ }
+
+ /**
+ * Constructor for Version.
+ *
+ * @param other
+ */
+ public ApacheVersionMarker(VersionIdentifier id, Version version, Map attributes, List annotations)
+ throws VersionFormatException, VersionException {
+ this(id, version);
+
+ // :TODO: Ensure importProperties does return the
+ // ununsed ones
+ m_attributes = importProperties(attributes);
+ m_annotations = annotations;
+ validate();
+ }
+
+ /**
+ * Constructor for Version.
+ *
+ * @param other
+ */
+ public ApacheVersionMarker(String id, Version version, Map attributes, List annotations)
+ throws VersionFormatException, VersionException {
+ this(new VersionIdentifier(id), version);
+
+ importProperties(attributes);
+
+ m_attributes = attributes;
+ m_annotations = annotations;
+ validate();
+ }
+
+ /**
+ * @param string
+ * @param version
+ * @param attributes
+ * @param m_annotationList
+ * @param date
+ */
+ public ApacheVersionMarker(String id, Version version, HashMap attributes, List annotationList, Date date)
+ throws VersionFormatException, VersionException {
+ this(id, version, attributes, annotationList);
+ m_version.setBuildDate(date);
+ }
+
+ /**
+ * Constructor for Version.
+ *
+ * @param other
+ */
+ public ApacheVersionMarker(String id, String data, Map properties) throws VersionFormatException, VersionException {
+ this(VersionImporter.importApacheVersionMarker(id, data));
+ importProperties(properties);
+ validate();
+ }
+
+ public Map importProperties(Map properties) throws VersionException {
+ return m_version.importProperties(properties);
+ }
+
+ public String getId() {
+ return m_identifier.toString();
+ }
+
+ /**
+ * Returns the identifier.
+ *
+ * @return VersionIdentifier
+ */
+ public VersionIdentifier getIdentifier() {
+ return m_identifier;
+ }
+
+ public Version getVersion() {
+ return m_version;
+ }
+
+ public ApacheVersion getApacheVersion() {
+ return m_version;
+ }
+
+ // :TODO: Nick, let me complete 'MASK' in format first
+ // :TODO: Nick, this really a description?
+ // Please let me complete 'MASK' in format first
+ public String getLongVersion() {
+ return FORMAT.toVersionString(this.m_version.getData());
+ }
+
+ // Please let me complete 'MASK' in format first
+ public String getShortVersion() {
+ return getVersion().toString();
+ }
+
+ public int hashCode() {
+ int hashCode = 0;
+
+ if (null != m_identifier) hashCode = m_identifier.hashCode();
+
+ if (null != m_version) hashCode += m_version.hashCode();
+
+ return hashCode;
+ }
+
+ public boolean equals(Object other) {
+ boolean equal = false;
+
+ if (other instanceof ApacheVersionMarker) {
+ ApacheVersionMarker otherVersionMarker = (ApacheVersionMarker) other;
+
+ equal = otherVersionMarker.m_identifier.equals(m_identifier);
+
+ if (equal) equal = otherVersionMarker.m_version.equals(m_version);
+ } else
+ throw new IllegalArgumentException("Not a ApacheVersionMarker: "
+ + other.getClass()
+ + " : "
+ + other.toString());
+
+ return equal;
+ }
+
+ public int compareTo(Object other) {
+ int comparison = -1;
+
+ if (other instanceof ApacheVersionMarker) {
+ ApacheVersionMarker otherVersionMarker = (ApacheVersionMarker) other;
+
+ comparison = otherVersionMarker.m_identifier.compareTo(m_identifier);
+
+ if (0 == comparison) comparison = otherVersionMarker.m_version.compareTo(m_version);
+ } else
+ throw new IllegalArgumentException("Not a ApacheVersionMarker: "
+ + other.getClass()
+ + " : "
+ + other.toString());
+
+ return comparison;
+ }
+
+ public String toString() {
+
+ String v = FORMAT.toVersionString(m_version.getData());
+ return m_identifier + " version " + v;
+ }
+
+ public void dump(PrintWriter out, int depth, boolean verbose) {
+ final String indent = DebugUtils.getIndent(depth);
+
+ if (verbose) {
+
+ if (null != m_identifier) m_identifier.dump(out, depth + 1, verbose);
+
+ if (null != m_version) m_version.dump(out, depth + 1, verbose);
+
+ if (null != m_annotations) {
+ for (Iterator ai = m_annotations.iterator(); ai.hasNext();) {
+ Object note = ai.next();
+ out.println(" - " + note.toString());
+ }
+ }
+
+ if (null != m_attributes) {
+ for (Iterator ai = m_attributes.keySet().iterator(); ai.hasNext();) {
+ Object key = ai.next();
+ Object value = m_attributes.get(key);
+
+ out.println(" - " + key + " -> [" + value.toString() + "]");
+ }
+ }
+ } else {
+ out.print(indent);
+ out.print(m_identifier.toString());
+ out.print(" : ");
+ out.println(m_version.toString());
+
+ if (null != m_attributes) {
+ out.print(indent);
+ out.print("Attributes :");
+ out.println(m_attributes);
+ }
+
+ if (null != m_annotations) {
+ out.print(indent);
+ out.print("Annotations :");
+ out.println(m_annotations);
+ }
+ }
+ }
+
+ /**
+ * Returns the attributes.
+ *
+ * @return Map
+ */
+ public Map getAttributes() {
+ return m_attributes;
+ }
+
+ /**
+ * Sets the attributes.
+ *
+ * @param attributes
+ * The attributes to set
+ */
+ public void setAttributes(Map attributes) {
+ m_attributes = attributes;
+ }
+
+ public void setAttribute(String key, Object value) {
+ if (null == m_attributes) m_attributes = new HashMap();
+
+ m_attributes.put(key, value);
+ }
+
+ public Object getAttribute(String key) {
+ Object value = null;
+
+ if (null != m_attributes) value = m_attributes.get(key);
+
+ return value;
+ }
+
+ public String getAttributeAsString(String key) {
+ Object value = null;
+
+ if (null != m_attributes) value = m_attributes.get(key);
+
+ return ((null != value) ? value.toString() : null);
+ }
+
+ public void addAnnotation(Object note) {
+ if (null == m_annotations) m_annotations = new ArrayList();
+
+ m_annotations.add(note);
+ }
+
+ /**
+ * Returns the annotations.
+ *
+ * @return List
+ */
+ public List getAnnotations() {
+ return m_annotations;
+ }
+
+ /**
+ * Sets the annotations.
+ *
+ * @param annotations
+ * The annotations to set
+ */
+ public void setAnnotations(List annotations) {
+ m_annotations = annotations;
+ }
+
+ private void validate() {
+ if (null == m_identifier){
+ throw new IllegalArgumentException("Invalid (null) identifier");
+ }
+ m_identifier.validate();
+
+ if (null == m_version) {
+ throw new IllegalArgumentException("Invalid (null) version");
+ }
+ m_version.validate();
+ }
+
+ public void produceDOM(Document document, Element element) {
+
+ //
+ // Import XML as 'smart'
+ //
+ Element v = document.createElement(VERSION_MARKER_TAG);
+ DOMUtils.appendChild(document, element, v);
+
+ Attr a = document.createAttribute(VERSION_ID_ATTRIBUTE);
+ a.setNodeValue(getId());
+ v.setAttributeNode(a);
+ DOMUtils.produceDOM(document, v, m_version);
+ }
+
+ /**
+ * The Date this version was Built.
+ *
+ * @return the Date the version was Built
+ */
+ public Date getBuildDate() {
+ return (Date) m_attributes.get(VersionConstants.BUILD_DATETIME);
+ }
+
+ //
+ // XML handling
+ //
+
+ public ApacheVersionMarker(Element element) throws DepotException {
+ //
+ // Any attributes we need?
+ //
+ if (element.getNodeName().equals(VERSION_MARKER_TAG)) {
+ DOMUtils.consumeDOMSubElements(this, l_parts, element);
+ }
+ // Identifier...
+ m_identifier = new VersionIdentifier(element.getAttribute(VERSION_ID_ATTRIBUTE));
+ }
+
+ public void consumeDOMElement(String tag, Element element) {
+ }
+ public void consumeDOMObject(String tag, Object object) {
+ if (object instanceof ApacheVersion) m_version = (ApacheVersion) object;
+ }
+
+ public static ApacheVersionMarker getTestVersionMarker(String identifier) {
+ return new TestApacheVersionMarker(identifier);
+ }
+
+ public static ApacheVersionMarker getTestVersionMarker(VersionIdentifier identifier) {
+ return new TestApacheVersionMarker(identifier);
+ }
+
+ public static ApacheVersionMarker getTestVersionMarker(String identifier, int major, int minor) {
+ return new TestApacheVersionMarker(identifier, major, minor);
+ }
+
+ public static ApacheVersionMarker getTestVersionMarker(VersionIdentifier identifier, int major, int minor) {
+ return new TestApacheVersionMarker(identifier, major, minor);
+ }
}
//
// Testing Instances
//
class TestApacheVersionMarker extends ApacheVersionMarker {
- TestApacheVersionMarker(String identifier) {
- super(identifier, ApacheVersion.getTestVersion());
- }
-
- TestApacheVersionMarker(String identifier,int major,int minor) {
- super(identifier, ApacheVersion.getTestVersion(major,minor));
- }
-
- TestApacheVersionMarker(VersionIdentifier identifier) {
- super(identifier, ApacheVersion.getTestVersion());
- }
-
- TestApacheVersionMarker(VersionIdentifier identifier,int major,int minor) {
- super(identifier, ApacheVersion.getTestVersion(major,minor));
- }
+ TestApacheVersionMarker(String identifier) {
+ super(identifier, ApacheVersion.getTestVersion());
+ }
+
+ TestApacheVersionMarker(String identifier, int major, int minor) {
+ super(identifier, ApacheVersion.getTestVersion(major, minor));
+ }
+
+ TestApacheVersionMarker(VersionIdentifier identifier) {
+ super(identifier, ApacheVersion.getTestVersion());
+ }
+
+ TestApacheVersionMarker(VersionIdentifier identifier, int major, int minor) {
+ super(identifier, ApacheVersion.getTestVersion(major, minor));
+ }
}
Modified: incubator/depot/trunk/version/src/java/org/apache/depot/version/impl/data/VersionData.java
==============================================================================
--- incubator/depot/trunk/version/src/java/org/apache/depot/version/impl/data/VersionData.java (original)
+++ incubator/depot/trunk/version/src/java/org/apache/depot/version/impl/data/VersionData.java Fri Jul 30 16:46:01 2004
@@ -28,7 +28,6 @@
import org.apache.depot.common.util.dom.DOMConsumer;
import org.apache.depot.common.util.dom.DOMProducer;
import org.apache.depot.common.util.dom.DOMUtils;
-import org.apache.depot.version.Version;
import org.apache.depot.version.VersionError;
import org.apache.depot.version.VersionException;
import org.apache.depot.version.impl.VersionImplementationConstants;
Modified: incubator/depot/trunk/version/src/java/org/apache/depot/version/impl/data/VersionDataComparator.java
==============================================================================
--- incubator/depot/trunk/version/src/java/org/apache/depot/version/impl/data/VersionDataComparator.java (original)
+++ incubator/depot/trunk/version/src/java/org/apache/depot/version/impl/data/VersionDataComparator.java Fri Jul 30 16:46:01 2004
@@ -18,8 +18,6 @@
import java.util.Comparator;
-import org.apache.depot.common.util.debug.DebugUtils;
-
// :TODO: Compatibility a class -- a range?
// :TODO: Types of compatiblity, see commons...
Modified: incubator/depot/trunk/version/src/java/org/apache/depot/version/specification/formatting/VersionFormat.java
==============================================================================
--- incubator/depot/trunk/version/src/java/org/apache/depot/version/specification/formatting/VersionFormat.java (original)
+++ incubator/depot/trunk/version/src/java/org/apache/depot/version/specification/formatting/VersionFormat.java Fri Jul 30 16:46:01 2004
@@ -17,7 +17,6 @@
package org.apache.depot.version.specification.formatting;
import org.apache.depot.common.util.debug.Dumpable;
-import org.apache.depot.version.Version;
import org.apache.depot.version.impl.data.VersionData;
/**
Modified: incubator/depot/trunk/version/src/java/org/apache/depot/version/specification/formatting/format/VersionFormatImpl.java
==============================================================================
--- incubator/depot/trunk/version/src/java/org/apache/depot/version/specification/formatting/format/VersionFormatImpl.java (original)
+++ incubator/depot/trunk/version/src/java/org/apache/depot/version/specification/formatting/format/VersionFormatImpl.java Fri Jul 30 16:46:01 2004
@@ -44,7 +44,7 @@
public int parseInt(String input, VersionDataElement element, String data)
throws VersionFormatException {
- int value = (int) - 1;
+ int value = - 1;
try {
value = Integer.parseInt(data, 10);
Modified: incubator/depot/trunk/version/src/java/org/apache/depot/version/taglib/VersionEnvironmentTag.java
==============================================================================
--- incubator/depot/trunk/version/src/java/org/apache/depot/version/taglib/VersionEnvironmentTag.java (original)
+++ incubator/depot/trunk/version/src/java/org/apache/depot/version/taglib/VersionEnvironmentTag.java Fri Jul 30 16:46:01 2004
@@ -27,7 +27,6 @@
import org.apache.depot.common.util.classpath.PathPart;
import org.apache.depot.common.util.classpath.PathSet;
import org.apache.depot.common.util.debug.DebugUtils;
-import org.apache.depot.version.VersionException;
import org.apache.depot.version.VersionMarker;
import org.apache.depot.version.VersionRuntime;
import org.apache.depot.version.constraint.ConstraintSet;
@@ -46,216 +45,199 @@
* @author ajack
*/
public class VersionEnvironmentTag extends TagSupport {
- private static boolean l_initialized = false;
+ private static boolean l_initialized = false;
- private static VersionRuntime l_runtime = null;
- private boolean m_annotated = false;
+ private static VersionRuntime l_runtime = null;
+ private boolean m_annotated = false;
- public VersionEnvironmentTag() {
- if (!l_initialized)
- initialize();
- }
-
- private synchronized void initialize() {
- if (l_initialized)
- return;
-
- l_runtime = VersionRuntime.getRuntime();
-
- l_initialized = true;
- }
-
- public int doStartTag() {
-
- if (null == l_runtime) {
- // Bad initialization
- return Tag.SKIP_BODY;
- }
-
- try {
- HtmlContent versionEnvTag = new HtmlContent();
-
- try {
- VersionEnvironment env = l_runtime.getEnvironment();
-
- generateHtml(versionEnvTag, env);
-
- } catch (VersionException ve) {
- Logger.getLogger().error("VersionEnvironmentTag:error", ve);
- versionEnvTag.generateError("VersionEnvironmentTag:Failed to get environment", ve);
- }
-
- // Output the HTML...
- pageContext.getOut().print(versionEnvTag.toString());
- } catch (IOException ioe) {
- Logger.getLogger().error("VersionEnvironmentTag error", ioe);
- }
-
- return Tag.SKIP_BODY;
- }
-
- private void generateHtml(HtmlContent htmlBuf, VersionEnvironment env) {
-
- htmlBuf.generateTitle("JVM Information:");
- VersionMarker jvm = env.getJvmVersion();
- VersionMarker jvmSpec = env.getJvmSpecificationVersion();
- htmlBuf.generateDefinition(jvm.toString(), jvmSpec.toString());
-
- generateHtml(htmlBuf, env.getPathContext());
- generateHtml(htmlBuf, env.getExtensions());
- generateHtml(htmlBuf, env.getVersions());
- generateHtml(htmlBuf, env.getConstraints());
- }
-
- private void generateHtml(HtmlContent htmlBuf, PathContext pathContext) {
- generateHtmlClassloader(htmlBuf, 0, pathContext.getClassLoader());
- generateHtmlPathSet(htmlBuf, pathContext.getPathSet());
- }
-
- public void generateHtmlClassloader(HtmlContent htmlBuf, int depth,
- ClassLoader classloader) {
-
- htmlBuf.generateTitle("ClassLoader Tree:");
-
- String indent = DebugUtils.getIndent(depth);
-
- HtmlContent out = new HtmlContent();
-
- out.generateLine(indent);
- out.generateLine(classloader.getClass().getName());
- out.generateLine(" : ");
- out.generateHtml(classloader.toString());
-
- htmlBuf.generateLine("Classloader @ Depth (" + depth + ") :"
- + out.toString());
-
- if (null != classloader.getParent()) {
- generateHtmlClassloader(htmlBuf, depth + 1, classloader.getParent());
- }
- }
-
- private void generateHtmlPathSet(HtmlContent htmlBuf, PathSet pathSet) {
- htmlBuf.generateTitle("PathSet: " + pathSet.getName());
-
- for (Iterator i = pathSet.iterator(); i.hasNext();) {
- PathPart part = (PathPart) i.next();
-
- htmlBuf.generateLine(" - " + part);
- }
- }
-
- private void generateHtml(HtmlContent htmlBuf, VersionRegistry versions) {
-
- htmlBuf.generateTitle("Versions:");
- if (versions.hasEntries()) {
-
-
- htmlBuf.startDefinitions();
-
- for (Iterator i = versions.iterator(); i.hasNext();) {
- Object entry = (Object) i.next();
- if (entry instanceof VersionInformation) {
- VersionInformation info = (VersionInformation) entry;
- VersionLoadContext context = info.getLoadContext();
- VersionMarker versionMarker = context.getVersionMarker();
-
- String id = versionMarker.getId();
- String version = versionMarker.getVersion().toString();
-
- //
- // Perhaps allow these to show, if verbose.
- //
- if (IdentifierHelper.isPartOfJdk(id))
- continue;
-
- htmlBuf.generateDefinition(id, version);
- } else
- htmlBuf.generateDefinition(entry.getClass().getName(),
- entry.toString());
- }
-
- htmlBuf.stopDefinitions();
-
- } else
- htmlBuf.generateLine("No versions found in registry");
- }
-
- private void generateHtml(HtmlContent htmlBuf, ExtensionRegistry extensions) {
-
- htmlBuf.generateTitle("Virtual Machine Extensions:");
- if (extensions.hasEntries()) {
-
-
- htmlBuf.startDefinitions();
-
- for (Iterator i = extensions.iterator(); i.hasNext();) {
- Object entry = (Object) i.next();
- if (entry instanceof VirtualMachineExtensionInformation) {
- VirtualMachineExtensionInformation extensionInfo = (VirtualMachineExtensionInformation) entry;
- VirtualMachineExtension extension = extensionInfo.getExtensionLoadContext().getExtension();
-
- //
- // Perhaps allow these to show, if verbose.
- //
- if (IdentifierHelper.isPartOfJdk(extension.getName()))
- continue;
-
- htmlBuf.generateDefinition(extension.getName() + " : " + extension.getSpecificationTitle(),
- extension.getSpecificationVersion().toString());
-
- if (m_annotated) {
- htmlBuf.generateDefinition(extension.getImplementationTitle(),
- extension.getImplementationVersion().toString());
-
- if (null != extension.getComment())
- htmlBuf.generateDefinition("Comment:",
- extension.getComment());
- }
- } else {
- String id = entry.getClass().getName();
- //
- // Perhaps allow these to show, if verbose.
- //
- if (IdentifierHelper.isPartOfJdk(id))
- continue;
-
- htmlBuf.generateLine(id + ":" + entry.toString());
- }
- }
- htmlBuf.stopDefinitions();
- } else
- htmlBuf.generateLine("No versions found in registry");
- }
-
- private void generateHtml(HtmlContent htmlBuf,
- ConstraintRegistry constraints) {
-
- htmlBuf.generateTitle("Constraints:");
-
- if (constraints.hasEntries()) {
-
- htmlBuf.generateTitle("Constraints:");
-
- for (Iterator i = constraints.iterator(); i.hasNext();) {
- generateHtml(htmlBuf, (ConstraintSet) i.next());
- }
- } else
- htmlBuf.generateLine("No constraints in registry");
- }
-
- private void generateHtml(HtmlContent htmlBuf, ConstraintSet set) {
-
- htmlBuf.generateLine("ConstraintSet: " + set.getName());
-
- if (set.hasEntries()) {
-
- htmlBuf.startDefinitions();
- for (Iterator i = set.iterator(); i.hasNext();) {
- IContextConstraint constraint = (IContextConstraint) i.next();
- htmlBuf.generateDefinition(constraint.toString());
- }
- htmlBuf.stopDefinitions();
- } else
- htmlBuf.generateLine("No constraints in set");
- }
-}
+ public VersionEnvironmentTag() {
+ if (!l_initialized) initialize();
+ }
+
+ private synchronized void initialize() {
+ if (l_initialized) return;
+
+ l_runtime = VersionRuntime.getRuntime();
+
+ l_initialized = true;
+ }
+
+ public int doStartTag() {
+
+ if (null == l_runtime) {
+ // Bad initialization
+ return Tag.SKIP_BODY;
+ }
+
+ try {
+ HtmlContent versionEnvTag = new HtmlContent();
+
+ VersionEnvironment env = l_runtime.getEnvironment();
+
+ generateHtml(versionEnvTag, env);
+
+ // Output the HTML...
+ pageContext.getOut().print(versionEnvTag.toString());
+ } catch (IOException ioe) {
+ Logger.getLogger().error("VersionEnvironmentTag error", ioe);
+ }
+
+ return Tag.SKIP_BODY;
+ }
+
+ private void generateHtml(HtmlContent htmlBuf, VersionEnvironment env) {
+
+ htmlBuf.generateTitle("JVM Information:");
+ VersionMarker jvm = env.getJvmVersion();
+ VersionMarker jvmSpec = env.getJvmSpecificationVersion();
+ htmlBuf.generateDefinition(jvm.toString(), jvmSpec.toString());
+
+ generateHtml(htmlBuf, env.getPathContext());
+ generateHtml(htmlBuf, env.getExtensions());
+ generateHtml(htmlBuf, env.getVersions());
+ generateHtml(htmlBuf, env.getConstraints());
+ }
+
+ private void generateHtml(HtmlContent htmlBuf, PathContext pathContext) {
+ generateHtmlClassloader(htmlBuf, 0, pathContext.getClassLoader());
+ generateHtmlPathSet(htmlBuf, pathContext.getPathSet());
+ }
+
+ public void generateHtmlClassloader(HtmlContent htmlBuf, int depth, ClassLoader classloader) {
+
+ htmlBuf.generateTitle("ClassLoader Tree:");
+
+ String indent = DebugUtils.getIndent(depth);
+
+ HtmlContent out = new HtmlContent();
+
+ out.generateLine(indent);
+ out.generateLine(classloader.getClass().getName());
+ out.generateLine(" : ");
+ out.generateHtml(classloader.toString());
+
+ htmlBuf.generateLine("Classloader @ Depth (" + depth + ") :" + out.toString());
+
+ if (null != classloader.getParent()) {
+ generateHtmlClassloader(htmlBuf, depth + 1, classloader.getParent());
+ }
+ }
+
+ private void generateHtmlPathSet(HtmlContent htmlBuf, PathSet pathSet) {
+ htmlBuf.generateTitle("PathSet: " + pathSet.getName());
+
+ for (Iterator i = pathSet.iterator(); i.hasNext();) {
+ PathPart part = (PathPart) i.next();
+
+ htmlBuf.generateLine(" - " + part);
+ }
+ }
+
+ private void generateHtml(HtmlContent htmlBuf, VersionRegistry versions) {
+
+ htmlBuf.generateTitle("Versions:");
+ if (versions.hasEntries()) {
+
+ htmlBuf.startDefinitions();
+
+ for (Iterator i = versions.iterator(); i.hasNext();) {
+ Object entry = i.next();
+ if (entry instanceof VersionInformation) {
+ VersionInformation info = (VersionInformation) entry;
+ VersionLoadContext context = info.getLoadContext();
+ VersionMarker versionMarker = context.getVersionMarker();
+
+ String id = versionMarker.getId();
+ String version = versionMarker.getVersion().toString();
+
+ //
+ // Perhaps allow these to show, if verbose.
+ //
+ if (IdentifierHelper.isPartOfJdk(id)) continue;
+
+ htmlBuf.generateDefinition(id, version);
+ } else
+ htmlBuf.generateDefinition(entry.getClass().getName(), entry.toString());
+ }
+
+ htmlBuf.stopDefinitions();
+
+ } else
+ htmlBuf.generateLine("No versions found in registry");
+ }
+
+ private void generateHtml(HtmlContent htmlBuf, ExtensionRegistry extensions) {
+
+ htmlBuf.generateTitle("Virtual Machine Extensions:");
+ if (extensions.hasEntries()) {
+
+ htmlBuf.startDefinitions();
+
+ for (Iterator i = extensions.iterator(); i.hasNext();) {
+ Object entry = i.next();
+ if (entry instanceof VirtualMachineExtensionInformation) {
+ VirtualMachineExtensionInformation extensionInfo = (VirtualMachineExtensionInformation) entry;
+ VirtualMachineExtension extension = extensionInfo.getExtensionLoadContext().getExtension();
+
+ //
+ // Perhaps allow these to show, if verbose.
+ //
+ if (IdentifierHelper.isPartOfJdk(extension.getName())) continue;
+
+ htmlBuf.generateDefinition(
+ extension.getName() + " : " + extension.getSpecificationTitle(),
+ extension.getSpecificationVersion().toString());
+
+ if (m_annotated) {
+ htmlBuf.generateDefinition(extension.getImplementationTitle(), extension
+ .getImplementationVersion().toString());
+
+ if (null != extension.getComment())
+ htmlBuf.generateDefinition("Comment:", extension.getComment());
+ }
+ } else {
+ String id = entry.getClass().getName();
+ //
+ // Perhaps allow these to show, if verbose.
+ //
+ if (IdentifierHelper.isPartOfJdk(id)) continue;
+
+ htmlBuf.generateLine(id + ":" + entry.toString());
+ }
+ }
+ htmlBuf.stopDefinitions();
+ } else
+ htmlBuf.generateLine("No versions found in registry");
+ }
+
+ private void generateHtml(HtmlContent htmlBuf, ConstraintRegistry constraints) {
+
+ htmlBuf.generateTitle("Constraints:");
+
+ if (constraints.hasEntries()) {
+
+ htmlBuf.generateTitle("Constraints:");
+
+ for (Iterator i = constraints.iterator(); i.hasNext();) {
+ generateHtml(htmlBuf, (ConstraintSet) i.next());
+ }
+ } else
+ htmlBuf.generateLine("No constraints in registry");
+ }
+
+ private void generateHtml(HtmlContent htmlBuf, ConstraintSet set) {
+
+ htmlBuf.generateLine("ConstraintSet: " + set.getName());
+
+ if (set.hasEntries()) {
+
+ htmlBuf.startDefinitions();
+ for (Iterator i = set.iterator(); i.hasNext();) {
+ IContextConstraint constraint = (IContextConstraint) i.next();
+ htmlBuf.generateDefinition(constraint.toString());
+ }
+ htmlBuf.stopDefinitions();
+ } else
+ htmlBuf.generateLine("No constraints in set");
+ }
+}
\ No newline at end of file
Modified: incubator/depot/trunk/version/src/java/org/apache/depot/version/tool/VersionToolImpl.java
==============================================================================
--- incubator/depot/trunk/version/src/java/org/apache/depot/version/tool/VersionToolImpl.java (original)
+++ incubator/depot/trunk/version/src/java/org/apache/depot/version/tool/VersionToolImpl.java Fri Jul 30 16:46:01 2004
@@ -68,7 +68,7 @@
}
}
- public void displayEnvironment() throws VersionException {
+ public void displayEnvironment() {
m_runtime.printEnvironment(m_out,m_verbose);
}
@@ -83,7 +83,7 @@
return pad;
}
- public void checkEnvironment() throws VersionException {
+ public void checkEnvironment() {
ConstraintResultSet resultSet = m_runtime.checkEnvironment();