Update of /cvsroot/krysalis/krysalis-version/src/main/org/krysalis/version
In directory sc8-pr-cvs1:/tmp/cvs-serv6646/src/main/org/krysalis/version
Modified Files:
VersionRuntime.java
Log Message:
Start on environment analysis (comparison against a fixed base)
Index: VersionRuntime.java
===================================================================
RCS file: /cvsroot/krysalis/krysalis-version/src/main/org/krysalis/version/VersionRuntime.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** VersionRuntime.java 22 Oct 2003 01:47:02 -0000 1.10
--- VersionRuntime.java 2 Nov 2003 22:11:11 -0000 1.11
***************
*** 56,62 ****
--- 56,68 ----
package org.krysalis.version;
+ import java.io.FileReader;
+ import java.io.FileWriter;
+ import java.io.IOException;
import java.io.PrintWriter;
+ import java.io.Reader;
+ import java.io.Writer;
import java.util.HashMap;
+ import org.krysalis.version.analysis.Analyzer;
import org.krysalis.version.constraint.ConstraintEvaluator;
import org.krysalis.version.constraint.ConstraintResultSet;
***************
*** 70,73 ****
--- 76,81 ----
import org.krysalis.version.util.classpath.PathContext;
import org.krysalis.version.util.debug.DebugUtils;
+ import org.krysalis.version.util.dom.DOMUtils;
+ import org.krysalis.version.util.io.IOUtils;
import org.krysalis.version.util.note.AnnotationScratchpad;
***************
*** 155,158 ****
--- 163,266 ----
/**
*
+ * Compare the current environment to that in a file.
+ *
+ * @param writer --- the PrintWriter to print to
+ * @param verbose --- true for verbose
+ * @throws VersionException
+ */
+ public AnnotationScratchpad compareEnvironment(String filename)
+ throws VersionException {
+ AnnotationScratchpad pad = null;
+ Reader inp = null;
+ try {
+ try {
+ inp = new FileReader(filename);
+ pad = compareEnvironment(inp);
+ }
+ finally {
+ IOUtils.close(inp);
+ }
+ }
+ catch (IOException e) {
+ throw new VersionException("Failed to read file : " + filename, e);
+ }
+
+ return pad;
+ }
+
+ /**
+ *
+ * Compare the current environment to that in a file.
+ *
+ * @param writer --- the PrintWriter to print to
+ * @param verbose --- true for verbose
+ * @throws VersionException
+ */
+ public AnnotationScratchpad compareEnvironment(Reader reader)
+ throws VersionException {
+ AnnotationScratchpad pad = null;
+ try {
+ VersionEnvironment baseEnv =
+ new VersionEnvironment(
+ DOMUtils.getRootElement(DOMUtils.deserialize(reader)));
+
+ pad = Analyzer.analyze(baseEnv, getEnvironment());
+ }
+ catch (Exception e) {
+ throw new VersionException("Failed to read input", e);
+ }
+
+ return pad;
+ }
+ /**
+ *
+ * Write the environment to a file.
+ *
+ * @param writer --- the PrintWriter to print to
+ * @param verbose --- true for verbose
+ * @throws VersionException
+ */
+ public void writeEnvironment(String filename) throws VersionException {
+ Writer out = null;
+ PrintWriter printer = null;
+ try {
+ try {
+ out = new FileWriter(filename);
+
+ try {
+ printer = new PrintWriter(out, true);
+
+ writeEnvironment(printer);
+ }
+ finally {
+ IOUtils.close(printer);
+ }
+ }
+ finally {
+ IOUtils.close(out);
+ }
+ }
+ catch (IOException e) {
+ throw new VersionException("Failed to write file : " + filename, e);
+ }
+ }
+
+ /**
+ *
+ * Writes the environment to a PrintWriter.
+ *
+ * @param writer --- the PrintWriter to print to
+ * @param verbose --- true for verbose
+ * @throws VersionException
+ */
+ public void writeEnvironment(PrintWriter writer) throws VersionException {
+ DOMUtils.serialize(
+ writer,
+ DOMUtils.produceDOM(m_context.getEnvironment()));
+
+ }
+
+ /**
+ *
* Search the current context for all versions/constraints.
*
***************
*** 182,186 ****
}
-
/**
*
--- 290,293 ----
***************
*** 209,214 ****
* @throws VersionException
*/
! public VersionInformation resolve(String id)
! throws VersionException {
VersionInformation info = m_context.getResolver().resolve(id);
return info;
--- 316,320 ----
* @throws VersionException
*/
! public VersionInformation resolve(String id) throws VersionException {
VersionInformation info = m_context.getResolver().resolve(id);
return info;
***************
*** 222,226 ****
return m_context.getConstraints();
}
!
/**
* Not for the faint hearted, there be dragons...
--- 328,332 ----
return m_context.getConstraints();
}
!
/**
* Not for the faint hearted, there be dragons...
-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive? Does it
help you create better code? SHARE THE LOVE, and help us help
YOU! Click Here: http://sourceforge.net/donate/
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.