[CVS jcontainer] Renamed org.jcontainer.loom -> org.codehaus.loom
mauro-yCVjj/[email protected] Mon, 19 Apr 2004 16:40:42 -0500
| Newsgroups | gmane.comp.java.jcontainer.cvs |
|---|---|
| Message-ID | <[email protected]> |
<html>
<head>
<style><!--
body {background-color:#ffffff;}
.file {border:1px solid #eeeeee;margin-top:1em;margin-bottom:1em;}
.pathname {font-family:monospace; float:right;}
.fileheader {margin-bottom:.5em;}
.diff {margin:0;}
.tasklist {padding:4px;border:1px dashed #000000;margin-top:1em;}
.tasklist ul {margin-top:0;margin-bottom:0;}
tr.alt {background-color:#eeeeee}
#added {background-color:#ddffdd;}
#addedchars {background-color:#99ff99;font-weight:bolder;}
tr.alt #added {background-color:#ccf7cc;}
#removed {background-color:#ffdddd;}
#removedchars {background-color:#ff9999;font-weight:bolder;}
tr.alt #removed {background-color:#f7cccc;}
#info {color:#888888;}
#context {background-color:#eeeeee;}
td {padding-left:.3em;padding-right:.3em;}
tr.head {border-bottom-width:1px;border-bottom-style:solid;}
tr.head td {padding:0;padding-top:.2em;}
.task {background-color:#ffff00;}
.comment {padding:4px;border:1px dashed #000000;background-color:#ffffd=
d}
.error {color:red;}
hr {border-width:0px;height:2px;background:black;}
--></style>
</head>
<body>
<table cellspacing=3D"0" cellpadding=3D"0" border=3D"0" rules=3D"cols">
<tr class=3D"head"><td colspan=3D"4">Commit in <b><tt>jcontainer/loom/sup=
port/extension</tt></b><span id=3D"info"> on MAIN</span></td></tr>
<tr><td><tt><a href=3D"#file1">project.xml</a></tt></td><td align=3D"righ=
t" id=3D"added">+1</td><td align=3D"right" id=3D"removed">-1</td><td nowr=
ap=3D"nowrap" align=3D"center"><a href=3D"http://xstream.cvs.codehaus.org=
/jcontainer/loom/support/extension/project.xml?rev=3D1.7&content-type=
=3Dtext/vnd.viewcvs-markup">1.7</a> <a href=3D"http://xstream.cvs.codehau=
s.org/jcontainer/loom/support/extension/project.xml.diff?r1=3D1.7&r2=3D=
1.8">-></a> <a href=3D"http://xstream.cvs.codehaus.org/jcontainer/loom=
/support/extension/project.xml?rev=3D1.8&content-type=3Dtext/vnd.view=
cvs-markup">1.8</a></td></tr>
<tr class=3D"alt"><td><tt>src/java/org/codehaus/loom/extension/<a href=3D=
"#file2"><span id=3D"added">Specification.java</span></a></tt></td><td al=
ign=3D"right" id=3D"added">+614</td><td></td><td nowrap=3D"nowrap" align=3D=
"right">added <a href=3D"http://xstream.cvs.codehaus.org/jcontainer/loom/=
support/extension/src/java/org/codehaus/loom/extension/Specification.java=
?rev=3D1.1&content-type=3Dtext/vnd.viewcvs-markup">1.1</a></td></tr>
<tr><td><tt> &=
nbsp; &n=
bsp; &nb=
sp; /<a href=3D"#file3"><span id=3D"added">Extension.java</span></a>=
</tt></td><td align=3D"right" id=3D"added">+722</td><td></td><td nowrap=3D=
"nowrap" align=3D"right">added <a href=3D"http://xstream.cvs.codehaus.org=
/jcontainer/loom/support/extension/src/java/org/codehaus/loom/extension/E=
xtension.java?rev=3D1.1&content-type=3Dtext/vnd.viewcvs-markup">1.1</=
a></td></tr>
<tr class=3D"alt"><td><tt>  =
; =
&=
nbsp; /<a href=3D"#file4"><span id=3D"added">DeweyDecima=
l.java</span></a></tt></td><td align=3D"right" id=3D"added">+231</td><td>=
</td><td nowrap=3D"nowrap" align=3D"right">added <a href=3D"http://xstrea=
m.cvs.codehaus.org/jcontainer/loom/support/extension/src/java/org/codehau=
s/loom/extension/DeweyDecimal.java?rev=3D1.1&content-type=3Dtext/vnd.=
viewcvs-markup">1.1</a></td></tr>
<tr><td><tt> &=
nbsp; &n=
bsp; &nb=
sp; /<a href=3D"#file5"><span id=3D"added">Compatability.java</span>=
</a></tt></td><td align=3D"right" id=3D"added">+56</td><td></td><td nowra=
p=3D"nowrap" align=3D"right">added <a href=3D"http://xstream.cvs.codehaus=
.org/jcontainer/loom/support/extension/src/java/org/codehaus/loom/extensi=
on/Compatability.java?rev=3D1.1&content-type=3Dtext/vnd.viewcvs-marku=
p">1.1</a></td></tr>
<tr class=3D"alt"><td><tt>src/test/org/codehaus/loom/extension/<a href=3D=
"#file6"><span id=3D"added">DeweyDecimalTestCase.java</span></a></tt></td=
><td align=3D"right" id=3D"added">+265</td><td></td><td nowrap=3D"nowrap"=
align=3D"right">added <a href=3D"http://xstream.cvs.codehaus.org/jcontai=
ner/loom/support/extension/src/test/org/codehaus/loom/extension/DeweyDeci=
malTestCase.java?rev=3D1.1&content-type=3Dtext/vnd.viewcvs-markup">1.=
1</a></td></tr>
<tr><td><tt> &=
nbsp; &n=
bsp; &nb=
sp; /<a href=3D"#file7"><span id=3D"added">SpecificationTestCase.jav=
a</span></a></tt></td><td align=3D"right" id=3D"added">+454</td><td></td>=
<td nowrap=3D"nowrap" align=3D"right">added <a href=3D"http://xstream.cvs=
.codehaus.org/jcontainer/loom/support/extension/src/test/org/codehaus/loo=
m/extension/SpecificationTestCase.java?rev=3D1.1&content-type=3Dtext/=
vnd.viewcvs-markup">1.1</a></td></tr>
<tr class=3D"alt"><td><tt>  =
; =
&=
nbsp; /<a href=3D"#file8"><span id=3D"added">ExtensionTe=
stCase.java</span></a></tt></td><td align=3D"right" id=3D"added">+384</td=
><td></td><td nowrap=3D"nowrap" align=3D"right">added <a href=3D"http://x=
stream.cvs.codehaus.org/jcontainer/loom/support/extension/src/test/org/co=
dehaus/loom/extension/ExtensionTestCase.java?rev=3D1.1&content-type=3D=
text/vnd.viewcvs-markup">1.1</a></td></tr>
<tr><td><tt>src/java/org/jcontainer/loom/extension/<a href=3D"#file9"><sp=
an id=3D"removed">Extension.java</span></a></tt></td><td></td><td align=3D=
"right" id=3D"removed">-722</td><td nowrap=3D"nowrap"><a href=3D"http://x=
stream.cvs.codehaus.org/jcontainer/loom/support/extension/src/java/org/jc=
ontainer/loom/extension/Extension.java?rev=3D1.1&content-type=3Dtext/=
vnd.viewcvs-markup">1.1</a> removed</td></tr>
<tr class=3D"alt"><td><tt>  =
; =
&=
nbsp; /<a href=3D"#file10"><span id=3D"remov=
ed">Compatability.java</span></a></tt></td><td></td><td align=3D"right" i=
d=3D"removed">-56</td><td nowrap=3D"nowrap"><a href=3D"http://xstream.cvs=
.codehaus.org/jcontainer/loom/support/extension/src/java/org/jcontainer/l=
oom/extension/Compatability.java?rev=3D1.1&content-type=3Dtext/vnd.vi=
ewcvs-markup">1.1</a> removed</td></tr>
<tr><td><tt> &=
nbsp; &n=
bsp; &nb=
sp; /<a href=3D"#file11"><span id=3D"removed">DeweyDecim=
al.java</span></a></tt></td><td></td><td align=3D"right" id=3D"removed">-=
231</td><td nowrap=3D"nowrap"><a href=3D"http://xstream.cvs.codehaus.org/=
jcontainer/loom/support/extension/src/java/org/jcontainer/loom/extension/=
DeweyDecimal.java?rev=3D1.1&content-type=3Dtext/vnd.viewcvs-markup">1=
.1</a> removed</td></tr>
<tr class=3D"alt"><td><tt>  =
; =
&=
nbsp; /<a href=3D"#file12"><span id=3D"remov=
ed">Specification.java</span></a></tt></td><td></td><td align=3D"right" i=
d=3D"removed">-614</td><td nowrap=3D"nowrap"><a href=3D"http://xstream.cv=
s.codehaus.org/jcontainer/loom/support/extension/src/java/org/jcontainer/=
loom/extension/Specification.java?rev=3D1.1&content-type=3Dtext/vnd.v=
iewcvs-markup">1.1</a> removed</td></tr>
<tr><td><tt>src/test/org/jcontainer/loom/extension/<a href=3D"#file13"><s=
pan id=3D"removed">ExtensionTestCase.java</span></a></tt></td><td></td><t=
d align=3D"right" id=3D"removed">-381</td><td nowrap=3D"nowrap"><a href=3D=
"http://xstream.cvs.codehaus.org/jcontainer/loom/support/extension/src/te=
st/org/jcontainer/loom/extension/ExtensionTestCase.java?rev=3D1.1&con=
tent-type=3Dtext/vnd.viewcvs-markup">1.1</a> removed</td></tr>
<tr class=3D"alt"><td><tt>  =
; =
&=
nbsp; /<a href=3D"#file14"><span id=3D"remov=
ed">DeweyDecimalTestCase.java</span></a></tt></td><td></td><td align=3D"r=
ight" id=3D"removed">-263</td><td nowrap=3D"nowrap"><a href=3D"http://xst=
ream.cvs.codehaus.org/jcontainer/loom/support/extension/src/test/org/jcon=
tainer/loom/extension/DeweyDecimalTestCase.java?rev=3D1.1&content-typ=
e=3Dtext/vnd.viewcvs-markup">1.1</a> removed</td></tr>
<tr><td><tt> &=
nbsp; &n=
bsp; &nb=
sp; /<a href=3D"#file15"><span id=3D"removed">Specificat=
ionTestCase.java</span></a></tt></td><td></td><td align=3D"right" id=3D"r=
emoved">-451</td><td nowrap=3D"nowrap"><a href=3D"http://xstream.cvs.code=
haus.org/jcontainer/loom/support/extension/src/test/org/jcontainer/loom/e=
xtension/SpecificationTestCase.java?rev=3D1.1&content-type=3Dtext/vnd=
.viewcvs-markup">1.1</a> removed</td></tr>
<tr><td></td><td align=3D"right" id=3D"added">+2727</td><td align=3D"righ=
t" id=3D"removed">-2719</td><td></td></tr>
</table>
<small id=3D"info">7 added + 7 removed + 1 modified, total 15 files</smal=
l><br />
<pre class=3D"comment">
Renamed org.jcontainer.loom -> org.codehaus.loom
</pre>
<hr /><a name=3D"file1" /><div class=3D"file">
<span class=3D"pathname"><a href=3D"http://xstream.cvs.codehaus.org/jcont=
ainer">jcontainer</a>/<a href=3D"http://xstream.cvs.codehaus.org/jcontain=
er/loom">loom</a>/<a href=3D"http://xstream.cvs.codehaus.org/jcontainer/l=
oom/support">support</a>/<a href=3D"http://xstream.cvs.codehaus.org/jcont=
ainer/loom/support/extension">extension</a><br /></span>
<div class=3D"fileheader"><big><b>project.xml</b></big> <small id=3D"info=
"><a href=3D"http://xstream.cvs.codehaus.org/jcontainer/loom/support/exte=
nsion/project.xml?rev=3D1.7&content-type=3Dtext/vnd.viewcvs-markup">1=
.7</a> <a href=3D"http://xstream.cvs.codehaus.org/jcontainer/loom/support=
/extension/project.xml.diff?r1=3D1.7&r2=3D1.8">-></a> <a href=3D"h=
ttp://xstream.cvs.codehaus.org/jcontainer/loom/support/extension/project.=
xml?rev=3D1.8&content-type=3Dtext/vnd.viewcvs-markup">1.8</a></small>=
</div>
<pre class=3D"diff"><small id=3D"info">diff -u -r1.7 -r1.8
--- project.xml 31 Mar 2004 02:43:55 -0000 1.7
+++ project.xml 19 Apr 2004 21:40:38 -0000 1.8
@@ -4,7 +4,7 @@
</small></pre><pre class=3D"diff" id=3D"context"> <name>Extensi=
on</name>
<id>loom-extension</id>
<inceptionYear>2000</inceptionYear>
</pre><pre class=3D"diff" id=3D"removed">- <package>org.<span id=
=3D"removedchars">jcontainer</span>.loom.extension</package>
</pre><pre class=3D"diff" id=3D"added">+ <package>org.<span id=3D=
"addedchars">codehaus</span>.loom.extension</package>
</pre><pre class=3D"diff" id=3D"context">=20
<shortDescription>Parse and represent "Extension" and Specific=
ation information</shortDescription>
=20
</pre></div>
<hr /><a name=3D"file2" /><div class=3D"file">
<span class=3D"pathname" id=3D"added"><a href=3D"http://xstream.cvs.codeh=
aus.org/jcontainer">jcontainer</a>/<a href=3D"http://xstream.cvs.codehaus=
.org/jcontainer/loom">loom</a>/<a href=3D"http://xstream.cvs.codehaus.org=
/jcontainer/loom/support">support</a>/<a href=3D"http://xstream.cvs.codeh=
aus.org/jcontainer/loom/support/extension">extension</a>/<a href=3D"http:=
//xstream.cvs.codehaus.org/jcontainer/loom/support/extension/src">src</a>=
/<a href=3D"http://xstream.cvs.codehaus.org/jcontainer/loom/support/exten=
sion/src/java">java</a>/<a href=3D"http://xstream.cvs.codehaus.org/jconta=
iner/loom/support/extension/src/java/org">org</a>/<a href=3D"http://xstre=
am.cvs.codehaus.org/jcontainer/loom/support/extension/src/java/org/codeha=
us">codehaus</a>/<a href=3D"http://xstream.cvs.codehaus.org/jcontainer/lo=
om/support/extension/src/java/org/codehaus/loom">loom</a>/<a href=3D"http=
://xstream.cvs.codehaus.org/jcontainer/loom/support/extension/src/java/or=
g/codehaus/loom/extension">extension</a><br /></span>
<div class=3D"fileheader" id=3D"added"><big><b>Specification.java</b></bi=
g> <small id=3D"info">added at <a href=3D"http://xstream.cvs.codehaus.org=
/jcontainer/loom/support/extension/src/java/org/codehaus/loom/extension/S=
pecification.java?rev=3D1.1&content-type=3Dtext/vnd.viewcvs-markup">1=
.1</a></small></div>
<pre class=3D"diff"><small id=3D"info">diff -N Specification.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ Specification.java 19 Apr 2004 21:40:38 -0000 1.1
@@ -0,0 +1,614 @@
</small></pre><pre class=3D"diff" id=3D"added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.loom.extension;
+
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.jar.Attributes;
+import java.util.jar.Manifest;
+
+/**
+ * <p>Utility class that represents either an available "Optional =
Package"
+ * (formerly known as "Standard Extension") as described in the manifest=
of a
+ * JAR file, or the requirement for such an optional package.</p>
+ *
+ * <p>For more information about optional packages, see the docume=
nt
+ * <em>Optional Package Versioning</em> in the documentation=
bundle for your
+ * Java2 Standard Edition package, in file <code>guide/extensions/=
versioning.html</code>.</p>
+ *
+ * @author Peter Donald
+ * @version $Revision: 1.1 $ $Date: 2004/04/19 21:40:38 $
+ */
+public final class Specification
+{
+ /**
+ * Manifest Attribute Name object for SPECIFICATION_TITLE.
+ *
+ * @see Attributes.Name#SPECIFICATION_TITLE
+ */
+ public static final Attributes.Name SPECIFICATION_TITLE =3D Attribut=
es.Name.SPECIFICATION_TITLE;
+ /**
+ * Manifest Attribute Name object for SPECIFICATION_VERSION.
+ *
+ * @see Attributes.Name#SPECIFICATION_VERSION
+ */
+ public static final Attributes.Name SPECIFICATION_VERSION =3D Attrib=
utes.Name.SPECIFICATION_VERSION;
+ /**
+ * Manifest Attribute Name object for SPECIFICATION_VENDOR.
+ *
+ * @see Attributes.Name#SPECIFICATION_VENDOR
+ */
+ public static final Attributes.Name SPECIFICATION_VENDOR =3D Attribu=
tes.Name.SPECIFICATION_VENDOR;
+ /**
+ * Manifest Attribute Name object for IMPLEMENTATION_TITLE.
+ *
+ * @see Attributes.Name#IMPLEMENTATION_TITLE
+ */
+ public static final Attributes.Name IMPLEMENTATION_TITLE =3D Attribu=
tes.Name.IMPLEMENTATION_TITLE;
+ /**
+ * Manifest Attribute Name object for IMPLEMENTATION_VERSION.
+ *
+ * @see Attributes.Name#IMPLEMENTATION_VERSION
+ */
+ public static final Attributes.Name IMPLEMENTATION_VERSION =3D Attri=
butes.Name.IMPLEMENTATION_VERSION;
+ /**
+ * Manifest Attribute Name object for IMPLEMENTATION_VENDOR.
+ *
+ * @see Attributes.Name#IMPLEMENTATION_VENDOR
+ */
+ public static final Attributes.Name IMPLEMENTATION_VENDOR =3D Attrib=
utes.Name.IMPLEMENTATION_VENDOR;
+ /**
+ * Enum indicating that extension is compatible with other Package
+ * Specification.
+ */
+ public static final Compatability COMPATIBLE =3D
+ new Compatability( "COMPATIBLE" );
+ /**
+ * Enum indicating that extension requires an upgrade of specificati=
on to be
+ * compatible with other Package Specification.
+ */
+ public static final Compatability REQUIRE_SPECIFICATION_UPGRADE =3D
+ new Compatability( "REQUIRE_SPECIFICATION_UPGRADE" );
+ /**
+ * Enum indicating that extension requires a vendor switch to be com=
patible
+ * with other Package Specification.
+ */
+ public static final Compatability REQUIRE_VENDOR_SWITCH =3D
+ new Compatability( "REQUIRE_VENDOR_SWITCH" );
+ /**
+ * Enum indicating that extension requires an upgrade of implementat=
ion to
+ * be compatible with other Package Specification.
+ */
+ public static final Compatability REQUIRE_IMPLEMENTATION_CHANGE =3D
+ new Compatability( "REQUIRE_IMPLEMENTATION_CHANGE" );
+ /**
+ * Enum indicating that extension is incompatible with other Package
+ * Specification in ways other than other enums indicate). ie For ex=
ample
+ * the other Package Specification may have a different ID.
+ */
+ public static final Compatability INCOMPATIBLE =3D
+ new Compatability( "INCOMPATIBLE" );
+ /** The name of the Package Specification. */
+ private String m_specificationTitle;
+ /**
+ * The version number (dotted decimal notation) of the specification=
to
+ * which this optional package conforms.
+ */
+ private DeweyDecimal m_specificationVersion;
+ /**
+ * The name of the company or organization that originated the speci=
fication
+ * to which this specification conforms.
+ */
+ private String m_specificationVendor;
+ /** The title of implementation. */
+ private String m_implementationTitle;
+ /**
+ * The name of the company or organization that produced this implem=
entation
+ * of this specification.
+ */
+ private String m_implementationVendor;
+ /**
+ * The version string for implementation. The version string is opaq=
ue.
+ */
+ private String m_implementationVersion;
+ /** The sections of jar that the specification applies to. */
+ private String[] m_sections;
+
+ /**
+ * Return an array of <code>Package Specification</code>=
objects. If there
+ * are no such optional packages, a zero-length array is returned.
+ *
+ * @param manifest Manifest to be parsed
+ * @return the Package Specifications extensions in specified manife=
st
+ */
+ public static Specification[] getSpecifications( final Manifest mani=
fest )
+ throws ParseException
+ {
+ if( null =3D=3D manifest )
+ {
+ return new Specification[ 0 ];
+ }
+ final ArrayList results =3D new ArrayList();
+ final Map entries =3D manifest.getEntries();
+ final Iterator keys =3D entries.keySet().iterator();
+ while( keys.hasNext() )
+ {
+ final String key =3D (String)keys.next();
+ final Attributes attributes =3D (Attributes)entries.get( key=
);
+ final Specification specification =3D getSpecification( key,
+ attrib=
utes );
+ if( null !=3D specification )
+ {
+ results.add( specification );
+ }
+ }
+ final ArrayList trimmedResults =3D removeDuplicates( results );
+ return (Specification[])trimmedResults.toArray( new Specificatio=
n[ 0 ] );
+ }
+
+ /**
+ * The constructor to create Package Specification object. Note that=
every
+ * component is allowed to be specified but only the specificationTi=
tle is
+ * mandatory.
+ *
+ * @param specificationTitle the name of specification.
+ * @param specificationVersion the specification Version.
+ * @param specificationVendor the specification Vendor.
+ * @param implementationTitle the title of implementation.
+ * @param implementationVersion the implementation Version.
+ * @param implementationVendor the implementation Vendor.
+ */
+ public Specification( final String specificationTitle,
+ final String specificationVersion,
+ final String specificationVendor,
+ final String implementationTitle,
+ final String implementationVersion,
+ final String implementationVendor )
+ {
+ this( specificationTitle, specificationVersion, specificationVen=
dor,
+ implementationTitle, implementationVersion, implementation=
Vendor,
+ null );
+ }
+
+ /**
+ * The constructor to create Package Specification object. Note that=
every
+ * component is allowed to be specified but only the specificationTi=
tle is
+ * mandatory.
+ *
+ * @param specificationTitle the name of specification.
+ * @param specificationVersion the specification Version.
+ * @param specificationVendor the specification Vendor.
+ * @param implementationTitle the title of implementation.
+ * @param implementationVersion the implementation Version.
+ * @param implementationVendor the implementation Vendor.
+ * @param sections the sections/packages that Specification applies =
to.
+ */
+ public Specification( final String specificationTitle,
+ final String specificationVersion,
+ final String specificationVendor,
+ final String implementationTitle,
+ final String implementationVersion,
+ final String implementationVendor,
+ final String[] sections )
+ {
+ if( null =3D=3D specificationTitle )
+ {
+ throw new NullPointerException( "specificationTitle" );
+ }
+ m_specificationTitle =3D specificationTitle;
+ m_specificationVendor =3D specificationVendor;
+ if( null !=3D specificationVersion )
+ {
+ try
+ {
+ m_specificationVersion =3D
+ new DeweyDecimal( specificationVersion );
+ }
+ catch( final NumberFormatException nfe )
+ {
+ final String error =3D "Bad specification version format=
'" +
+ specificationVersion +
+ "' in '" + specificationTitle + "'. (Reason: " + nfe=
+ ")";
+ throw new IllegalArgumentException( error );
+ }
+ }
+ m_implementationTitle =3D implementationTitle;
+ m_implementationVendor =3D implementationVendor;
+ m_implementationVersion =3D implementationVersion;
+ String[] copy =3D null;
+ if( null !=3D sections )
+ {
+ copy =3D new String[ sections.length ];
+ System.arraycopy( sections, 0, copy, 0, sections.length );
+ }
+ m_sections =3D copy;
+ }
+
+ /**
+ * Get the title of the specification.
+ *
+ * @return the title of speciication
+ */
+ public String getSpecificationTitle()
+ {
+ return m_specificationTitle;
+ }
+
+ /**
+ * Get the vendor of the specification.
+ *
+ * @return the vendor of the specification.
+ */
+ public String getSpecificationVendor()
+ {
+ return m_specificationVendor;
+ }
+
+ /**
+ * Get the title of the specification.
+ *
+ * @return the title of the specification.
+ */
+ public String getImplementationTitle()
+ {
+ return m_implementationTitle;
+ }
+
+ /**
+ * Get the version of the specification.
+ *
+ * @return the version of the specification.
+ */
+ public DeweyDecimal getSpecificationVersion()
+ {
+ return m_specificationVersion;
+ }
+
+ /**
+ * Get the vendor of the extensions implementation.
+ *
+ * @return the vendor of the extensions implementation.
+ */
+ public String getImplementationVendor()
+ {
+ return m_implementationVendor;
+ }
+
+ /**
+ * Get the version of the implementation.
+ *
+ * @return the version of the implementation.
+ */
+ public String getImplementationVersion()
+ {
+ return m_implementationVersion;
+ }
+
+ /**
+ * Return an array containing sections to which specification applie=
s or
+ * null if relevant to no sections.
+ *
+ * @return an array containing sections to which specification appli=
es or
+ * null if relevant to no sections.
+ */
+ public String[] getSections()
+ {
+ if( null =3D=3D m_sections )
+ {
+ return null;
+ }
+ else
+ {
+ final String[] sections =3D new String[ m_sections.length ];
+ System.arraycopy( m_sections, 0, sections, 0, m_sections.len=
gth );
+ return sections;
+ }
+ }
+
+ /**
+ * Return a Compatibility enum indicating the relationship of this
+ * <code>Package Specification</code> with the specified
+ * <code>Extension</code>.
+ *
+ * @param other the other specification
+ * @return the enum indicating the compatability (or lack thereof) o=
f
+ * specifed Package Specification
+ */
+ public Compatability getCompatibilityWith( final Specification other=
)
+ {
+ // Specification Name must match
+ if( !m_specificationTitle.equals( other.getSpecificationTitle() =
) )
+ {
+ return INCOMPATIBLE;
+ }
+ // Available specification version must be >=3D required
+ final DeweyDecimal specificationVersion =3D other.getSpecificati=
onVersion();
+ if( null !=3D specificationVersion )
+ {
+ if( null =3D=3D m_specificationVersion ||
+ !isCompatible( m_specificationVersion, specificationVers=
ion ) )
+ {
+ return REQUIRE_SPECIFICATION_UPGRADE;
+ }
+ }
+ // Implementation Vendor ID must match
+ final String implementationVendor =3D other.getImplementationVen=
dor();
+ if( null !=3D implementationVendor )
+ {
+ if( null =3D=3D m_implementationVendor ||
+ !m_implementationVendor.equals( implementationVendor ) )
+ {
+ return REQUIRE_VENDOR_SWITCH;
+ }
+ }
+ // Implementation version must be >=3D required
+ final String implementationVersion =3D other.getImplementationVe=
rsion();
+ if( null !=3D implementationVersion )
+ {
+ if( null =3D=3D m_implementationVersion ||
+ !m_implementationVersion.equals( implementationVersion )=
)
+ {
+ return REQUIRE_IMPLEMENTATION_CHANGE;
+ }
+ }
+ // This available optional package satisfies the requirements
+ return COMPATIBLE;
+ }
+
+ /**
+ * Return <code>true</code> if the specified <code>=
;package</code> is
+ * satisfied by this <code>Specification</code>. Otherwi=
se, return
+ * <code>false</code>.
+ *
+ * @param other the specification
+ * @return true if the specification is compatible with this specifi=
cation
+ */
+ public boolean isCompatibleWith( final Specification other )
+ {
+ return ( COMPATIBLE =3D=3D getCompatibilityWith( other ) );
+ }
+
+ /**
+ * Return a String representation of this object.
+ *
+ * @return string representation of object.
+ */
+ public String toString()
+ {
+ final String lineSeparator =3D System.getProperty( "line.separat=
or" );
+ final String brace =3D ": ";
+ final StringBuffer sb =3D new StringBuffer(
+ SPECIFICATION_TITLE.toString() );
+ sb.append( brace );
+ sb.append( m_specificationTitle );
+ sb.append( lineSeparator );
+ if( null !=3D m_specificationVersion )
+ {
+ sb.append( SPECIFICATION_VERSION );
+ sb.append( brace );
+ sb.append( m_specificationVersion );
+ sb.append( lineSeparator );
+ }
+ if( null !=3D m_specificationVendor )
+ {
+ sb.append( SPECIFICATION_VENDOR );
+ sb.append( brace );
+ sb.append( m_specificationVendor );
+ sb.append( lineSeparator );
+ }
+ if( null !=3D m_implementationTitle )
+ {
+ sb.append( IMPLEMENTATION_TITLE );
+ sb.append( brace );
+ sb.append( m_implementationTitle );
+ sb.append( lineSeparator );
+ }
+ if( null !=3D m_implementationVersion )
+ {
+ sb.append( IMPLEMENTATION_VERSION );
+ sb.append( brace );
+ sb.append( m_implementationVersion );
+ sb.append( lineSeparator );
+ }
+ if( null !=3D m_implementationVendor )
+ {
+ sb.append( IMPLEMENTATION_VENDOR );
+ sb.append( brace );
+ sb.append( m_implementationVendor );
+ sb.append( lineSeparator );
+ }
+ return sb.toString();
+ }
+
+ /**
+ * Return <code>true</code> if the first version number =
is greater than or
+ * equal to the second; otherwise return <code>false</code&=
gt;.
+ *
+ * @param first First version number (dotted decimal)
+ * @param second Second version number (dotted decimal)
+ */
+ private boolean isCompatible( final DeweyDecimal first,
+ final DeweyDecimal second )
+ {
+ return first.isGreaterThanOrEqual( second );
+ }
+
+ /**
+ * Combine all specifications objects that are identical except for =
the
+ * sections.
+ *
+ * <p>Note this is very inefficent and should probably be fixe=
d in the
+ * future.</p>
+ *
+ * @param list the array of results to trim
+ * @return an array list with all duplicates removed
+ */
+ private static ArrayList removeDuplicates( final ArrayList list )
+ {
+ final ArrayList results =3D new ArrayList();
+ final ArrayList sections =3D new ArrayList();
+ while( list.size() > 0 )
+ {
+ final Specification specification =3D (Specification)list.re=
move( 0 );
+ final Iterator iterator =3D list.iterator();
+ while( iterator.hasNext() )
+ {
+ final Specification other =3D (Specification)iterator.ne=
xt();
+ if( isEqual( specification, other ) )
+ {
+ final String[] otherSections =3D other.getSections()=
;
+ if( null !=3D sections )
+ {
+ sections.addAll( Arrays.asList( otherSections ) =
);
+ }
+ iterator.remove();
+ }
+ }
+ final Specification merged =3D
+ mergeInSections( specification, sections );
+ results.add( merged );
+ //Reset list of sections
+ sections.clear();
+ }
+ return results;
+ }
+
+ /**
+ * Test if two specifications are equal except for their sections.
+ *
+ * @param specification one specificaiton
+ * @param other the ohter specification
+ * @return true if two specifications are equal except for their sec=
tions,
+ * else false
+ */
+ private static boolean isEqual( final Specification specification,
+ final Specification other )
+ {
+ return
+ specification.getSpecificationTitle().equals(
+ other.getSpecificationTitle() ) &&
+ specification.getSpecificationVersion().isEqual(
+ other.getSpecificationVersion() ) &&
+ specification.getSpecificationVendor().equals(
+ other.getSpecificationVendor() ) &&
+ specification.getImplementationTitle().equals(
+ other.getImplementationTitle() ) &&
+ specification.getImplementationVersion().equals(
+ other.getImplementationVersion() ) &&
+ specification.getImplementationVendor().equals(
+ other.getImplementationVendor() );
+ }
+
+ /**
+ * Merge the specified sections into specified section and return re=
sult. If
+ * no sections to be added then just return original specification.
+ *
+ * @param specification the specification
+ * @param sectionsToAdd the list of sections to merge
+ * @return the merged specification
+ */
+ private static Specification mergeInSections(
+ final Specification specification,
+ final ArrayList sectionsToAdd )
+ {
+ if( 0 =3D=3D sectionsToAdd.size() )
+ {
+ return specification;
+ }
+ else
+ {
+ sectionsToAdd.addAll( Arrays.asList( specification.getSectio=
ns() ) );
+ final String[] sections =3D
+ (String[])sectionsToAdd.toArray(
+ new String[ sectionsToAdd.size() ] );
+ return new Specification( specification.getSpecificationTitl=
e(),
+ specification.getSpecificationVers=
ion()
+ .toString(),
+ specification.getSpecificationVend=
or(),
+ specification.getImplementationTit=
le(),
+ specification.getImplementationVer=
sion(),
+ specification.getImplementationVen=
dor(),
+ sections );
+ }
+ }
+
+ /**
+ * Trim the supplied string if the string is non-null
+ *
+ * @param value the string to trim or null
+ * @return the trimmed string or null
+ */
+ private static String getTrimmedString( final String value )
+ {
+ if( null =3D=3D value )
+ {
+ return null;
+ }
+ else
+ {
+ return value.trim();
+ }
+ }
+
+ /**
+ * Extract an Package Specification from Attributes.
+ *
+ * @param attributes Attributes to searched
+ * @return the new Specification object, or null
+ */
+ private static Specification getSpecification( final String section,
+ final Attributes attr=
ibutes )
+ throws ParseException
+ {
+ //WARNING: We trim the values of all the attributes because
+ //Some extension declarations are badly defined (ie have spaces
+ //after version or vendor)
+ final String name =3D getTrimmedString(
+ attributes.getValue( SPECIFICATION_TITLE ) );
+ if( null =3D=3D name )
+ {
+ return null;
+ }
+ final String specVendor =3D getTrimmedString(
+ attributes.getValue( SPECIFICATION_VENDOR ) );
+ if( null =3D=3D specVendor )
+ {
+ throw new ParseException( "Missing " + SPECIFICATION_VENDOR,=
0 );
+ }
+ final String specVersion =3D getTrimmedString(
+ attributes.getValue( SPECIFICATION_VERSION ) );
+ if( null =3D=3D specVersion )
+ {
+ throw new ParseException( "Missing " + SPECIFICATION_VERSION=
, 0 );
+ }
+ final String impTitle =3D getTrimmedString(
+ attributes.getValue( IMPLEMENTATION_TITLE ) );
+ if( null =3D=3D impTitle )
+ {
+ throw new ParseException( "Missing " + IMPLEMENTATION_TITLE,=
0 );
+ }
+ final String impVersion =3D getTrimmedString(
+ attributes.getValue( IMPLEMENTATION_VERSION ) );
+ if( null =3D=3D impVersion )
+ {
+ throw new ParseException( "Missing " + IMPLEMENTATION_VERSIO=
N, 0 );
+ }
+ final String impVendor =3D getTrimmedString(
+ attributes.getValue( IMPLEMENTATION_VENDOR ) );
+ if( null =3D=3D impVendor )
+ {
+ throw new ParseException( "Missing " + IMPLEMENTATION_VENDOR=
, 0 );
+ }
+ return new Specification( name, specVersion, specVendor,
+ impTitle, impVersion, impVendor,
+ new String[]{section} );
+ }
+}
</pre></div>
<hr /><a name=3D"file3" /><div class=3D"file">
<span class=3D"pathname" id=3D"added"><a href=3D"http://xstream.cvs.codeh=
aus.org/jcontainer">jcontainer</a>/<a href=3D"http://xstream.cvs.codehaus=
.org/jcontainer/loom">loom</a>/<a href=3D"http://xstream.cvs.codehaus.org=
/jcontainer/loom/support">support</a>/<a href=3D"http://xstream.cvs.codeh=
aus.org/jcontainer/loom/support/extension">extension</a>/<a href=3D"http:=
//xstream.cvs.codehaus.org/jcontainer/loom/support/extension/src">src</a>=
/<a href=3D"http://xstream.cvs.codehaus.org/jcontainer/loom/support/exten=
sion/src/java">java</a>/<a href=3D"http://xstream.cvs.codehaus.org/jconta=
iner/loom/support/extension/src/java/org">org</a>/<a href=3D"http://xstre=
am.cvs.codehaus.org/jcontainer/loom/support/extension/src/java/org/codeha=
us">codehaus</a>/<a href=3D"http://xstream.cvs.codehaus.org/jcontainer/lo=
om/support/extension/src/java/org/codehaus/loom">loom</a>/<a href=3D"http=
://xstream.cvs.codehaus.org/jcontainer/loom/support/extension/src/java/or=
g/codehaus/loom/extension">extension</a><br /></span>
<div class=3D"fileheader" id=3D"added"><big><b>Extension.java</b></big> <=
small id=3D"info">added at <a href=3D"http://xstream.cvs.codehaus.org/jco=
ntainer/loom/support/extension/src/java/org/codehaus/loom/extension/Exten=
sion.java?rev=3D1.1&content-type=3Dtext/vnd.viewcvs-markup">1.1</a></=
small></div>
<pre class=3D"diff"><small id=3D"info">diff -N Extension.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ Extension.java 19 Apr 2004 21:40:38 -0000 1.1
@@ -0,0 +1,722 @@
</small></pre><pre class=3D"diff" id=3D"added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ *
+ * This product includes software developed by the
+=EF=BF=BD*=EF=BF=BDApache Software Foundation (http://www.apache.org/).
+ */
+package org.codehaus.loom.extension;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.StringTokenizer;
+import java.util.jar.Attributes;
+import java.util.jar.Manifest;
+
+/**
+ * <p>Utility class that represents either an available "Optional =
Package"
+ * (formerly known as "Standard Extension") as described in the manifest=
of a
+ * JAR file, or the requirement for such an optional package.</p>
+ *
+ * <p>For more information about optional packages, see the docume=
nt
+ * <em>Optional Package Versioning</em> in the documentation=
bundle for your
+ * Java2 Standard Edition package, in file <code>guide/extensions/=
versioning.html</code>.</p>
+ *
+ * @author <a href=3D"mailto:craigmcc at apache.org">Craig R. McCl=
anahan</a>
+ * @author Peter Donald
+ * @version $Revision: 1.1 $ $Date: 2004/04/19 21:40:38 $
+ */
+public final class Extension
+{
+ /**
+ * Manifest Attribute Name object for EXTENSION_LIST.
+ *
+ * @see Attributes.Name#EXTENSION_LIST
+ */
+ public static final Attributes.Name EXTENSION_LIST =3D Attributes.Na=
me.EXTENSION_LIST;
+ /**
+ * <code>Name</code> object for <code>Optional-Ext=
ension-List</code>
+ * manifest attribute used for declaring optional dependencies on in=
stalled
+ * extensions. Note that the dependencies declared by this method ar=
e not
+ * required for the library to operate but if present will be used. =
It is
+ * NOT part of the official "Optional Package" specification.
+ *
+ * @see <a href=3D"http://java.sun.com/j2se/1.3/docs/guide/extens=
ions/spec.html#dependnecy">
+ * Installed extension dependency</a>
+ */
+ public static final Attributes.Name OPTIONAL_EXTENSION_LIST =3D
+ new Attributes.Name( "Optional-Extension-List" );
+ /**
+ * Manifest Attribute Name object for EXTENSION_NAME.
+ *
+ * @see Attributes.Name#EXTENSION_NAME
+ */
+ public static final Attributes.Name EXTENSION_NAME =3D
+ Attributes.Name.EXTENSION_NAME;
+ /**
+ * Manifest Attribute Name object for SPECIFICATION_VERSION.
+ *
+ * @see Attributes.Name#SPECIFICATION_VERSION
+ */
+ public static final Attributes.Name SPECIFICATION_VERSION =3D
+ Attributes.Name.SPECIFICATION_VERSION;
+ /**
+ * Manifest Attribute Name object for SPECIFICATION_VENDOR.
+ *
+ * @see Attributes.Name#SPECIFICATION_VENDOR
+ */
+ public static final Attributes.Name SPECIFICATION_VENDOR =3D
+ Attributes.Name.SPECIFICATION_VENDOR;
+ /**
+ * Manifest Attribute Name object for IMPLEMENTATION_VERSION.
+ *
+ * @see Attributes.Name#IMPLEMENTATION_VERSION
+ */
+ public static final Attributes.Name IMPLEMENTATION_VERSION =3D
+ Attributes.Name.IMPLEMENTATION_VERSION;
+ /**
+ * Manifest Attribute Name object for IMPLEMENTATION_VENDOR.
+ *
+ * @see Attributes.Name#IMPLEMENTATION_VENDOR
+ */
+ public static final Attributes.Name IMPLEMENTATION_VENDOR =3D
+ Attributes.Name.IMPLEMENTATION_VENDOR;
+ /**
+ * Manifest Attribute Name object for IMPLEMENTATION_URL.
+ *
+ * @see Attributes.Name#IMPLEMENTATION_URL
+ */
+ public static final Attributes.Name IMPLEMENTATION_URL =3D
+ Attributes.Name.IMPLEMENTATION_URL;
+ /**
+ * Manifest Attribute Name object for IMPLEMENTATION_VENDOR_ID.
+ *
+ * @see Attributes.Name#IMPLEMENTATION_VENDOR_ID
+ */
+ public static final Attributes.Name IMPLEMENTATION_VENDOR_ID =3D
+ Attributes.Name.IMPLEMENTATION_VENDOR_ID;
+ /** Enum indicating that extension is compatible with other extensio=
n. */
+ public static final Compatability COMPATIBLE =3D
+ new Compatability( "COMPATIBLE" );
+ /**
+ * Enum indicating that extension requires an upgrade of specificati=
on to be
+ * compatible with other extension.
+ */
+ public static final Compatability REQUIRE_SPECIFICATION_UPGRADE =3D
+ new Compatability( "REQUIRE_SPECIFICATION_UPGRADE" );
+ /**
+ * Enum indicating that extension requires a vendor switch to be com=
patible
+ * with other extension.
+ */
+ public static final Compatability REQUIRE_VENDOR_SWITCH =3D
+ new Compatability( "REQUIRE_VENDOR_SWITCH" );
+ /**
+ * Enum indicating that extension requires an upgrade of implementat=
ion to
+ * be compatible with other extension.
+ */
+ public static final Compatability REQUIRE_IMPLEMENTATION_UPGRADE =3D
+ new Compatability( "REQUIRE_IMPLEMENTATION_UPGRADE" );
+ /**
+ * Enum indicating that extension is incompatible with other extensi=
on in
+ * ways other than other enums indicate). ie For example the other e=
xtension
+ * may have a different ID.
+ */
+ public static final Compatability INCOMPATIBLE =3D
+ new Compatability( "INCOMPATIBLE" );
+ /** The name of the optional package being made available, or requir=
ed. */
+ private String m_extensionName;
+ /**
+ * The version number (dotted decimal notation) of the specification=
to
+ * which this optional package conforms.
+ */
+ private DeweyDecimal m_specificationVersion;
+ /**
+ * The name of the company or organization that originated the speci=
fication
+ * to which this optional package conforms.
+ */
+ private String m_specificationVendor;
+ /**
+ * The unique identifier of the company that produced the optional p=
ackage
+ * contained in this JAR file.
+ */
+ private String m_implementationVendorID;
+ /**
+ * The name of the company or organization that produced this implem=
entation
+ * of this optional package.
+ */
+ private String m_implementationVendor;
+ /**
+ * The version number (dotted decimal notation) for this implementat=
ion of
+ * the optional package.
+ */
+ private String m_implementationVersion;
+ /**
+ * The URL from which the most recent version of this optional packa=
ge can
+ * be obtained if it is not already installed.
+ */
+ private String m_implementationURL;
+
+ /**
+ * Return an array of <code>Extension</code> objects rep=
resenting optional
+ * packages that are available in the JAR file associated with the s=
pecified
+ * <code>Manifest</code>. If there are no such optional=
packages, a
+ * zero-length array is returned.
+ *
+ * @param manifest Manifest to be parsed
+ * @return the "available" extensions in specified manifest
+ */
+ public static Extension[] getAvailable( final Manifest manifest )
+ {
+ if( null =3D=3D manifest )
+ {
+ return new Extension[ 0 ];
+ }
+ final ArrayList results =3D new ArrayList();
+ final Attributes mainAttributes =3D manifest.getMainAttributes()=
;
+ if( null !=3D mainAttributes )
+ {
+ final Extension extension =3D getExtension( "", mainAttribut=
es );
+ if( null !=3D extension )
+ {
+ results.add( extension );
+ }
+ }
+ final Map entries =3D manifest.getEntries();
+ final Iterator keys =3D entries.keySet().iterator();
+ while( keys.hasNext() )
+ {
+ final String key =3D (String)keys.next();
+ final Attributes attributes =3D (Attributes)entries.get( key=
);
+ final Extension extension =3D getExtension( "", attributes )=
;
+ if( null !=3D extension )
+ {
+ results.add( extension );
+ }
+ }
+ return (Extension[])results.toArray( new Extension[ results.size=
() ] );
+ }
+
+ /**
+ * Retrieve the set of <code>Extension</code> objects th=
at are available by
+ * the specified Manifest objects. If there are no such optional pac=
kages, a
+ * zero-length list is returned.
+ *
+ * @param manifests the manifests to scan
+ * @return the extensions
+ */
+ public static Extension[] getAvailable( final Manifest[] manifests )
+ {
+ final ArrayList set =3D new ArrayList();
+ for( int i =3D 0; i < manifests.length; i++ )
+ {
+ final Extension[] extensions =3D getAvailable( manifests[ i =
] );
+ for( int j =3D 0; j < extensions.length; j++ )
+ {
+ set.add( extensions[ j ] );
+ }
+ }
+ return (Extension[])set.toArray( new Extension[ set.size() ] );
+ }
+
+ /**
+ * Return the set of <code>Extension</code> objects repr=
esenting optional
+ * packages that are required by the application contained in the JA=
R file
+ * associated with the specified <code>Manifest</code>. =
If there are no
+ * such optional packages, a zero-length list is returned.
+ *
+ * @param manifest Manifest to be parsed
+ * @return the dependencies that are specified in manifes
+ */
+ public static Extension[] getRequired( final Manifest manifest )
+ {
+ return getListed( manifest, EXTENSION_LIST );
+ }
+
+ /**
+ * Retrieve the set of <code>Extension</code> objects th=
at are required by
+ * the specified Manifest objects. If there are no such optional pac=
kages, a
+ * zero-length list is returned.
+ *
+ * @param manifests the manifests to scan
+ * @return the extensions
+ */
+ public static Extension[] getRequired( final Manifest[] manifests )
+ {
+ final ArrayList set =3D new ArrayList();
+ for( int i =3D 0; i < manifests.length; i++ )
+ {
+ final Extension[] extensions =3D getRequired( manifests[ i ]=
);
+ for( int j =3D 0; j < extensions.length; j++ )
+ {
+ set.add( extensions[ j ] );
+ }
+ }
+ return (Extension[])set.toArray( new Extension[ set.size() ] );
+ }
+
+ /**
+ * Return the set of <code>Extension</code> objects repr=
esenting "Optional
+ * Packages" that the application declares they will use if present.=
If
+ * there are no such optional packages, a zero-length list is return=
ed.
+ *
+ * @param manifest Manifest to be parsed
+ * @return the optional dependencies that are specified in manifest
+ */
+ public static Extension[] getOptions( final Manifest manifest )
+ {
+ return getListed( manifest, OPTIONAL_EXTENSION_LIST );
+ }
+
+ /**
+ * Add Extension to the specified manifest Attributes.
+ *
+ * @param attributes the attributes of manifest to add to
+ * @param extension the extension
+ */
+ public static void addExtension( final Extension extension,
+ final Attributes attributes )
+ {
+ addExtension( extension, "", attributes );
+ }
+
+ /**
+ * Add Extension to the specified manifest Attributes. Use the speci=
fied
+ * prefix so that dependencies can added with a prefix such as "java=
3d-"
+ * etc.
+ *
+ * @param attributes the attributes of manifest to add to
+ * @param extension the extension
+ * @param prefix the name to prefix to extension
+ */
+ public static void addExtension( final Extension extension,
+ final String prefix,
+ final Attributes attributes )
+ {
+ attributes.putValue( prefix + EXTENSION_NAME,
+ extension.getExtensionName() );
+ final String specificationVendor =3D extension.getSpecificationV=
endor();
+ if( null !=3D specificationVendor )
+ {
+ attributes.putValue( prefix + SPECIFICATION_VENDOR,
+ specificationVendor );
+ }
+ final DeweyDecimal specificationVersion =3D extension.getSpecifi=
cationVersion();
+ if( null !=3D specificationVersion )
+ {
+ attributes.putValue( prefix + SPECIFICATION_VERSION,
+ specificationVersion.toString() );
+ }
+ final String implementationVendorID =3D extension.getImplementat=
ionVendorID();
+ if( null !=3D implementationVendorID )
+ {
+ attributes.putValue( prefix + IMPLEMENTATION_VENDOR_ID,
+ implementationVendorID );
+ }
+ final String implementationVendor =3D extension.getImplementatio=
nVendor();
+ if( null !=3D implementationVendor )
+ {
+ attributes.putValue( prefix + IMPLEMENTATION_VENDOR,
+ implementationVendor );
+ }
+ final String implementationVersion =3D extension.getImplementati=
onVersion();
+ if( null !=3D implementationVersion )
+ {
+ attributes.putValue( prefix + IMPLEMENTATION_VERSION,
+ implementationVersion.toString() );
+ }
+ final String implementationURL =3D extension.getImplementationUR=
L();
+ if( null !=3D implementationURL )
+ {
+ attributes.putValue( prefix + IMPLEMENTATION_URL,
+ implementationURL );
+ }
+ }
+
+ /**
+ * The constructor to create Extension object. Note that every compo=
nent is
+ * allowed to be specified but only the extensionName is mandatory.
+ *
+ * @param extensionName the name of extension.
+ * @param specificationVersion the specification Version of extensio=
n.
+ * @param specificationVendor the specification Vendor of extension.
+ * @param implementationVersion the implementation Version of extens=
ion.
+ * @param implementationVendor the implementation Vendor of extensio=
n.
+ * @param implementationVendorId the implementation VendorId of exte=
nsion.
+ * @param implementationURL the implementation URL of extension.
+ */
+ public Extension( final String extensionName,
+ final String specificationVersion,
+ final String specificationVendor,
+ final String implementationVersion,
+ final String implementationVendor,
+ final String implementationVendorId,
+ final String implementationURL )
+ {
+ if( null =3D=3D extensionName )
+ {
+ throw new NullPointerException( "extensionName" );
+ }
+ m_extensionName =3D extensionName;
+ m_specificationVendor =3D specificationVendor;
+ if( null !=3D specificationVersion )
+ {
+ try
+ {
+ m_specificationVersion =3D
+ new DeweyDecimal( specificationVersion );
+ }
+ catch( final NumberFormatException nfe )
+ {
+ final String error =3D "Bad specification version format=
'" +
+ specificationVersion +
+ "' in '" + extensionName + "'. (Reason: " + nfe + ")=
";
+ throw new IllegalArgumentException( error );
+ }
+ }
+ m_implementationURL =3D implementationURL;
+ m_implementationVendor =3D implementationVendor;
+ m_implementationVendorID =3D implementationVendorId;
+ m_implementationVersion =3D implementationVersion;
+ }
+
+ /**
+ * Get the name of the extension.
+ *
+ * @return the name of the extension
+ */
+ public String getExtensionName()
+ {
+ return m_extensionName;
+ }
+
+ /**
+ * Get the vendor of the extensions specification.
+ *
+ * @return the vendor of the extensions specification.
+ */
+ public String getSpecificationVendor()
+ {
+ return m_specificationVendor;
+ }
+
+ /**
+ * Get the version of the extensions specification.
+ *
+ * @return the version of the extensions specification.
+ */
+ public DeweyDecimal getSpecificationVersion()
+ {
+ return m_specificationVersion;
+ }
+
+ /**
+ * Get the url of the extensions implementation.
+ *
+ * @return the url of the extensions implementation.
+ */
+ public String getImplementationURL()
+ {
+ return m_implementationURL;
+ }
+
+ /**
+ * Get the vendor of the extensions implementation.
+ *
+ * @return the vendor of the extensions implementation.
+ */
+ public String getImplementationVendor()
+ {
+ return m_implementationVendor;
+ }
+
+ /**
+ * Get the vendorID of the extensions implementation.
+ *
+ * @return the vendorID of the extensions implementation.
+ */
+ public String getImplementationVendorID()
+ {
+ return m_implementationVendorID;
+ }
+
+ /**
+ * Get the version of the extensions implementation.
+ *
+ * @return the version of the extensions implementation.
+ */
+ public String getImplementationVersion()
+ {
+ return m_implementationVersion;
+ }
+
+ /**
+ * Return a Compatibility enum indicating the relationship of this
+ * <code>Extension</code> with the specified <code>=
;Extension</code>.
+ *
+ * @param required Description of the required optional package
+ * @return the enum indicating the compatability (or lack thereof) o=
f
+ * specifed extension
+ */
+ public Compatability getCompatibilityWith( final Extension required =
)
+ {
+ // Extension Name must match
+ if( !m_extensionName.equals( required.getExtensionName() ) )
+ {
+ return INCOMPATIBLE;
+ }
+ // Available specification version must be >=3D required
+ final DeweyDecimal specificationVersion =3D required.getSpecific=
ationVersion();
+ if( null !=3D specificationVersion )
+ {
+ if( null =3D=3D m_specificationVersion ||
+ !isCompatible( m_specificationVersion, specificationVers=
ion ) )
+ {
+ return REQUIRE_SPECIFICATION_UPGRADE;
+ }
+ }
+ // Implementation Vendor ID must match
+ final String implementationVendorId =3D required.getImplementati=
onVendorID();
+ if( null !=3D implementationVendorId )
+ {
+ if( null =3D=3D m_implementationVendorID ||
+ !m_implementationVendorID.equals( implementationVendorId=
) )
+ {
+ return REQUIRE_VENDOR_SWITCH;
+ }
+ }
+
+ // This available optional package satisfies the requirements
+ return COMPATIBLE;
+ }
+
+ /**
+ * Return <code>true</code> if the specified <code>=
;Extension</code> (which
+ * represents an optional package required by an application) is sat=
isfied
+ * by this <code>Extension</code> (which represents an o=
ptional package that
+ * is already installed. Otherwise, return <code>false</co=
de>.
+ *
+ * @param required Description of the required optional package
+ * @return true if the specified extension is compatible with this
+ * extension
+ */
+ public boolean isCompatibleWith( final Extension required )
+ {
+ return ( COMPATIBLE =3D=3D getCompatibilityWith( required ) );
+ }
+
+ /**
+ * Return a String representation of this object.
+ *
+ * @return string representation of object.
+ */
+ public String toString()
+ {
+ final String lineSeparator =3D System.getProperty( "line.separat=
or" );
+ final String brace =3D ": ";
+ final StringBuffer sb =3D new StringBuffer( EXTENSION_NAME.toStr=
ing() );
+ sb.append( brace );
+ sb.append( m_extensionName );
+ sb.append( lineSeparator );
+ if( null !=3D m_specificationVersion )
+ {
+ sb.append( SPECIFICATION_VERSION );
+ sb.append( brace );
+ sb.append( m_specificationVersion );
+ sb.append( lineSeparator );
+ }
+ if( null !=3D m_specificationVendor )
+ {
+ sb.append( SPECIFICATION_VENDOR );
+ sb.append( brace );
+ sb.append( m_specificationVendor );
+ sb.append( lineSeparator );
+ }
+ if( null !=3D m_implementationVersion )
+ {
+ sb.append( IMPLEMENTATION_VERSION );
+ sb.append( brace );
+ sb.append( m_implementationVersion );
+ sb.append( lineSeparator );
+ }
+ if( null !=3D m_implementationVendorID )
+ {
+ sb.append( IMPLEMENTATION_VENDOR_ID );
+ sb.append( brace );
+ sb.append( m_implementationVendorID );
+ sb.append( lineSeparator );
+ }
+ if( null !=3D m_implementationVendor )
+ {
+ sb.append( IMPLEMENTATION_VENDOR );
+ sb.append( brace );
+ sb.append( m_implementationVendor );
+ sb.append( lineSeparator );
+ }
+ if( null !=3D m_implementationURL )
+ {
+ sb.append( IMPLEMENTATION_URL );
+ sb.append( brace );
+ sb.append( m_implementationURL );
+ sb.append( lineSeparator );
+ }
+ return sb.toString();
+ }
+
+ /**
+ * Return <code>true</code> if the first version number =
is greater than or
+ * equal to the second; otherwise return <code>false</code&=
gt;.
+ *
+ * @param first First version number (dotted decimal)
+ * @param second Second version number (dotted decimal)
+ */
+ private boolean isCompatible( final DeweyDecimal first,
+ final DeweyDecimal second )
+ {
+ return first.isGreaterThanOrEqual( second );
+ }
+
+ /**
+ * Retrieve all the extensions listed under a particular key (Usuall=
y
+ * EXTENSION_LIST or OPTIONAL_EXTENSION_LIST).
+ *
+ * @param manifest the manifest to extract extensions from
+ * @param listKey the key used to get list (Usually EXTENSION_LIST o=
r
+ * OPTIONAL_EXTENSION_LIST)
+ * @return the list of listed extensions
+ */
+ private static Extension[] getListed( final Manifest manifest,
+ final Attributes.Name listKey =
)
+ {
+ final ArrayList results =3D new ArrayList();
+ final Attributes mainAttributes =3D manifest.getMainAttributes()=
;
+ if( null !=3D mainAttributes )
+ {
+ getExtension( mainAttributes, results, listKey );
+ }
+ final Map entries =3D manifest.getEntries();
+ final Iterator keys =3D entries.keySet().iterator();
+ while( keys.hasNext() )
+ {
+ final String key =3D (String)keys.next();
+ final Attributes attributes =3D (Attributes)entries.get( key=
);
+ getExtension( attributes, results, listKey );
+ }
+ return (Extension[])results.toArray( new Extension[ 0 ] );
+ }
+
+ /**
+ * Add required optional packages defined in the specified attribute=
s entry,
+ * if any.
+ *
+ * @param attributes Attributes to be parsed
+ * @param required list to add required optional packages to
+ * @param listKey the key to use to lookup list, usually EXTENSION_L=
IST or
+ * OPTIONAL_EXTENSION_LIST
+ */
+ private static void getExtension( final Attributes attributes,
+ final ArrayList required,
+ final Attributes.Name listKey )
+ {
+ final String names =3D attributes.getValue( listKey );
+ if( null =3D=3D names )
+ {
+ return;
+ }
+ final String[] extentions =3D split( names, " " );
+ for( int i =3D 0; i < extentions.length; i++ )
+ {
+ final String prefix =3D extentions[ i ] + "-";
+ final Extension extension =3D getExtension( prefix, attribut=
es );
+ if( null !=3D extension )
+ {
+ required.add( extension );
+ }
+ }
+ }
+
+ /**
+ * Splits the string on every token into an array of strings.
+ *
+ * @param string the string
+ * @param onToken the token
+ * @return the resultant array
+ */
+ private static final String[] split( final String string,
+ final String onToken )
+ {
+ final StringTokenizer tokenizer =3D new StringTokenizer( string,
+ onToken )=
;
+ final String[] result =3D new String[ tokenizer.countTokens() ];
+ for( int i =3D 0; i < result.length; i++ )
+ {
+ result[ i ] =3D tokenizer.nextToken();
+ }
+ return result;
+ }
+
+ /**
+ * Extract an Extension from Attributes. Prefix indicates the prefix=
checked
+ * for each string. Usually the prefix is <em>"&lt;extensi=
on&gt;-"</em> if
+ * looking for a <b>Required</b> extension. If you are l=
ooking for an
+ * <b>Available</b> extension then the prefix is <em&=
gt;""</em>.
+ *
+ * @param prefix the prefix for each attribute name
+ * @param attributes Attributes to searched
+ * @return the new Extension object, or null
+ */
+ private static Extension getExtension( final String prefix,
+ final Attributes attributes )
+ {
+ //WARNING: We trim the values of all the attributes because
+ //Some extension declarations are badly defined (ie have spaces
+ //after version or vendorID)
+ final String nameKey =3D prefix + EXTENSION_NAME;
+ final String name =3D getTrimmedString( attributes.getValue( nam=
eKey ) );
+ if( null =3D=3D name )
+ {
+ return null;
+ }
+ final String specVendorKey =3D prefix + SPECIFICATION_VENDOR;
+ final String specVendor =3D getTrimmedString(
+ attributes.getValue( specVendorKey ) );
+ final String specVersionKey =3D prefix + SPECIFICATION_VERSION;
+ final String specVersion =3D getTrimmedString(
+ attributes.getValue( specVersionKey ) );
+ final String impVersionKey =3D prefix + IMPLEMENTATION_VERSION;
+ final String impVersion =3D getTrimmedString(
+ attributes.getValue( impVersionKey ) );
+ final String impVendorKey =3D prefix + IMPLEMENTATION_VENDOR;
+ final String impVendor =3D getTrimmedString(
+ attributes.getValue( impVendorKey ) );
+ final String impVendorIDKey =3D prefix + IMPLEMENTATION_VENDOR_I=
D;
+ final String impVendorId =3D getTrimmedString(
+ attributes.getValue( impVendorIDKey ) );
+ final String impURLKey =3D prefix + IMPLEMENTATION_URL;
+ final String impURL =3D getTrimmedString(
+ attributes.getValue( impURLKey ) );
+ return new Extension( name, specVersion, specVendor, impVersion,
+ impVendor, impVendorId, impURL );
+ }
+
+ /**
+ * Trim the supplied string if the string is non-null
+ *
+ * @param value the string to trim or null
+ * @return the trimmed string or null
+ */
+ private static String getTrimmedString( final String value )
+ {
+ if( null =3D=3D value )
+ {
+ return null;
+ }
+ else
+ {
+ return value.trim();
+ }
+ }
+}
</pre></div>
<hr /><a name=3D"file4" /><div class=3D"file">
<span class=3D"pathname" id=3D"added"><a href=3D"http://xstream.cvs.codeh=
aus.org/jcontainer">jcontainer</a>/<a href=3D"http://xstream.cvs.codehaus=
.org/jcontainer/loom">loom</a>/<a href=3D"http://xstream.cvs.codehaus.org=
/jcontainer/loom/support">support</a>/<a href=3D"http://xstream.cvs.codeh=
aus.org/jcontainer/loom/support/extension">extension</a>/<a href=3D"http:=
//xstream.cvs.codehaus.org/jcontainer/loom/support/extension/src">src</a>=
/<a href=3D"http://xstream.cvs.codehaus.org/jcontainer/loom/support/exten=
sion/src/java">java</a>/<a href=3D"http://xstream.cvs.codehaus.org/jconta=
iner/loom/support/extension/src/java/org">org</a>/<a href=3D"http://xstre=
am.cvs.codehaus.org/jcontainer/loom/support/extension/src/java/org/codeha=
us">codehaus</a>/<a href=3D"http://xstream.cvs.codehaus.org/jcontainer/lo=
om/support/extension/src/java/org/codehaus/loom">loom</a>/<a href=3D"http=
://xstream.cvs.codehaus.org/jcontainer/loom/support/extension/src/java/or=
g/codehaus/loom/extension">extension</a><br /></span>
<div class=3D"fileheader" id=3D"added"><big><b>DeweyDecimal.java</b></big=
> <small id=3D"info">added at <a href=3D"http://xstream.cvs.codehaus.org/=
jcontainer/loom/support/extension/src/java/org/codehaus/loom/extension/De=
weyDecimal.java?rev=3D1.1&content-type=3Dtext/vnd.viewcvs-markup">1.1=
</a></small></div>
<pre class=3D"diff"><small id=3D"info">diff -N DeweyDecimal.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ DeweyDecimal.java 19 Apr 2004 21:40:38 -0000 1.1
@@ -0,0 +1,231 @@
</small></pre><pre class=3D"diff" id=3D"added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.loom.extension;
+
+import java.util.StringTokenizer;
+
+/**
+ * Utility class to contain version numbers in "Dewey Decimal" syntax. =
Numbers
+ * in the "Dewey Decimal" syntax consist of positive decimal integers se=
parated
+ * by periods ".". For example, "2.0" or "1.2.3.4.5.6.7". This allows =
an
+ * extensible number to be used to represent major, minor, micro, etc ve=
rsions.
+ * The version number must begin with a number.
+ *
+ * @author Peter Donald
+ * @version $Revision: 1.1 $ $Date: 2004/04/19 21:40:38 $
+ */
+public final class DeweyDecimal
+{
+ ///Array of components that make up DeweyDecimal
+ private int[] m_components;
+
+ /**
+ * Construct a DeweyDecimal from an array of integer components.
+ *
+ * @param components an array of integer components.
+ */
+ public DeweyDecimal( final int[] components )
+ {
+ m_components =3D new int[ components.length ];
+ for( int i =3D 0; i < m_components.length; i++ )
+ {
+ m_components[ i ] =3D components[ i ];
+ }
+ }
+
+ /**
+ * Construct a DeweyDecimal from string in DeweyDecimal format.
+ *
+ * @param string the string in dewey decimal format
+ * @throws java.lang.NumberFormatException if string is malformed
+ */
+ public DeweyDecimal( final String string )
+ throws NumberFormatException
+ {
+ final StringTokenizer tokenizer =3D new StringTokenizer( string,
+ ".",
+ true );
+ final int size =3D tokenizer.countTokens();
+ m_components =3D new int[ ( size + 1 ) / 2 ];
+ for( int i =3D 0; i < m_components.length; i++ )
+ {
+ final String component =3D tokenizer.nextToken();
+ if( component.equals( "" ) )
+ {
+ throw new NumberFormatException( "Empty component in str=
ing" );
+ }
+ m_components[ i ] =3D Integer.parseInt( component );
+ //Strip '.' token
+ if( tokenizer.hasMoreTokens() )
+ {
+ tokenizer.nextToken();
+ //If it ended in a dot, throw an exception
+ if( !tokenizer.hasMoreTokens() )
+ {
+ final String message =3D "DeweyDecimal ended in a '.=
'";
+ throw new NumberFormatException( message );
+ }
+ }
+ }
+ }
+
+ /**
+ * Return number of components in <code>DeweyDecimal</code&=
gt;.
+ *
+ * @return the number of components in dewey decimal
+ */
+ public int getSize()
+ {
+ return m_components.length;
+ }
+
+ /**
+ * Return the component at specified index.
+ *
+ * @param index the index of components
+ * @return the value of component at index
+ */
+ public int get( final int index )
+ {
+ return m_components[ index ];
+ }
+
+ /**
+ * Return <code>true</code> if this <code>DeweyDec=
imal</code> is equal to
+ * the other <code>DeweyDecimal</code>.
+ *
+ * @param other the other DeweyDecimal
+ * @return true if equal to other DeweyDecimal, false otherwise
+ */
+ public boolean isEqual( final DeweyDecimal other )
+ {
+ final int max =3D Math.max( other.m_components.length,
+ m_components.length );
+ for( int i =3D 0; i < max; i++ )
+ {
+ final int component1 =3D ( i < m_components.length ) ?
+ m_components[ i ] :
+ 0;
+ final int component2 =3D ( i < other.m_components.length =
) ?
+ other.m_components[ i ] :
+ 0;
+ if( component2 !=3D component1 )
+ {
+ return false;
+ }
+ }
+ return true; // Exact match
+ }
+
+ /**
+ * Return <code>true</code> if this <code>DeweyDec=
imal</code> is less than
+ * the other <code>DeweyDecimal</code>.
+ *
+ * @param other the other DeweyDecimal
+ * @return true if less than other DeweyDecimal, false otherwise
+ */
+ public boolean isLessThan( final DeweyDecimal other )
+ {
+ return !isGreaterThanOrEqual( other );
+ }
+
+ /**
+ * Return <code>true</code> if this <code>DeweyDec=
imal</code> is less than
+ * or equal to the other <code>DeweyDecimal</code>.
+ *
+ * @param other the other DeweyDecimal
+ * @return true if less than or equal to other DeweyDecimal, false
+ * otherwise
+ */
+ public boolean isLessThanOrEqual( final DeweyDecimal other )
+ {
+ return !isGreaterThan( other );
+ }
+
+ /**
+ * Return <code>true</code> if this <code>DeweyDec=
imal</code> is greater
+ * than the other <code>DeweyDecimal</code>.
+ *
+ * @param other the other DeweyDecimal
+ * @return true if greater than other DeweyDecimal, false otherwise
+ */
+ public boolean isGreaterThan( final DeweyDecimal other )
+ {
+ final int max =3D Math.max( other.m_components.length,
+ m_components.length );
+ for( int i =3D 0; i < max; i++ )
+ {
+ final int component1 =3D ( i < m_components.length ) ?
+ m_components[ i ] :
+ 0;
+ final int component2 =3D ( i < other.m_components.length =
) ?
+ other.m_components[ i ] :
+ 0;
+ if( component2 > component1 )
+ {
+ return false;
+ }
+ if( component2 < component1 )
+ {
+ return true;
+ }
+ }
+ return false; // Exact match
+ }
+
+ /**
+ * Return <code>true</code> if this <code>DeweyDec=
imal</code> is greater
+ * than or equal to the other <code>DeweyDecimal</code>.
+ *
+ * @param other the other DeweyDecimal
+ * @return true if greater than or equal to other DeweyDecimal, fals=
e
+ * otherwise
+ */
+ public boolean isGreaterThanOrEqual( final DeweyDecimal other )
+ {
+ final int max =3D Math.max( other.m_components.length,
+ m_components.length );
+ for( int i =3D 0; i < max; i++ )
+ {
+ final int component1 =3D ( i < m_components.length ) ?
+ m_components[ i ] :
+ 0;
+ final int component2 =3D ( i < other.m_components.length =
) ?
+ other.m_components[ i ] :
+ 0;
+ if( component2 > component1 )
+ {
+ return false;
+ }
+ if( component2 < component1 )
+ {
+ return true;
+ }
+ }
+ return true; // Exact match
+ }
+
+ /**
+ * Return string representation of <code>DeweyDecimal</code=
>.
+ *
+ * @return the string representation of DeweyDecimal.
+ */
+ public String toString()
+ {
+ final StringBuffer sb =3D new StringBuffer();
+ for( int i =3D 0; i < m_components.length; i++ )
+ {
+ if( i !=3D 0 )
+ {
+ sb.append( '.' );
+ }
+ sb.append( m_components[ i ] );
+ }
+ return sb.toString();
+ }
+}
</pre></div>
<hr /><a name=3D"file5" /><div class=3D"file">
<span class=3D"pathname" id=3D"added"><a href=3D"http://xstream.cvs.codeh=
aus.org/jcontainer">jcontainer</a>/<a href=3D"http://xstream.cvs.codehaus=
.org/jcontainer/loom">loom</a>/<a href=3D"http://xstream.cvs.codehaus.org=
/jcontainer/loom/support">support</a>/<a href=3D"http://xstream.cvs.codeh=
aus.org/jcontainer/loom/support/extension">extension</a>/<a href=3D"http:=
//xstream.cvs.codehaus.org/jcontainer/loom/support/extension/src">src</a>=
/<a href=3D"http://xstream.cvs.codehaus.org/jcontainer/loom/support/exten=
sion/src/java">java</a>/<a href=3D"http://xstream.cvs.codehaus.org/jconta=
iner/loom/support/extension/src/java/org">org</a>/<a href=3D"http://xstre=
am.cvs.codehaus.org/jcontainer/loom/support/extension/src/java/org/codeha=
us">codehaus</a>/<a href=3D"http://xstream.cvs.codehaus.org/jcontainer/lo=
om/support/extension/src/java/org/codehaus/loom">loom</a>/<a href=3D"http=
://xstream.cvs.codehaus.org/jcontainer/loom/support/extension/src/java/or=
g/codehaus/loom/extension">extension</a><br /></span>
<div class=3D"fileheader" id=3D"added"><big><b>Compatability.java</b></bi=
g> <small id=3D"info">added at <a href=3D"http://xstream.cvs.codehaus.org=
/jcontainer/loom/support/extension/src/java/org/codehaus/loom/extension/C=
ompatability.java?rev=3D1.1&content-type=3Dtext/vnd.viewcvs-markup">1=
.1</a></small></div>
<pre class=3D"diff"><small id=3D"info">diff -N Compatability.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ Compatability.java 19 Apr 2004 21:40:38 -0000 1.1
@@ -0,0 +1,56 @@
</small></pre><pre class=3D"diff" id=3D"added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.loom.extension;
+
+/**
+ * Enum used in {@link Extension} to indicate the compatability of one e=
xtension
+ * to another. See {@link Extension} for instances of object.
+ *
+ * @author Peter Donald
+ * @version $Revision: 1.1 $ $Date: 2004/04/19 21:40:38 $
+ * @see Extension
+ */
+public final class Compatability
+{
+ /** A string representaiton of compatability level. */
+ private final String m_name;
+
+ /**
+ * Create a compatability enum with specified name.
+ *
+ * @param name the name of compatability level
+ */
+ Compatability( final String name )
+ {
+ if( null =3D=3D name )
+ {
+ throw new NullPointerException( "name" );
+ }
+ m_name =3D name;
+ }
+
+ /**
+ * Return name of compatability level.
+ *
+ * @return the name of compatability level
+ */
+ public String getName()
+ {
+ return m_name;
+ }
+
+ /**
+ * Return name of compatability level.
+ *
+ * @return the name of compatability level
+ */
+ public String toString()
+ {
+ return m_name;
+ }
+}
</pre></div>
<hr /><a name=3D"file6" /><div class=3D"file">
<span class=3D"pathname" id=3D"added"><a href=3D"http://xstream.cvs.codeh=
aus.org/jcontainer">jcontainer</a>/<a href=3D"http://xstream.cvs.codehaus=
.org/jcontainer/loom">loom</a>/<a href=3D"http://xstream.cvs.codehaus.org=
/jcontainer/loom/support">support</a>/<a href=3D"http://xstream.cvs.codeh=
aus.org/jcontainer/loom/support/extension">extension</a>/<a href=3D"http:=
//xstream.cvs.codehaus.org/jcontainer/loom/support/extension/src">src</a>=
/<a href=3D"http://xstream.cvs.codehaus.org/jcontainer/loom/support/exten=
sion/src/test">test</a>/<a href=3D"http://xstream.cvs.codehaus.org/jconta=
iner/loom/support/extension/src/test/org">org</a>/<a href=3D"http://xstre=
am.cvs.codehaus.org/jcontainer/loom/support/extension/src/test/org/codeha=
us">codehaus</a>/<a href=3D"http://xstream.cvs.codehaus.org/jcontainer/lo=
om/support/extension/src/test/org/codehaus/loom">loom</a>/<a href=3D"http=
://xstream.cvs.codehaus.org/jcontainer/loom/support/extension/src/test/or=
g/codehaus/loom/extension">extension</a><br /></span>
<div class=3D"fileheader" id=3D"added"><big><b>DeweyDecimalTestCase.java<=
/b></big> <small id=3D"info">added at <a href=3D"http://xstream.cvs.codeh=
aus.org/jcontainer/loom/support/extension/src/test/org/codehaus/loom/exte=
nsion/DeweyDecimalTestCase.java?rev=3D1.1&content-type=3Dtext/vnd.vie=
wcvs-markup">1.1</a></small></div>
<pre class=3D"diff"><small id=3D"info">diff -N DeweyDecimalTestCase.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ DeweyDecimalTestCase.java 19 Apr 2004 21:40:38 -0000 1.1
@@ -0,0 +1,265 @@
</small></pre><pre class=3D"diff" id=3D"added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.loom.extension;
+
+import org.codehaus.loom.extension.DeweyDecimal;
+
+import junit.framework.TestCase;
+
+/**
+ * TestCases for DeweyDecimal.
+ *
+ * @author Peter Donald
+ * @version $Revision: 1.1 $ $Date: 2004/04/19 21:40:38 $
+ */
+public class DeweyDecimalTestCase
+ extends TestCase
+{
+ private static final String DD1 =3D "1";
+ private static final String DD2 =3D "1.0.1";
+ private static final String DD3 =3D "1.0.2";
+ private static final String DD4 =3D "0.9.0.2";
+ private static final String DD5 =3D "2.0.9";
+ private static final String DD6 =3D "2..9";
+ private static final String DD7 =3D ".9";
+ private static final String DD8 =3D "9.";
+
+ public void testParse()
+ throws Exception
+ {
+ final DeweyDecimal dd1 =3D new DeweyDecimal( DD1 );
+ final DeweyDecimal dd2 =3D new DeweyDecimal( DD2 );
+ final DeweyDecimal dd3 =3D new DeweyDecimal( DD3 );
+ final DeweyDecimal dd4 =3D new DeweyDecimal( DD4 );
+ final DeweyDecimal dd5 =3D new DeweyDecimal( DD5 );
+ assertEquals( "DeweyDecimal 1", DD1, dd1.toString() );
+ assertEquals( "DeweyDecimal 2", DD2, dd2.toString() );
+ assertEquals( "DeweyDecimal 3", DD3, dd3.toString() );
+ assertEquals( "DeweyDecimal 4", DD4, dd4.toString() );
+ assertEquals( "DeweyDecimal 5", DD5, dd5.toString() );
+ }
+
+ public void testMalParse()
+ throws Exception
+ {
+ try
+ {
+ new DeweyDecimal( DD6 );
+ fail( "DeweyDecimal 6 parsed!" );
+ }
+ catch( final NumberFormatException nfe )
+ {
+ }
+ try
+ {
+ new DeweyDecimal( DD7 );
+ fail( "DeweyDecimal 7 parsed!" );
+ }
+ catch( final NumberFormatException nfe )
+ {
+ }
+ try
+ {
+ new DeweyDecimal( DD8 );
+ fail( "DeweyDecimal 8 parsed!" );
+ }
+ catch( final NumberFormatException nfe )
+ {
+ }
+ }
+
+ public void testGreaterThan()
+ throws Exception
+ {
+ final DeweyDecimal dd1 =3D new DeweyDecimal( DD1 );
+ final DeweyDecimal dd2 =3D new DeweyDecimal( DD2 );
+ final DeweyDecimal dd3 =3D new DeweyDecimal( DD3 );
+ final DeweyDecimal dd4 =3D new DeweyDecimal( DD4 );
+ final DeweyDecimal dd5 =3D new DeweyDecimal( DD5 );
+ assertTrue( "Bad: " + DD1 + " > " + DD1, !dd1.isGreaterThan( =
dd1 ) );
+ assertTrue( "Bad: " + DD1 + " > " + DD2, !dd1.isGreaterThan( =
dd2 ) );
+ assertTrue( "Bad: " + DD1 + " > " + DD3, !dd1.isGreaterThan( =
dd3 ) );
+ assertTrue( "Bad: " + DD1 + " < " + DD4, dd1.isGreaterThan( d=
d4 ) );
+ assertTrue( "Bad: " + DD1 + " > " + DD5, !dd1.isGreaterThan( =
dd5 ) );
+ assertTrue( "Bad: " + DD2 + " < " + DD1, dd2.isGreaterThan( d=
d1 ) );
+ assertTrue( "Bad: " + DD2 + " > " + DD2, !dd2.isGreaterThan( =
dd2 ) );
+ assertTrue( "Bad: " + DD2 + " > " + DD3, !dd2.isGreaterThan( =
dd3 ) );
+ assertTrue( "Bad: " + DD2 + " < " + DD4, dd2.isGreaterThan( d=
d4 ) );
+ assertTrue( "Bad: " + DD2 + " > " + DD5, !dd2.isGreaterThan( =
dd5 ) );
+ assertTrue( "Bad: " + DD3 + " < " + DD1, dd3.isGreaterThan( d=
d1 ) );
+ assertTrue( "Bad: " + DD3 + " < " + DD2, dd3.isGreaterThan( d=
d2 ) );
+ assertTrue( "Bad: " + DD3 + " > " + DD3, !dd3.isGreaterThan( =
dd3 ) );
+ assertTrue( "Bad: " + DD3 + " < " + DD4, dd3.isGreaterThan( d=
d4 ) );
+ assertTrue( "Bad: " + DD3 + " > " + DD5, !dd3.isGreaterThan( =
dd5 ) );
+ assertTrue( "Bad: " + DD4 + " > " + DD1, !dd4.isGreaterThan( =
dd1 ) );
+ assertTrue( "Bad: " + DD4 + " > " + DD2, !dd4.isGreaterThan( =
dd2 ) );
+ assertTrue( "Bad: " + DD4 + " > " + DD3, !dd4.isGreaterThan( =
dd3 ) );
+ assertTrue( "Bad: " + DD4 + " > " + DD4, !dd4.isGreaterThan( =
dd4 ) );
+ assertTrue( "Bad: " + DD4 + " > " + DD5, !dd4.isGreaterThan( =
dd5 ) );
+ assertTrue( "Bad: " + DD5 + " < " + DD1, dd5.isGreaterThan( d=
d1 ) );
+ assertTrue( "Bad: " + DD5 + " < " + DD2, dd5.isGreaterThan( d=
d2 ) );
+ assertTrue( "Bad: " + DD5 + " < " + DD3, dd5.isGreaterThan( d=
d3 ) );
+ assertTrue( "Bad: " + DD5 + " < " + DD4, dd5.isGreaterThan( d=
d4 ) );
+ assertTrue( "Bad: " + DD5 + " > " + DD5, !dd5.isGreaterThan( =
dd5 ) );
+ }
+
+ public void testGreaterThanOrEqual()
+ throws Exception
+ {
+ final DeweyDecimal dd1 =3D new DeweyDecimal( DD1 );
+ final DeweyDecimal dd2 =3D new DeweyDecimal( DD2 );
+ final DeweyDecimal dd3 =3D new DeweyDecimal( DD3 );
+ final DeweyDecimal dd4 =3D new DeweyDecimal( DD4 );
+ final DeweyDecimal dd5 =3D new DeweyDecimal( DD5 );
+ assertTrue( "Bad: " + DD1 + " < " + DD1,
+ dd1.isGreaterThanOrEqual( dd1 ) );
+ assertTrue( "Bad: " + DD1 + " > " + DD2,
+ !dd1.isGreaterThanOrEqual( dd2 ) );
+ assertTrue( "Bad: " + DD1 + " > " + DD3,
+ !dd1.isGreaterThanOrEqual( dd3 ) );
+ assertTrue( "Bad: " + DD1 + " < " + DD4,
+ dd1.isGreaterThanOrEqual( dd4 ) );
+ assertTrue( "Bad: " + DD1 + " > " + DD5,
+ !dd1.isGreaterThanOrEqual( dd5 ) );
+ assertTrue( "Bad: " + DD2 + " < " + DD1,
+ dd2.isGreaterThanOrEqual( dd1 ) );
+ assertTrue( "Bad: " + DD2 + " < " + DD2,
+ dd2.isGreaterThanOrEqual( dd2 ) );
+ assertTrue( "Bad: " + DD2 + " > " + DD3,
+ !dd2.isGreaterThanOrEqual( dd3 ) );
+ assertTrue( "Bad: " + DD2 + " < " + DD4,
+ dd2.isGreaterThanOrEqual( dd4 ) );
+ assertTrue( "Bad: " + DD2 + " > " + DD5,
+ !dd2.isGreaterThanOrEqual( dd5 ) );
+ assertTrue( "Bad: " + DD3 + " < " + DD1,
+ dd3.isGreaterThanOrEqual( dd1 ) );
+ assertTrue( "Bad: " + DD3 + " < " + DD2,
+ dd3.isGreaterThanOrEqual( dd2 ) );
+ assertTrue( "Bad: " + DD3 + " < " + DD3,
+ dd3.isGreaterThanOrEqual( dd3 ) );
+ assertTrue( "Bad: " + DD3 + " < " + DD4,
+ dd3.isGreaterThanOrEqual( dd4 ) );
+ assertTrue( "Bad: " + DD3 + " > " + DD5,
+ !dd3.isGreaterThanOrEqual( dd5 ) );
+ assertTrue( "Bad: " + DD4 + " > " + DD1,
+ !dd4.isGreaterThanOrEqual( dd1 ) );
+ assertTrue( "Bad: " + DD4 + " > " + DD2,
+ !dd4.isGreaterThanOrEqual( dd2 ) );
+ assertTrue( "Bad: " + DD4 + " > " + DD3,
+ !dd4.isGreaterThanOrEqual( dd3 ) );
+ assertTrue( "Bad: " + DD4 + " < " + DD4,
+ dd4.isGreaterThanOrEqual( dd4 ) );
+ assertTrue( "Bad: " + DD4 + " > " + DD5,
+ !dd4.isGreaterThanOrEqual( dd5 ) );
+ assertTrue( "Bad: " + DD5 + " < " + DD1,
+ dd5.isGreaterThanOrEqual( dd1 ) );
+ assertTrue( "Bad: " + DD5 + " < " + DD2,
+ dd5.isGreaterThanOrEqual( dd2 ) );
+ assertTrue( "Bad: " + DD5 + " < " + DD3,
+ dd5.isGreaterThanOrEqual( dd3 ) );
+ assertTrue( "Bad: " + DD5 + " < " + DD4,
+ dd5.isGreaterThanOrEqual( dd4 ) );
+ assertTrue( "Bad: " + DD5 + " < " + DD5,
+ dd5.isGreaterThanOrEqual( dd5 ) );
+ }
+
+ public void testLessThan()
+ throws Exception
+ {
+ final DeweyDecimal dd1 =3D new DeweyDecimal( DD1 );
+ final DeweyDecimal dd2 =3D new DeweyDecimal( DD2 );
+ final DeweyDecimal dd3 =3D new DeweyDecimal( DD3 );
+ final DeweyDecimal dd4 =3D new DeweyDecimal( DD4 );
+ final DeweyDecimal dd5 =3D new DeweyDecimal( DD5 );
+ assertTrue( "Bad: " + DD1 + " <=3D " + DD1, !dd1.isLessThan( =
dd1 ) );
+ assertTrue( "Bad: " + DD1 + " <=3D " + DD2, dd1.isLessThan( d=
d2 ) );
+ assertTrue( "Bad: " + DD1 + " <=3D " + DD3, dd1.isLessThan( d=
d3 ) );
+ assertTrue( "Bad: " + DD1 + " >=3D " + DD4, !dd1.isLessThan( =
dd4 ) );
+ assertTrue( "Bad: " + DD1 + " <=3D " + DD5, dd1.isLessThan( d=
d5 ) );
+ assertTrue( "Bad: " + DD2 + " >=3D " + DD1, !dd2.isLessThan( =
dd1 ) );
+ assertTrue( "Bad: " + DD2 + " <=3D " + DD2, !dd2.isLessThan( =
dd2 ) );
+ assertTrue( "Bad: " + DD2 + " <=3D " + DD3, dd2.isLessThan( d=
d3 ) );
+ assertTrue( "Bad: " + DD2 + " >=3D " + DD4, !dd2.isLessThan( =
dd4 ) );
+ assertTrue( "Bad: " + DD2 + " <=3D " + DD5, dd2.isLessThan( d=
d5 ) );
+ assertTrue( "Bad: " + DD3 + " >=3D " + DD1, !dd3.isLessThan( =
dd1 ) );
+ assertTrue( "Bad: " + DD3 + " >=3D " + DD2, !dd3.isLessThan( =
dd2 ) );
+ assertTrue( "Bad: " + DD3 + " <=3D " + DD3, !dd3.isLessThan( =
dd3 ) );
+ assertTrue( "Bad: " + DD3 + " >=3D " + DD4, !dd3.isLessThan( =
dd4 ) );
+ assertTrue( "Bad: " + DD3 + " <=3D " + DD5, dd3.isLessThan( d=
d5 ) );
+ assertTrue( "Bad: " + DD4 + " <=3D " + DD1, dd4.isLessThan( d=
d1 ) );
+ assertTrue( "Bad: " + DD4 + " <=3D " + DD2, dd4.isLessThan( d=
d2 ) );
+ assertTrue( "Bad: " + DD4 + " <=3D " + DD3, dd4.isLessThan( d=
d3 ) );
+ assertTrue( "Bad: " + DD4 + " <=3D " + DD4, !dd4.isLessThan( =
dd4 ) );
+ assertTrue( "Bad: " + DD4 + " <=3D " + DD5, dd4.isLessThan( d=
d5 ) );
+ assertTrue( "Bad: " + DD5 + " >=3D " + DD1, !dd5.isLessThan( =
dd1 ) );
+ assertTrue( "Bad: " + DD5 + " >=3D " + DD2, !dd5.isLessThan( =
dd2 ) );
+ assertTrue( "Bad: " + DD5 + " >=3D " + DD3, !dd5.isLessThan( =
dd3 ) );
+ assertTrue( "Bad: " + DD5 + " >=3D " + DD4, !dd5.isLessThan( =
dd4 ) );
+ assertTrue( "Bad: " + DD5 + " <=3D " + DD5, !dd5.isLessThan( =
dd5 ) );
+ }
+
+ public void testLessThanOrEqual()
+ throws Exception
+ {
+ final DeweyDecimal dd1 =3D new DeweyDecimal( DD1 );
+ final DeweyDecimal dd2 =3D new DeweyDecimal( DD2 );
+ final DeweyDecimal dd3 =3D new DeweyDecimal( DD3 );
+ final DeweyDecimal dd4 =3D new DeweyDecimal( DD4 );
+ final DeweyDecimal dd5 =3D new DeweyDecimal( DD5 );
+ assertTrue( "Bad: " + DD1 + " >=3D " + DD1,
+ dd1.isLessThanOrEqual( dd1 ) );
+ assertTrue( "Bad: " + DD1 + " <=3D " + DD2,
+ dd1.isLessThanOrEqual( dd2 ) );
+ assertTrue( "Bad: " + DD1 + " <=3D " + DD3,
+ dd1.isLessThanOrEqual( dd3 ) );
+ assertTrue( "Bad: " + DD1 + " >=3D " + DD4,
+ !dd1.isLessThanOrEqual( dd4 ) );
+ assertTrue( "Bad: " + DD1 + " <=3D " + DD5,
+ dd1.isLessThanOrEqual( dd5 ) );
+ assertTrue( "Bad: " + DD2 + " >=3D " + DD1,
+ !dd2.isLessThanOrEqual( dd1 ) );
+ assertTrue( "Bad: " + DD2 + " >=3D " + DD2,
+ dd2.isLessThanOrEqual( dd2 ) );
+ assertTrue( "Bad: " + DD2 + " <=3D " + DD3,
+ dd2.isLessThanOrEqual( dd3 ) );
+ assertTrue( "Bad: " + DD2 + " >=3D " + DD4,
+ !dd2.isLessThanOrEqual( dd4 ) );
+ assertTrue( "Bad: " + DD2 + " <=3D " + DD5,
+ dd2.isLessThanOrEqual( dd5 ) );
+ assertTrue( "Bad: " + DD3 + " >=3D " + DD1,
+ !dd3.isLessThanOrEqual( dd1 ) );
+ assertTrue( "Bad: " + DD3 + " >=3D " + DD2,
+ !dd3.isLessThanOrEqual( dd2 ) );
+ assertTrue( "Bad: " + DD3 + " >=3D " + DD3,
+ dd3.isLessThanOrEqual( dd3 ) );
+ assertTrue( "Bad: " + DD3 + " >=3D " + DD4,
+ !dd3.isLessThanOrEqual( dd4 ) );
+ assertTrue( "Bad: " + DD3 + " <=3D " + DD5,
+ dd3.isLessThanOrEqual( dd5 ) );
+ assertTrue( "Bad: " + DD4 + " <=3D " + DD1,
+ dd4.isLessThanOrEqual( dd1 ) );
+ assertTrue( "Bad: " + DD4 + " <=3D " + DD2,
+ dd4.isLessThanOrEqual( dd2 ) );
+ assertTrue( "Bad: " + DD4 + " <=3D " + DD3,
+ dd4.isLessThanOrEqual( dd3 ) );
+ assertTrue( "Bad: " + DD4 + " >=3D " + DD4,
+ dd4.isLessThanOrEqual( dd4 ) );
+ assertTrue( "Bad: " + DD4 + " <=3D " + DD5,
+ dd4.isLessThanOrEqual( dd5 ) );
+ assertTrue( "Bad: " + DD5 + " >=3D " + DD1,
+ !dd5.isLessThanOrEqual( dd1 ) );
+ assertTrue( "Bad: " + DD5 + " >=3D " + DD2,
+ !dd5.isLessThanOrEqual( dd2 ) );
+ assertTrue( "Bad: " + DD5 + " >=3D " + DD3,
+ !dd5.isLessThanOrEqual( dd3 ) );
+ assertTrue( "Bad: " + DD5 + " >=3D " + DD4,
+ !dd5.isLessThanOrEqual( dd4 ) );
+ assertTrue( "Bad: " + DD5 + " >=3D " + DD5,
+ dd5.isLessThanOrEqual( dd5 ) );
+ }
+}
</pre></div>
<hr /><a name=3D"file7" /><div class=3D"file">
<span class=3D"pathname" id=3D"added"><a href=3D"http://xstream.cvs.codeh=
aus.org/jcontainer">jcontainer</a>/<a href=3D"http://xstream.cvs.codehaus=
.org/jcontainer/loom">loom</a>/<a href=3D"http://xstream.cvs.codehaus.org=
/jcontainer/loom/support">support</a>/<a href=3D"http://xstream.cvs.codeh=
aus.org/jcontainer/loom/support/extension">extension</a>/<a href=3D"http:=
//xstream.cvs.codehaus.org/jcontainer/loom/support/extension/src">src</a>=
/<a href=3D"http://xstream.cvs.codehaus.org/jcontainer/loom/support/exten=
sion/src/test">test</a>/<a href=3D"http://xstream.cvs.codehaus.org/jconta=
iner/loom/support/extension/src/test/org">org</a>/<a href=3D"http://xstre=
am.cvs.codehaus.org/jcontainer/loom/support/extension/src/test/org/codeha=
us">codehaus</a>/<a href=3D"http://xstream.cvs.codehaus.org/jcontainer/lo=
om/support/extension/src/test/org/codehaus/loom">loom</a>/<a href=3D"http=
://xstream.cvs.codehaus.org/jcontainer/loom/support/extension/src/test/or=
g/codehaus/loom/extension">extension</a><br /></span>
<div class=3D"fileheader" id=3D"added"><big><b>SpecificationTestCase.java=
</b></big> <small id=3D"info">added at <a href=3D"http://xstream.cvs.code=
haus.org/jcontainer/loom/support/extension/src/test/org/codehaus/loom/ext=
ension/SpecificationTestCase.java?rev=3D1.1&content-type=3Dtext/vnd.v=
iewcvs-markup">1.1</a></small></div>
<pre class=3D"diff"><small id=3D"info">diff -N SpecificationTestCase.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ SpecificationTestCase.java 19 Apr 2004 21:40:38 -0000 1.1
@@ -0,0 +1,454 @@
</small></pre><pre class=3D"diff" id=3D"added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.loom.extension;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.jar.Manifest;
+
+import org.codehaus.loom.extension.Specification;
+
+import junit.framework.TestCase;
+
+/**
+ * TestCases for Specification.
+ *
+ * @author Peter Donald
+ * @version $Revision: 1.1 $ $Date: 2004/04/19 21:40:38 $
+ */
+public class SpecificationTestCase
+ extends TestCase
+{
+ public void testSingleSpecification()
+ throws Exception
+ {
+ final String manifest =3D
+ "Manifest-Version: 1.0\n" +
+ "\n" +
+ "Name: org/realityforge/dve\n" +
+ "Specification-Title: org.realityforge.dve\n" +
+ "Specification-Version: 1.0.2\n" +
+ "Specification-Vendor: Peter Donald\n" +
+ "Implementation-Title: DVE vi OS3P\n" +
+ "Implementation-Vendor: Peter Donald\n" +
+ "Implementation-Version: 1.0.2Alpha\n";
+ final Specification[] specifications =3D getSpecifications( mani=
fest );
+
+ assertEquals( "Count", 1, specifications.length );
+ assertEquals( "Name", "org.realityforge.dve",
+ specifications[ 0 ].getSpecificationTitle() );
+ assertEquals( "SpecVendor", "Peter Donald",
+ specifications[ 0 ].getSpecificationVendor() );
+ assertEquals( "SpecVersion",
+ "1.0.2",
+ specifications[ 0 ].getSpecificationVersion().toSt=
ring() );
+ assertEquals( "ImpVendor", "Peter Donald",
+ specifications[ 0 ].getImplementationVendor() );
+ assertEquals( "ImpTitle", "DVE vi OS3P",
+ specifications[ 0 ].getImplementationTitle() );
+ assertEquals( "ImpVersion",
+ "1.0.2Alpha",
+ specifications[ 0 ].getImplementationVersion().toS=
tring() );
+ }
+
+ public void testSingleSpecificationWithSpacesAtEOL()
+ throws Exception
+ {
+ final String manifest =3D
+ "Manifest-Version: 1.0\n" +
+ "\n" +
+ "Name: org/realityforge/dve \n" +
+ "Specification-Title: org.realityforge.dve \n" +
+ "Specification-Version: 1.0.2 \n" +
+ "Specification-Vendor: Peter Donald \n" +
+ "Implementation-Title: DVE vi OS3P \n" +
+ "Implementation-Vendor: Peter Donald \n" +
+ "Implementation-Version: 1.0.2Alpha \n";
+ final Specification[] specifications =3D getSpecifications( mani=
fest );
+
+ assertEquals( "Count", 1, specifications.length );
+ assertEquals( "Name", "org.realityforge.dve",
+ specifications[ 0 ].getSpecificationTitle() );
+ assertEquals( "SpecVendor", "Peter Donald",
+ specifications[ 0 ].getSpecificationVendor() );
+ assertEquals( "SpecVersion",
+ "1.0.2",
+ specifications[ 0 ].getSpecificationVersion().toSt=
ring() );
+ assertEquals( "ImpVendor", "Peter Donald",
+ specifications[ 0 ].getImplementationVendor() );
+ assertEquals( "ImpTitle", "DVE vi OS3P",
+ specifications[ 0 ].getImplementationTitle() );
+ assertEquals( "ImpVersion",
+ "1.0.2Alpha",
+ specifications[ 0 ].getImplementationVersion().toS=
tring() );
+ }
+
+ public void testSingleSpecificationWithMissingSpecificationVersion()
+ throws Exception
+ {
+ final String manifestString =3D
+ "Manifest-Version: 1.0\n" +
+ "\n" +
+ "Name: org/realityforge/dve\n" +
+ "Specification-Title: org.realityforge.dve\n" +
+ "Specification-Vendor: Peter Donald\n" +
+ "Implementation-Title: DVE vi OS3P\n" +
+ "Implementation-Vendor: Peter Donald\n" +
+ "Implementation-Version: 1.0.2Alpha\n";
+ final Manifest manifest =3D getManifest( manifestString );
+ try
+ {
+ Specification.getSpecifications( manifest );
+ }
+ catch( final Throwable t )
+ {
+ return;
+ }
+ fail( "Missing SpecificationVersion parsed" );
+ }
+
+ public void testSingleSpecificationWithMissingSpecificationVendor()
+ throws Exception
+ {
+ final String manifestString =3D
+ "Manifest-Version: 1.0\n" +
+ "\n" +
+ "Name: org/realityforge/dve\n" +
+ "Specification-Title: org.realityforge.dve\n" +
+ "Specification-Version: 1.0.2\n" +
+ "Implementation-Title: DVE vi OS3P\n" +
+ "Implementation-Vendor: Peter Donald\n" +
+ "Implementation-Version: 1.0.2Alpha\n";
+ final Manifest manifest =3D getManifest( manifestString );
+ try
+ {
+ Specification.getSpecifications( manifest );
+ }
+ catch( final Throwable t )
+ {
+ return;
+ }
+ fail( "Missing SpecificationVendor parsed" );
+ }
+
+ public void testSingleSpecificationMissingImplementationTitle()
+ throws Exception
+ {
+ final String manifestString =3D
+ "Manifest-Version: 1.0\n" +
+ "\n" +
+ "Name: org/realityforge/dve\n" +
+ "Specification-Title: org.realityforge.dve\n" +
+ "Specification-Version: 1.0.2\n" +
+ "Specification-Vendor: Peter Donald\n" +
+ "Implementation-Vendor: Peter Donald\n" +
+ "Implementation-Version: 1.0.2Alpha\n";
+ final Manifest manifest =3D getManifest( manifestString );
+ try
+ {
+ Specification.getSpecifications( manifest );
+ }
+ catch( final Throwable t )
+ {
+ return;
+ }
+ fail( "Missing ImplementationTitle parsed" );
+ }
+
+ public void testSingleSpecificationMissingImplementationVendor()
+ throws Exception
+ {
+ final String manifestString =3D
+ "Manifest-Version: 1.0\n" +
+ "\n" +
+ "Name: org/realityforge/dve\n" +
+ "Specification-Title: org.realityforge.dve\n" +
+ "Specification-Version: 1.0.2\n" +
+ "Specification-Vendor: Peter Donald\n" +
+ "Implementation-Title: DVE vi OS3P\n" +
+ "Implementation-Version: 1.0.2Alpha\n";
+ final Manifest manifest =3D getManifest( manifestString );
+ try
+ {
+ Specification.getSpecifications( manifest );
+ }
+ catch( final Throwable t )
+ {
+ return;
+ }
+ fail( "Missing ImplementationVendor parsed" );
+ }
+
+ public void testSingleSpecificationMissingImplementationVersion()
+ throws Exception
+ {
+ final String manifestString =3D
+ "Manifest-Version: 1.0\n" +
+ "\n" +
+ "Name: org/realityforge/dve\n" +
+ "Specification-Title: org.realityforge.dve\n" +
+ "Specification-Version: 1.0.2\n" +
+ "Specification-Vendor: Peter Donald\n" +
+ "Implementation-Title: DVE vi OS3P\n" +
+ "Implementation-Vendor: Peter Donald\n";
+ final Manifest manifest =3D getManifest( manifestString );
+ try
+ {
+ Specification.getSpecifications( manifest );
+ }
+ catch( final Throwable t )
+ {
+ return;
+ }
+ fail( "Missing ImplementationVersion parsed" );
+ }
+
+ public void testSingleSpecificationWithMultipleSections()
+ throws Exception
+ {
+ final String manifestString =3D
+ "Manifest-Version: 1.0\n" +
+ "\n" +
+ "Name: org/realityforge/dve\n" +
+ "Specification-Title: org.realityforge.dve\n" +
+ "Specification-Version: 1.0.2\n" +
+ "Specification-Vendor: Peter Donald\n" +
+ "Implementation-Title: DVE vi OS3P\n" +
+ "Implementation-Vendor: Peter Donald\n" +
+ "Implementation-Version: 1.0.2Alpha\n" +
+ "\n" +
+ "Name: org/realityforge/dve/input\n" +
+ "Specification-Title: org.realityforge.dve\n" +
+ "Specification-Version: 1.0.2\n" +
+ "Specification-Vendor: Peter Donald\n" +
+ "Implementation-Title: DVE vi OS3P\n" +
+ "Implementation-Vendor: Peter Donald\n" +
+ "Implementation-Version: 1.0.2Alpha\n" +
+ "\n" +
+ "Name: org/realityforge/dve/sim\n" +
+ "Specification-Title: org.realityforge.dve\n" +
+ "Specification-Version: 1.0.2\n" +
+ "Specification-Vendor: Peter Donald\n" +
+ "Implementation-Title: DVE vi OS3P\n" +
+ "Implementation-Vendor: Peter Donald\n" +
+ "Implementation-Version: 1.0.2Alpha\n";
+ final Specification[] specifications =3D getSpecifications(
+ manifestString );
+
+ assertEquals( "Count", 1, specifications.length );
+ final String[] sections =3D specifications[ 0 ].getSections();
+ assertEquals( "sections.length", 3, sections.length );
+ final HashSet set =3D new HashSet();
+ set.addAll( Arrays.asList( sections ) );
+ assertTrue( "sections.contains(org/realityforge/dve)",
+ set.contains( "org/realityforge/dve" ) );
+ assertTrue( "sections.contains(org/realityforge/dve/input)",
+ set.contains( "org/realityforge/dve/input" ) );
+ assertTrue( "sections.contains(org/realityforge/dve/sim)",
+ set.contains( "org/realityforge/dve/sim" ) );
+ assertEquals( "Name", "org.realityforge.dve",
+ specifications[ 0 ].getSpecificationTitle() );
+ assertEquals( "SpecVendor", "Peter Donald",
+ specifications[ 0 ].getSpecificationVendor() );
+ assertEquals( "SpecVersion",
+ "1.0.2",
+ specifications[ 0 ].getSpecificationVersion().toSt=
ring() );
+ assertEquals( "ImpVendor", "Peter Donald",
+ specifications[ 0 ].getImplementationVendor() );
+ assertEquals( "ImpTitle", "DVE vi OS3P",
+ specifications[ 0 ].getImplementationTitle() );
+ assertEquals( "ImpVersion",
+ "1.0.2Alpha",
+ specifications[ 0 ].getImplementationVersion().toS=
tring() );
+ }
+
+ public void testMultipleSpecificationWithMultipleSections()
+ throws Exception
+ {
+ final String manifestString =3D
+ "Manifest-Version: 1.0\n" +
+ "\n" +
+ "Name: org/realityforge/dve\n" +
+ "Specification-Title: org.realityforge.dve\n" +
+ "Specification-Version: 1.0.2\n" +
+ "Specification-Vendor: Peter Donald\n" +
+ "Implementation-Title: DVE vi OS3P\n" +
+ "Implementation-Vendor: Peter Donald\n" +
+ "Implementation-Version: 1.0.2Alpha\n" +
+ "\n" +
+ "Name: org/realityforge/dve/input\n" +
+ "Specification-Title: org.realityforge.dve\n" +
+ "Specification-Version: 1.0.2\n" +
+ "Specification-Vendor: Peter Donald\n" +
+ "Implementation-Title: DVE vi OS3P\n" +
+ "Implementation-Vendor: Peter Donald\n" +
+ "Implementation-Version: 1.0.2Alpha\n" +
+ "\n" +
+ "Name: org/realityforge/dve/sim\n" +
+ "Specification-Title: org.realityforge.dve\n" +
+ "Specification-Version: 1.0.2\n" +
+ "Specification-Vendor: Peter Donald\n" +
+ "Implementation-Title: DVE vi OS3P\n" +
+ "Implementation-Vendor: Peter Donald\n" +
+ "Implementation-Version: 1.0.2Alpha\n" +
+ "\n" +
+ "Name: com/biz/foo\n" +
+ "Specification-Title: com.biz.foo\n" +
+ "Specification-Version: 1.0.2\n" +
+ "Specification-Vendor: Peter Donald\n" +
+ "Implementation-Title: DVE vi OS3P\n" +
+ "Implementation-Vendor: Peter Donald\n" +
+ "Implementation-Version: 1.0.2Alpha\n";
+ final Specification[] specifications =3D getSpecifications(
+ manifestString );
+
+ assertEquals( "Count", 2, specifications.length );
+ Specification dveSpecification;
+ Specification fooSpecification;
+ if( 3 =3D=3D specifications[ 0 ].getSections().length )
+ {
+ dveSpecification =3D specifications[ 0 ];
+ fooSpecification =3D specifications[ 1 ];
+ }
+ else
+ {
+ dveSpecification =3D specifications[ 1 ];
+ fooSpecification =3D specifications[ 0 ];
+ }
+
+ final String[] sections =3D dveSpecification.getSections();
+ assertEquals( "sections.length", 3, sections.length );
+ assertEquals( "sections.length", 3, sections.length );
+ final HashSet set =3D new HashSet();
+ set.addAll( Arrays.asList( sections ) );
+ assertTrue( "sections.contains(org/realityforge/dve)",
+ set.contains( "org/realityforge/dve" ) );
+ assertTrue( "sections.contains(org/realityforge/dve/input)",
+ set.contains( "org/realityforge/dve/input" ) );
+ assertTrue( "sections.contains(org/realityforge/dve/sim)",
+ set.contains( "org/realityforge/dve/sim" ) );
+ assertEquals( "Name", "org.realityforge.dve",
+ dveSpecification.getSpecificationTitle() );
+ assertEquals( "SpecVendor", "Peter Donald",
+ dveSpecification.getSpecificationVendor() );
+ assertEquals( "SpecVersion", "1.0.2",
+ dveSpecification.getSpecificationVersion().toStrin=
g() );
+ assertEquals( "ImpVendor", "Peter Donald",
+ dveSpecification.getImplementationVendor() );
+ assertEquals( "ImpTitle", "DVE vi OS3P",
+ dveSpecification.getImplementationTitle() );
+ assertEquals( "ImpVersion", "1.0.2Alpha",
+ dveSpecification.getImplementationVersion().toStri=
ng() );
+
+ assertEquals( "sections.length",
+ 1,
+ fooSpecification.getSections().length );
+ assertEquals( "sections[0]",
+ "com/biz/foo",
+ fooSpecification.getSections()[ 0 ] );
+ assertEquals( "Name", "com.biz.foo",
+ fooSpecification.getSpecificationTitle() );
+ assertEquals( "SpecVendor", "Peter Donald",
+ fooSpecification.getSpecificationVendor() );
+ assertEquals( "SpecVersion", "1.0.2",
+ fooSpecification.getSpecificationVersion().toStrin=
g() );
+ assertEquals( "ImpVendor", "Peter Donald",
+ fooSpecification.getImplementationVendor() );
+ assertEquals( "ImpTitle", "DVE vi OS3P",
+ fooSpecification.getImplementationTitle() );
+ assertEquals( "ImpVersion", "1.0.2Alpha",
+ fooSpecification.getImplementationVersion().toStri=
ng() );
+ }
+
+ public void testCompatible()
+ throws Exception
+ {
+ final String title =3D "org.realityforge.dve";
+ final String version =3D "1.0.2";
+ final String vendor =3D "Peter Donald";
+ final String implTitle =3D "DVE vi OS3P";
+ final String implVendor =3D "Peter Donald";
+ final String implVersion =3D "1.0.2Alpha";
+
+ final Specification req1 =3D
+ new Specification( title, version, vendor,
+ implTitle, implVersion, implVendor );
+ final Specification req2 =3D
+ new Specification( title, version, vendor,
+ null, null, null );
+ final Specification req3 =3D
+ new Specification( title, "1.0.1", vendor,
+ null, null, null );
+ final Specification req4 =3D
+ new Specification( title, version, null,
+ null, null, null );
+ final Specification req5 =3D
+ new Specification( "another title", version, vendor,
+ implTitle, implVersion, implVendor );
+
+ final Specification avail1 =3D
+ new Specification( title, version, vendor,
+ implTitle, implVersion, implVendor );
+ final Specification avail2 =3D
+ new Specification( title, version, vendor,
+ implTitle, "another version", implVendor =
);
+ final Specification avail3 =3D
+ new Specification( title, version, vendor,
+ implTitle, implVersion, "another vendor" =
);
+
+ assertTrue( "avail1.isCompatibleWith( req1 )",
+ avail1.isCompatibleWith( req1 ) );
+ assertTrue( "avail1.isCompatibleWith( req2 )",
+ avail1.isCompatibleWith( req2 ) );
+ assertTrue( "avail1.isCompatibleWith( req3 )",
+ avail1.isCompatibleWith( req3 ) );
+ assertTrue( "avail1.isCompatibleWith( req4 )",
+ avail1.isCompatibleWith( req4 ) );
+ assertTrue( "!avail1.isCompatibleWith( req5 )",
+ !avail1.isCompatibleWith( req5 ) );
+
+ assertTrue( "!avail2.isCompatibleWith( req1 )",
+ !avail2.isCompatibleWith( req1 ) );
+ assertTrue( "avail2.isCompatibleWith( req2 )",
+ avail2.isCompatibleWith( req2 ) );
+ assertTrue( "avail2.isCompatibleWith( req3 )",
+ avail2.isCompatibleWith( req3 ) );
+ assertTrue( "avail2.isCompatibleWith( req4 )",
+ avail2.isCompatibleWith( req4 ) );
+ assertTrue( "!avail2.isCompatibleWith( req5 )",
+ !avail2.isCompatibleWith( req5 ) );
+
+ assertTrue( "!avail3.isCompatibleWith( req1 )",
+ !avail3.isCompatibleWith( req1 ) );
+ assertTrue( "avail3.isCompatibleWith( req2 )",
+ avail3.isCompatibleWith( req2 ) );
+ assertTrue( "avail3.isCompatibleWith( req3 )",
+ avail3.isCompatibleWith( req3 ) );
+ assertTrue( "avail3.isCompatibleWith( req4 )",
+ avail3.isCompatibleWith( req4 ) );
+ assertTrue( "!avail3.isCompatibleWith( req5 )",
+ !avail3.isCompatibleWith( req5 ) );
+ }
+
+ private Specification[] getSpecifications( final String input )
+ throws Exception
+ {
+ final Manifest manifest =3D getManifest( input );
+ return Specification.getSpecifications( manifest );
+ }
+
+ private Manifest getManifest( final String manifestString )
+ throws IOException
+ {
+ final ByteArrayInputStream stream =3D
+ new ByteArrayInputStream( manifestString.getBytes() );
+ return new Manifest( stream );
+ }
+}
</pre><pre class=3D"diff"><small id=3D"info">\ No newline at end of file
</small></pre></div>
<hr /><a name=3D"file8" /><div class=3D"file">
<span class=3D"pathname" id=3D"added"><a href=3D"http://xstream.cvs.codeh=
aus.org/jcontainer">jcontainer</a>/<a href=3D"http://xstream.cvs.codehaus=
.org/jcontainer/loom">loom</a>/<a href=3D"http://xstream.cvs.codehaus.org=
/jcontainer/loom/support">support</a>/<a href=3D"http://xstream.cvs.codeh=
aus.org/jcontainer/loom/support/extension">extension</a>/<a href=3D"http:=
//xstream.cvs.codehaus.org/jcontainer/loom/support/extension/src">src</a>=
/<a href=3D"http://xstream.cvs.codehaus.org/jcontainer/loom/support/exten=
sion/src/test">test</a>/<a href=3D"http://xstream.cvs.codehaus.org/jconta=
iner/loom/support/extension/src/test/org">org</a>/<a href=3D"http://xstre=
am.cvs.codehaus.org/jcontainer/loom/support/extension/src/test/org/codeha=
us">codehaus</a>/<a href=3D"http://xstream.cvs.codehaus.org/jcontainer/lo=
om/support/extension/src/test/org/codehaus/loom">loom</a>/<a href=3D"http=
://xstream.cvs.codehaus.org/jcontainer/loom/support/extension/src/test/or=
g/codehaus/loom/extension">extension</a><br /></span>
<div class=3D"fileheader" id=3D"added"><big><b>ExtensionTestCase.java</b>=
</big> <small id=3D"info">added at <a href=3D"http://xstream.cvs.codehaus=
.org/jcontainer/loom/support/extension/src/test/org/codehaus/loom/extensi=
on/ExtensionTestCase.java?rev=3D1.1&content-type=3Dtext/vnd.viewcvs-m=
arkup">1.1</a></small></div>
<pre class=3D"diff"><small id=3D"info">diff -N ExtensionTestCase.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ExtensionTestCase.java 19 Apr 2004 21:40:38 -0000 1.1
@@ -0,0 +1,384 @@
</small></pre><pre class=3D"diff" id=3D"added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.loom.extension;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.util.jar.Manifest;
+
+import org.codehaus.loom.extension.Extension;
+
+import junit.framework.TestCase;
+
+/**
+ * TestCases for Extension.
+ *
+ * @author Peter Donald
+ * @version $Revision: 1.1 $ $Date: 2004/04/19 21:40:38 $
+ */
+public class ExtensionTestCase
+ extends TestCase
+{
+ public void testAvailable()
+ throws Exception
+ {
+ final String manifestString =3D
+ "Manifest-Version: 1.0\n" +
+ "Extension-Name: spice-configkit\n" +
+ "Specification-Version: 1.0\n" +
+ "Specification-Vendor: Spice Group\n" +
+ "Implementation-Vendor-Id: org.realityforge.spice\n" +
+ "Implementation-Vendor: Spice Group\n" +
+ "Implementation-Version: 2.8Alpha\n";
+ final Manifest manifest =3D getManifest( manifestString );
+
+ final Extension[] required =3D Extension.getRequired( manifest )=
;
+ assertEquals( "required Count", 0, required.length );
+
+ final Extension[] available =3D Extension.getAvailable( manifest=
);
+
+ assertEquals( "Available Count", 1, available.length );
+ assertEquals( "Available Name", "spice-configkit",
+ available[ 0 ].getExtensionName() );
+ assertEquals( "Available SpecVendor", "Spice Group",
+ available[ 0 ].getSpecificationVendor() );
+ assertEquals( "Available SpecVersion", "1.0",
+ available[ 0 ].getSpecificationVersion().toString(=
) );
+ assertEquals( "Available URL",
+ null,
+ available[ 0 ].getImplementationURL() );
+ assertEquals( "Available ImpVendor", "Spice Group",
+ available[ 0 ].getImplementationVendor() );
+ assertEquals( "Available ImpVendorId", "org.realityforge.spice",
+ available[ 0 ].getImplementationVendorID() );
+ assertEquals( "Available ImpVersion", "2.8Alpha",
+ available[ 0 ].getImplementationVersion().toString=
() );
+ }
+
+ public void testRequired()
+ throws Exception
+ {
+ final String manifestString =3D
+ "Manifest-Version: 1.0\n" +
+ "Extension-List: required1\n" +
+ "required1-Extension-Name: spice.required1\n" +
+ "required1-Specification-Version: 1.0\n" +
+ "required1-Implementation-Version: 1.0.2\n" +
+ "required1-Implementation-Vendor-Id: org.realityforge.spice\=
n" +
+ "required1-Implementation-URL: http://spice.codehaus.org/req=
uired1.jar\n";
+ final Manifest manifest =3D getManifest( manifestString );
+
+ final Extension[] available =3D Extension.getAvailable( manifest=
);
+ assertEquals( "available Count", 0, available.length );
+
+ final Extension[] required =3D Extension.getRequired( manifest )=
;
+
+ assertEquals( "required Count", 1, required.length );
+ assertEquals( "required Name", "spice.required1",
+ required[ 0 ].getExtensionName() );
+ assertEquals( "required SpecVendor", null,
+ required[ 0 ].getSpecificationVendor() );
+ assertEquals( "required SpecVersion", "1.0",
+ required[ 0 ].getSpecificationVersion().toString()=
);
+ assertEquals( "required URL", "http://spice.codehaus.org/require=
d1.jar",
+ required[ 0 ].getImplementationURL() );
+ assertEquals( "required ImpVendor", null,
+ required[ 0 ].getImplementationVendor() );
+ assertEquals( "required ImpVendorId", "org.realityforge.spice",
+ required[ 0 ].getImplementationVendorID() );
+ assertEquals( "required ImpVersion", "1.0.2",
+ required[ 0 ].getImplementationVersion().toString(=
) );
+ }
+
+ public void testMultiRequired()
+ throws Exception
+ {
+ final String manifestString =3D
+ "Manifest-Version: 1.0\n" +
+ "Extension-List: required1 required2\n" +
+ "required1-Extension-Name: spice.required1\n" +
+ "required1-Specification-Version: 1.0\n" +
+ "required1-Implementation-Version: 1.0.2\n" +
+ "required1-Implementation-Vendor-Id: org.realityforge.spice\=
n" +
+ "required1-Implementation-URL: http://spice.codehaus.org/req=
uired1.jar\n" +
+ "required2-Extension-Name: spice.required2\n" +
+ "required2-Specification-Version: 1.0\n" +
+ "required2-Implementation-Version: 1.0.2\n" +
+ "required2-Implementation-Vendor-Id: org.realityforge.spice\=
n" +
+ "required2-Implementation-URL: http://spice.codehaus.org/req=
uired2.jar\n";
+ final Manifest manifest =3D getManifest( manifestString );
+
+ final Extension[] available =3D Extension.getAvailable( manifest=
);
+ assertEquals( "available Count", 0, available.length );
+
+ final Extension[] required =3D Extension.getRequired( manifest )=
;
+ assertEquals( "required Count", 2, required.length );
+ assertEquals( "required Name", "spice.required1",
+ required[ 0 ].getExtensionName() );
+ assertEquals( "required SpecVendor", null,
+ required[ 0 ].getSpecificationVendor() );
+ assertEquals( "required SpecVersion", "1.0",
+ required[ 0 ].getSpecificationVersion().toString()=
);
+ assertEquals( "required URL", "http://spice.codehaus.org/require=
d1.jar",
+ required[ 0 ].getImplementationURL() );
+ assertEquals( "required ImpVendor", null,
+ required[ 0 ].getImplementationVendor() );
+ assertEquals( "required ImpVendorId", "org.realityforge.spice",
+ required[ 0 ].getImplementationVendorID() );
+ assertEquals( "required ImpVersion", "1.0.2",
+ required[ 0 ].getImplementationVersion().toString(=
) );
+
+ assertEquals( "required Name", "spice.required2",
+ required[ 1 ].getExtensionName() );
+ assertEquals( "required SpecVendor", null,
+ required[ 1 ].getSpecificationVendor() );
+ assertEquals( "required SpecVersion", "1.0",
+ required[ 1 ].getSpecificationVersion().toString()=
);
+ assertEquals( "required URL", "http://spice.codehaus.org/require=
d2.jar",
+ required[ 1 ].getImplementationURL() );
+ assertEquals( "required ImpVendor", null,
+ required[ 1 ].getImplementationVendor() );
+ assertEquals( "required ImpVendorId", "org.realityforge.spice",
+ required[ 1 ].getImplementationVendorID() );
+ assertEquals( "required ImpVersion", "1.0.2",
+ required[ 1 ].getImplementationVersion().toString(=
) );
+ }
+
+ public void testAvailableAndRequired()
+ throws Exception
+ {
+ final String manifestString =3D
+ "Manifest-Version: 1.0\n" +
+ "Extension-Name: spice-configkit\n" +
+ "Specification-Version: 1.0\n" +
+ "Specification-Vendor: Spice Group\n" +
+ "Implementation-Vendor-Id: org.realityforge.spice\n" +
+ "Implementation-Vendor: Spice Group\n" +
+ "Implementation-Version: 2.8Alpha\n" +
+ "Extension-List: required1\n" +
+ "required1-Extension-Name: spice.required1\n" +
+ "required1-Specification-Version: 1.0\n" +
+ "required1-Implementation-Version: 1.0.2\n" +
+ "required1-Implementation-Vendor-Id: org.realityforge.spice\=
n" +
+ "required1-Implementation-URL: http://spice.codehaus.org/req=
uired1.jar\n";
+ final Manifest manifest =3D getManifest( manifestString );
+
+ final Extension[] available =3D Extension.getAvailable( manifest=
);
+ assertEquals( "Available Count", 1, available.length );
+ assertEquals( "Available Name", "spice-configkit",
+ available[ 0 ].getExtensionName() );
+ assertEquals( "Available SpecVendor", "Spice Group",
+ available[ 0 ].getSpecificationVendor() );
+ assertEquals( "Available SpecVersion", "1.0",
+ available[ 0 ].getSpecificationVersion().toString(=
) );
+ assertEquals( "Available URL",
+ null,
+ available[ 0 ].getImplementationURL() );
+ assertEquals( "Available ImpVendor", "Spice Group",
+ available[ 0 ].getImplementationVendor() );
+ assertEquals( "Available ImpVendorId", "org.realityforge.spice",
+ available[ 0 ].getImplementationVendorID() );
+ assertEquals( "Available ImpVersion", "2.8Alpha",
+ available[ 0 ].getImplementationVersion().toString=
() );
+
+ final Extension[] required =3D Extension.getRequired( manifest )=
;
+ assertEquals( "required Count", 1, required.length );
+ assertEquals( "required Name", "spice.required1",
+ required[ 0 ].getExtensionName() );
+ assertEquals( "required SpecVendor", null,
+ required[ 0 ].getSpecificationVendor() );
+ assertEquals( "required SpecVersion", "1.0",
+ required[ 0 ].getSpecificationVersion().toString()=
);
+ assertEquals( "required URL", "http://spice.codehaus.org/require=
d1.jar",
+ required[ 0 ].getImplementationURL() );
+ assertEquals( "required ImpVendor", null,
+ required[ 0 ].getImplementationVendor() );
+ assertEquals( "required ImpVendorId", "org.realityforge.spice",
+ required[ 0 ].getImplementationVendorID() );
+ assertEquals( "required ImpVersion", "1.0.2",
+ required[ 0 ].getImplementationVersion().toString(=
) );
+ }
+
+ public void testRequiredWithSpacesAfterAttributes()
+ throws Exception
+ {
+ final String manifestString =3D
+ "Manifest-Version: 1.0 \n" +
+ "Extension-List: required1 \n" +
+ "required1-Extension-Name: spice.required1 \n" +
+ "required1-Specification-Version: 1.0 \n" +
+ "required1-Implementation-Version: 1.0.2 \n" +
+ "required1-Implementation-Vendor-Id: org.realityforge.spice =
\n" +
+ "required1-Implementation-URL: http://spice.codehaus.org/req=
uired1.jar \n";
+ final Manifest manifest =3D getManifest( manifestString );
+
+ final Extension[] available =3D Extension.getAvailable( manifest=
);
+ assertEquals( "available Count", 0, available.length );
+
+ final Extension[] required =3D Extension.getRequired( manifest )=
;
+
+ assertEquals( "required Count", 1, required.length );
+ assertEquals( "required Name", "spice.required1",
+ required[ 0 ].getExtensionName() );
+ assertEquals( "required SpecVendor", null,
+ required[ 0 ].getSpecificationVendor() );
+ assertEquals( "required SpecVersion", "1.0",
+ required[ 0 ].getSpecificationVersion().toString()=
);
+ assertEquals( "required URL", "http://spice.codehaus.org/require=
d1.jar",
+ required[ 0 ].getImplementationURL() );
+ assertEquals( "required ImpVendor", null,
+ required[ 0 ].getImplementationVendor() );
+ assertEquals( "required ImpVendorId", "org.realityforge.spice",
+ required[ 0 ].getImplementationVendorID() );
+ assertEquals( "required ImpVersion", "1.0.2",
+ required[ 0 ].getImplementationVersion().toString(=
) );
+ }
+
+ public void testAvailableWithSpacesAfterAttributes()
+ throws Exception
+ {
+ final String manifestString =3D
+ "Manifest-Version: 1.0\n" +
+ "Extension-Name: spice-configkit \n" +
+ "Specification-Version: 1.0 \n" +
+ "Specification-Vendor: Spice Group \n" +
+ "Implementation-Vendor-Id: org.realityforge.spice \n" +
+ "Implementation-Vendor: Spice Group \n" +
+ "Implementation-Version: 2.8Alpha \n";
+ final Manifest manifest =3D getManifest( manifestString );
+
+ final Extension[] required =3D Extension.getRequired( manifest )=
;
+ assertEquals( "required Count", 0, required.length );
+
+ final Extension[] available =3D Extension.getAvailable( manifest=
);
+
+ assertEquals( "Available Count", 1, available.length );
+ assertEquals( "Available Name", "spice-configkit",
+ available[ 0 ].getExtensionName() );
+ assertEquals( "Available SpecVendor", "Spice Group",
+ available[ 0 ].getSpecificationVendor() );
+ assertEquals( "Available SpecVersion", "1.0",
+ available[ 0 ].getSpecificationVersion().toString(=
) );
+ assertEquals( "Available URL",
+ null,
+ available[ 0 ].getImplementationURL() );
+ assertEquals( "Available ImpVendor", "Spice Group",
+ available[ 0 ].getImplementationVendor() );
+ assertEquals( "Available ImpVendorId", "org.realityforge.spice",
+ available[ 0 ].getImplementationVendorID() );
+ assertEquals( "Available ImpVersion", "2.8Alpha",
+ available[ 0 ].getImplementationVersion().toString=
() );
+ }
+
+ public void testCompatabilityRezultsIncompatability()
+ throws Exception
+ {
+ final Extension extension1 =3D
+ new Extension( "baz", null, null, null, null, null, null );
+ final Extension extension2 =3D
+ new Extension( "foo", null, null, null, null, null, null );
+ assertEquals( Extension.INCOMPATIBLE,
+ extension1.getCompatibilityWith( extension2 ) );
+ }
+
+ public void testCompatabilityRezultsNeedSpecUpgrade()
+ throws Exception
+ {
+ final Extension extension1 =3D
+ new Extension( "baz", "1.0", null, null, null, null, null );
+ final Extension extension2 =3D
+ new Extension( "baz", "1.1", null, null, null, null, null );
+ assertEquals( Extension.REQUIRE_SPECIFICATION_UPGRADE,
+ extension1.getCompatibilityWith( extension2 ) );
+ }
+
+ public void testCompatabilityRezultsCompatLowerVersion()
+ throws Exception
+ {
+ final Extension extension1 =3D
+ new Extension( "baz", "1.0", null, null, null, null, null );
+ final Extension extension2 =3D
+ new Extension( "baz", "0.9", null, null, null, null, null );
+ assertEquals( Extension.COMPATIBLE,
+ extension1.getCompatibilityWith( extension2 ) );
+ }
+
+ public void testCompatabilityRezultsCompatEqVersion()
+ throws Exception
+ {
+ final Extension extension1 =3D
+ new Extension( "baz", "1.0", null, null, null, null, null );
+ final Extension extension2 =3D
+ new Extension( "baz", "1.0", null, null, null, null, null );
+ assertEquals( Extension.COMPATIBLE,
+ extension1.getCompatibilityWith( extension2 ) );
+ }
+
+ public void testCompatabilityRezultsInCompatWIthNonNullSpecVersion()
+ throws Exception
+ {
+ final Extension extension1 =3D
+ new Extension( "baz", null, null, null, null, null, null );
+ final Extension extension2 =3D
+ new Extension( "baz", "1.0", null, null, null, null, null );
+ assertEquals( Extension.REQUIRE_SPECIFICATION_UPGRADE,
+ extension1.getCompatibilityWith( extension2 ) );
+ }
+
+ public void testCompatabilityRezultsInCompatWIthNullSpecVersion()
+ throws Exception
+ {
+ final Extension extension1 =3D
+ new Extension( "baz", "1.0", null, null, null, null, null );
+ final Extension extension2 =3D
+ new Extension( "baz", null, null, null, null, null, null );
+ assertEquals( Extension.COMPATIBLE,
+ extension1.getCompatibilityWith( extension2 ) );
+ }
+
+ public void testCompatabilityRezultsInCompatForVendorID()
+ throws Exception
+ {
+ final Extension extension1 =3D
+ new Extension( "baz", null, null, null, null, "Bob", null );
+ final Extension extension2 =3D
+ new Extension( "baz", null, null, null, null, "Bob", null );
+ assertEquals( Extension.COMPATIBLE,
+ extension1.getCompatibilityWith( extension2 ) );
+ }
+
+ public void testCompatabilityRezultsInCompatForNullVendorID()
+ throws Exception
+ {
+ final Extension extension1 =3D
+ new Extension( "baz", null, null, null, null, null, null );
+ final Extension extension2 =3D
+ new Extension( "baz", null, null, null, null, "Bob", null );
+ assertEquals( Extension.REQUIRE_VENDOR_SWITCH,
+ extension1.getCompatibilityWith( extension2 ) );
+ }
+
+ public void testCompatabilityRezultsInIncompatForNullVendorID()
+ throws Exception
+ {
+ final Extension extension1 =3D
+ new Extension( "baz", null, null, null, null, null, null );
+ final Extension extension2 =3D
+ new Extension( "baz", null, null, null, null, "Bob", null );
+ assertEquals( Extension.REQUIRE_VENDOR_SWITCH,
+ extension1.getCompatibilityWith( extension2 ) );
+ }
+
+ private Manifest getManifest( final String manifestString )
+ throws IOException
+ {
+ final ByteArrayInputStream stream =3D
+ new ByteArrayInputStream( manifestString.getBytes() );
+ return new Manifest( stream );
+ }
+}
</pre><pre class=3D"diff"><small id=3D"info">\ No newline at end of file
</small></pre></div>
<hr /><a name=3D"file9" /><div class=3D"file">
<span class=3D"pathname" id=3D"removed"><a href=3D"http://xstream.cvs.cod=
ehaus.org/jcontainer">jcontainer</a>/<a href=3D"http://xstream.cvs.codeha=
us.org/jcontainer/loom">loom</a>/<a href=3D"http://xstream.cvs.codehaus.o=
rg/jcontainer/loom/support">support</a>/<a href=3D"http://xstream.cvs.cod=
ehaus.org/jcontainer/loom/support/extension">extension</a>/<a href=3D"htt=
p://xstream.cvs.codehaus.org/jcontainer/loom/support/extension/src">src</=
a>/<a href=3D"http://xstream.cvs.codehaus.org/jcontainer/loom/support/ext=
ension/src/java">java</a>/<a href=3D"http://xstream.cvs.codehaus.org/jcon=
tainer/loom/support/extension/src/java/org">org</a>/<a href=3D"http://xst=
ream.cvs.codehaus.org/jcontainer/loom/support/extension/src/java/org/jcon=
tainer">jcontainer</a>/<a href=3D"http://xstream.cvs.codehaus.org/jcontai=
ner/loom/support/extension/src/java/org/jcontainer/loom">loom</a>/<a href=
=3D"http://xstream.cvs.codehaus.org/jcontainer/loom/support/extension/src=
/java/org/jcontainer/loom/extension">extension</a><br /></span>
<div class=3D"fileheader" id=3D"removed"><big><b>Extension.java</b></big>=
<small id=3D"info">removed after <a href=3D"http://xstream.cvs.codehaus.=
org/jcontainer/loom/support/extension/src/java/org/jcontainer/loom/extens=
ion/Extension.java?rev=3D1.1&content-type=3Dtext/vnd.viewcvs-markup">=
1.1</a></small></div>
<pre class=3D"diff"><small id=3D"info">diff -N Extension.java
--- Extension.java 31 Mar 2004 03:13:43 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,722 +0,0 @@
</small></pre><pre class=3D"diff" id=3D"removed">-/*
- * Copyright (C) The Spice Group. All rights reserved.
- *
- * This software is published under the terms of the Spice
- * Software License version 1.1, a copy of which has been included
- * with this distribution in the LICENSE.txt file.
- *
- * This product includes software developed by the
-=A0*=A0Apache Software Foundation (http://www.apache.org/).
- */
-package org.jcontainer.loom.extension;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.StringTokenizer;
-import java.util.jar.Attributes;
-import java.util.jar.Manifest;
-
-/**
- * <p>Utility class that represents either an available "Optional =
Package"
- * (formerly known as "Standard Extension") as described in the manifest=
of a
- * JAR file, or the requirement for such an optional package.</p>
- *
- * <p>For more information about optional packages, see the docume=
nt
- * <em>Optional Package Versioning</em> in the documentation=
bundle for your
- * Java2 Standard Edition package, in file <code>guide/extensions/=
versioning.html</code>.</p>
- *
- * @author <a href=3D"mailto:craigmcc at apache.org">Craig R. McCl=
anahan</a>
- * @author Peter Donald
- * @version $Revision: 1.1 $ $Date: 2004/03/31 03:13:43 $
- */
-public final class Extension
-{
- /**
- * Manifest Attribute Name object for EXTENSION_LIST.
- *
- * @see Attributes.Name#EXTENSION_LIST
- */
- public static final Attributes.Name EXTENSION_LIST =3D Attributes.Na=
me.EXTENSION_LIST;
- /**
- * <code>Name</code> object for <code>Optional-Ext=
ension-List</code>
- * manifest attribute used for declaring optional dependencies on in=
stalled
- * extensions. Note that the dependencies declared by this method ar=
e not
- * required for the library to operate but if present will be used. =
It is
- * NOT part of the official "Optional Package" specification.
- *
- * @see <a href=3D"http://java.sun.com/j2se/1.3/docs/guide/extens=
ions/spec.html#dependnecy">
- * Installed extension dependency</a>
- */
- public static final Attributes.Name OPTIONAL_EXTENSION_LIST =3D
- new Attributes.Name( "Optional-Extension-List" );
- /**
- * Manifest Attribute Name object for EXTENSION_NAME.
- *
- * @see Attributes.Name#EXTENSION_NAME
- */
- public static final Attributes.Name EXTENSION_NAME =3D
- Attributes.Name.EXTENSION_NAME;
- /**
- * Manifest Attribute Name object for SPECIFICATION_VERSION.
- *
- * @see Attributes.Name#SPECIFICATION_VERSION
- */
- public static final Attributes.Name SPECIFICATION_VERSION =3D
- Attributes.Name.SPECIFICATION_VERSION;
- /**
- * Manifest Attribute Name object for SPECIFICATION_VENDOR.
- *
- * @see Attributes.Name#SPECIFICATION_VENDOR
- */
- public static final Attributes.Name SPECIFICATION_VENDOR =3D
- Attributes.Name.SPECIFICATION_VENDOR;
- /**
- * Manifest Attribute Name object for IMPLEMENTATION_VERSION.
- *
- * @see Attributes.Name#IMPLEMENTATION_VERSION
- */
- public static final Attributes.Name IMPLEMENTATION_VERSION =3D
- Attributes.Name.IMPLEMENTATION_VERSION;
- /**
- * Manifest Attribute Name object for IMPLEMENTATION_VENDOR.
- *
- * @see Attributes.Name#IMPLEMENTATION_VENDOR
- */
- public static final Attributes.Name IMPLEMENTATION_VENDOR =3D
- Attributes.Name.IMPLEMENTATION_VENDOR;
- /**
- * Manifest Attribute Name object for IMPLEMENTATION_URL.
- *
- * @see Attributes.Name#IMPLEMENTATION_URL
- */
- public static final Attributes.Name IMPLEMENTATION_URL =3D
- Attributes.Name.IMPLEMENTATION_URL;
- /**
- * Manifest Attribute Name object for IMPLEMENTATION_VENDOR_ID.
- *
- * @see Attributes.Name#IMPLEMENTATION_VENDOR_ID
- */
- public static final Attributes.Name IMPLEMENTATION_VENDOR_ID =3D
- Attributes.Name.IMPLEMENTATION_VENDOR_ID;
- /** Enum indicating that extension is compatible with other extensio=
n. */
- public static final Compatability COMPATIBLE =3D
- new Compatability( "COMPATIBLE" );
- /**
- * Enum indicating that extension requires an upgrade of specificati=
on to be
- * compatible with other extension.
- */
- public static final Compatability REQUIRE_SPECIFICATION_UPGRADE =3D
- new Compatability( "REQUIRE_SPECIFICATION_UPGRADE" );
- /**
- * Enum indicating that extension requires a vendor switch to be com=
patible
- * with other extension.
- */
- public static final Compatability REQUIRE_VENDOR_SWITCH =3D
- new Compatability( "REQUIRE_VENDOR_SWITCH" );
- /**
- * Enum indicating that extension requires an upgrade of implementat=
ion to
- * be compatible with other extension.
- */
- public static final Compatability REQUIRE_IMPLEMENTATION_UPGRADE =3D
- new Compatability( "REQUIRE_IMPLEMENTATION_UPGRADE" );
- /**
- * Enum indicating that extension is incompatible with other extensi=
on in
- * ways other than other enums indicate). ie For example the other e=
xtension
- * may have a different ID.
- */
- public static final Compatability INCOMPATIBLE =3D
- new Compatability( "INCOMPATIBLE" );
- /** The name of the optional package being made available, or requir=
ed. */
- private String m_extensionName;
- /**
- * The version number (dotted decimal notation) of the specification=
to
- * which this optional package conforms.
- */
- private DeweyDecimal m_specificationVersion;
- /**
- * The name of the company or organization that originated the speci=
fication
- * to which this optional package conforms.
- */
- private String m_specificationVendor;
- /**
- * The unique identifier of the company that produced the optional p=
ackage
- * contained in this JAR file.
- */
- private String m_implementationVendorID;
- /**
- * The name of the company or organization that produced this implem=
entation
- * of this optional package.
- */
- private String m_implementationVendor;
- /**
- * The version number (dotted decimal notation) for this implementat=
ion of
- * the optional package.
- */
- private String m_implementationVersion;
- /**
- * The URL from which the most recent version of this optional packa=
ge can
- * be obtained if it is not already installed.
- */
- private String m_implementationURL;
-
- /**
- * Return an array of <code>Extension</code> objects rep=
resenting optional
- * packages that are available in the JAR file associated with the s=
pecified
- * <code>Manifest</code>. If there are no such optional=
packages, a
- * zero-length array is returned.
- *
- * @param manifest Manifest to be parsed
- * @return the "available" extensions in specified manifest
- */
- public static Extension[] getAvailable( final Manifest manifest )
- {
- if( null =3D=3D manifest )
- {
- return new Extension[ 0 ];
- }
- final ArrayList results =3D new ArrayList();
- final Attributes mainAttributes =3D manifest.getMainAttributes()=
;
- if( null !=3D mainAttributes )
- {
- final Extension extension =3D getExtension( "", mainAttribut=
es );
- if( null !=3D extension )
- {
- results.add( extension );
- }
- }
- final Map entries =3D manifest.getEntries();
- final Iterator keys =3D entries.keySet().iterator();
- while( keys.hasNext() )
- {
- final String key =3D (String)keys.next();
- final Attributes attributes =3D (Attributes)entries.get( key=
);
- final Extension extension =3D getExtension( "", attributes )=
;
- if( null !=3D extension )
- {
- results.add( extension );
- }
- }
- return (Extension[])results.toArray( new Extension[ results.size=
() ] );
- }
-
- /**
- * Retrieve the set of <code>Extension</code> objects th=
at are available by
- * the specified Manifest objects. If there are no such optional pac=
kages, a
- * zero-length list is returned.
- *
- * @param manifests the manifests to scan
- * @return the extensions
- */
- public static Extension[] getAvailable( final Manifest[] manifests )
- {
- final ArrayList set =3D new ArrayList();
- for( int i =3D 0; i < manifests.length; i++ )
- {
- final Extension[] extensions =3D getAvailable( manifests[ i =
] );
- for( int j =3D 0; j < extensions.length; j++ )
- {
- set.add( extensions[ j ] );
- }
- }
- return (Extension[])set.toArray( new Extension[ set.size() ] );
- }
-
- /**
- * Return the set of <code>Extension</code> objects repr=
esenting optional
- * packages that are required by the application contained in the JA=
R file
- * associated with the specified <code>Manifest</code>. =
If there are no
- * such optional packages, a zero-length list is returned.
- *
- * @param manifest Manifest to be parsed
- * @return the dependencies that are specified in manifes
- */
- public static Extension[] getRequired( final Manifest manifest )
- {
- return getListed( manifest, EXTENSION_LIST );
- }
-
- /**
- * Retrieve the set of <code>Extension</code> objects th=
at are required by
- * the specified Manifest objects. If there are no such optional pac=
kages, a
- * zero-length list is returned.
- *
- * @param manifests the manifests to scan
- * @return the extensions
- */
- public static Extension[] getRequired( final Manifest[] manifests )
- {
- final ArrayList set =3D new ArrayList();
- for( int i =3D 0; i < manifests.length; i++ )
- {
- final Extension[] extensions =3D getRequired( manifests[ i ]=
);
- for( int j =3D 0; j < extensions.length; j++ )
- {
- set.add( extensions[ j ] );
- }
- }
- return (Extension[])set.toArray( new Extension[ set.size() ] );
- }
-
- /**
- * Return the set of <code>Extension</code> objects repr=
esenting "Optional
- * Packages" that the application declares they will use if present.=
If
- * there are no such optional packages, a zero-length list is return=
ed.
- *
- * @param manifest Manifest to be parsed
- * @return the optional dependencies that are specified in manifest
- */
- public static Extension[] getOptions( final Manifest manifest )
- {
- return getListed( manifest, OPTIONAL_EXTENSION_LIST );
- }
-
- /**
- * Add Extension to the specified manifest Attributes.
- *
- * @param attributes the attributes of manifest to add to
- * @param extension the extension
- */
- public static void addExtension( final Extension extension,
- final Attributes attributes )
- {
- addExtension( extension, "", attributes );
- }
-
- /**
- * Add Extension to the specified manifest Attributes. Use the speci=
fied
- * prefix so that dependencies can added with a prefix such as "java=
3d-"
- * etc.
- *
- * @param attributes the attributes of manifest to add to
- * @param extension the extension
- * @param prefix the name to prefix to extension
- */
- public static void addExtension( final Extension extension,
- final String prefix,
- final Attributes attributes )
- {
- attributes.putValue( prefix + EXTENSION_NAME,
- extension.getExtensionName() );
- final String specificationVendor =3D extension.getSpecificationV=
endor();
- if( null !=3D specificationVendor )
- {
- attributes.putValue( prefix + SPECIFICATION_VENDOR,
- specificationVendor );
- }
- final DeweyDecimal specificationVersion =3D extension.getSpecifi=
cationVersion();
- if( null !=3D specificationVersion )
- {
- attributes.putValue( prefix + SPECIFICATION_VERSION,
- specificationVersion.toString() );
- }
- final String implementationVendorID =3D extension.getImplementat=
ionVendorID();
- if( null !=3D implementationVendorID )
- {
- attributes.putValue( prefix + IMPLEMENTATION_VENDOR_ID,
- implementationVendorID );
- }
- final String implementationVendor =3D extension.getImplementatio=
nVendor();
- if( null !=3D implementationVendor )
- {
- attributes.putValue( prefix + IMPLEMENTATION_VENDOR,
- implementationVendor );
- }
- final String implementationVersion =3D extension.getImplementati=
onVersion();
- if( null !=3D implementationVersion )
- {
- attributes.putValue( prefix + IMPLEMENTATION_VERSION,
- implementationVersion.toString() );
- }
- final String implementationURL =3D extension.getImplementationUR=
L();
- if( null !=3D implementationURL )
- {
- attributes.putValue( prefix + IMPLEMENTATION_URL,
- implementationURL );
- }
- }
-
- /**
- * The constructor to create Extension object. Note that every compo=
nent is
- * allowed to be specified but only the extensionName is mandatory.
- *
- * @param extensionName the name of extension.
- * @param specificationVersion the specification Version of extensio=
n.
- * @param specificationVendor the specification Vendor of extension.
- * @param implementationVersion the implementation Version of extens=
ion.
- * @param implementationVendor the implementation Vendor of extensio=
n.
- * @param implementationVendorId the implementation VendorId of exte=
nsion.
- * @param implementationURL the implementation URL of extension.
- */
- public Extension( final String extensionName,
- final String specificationVersion,
- final String specificationVendor,
- final String implementationVersion,
- final String implementationVendor,
- final String implementationVendorId,
- final String implementationURL )
- {
- if( null =3D=3D extensionName )
- {
- throw new NullPointerException( "extensionName" );
- }
- m_extensionName =3D extensionName;
- m_specificationVendor =3D specificationVendor;
- if( null !=3D specificationVersion )
- {
- try
- {
- m_specificationVersion =3D
- new DeweyDecimal( specificationVersion );
- }
- catch( final NumberFormatException nfe )
- {
- final String error =3D "Bad specification version format=
'" +
- specificationVersion +
- "' in '" + extensionName + "'. (Reason: " + nfe + ")=
";
- throw new IllegalArgumentException( error );
- }
- }
- m_implementationURL =3D implementationURL;
- m_implementationVendor =3D implementationVendor;
- m_implementationVendorID =3D implementationVendorId;
- m_implementationVersion =3D implementationVersion;
- }
-
- /**
- * Get the name of the extension.
- *
- * @return the name of the extension
- */
- public String getExtensionName()
- {
- return m_extensionName;
- }
-
- /**
- * Get the vendor of the extensions specification.
- *
- * @return the vendor of the extensions specification.
- */
- public String getSpecificationVendor()
- {
- return m_specificationVendor;
- }
-
- /**
- * Get the version of the extensions specification.
- *
- * @return the version of the extensions specification.
- */
- public DeweyDecimal getSpecificationVersion()
- {
- return m_specificationVersion;
- }
-
- /**
- * Get the url of the extensions implementation.
- *
- * @return the url of the extensions implementation.
- */
- public String getImplementationURL()
- {
- return m_implementationURL;
- }
-
- /**
- * Get the vendor of the extensions implementation.
- *
- * @return the vendor of the extensions implementation.
- */
- public String getImplementationVendor()
- {
- return m_implementationVendor;
- }
-
- /**
- * Get the vendorID of the extensions implementation.
- *
- * @return the vendorID of the extensions implementation.
- */
- public String getImplementationVendorID()
- {
- return m_implementationVendorID;
- }
-
- /**
- * Get the version of the extensions implementation.
- *
- * @return the version of the extensions implementation.
- */
- public String getImplementationVersion()
- {
- return m_implementationVersion;
- }
-
- /**
- * Return a Compatibility enum indicating the relationship of this
- * <code>Extension</code> with the specified <code>=
;Extension</code>.
- *
- * @param required Description of the required optional package
- * @return the enum indicating the compatability (or lack thereof) o=
f
- * specifed extension
- */
- public Compatability getCompatibilityWith( final Extension required =
)
- {
- // Extension Name must match
- if( !m_extensionName.equals( required.getExtensionName() ) )
- {
- return INCOMPATIBLE;
- }
- // Available specification version must be >=3D required
- final DeweyDecimal specificationVersion =3D required.getSpecific=
ationVersion();
- if( null !=3D specificationVersion )
- {
- if( null =3D=3D m_specificationVersion ||
- !isCompatible( m_specificationVersion, specificationVers=
ion ) )
- {
- return REQUIRE_SPECIFICATION_UPGRADE;
- }
- }
- // Implementation Vendor ID must match
- final String implementationVendorId =3D required.getImplementati=
onVendorID();
- if( null !=3D implementationVendorId )
- {
- if( null =3D=3D m_implementationVendorID ||
- !m_implementationVendorID.equals( implementationVendorId=
) )
- {
- return REQUIRE_VENDOR_SWITCH;
- }
- }
-
- // This available optional package satisfies the requirements
- return COMPATIBLE;
- }
-
- /**
- * Return <code>true</code> if the specified <code>=
;Extension</code> (which
- * represents an optional package required by an application) is sat=
isfied
- * by this <code>Extension</code> (which represents an o=
ptional package that
- * is already installed. Otherwise, return <code>false</co=
de>.
- *
- * @param required Description of the required optional package
- * @return true if the specified extension is compatible with this
- * extension
- */
- public boolean isCompatibleWith( final Extension required )
- {
- return ( COMPATIBLE =3D=3D getCompatibilityWith( required ) );
- }
-
- /**
- * Return a String representation of this object.
- *
- * @return string representation of object.
- */
- public String toString()
- {
- final String lineSeparator =3D System.getProperty( "line.separat=
or" );
- final String brace =3D ": ";
- final StringBuffer sb =3D new StringBuffer( EXTENSION_NAME.toStr=
ing() );
- sb.append( brace );
- sb.append( m_extensionName );
- sb.append( lineSeparator );
- if( null !=3D m_specificationVersion )
- {
- sb.append( SPECIFICATION_VERSION );
- sb.append( brace );
- sb.append( m_specificationVersion );
- sb.append( lineSeparator );
- }
- if( null !=3D m_specificationVendor )
- {
- sb.append( SPECIFICATION_VENDOR );
- sb.append( brace );
- sb.append( m_specificationVendor );
- sb.append( lineSeparator );
- }
- if( null !=3D m_implementationVersion )
- {
- sb.append( IMPLEMENTATION_VERSION );
- sb.append( brace );
- sb.append( m_implementationVersion );
- sb.append( lineSeparator );
- }
- if( null !=3D m_implementationVendorID )
- {
- sb.append( IMPLEMENTATION_VENDOR_ID );
- sb.append( brace );
- sb.append( m_implementationVendorID );
- sb.append( lineSeparator );
- }
- if( null !=3D m_implementationVendor )
- {
- sb.append( IMPLEMENTATION_VENDOR );
- sb.append( brace );
- sb.append( m_implementationVendor );
- sb.append( lineSeparator );
- }
- if( null !=3D m_implementationURL )
- {
- sb.append( IMPLEMENTATION_URL );
- sb.append( brace );
- sb.append( m_implementationURL );
- sb.append( lineSeparator );
- }
- return sb.toString();
- }
-
- /**
- * Return <code>true</code> if the first version number =
is greater than or
- * equal to the second; otherwise return <code>false</code&=
gt;.
- *
- * @param first First version number (dotted decimal)
- * @param second Second version number (dotted decimal)
- */
- private boolean isCompatible( final DeweyDecimal first,
- final DeweyDecimal second )
- {
- return first.isGreaterThanOrEqual( second );
- }
-
- /**
- * Retrieve all the extensions listed under a particular key (Usuall=
y
- * EXTENSION_LIST or OPTIONAL_EXTENSION_LIST).
- *
- * @param manifest the manifest to extract extensions from
- * @param listKey the key used to get list (Usually EXTENSION_LIST o=
r
- * OPTIONAL_EXTENSION_LIST)
- * @return the list of listed extensions
- */
- private static Extension[] getListed( final Manifest manifest,
- final Attributes.Name listKey =
)
- {
- final ArrayList results =3D new ArrayList();
- final Attributes mainAttributes =3D manifest.getMainAttributes()=
;
- if( null !=3D mainAttributes )
- {
- getExtension( mainAttributes, results, listKey );
- }
- final Map entries =3D manifest.getEntries();
- final Iterator keys =3D entries.keySet().iterator();
- while( keys.hasNext() )
- {
- final String key =3D (String)keys.next();
- final Attributes attributes =3D (Attributes)entries.get( key=
);
- getExtension( attributes, results, listKey );
- }
- return (Extension[])results.toArray( new Extension[ 0 ] );
- }
-
- /**
- * Add required optional packages defined in the specified attribute=
s entry,
- * if any.
- *
- * @param attributes Attributes to be parsed
- * @param required list to add required optional packages to
- * @param listKey the key to use to lookup list, usually EXTENSION_L=
IST or
- * OPTIONAL_EXTENSION_LIST
- */
- private static void getExtension( final Attributes attributes,
- final ArrayList required,
- final Attributes.Name listKey )
- {
- final String names =3D attributes.getValue( listKey );
- if( null =3D=3D names )
- {
- return;
- }
- final String[] extentions =3D split( names, " " );
- for( int i =3D 0; i < extentions.length; i++ )
- {
- final String prefix =3D extentions[ i ] + "-";
- final Extension extension =3D getExtension( prefix, attribut=
es );
- if( null !=3D extension )
- {
- required.add( extension );
- }
- }
- }
-
- /**
- * Splits the string on every token into an array of strings.
- *
- * @param string the string
- * @param onToken the token
- * @return the resultant array
- */
- private static final String[] split( final String string,
- final String onToken )
- {
- final StringTokenizer tokenizer =3D new StringTokenizer( string,
- onToken )=
;
- final String[] result =3D new String[ tokenizer.countTokens() ];
- for( int i =3D 0; i < result.length; i++ )
- {
- result[ i ] =3D tokenizer.nextToken();
- }
- return result;
- }
-
- /**
- * Extract an Extension from Attributes. Prefix indicates the prefix=
checked
- * for each string. Usually the prefix is <em>"&lt;extensi=
on&gt;-"</em> if
- * looking for a <b>Required</b> extension. If you are l=
ooking for an
- * <b>Available</b> extension then the prefix is <em&=
gt;""</em>.
- *
- * @param prefix the prefix for each attribute name
- * @param attributes Attributes to searched
- * @return the new Extension object, or null
- */
- private static Extension getExtension( final String prefix,
- final Attributes attributes )
- {
- //WARNING: We trim the values of all the attributes because
- //Some extension declarations are badly defined (ie have spaces
- //after version or vendorID)
- final String nameKey =3D prefix + EXTENSION_NAME;
- final String name =3D getTrimmedString( attributes.getValue( nam=
eKey ) );
- if( null =3D=3D name )
- {
- return null;
- }
- final String specVendorKey =3D prefix + SPECIFICATION_VENDOR;
- final String specVendor =3D getTrimmedString(
- attributes.getValue( specVendorKey ) );
- final String specVersionKey =3D prefix + SPECIFICATION_VERSION;
- final String specVersion =3D getTrimmedString(
- attributes.getValue( specVersionKey ) );
- final String impVersionKey =3D prefix + IMPLEMENTATION_VERSION;
- final String impVersion =3D getTrimmedString(
- attributes.getValue( impVersionKey ) );
- final String impVendorKey =3D prefix + IMPLEMENTATION_VENDOR;
- final String impVendor =3D getTrimmedString(
- attributes.getValue( impVendorKey ) );
- final String impVendorIDKey =3D prefix + IMPLEMENTATION_VENDOR_I=
D;
- final String impVendorId =3D getTrimmedString(
- attributes.getValue( impVendorIDKey ) );
- final String impURLKey =3D prefix + IMPLEMENTATION_URL;
- final String impURL =3D getTrimmedString(
- attributes.getValue( impURLKey ) );
- return new Extension( name, specVersion, specVendor, impVersion,
- impVendor, impVendorId, impURL );
- }
-
- /**
- * Trim the supplied string if the string is non-null
- *
- * @param value the string to trim or null
- * @return the trimmed string or null
- */
- private static String getTrimmedString( final String value )
- {
- if( null =3D=3D value )
- {
- return null;
- }
- else
- {
- return value.trim();
- }
- }
-}
</pre></div>
<hr /><a name=3D"file10" /><div class=3D"file">
<span class=3D"pathname" id=3D"removed"><a href=3D"http://xstream.cvs.cod=
ehaus.org/jcontainer">jcontainer</a>/<a href=3D"http://xstream.cvs.codeha=
us.org/jcontainer/loom">loom</a>/<a href=3D"http://xstream.cvs.codehaus.o=
rg/jcontainer/loom/support">support</a>/<a href=3D"http://xstream.cvs.cod=
ehaus.org/jcontainer/loom/support/extension">extension</a>/<a href=3D"htt=
p://xstream.cvs.codehaus.org/jcontainer/loom/support/extension/src">src</=
a>/<a href=3D"http://xstream.cvs.codehaus.org/jcontainer/loom/support/ext=
ension/src/java">java</a>/<a href=3D"http://xstream.cvs.codehaus.org/jcon=
tainer/loom/support/extension/src/java/org">org</a>/<a href=3D"http://xst=
ream.cvs.codehaus.org/jcontainer/loom/support/extension/src/java/org/jcon=
tainer">jcontainer</a>/<a href=3D"http://xstream.cvs.codehaus.org/jcontai=
ner/loom/support/extension/src/java/org/jcontainer/loom">loom</a>/<a href=
=3D"http://xstream.cvs.codehaus.org/jcontainer/loom/support/extension/src=
/java/org/jcontainer/loom/extension">extension</a><br /></span>
<div class=3D"fileheader" id=3D"removed"><big><b>Compatability.java</b></=
big> <small id=3D"info">removed after <a href=3D"http://xstream.cvs.codeh=
aus.org/jcontainer/loom/support/extension/src/java/org/jcontainer/loom/ex=
tension/Compatability.java?rev=3D1.1&content-type=3Dtext/vnd.viewcvs-=
markup">1.1</a></small></div>
<pre class=3D"diff"><small id=3D"info">diff -N Compatability.java
--- Compatability.java 31 Mar 2004 03:13:43 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,56 +0,0 @@
</small></pre><pre class=3D"diff" id=3D"removed">-/*
- * Copyright (C) The Spice Group. All rights reserved.
- *
- * This software is published under the terms of the Spice
- * Software License version 1.1, a copy of which has been included
- * with this distribution in the LICENSE.txt file.
- */
-package org.jcontainer.loom.extension;
-
-/**
- * Enum used in {@link Extension} to indicate the compatability of one e=
xtension
- * to another. See {@link Extension} for instances of object.
- *
- * @author Peter Donald
- * @version $Revision: 1.1 $ $Date: 2004/03/31 03:13:43 $
- * @see Extension
- */
-public final class Compatability
-{
- /** A string representaiton of compatability level. */
- private final String m_name;
-
- /**
- * Create a compatability enum with specified name.
- *
- * @param name the name of compatability level
- */
- Compatability( final String name )
- {
- if( null =3D=3D name )
- {
- throw new NullPointerException( "name" );
- }
- m_name =3D name;
- }
-
- /**
- * Return name of compatability level.
- *
- * @return the name of compatability level
- */
- public String getName()
- {
- return m_name;
- }
-
- /**
- * Return name of compatability level.
- *
- * @return the name of compatability level
- */
- public String toString()
- {
- return m_name;
- }
-}
</pre></div>
<hr /><a name=3D"file11" /><div class=3D"file">
<span class=3D"pathname" id=3D"removed"><a href=3D"http://xstream.cvs.cod=
ehaus.org/jcontainer">jcontainer</a>/<a href=3D"http://xstream.cvs.codeha=
us.org/jcontainer/loom">loom</a>/<a href=3D"http://xstream.cvs.codehaus.o=
rg/jcontainer/loom/support">support</a>/<a href=3D"http://xstream.cvs.cod=
ehaus.org/jcontainer/loom/support/extension">extension</a>/<a href=3D"htt=
p://xstream.cvs.codehaus.org/jcontainer/loom/support/extension/src">src</=
a>/<a href=3D"http://xstream.cvs.codehaus.org/jcontainer/loom/support/ext=
ension/src/java">java</a>/<a href=3D"http://xstream.cvs.codehaus.org/jcon=
tainer/loom/support/extension/src/java/org">org</a>/<a href=3D"http://xst=
ream.cvs.codehaus.org/jcontainer/loom/support/extension/src/java/org/jcon=
tainer">jcontainer</a>/<a href=3D"http://xstream.cvs.codehaus.org/jcontai=
ner/loom/support/extension/src/java/org/jcontainer/loom">loom</a>/<a href=
=3D"http://xstream.cvs.codehaus.org/jcontainer/loom/support/extension/src=
/java/org/jcontainer/loom/extension">extension</a><br /></span>
<div class=3D"fileheader" id=3D"removed"><big><b>DeweyDecimal.java</b></b=
ig> <small id=3D"info">removed after <a href=3D"http://xstream.cvs.codeha=
us.org/jcontainer/loom/support/extension/src/java/org/jcontainer/loom/ext=
ension/DeweyDecimal.java?rev=3D1.1&content-type=3Dtext/vnd.viewcvs-ma=
rkup">1.1</a></small></div>
<pre class=3D"diff"><small id=3D"info">diff -N DeweyDecimal.java
--- DeweyDecimal.java 31 Mar 2004 03:13:43 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,231 +0,0 @@
</small></pre><pre class=3D"diff" id=3D"removed">-/*
- * Copyright (C) The Spice Group. All rights reserved.
- *
- * This software is published under the terms of the Spice
- * Software License version 1.1, a copy of which has been included
- * with this distribution in the LICENSE.txt file.
- */
-package org.jcontainer.loom.extension;
-
-import java.util.StringTokenizer;
-
-/**
- * Utility class to contain version numbers in "Dewey Decimal" syntax. =
Numbers
- * in the "Dewey Decimal" syntax consist of positive decimal integers se=
parated
- * by periods ".". For example, "2.0" or "1.2.3.4.5.6.7". This allows =
an
- * extensible number to be used to represent major, minor, micro, etc ve=
rsions.
- * The version number must begin with a number.
- *
- * @author Peter Donald
- * @version $Revision: 1.1 $ $Date: 2004/03/31 03:13:43 $
- */
-public final class DeweyDecimal
-{
- ///Array of components that make up DeweyDecimal
- private int[] m_components;
-
- /**
- * Construct a DeweyDecimal from an array of integer components.
- *
- * @param components an array of integer components.
- */
- public DeweyDecimal( final int[] components )
- {
- m_components =3D new int[ components.length ];
- for( int i =3D 0; i < m_components.length; i++ )
- {
- m_components[ i ] =3D components[ i ];
- }
- }
-
- /**
- * Construct a DeweyDecimal from string in DeweyDecimal format.
- *
- * @param string the string in dewey decimal format
- * @throws java.lang.NumberFormatException if string is malformed
- */
- public DeweyDecimal( final String string )
- throws NumberFormatException
- {
- final StringTokenizer tokenizer =3D new StringTokenizer( string,
- ".",
- true );
- final int size =3D tokenizer.countTokens();
- m_components =3D new int[ ( size + 1 ) / 2 ];
- for( int i =3D 0; i < m_components.length; i++ )
- {
- final String component =3D tokenizer.nextToken();
- if( component.equals( "" ) )
- {
- throw new NumberFormatException( "Empty component in str=
ing" );
- }
- m_components[ i ] =3D Integer.parseInt( component );
- //Strip '.' token
- if( tokenizer.hasMoreTokens() )
- {
- tokenizer.nextToken();
- //If it ended in a dot, throw an exception
- if( !tokenizer.hasMoreTokens() )
- {
- final String message =3D "DeweyDecimal ended in a '.=
'";
- throw new NumberFormatException( message );
- }
- }
- }
- }
-
- /**
- * Return number of components in <code>DeweyDecimal</code&=
gt;.
- *
- * @return the number of components in dewey decimal
- */
- public int getSize()
- {
- return m_components.length;
- }
-
- /**
- * Return the component at specified index.
- *
- * @param index the index of components
- * @return the value of component at index
- */
- public int get( final int index )
- {
- return m_components[ index ];
- }
-
- /**
- * Return <code>true</code> if this <code>DeweyDec=
imal</code> is equal to
- * the other <code>DeweyDecimal</code>.
- *
- * @param other the other DeweyDecimal
- * @return true if equal to other DeweyDecimal, false otherwise
- */
- public boolean isEqual( final DeweyDecimal other )
- {
- final int max =3D Math.max( other.m_components.length,
- m_components.length );
- for( int i =3D 0; i < max; i++ )
- {
- final int component1 =3D ( i < m_components.length ) ?
- m_components[ i ] :
- 0;
- final int component2 =3D ( i < other.m_components.length =
) ?
- other.m_components[ i ] :
- 0;
- if( component2 !=3D component1 )
- {
- return false;
- }
- }
- return true; // Exact match
- }
-
- /**
- * Return <code>true</code> if this <code>DeweyDec=
imal</code> is less than
- * the other <code>DeweyDecimal</code>.
- *
- * @param other the other DeweyDecimal
- * @return true if less than other DeweyDecimal, false otherwise
- */
- public boolean isLessThan( final DeweyDecimal other )
- {
- return !isGreaterThanOrEqual( other );
- }
-
- /**
- * Return <code>true</code> if this <code>DeweyDec=
imal</code> is less than
- * or equal to the other <code>DeweyDecimal</code>.
- *
- * @param other the other DeweyDecimal
- * @return true if less than or equal to other DeweyDecimal, false
- * otherwise
- */
- public boolean isLessThanOrEqual( final DeweyDecimal other )
- {
- return !isGreaterThan( other );
- }
-
- /**
- * Return <code>true</code> if this <code>DeweyDec=
imal</code> is greater
- * than the other <code>DeweyDecimal</code>.
- *
- * @param other the other DeweyDecimal
- * @return true if greater than other DeweyDecimal, false otherwise
- */
- public boolean isGreaterThan( final DeweyDecimal other )
- {
- final int max =3D Math.max( other.m_components.length,
- m_components.length );
- for( int i =3D 0; i < max; i++ )
- {
- final int component1 =3D ( i < m_components.length ) ?
- m_components[ i ] :
- 0;
- final int component2 =3D ( i < other.m_components.length =
) ?
- other.m_components[ i ] :
- 0;
- if( component2 > component1 )
- {
- return false;
- }
- if( component2 < component1 )
- {
- return true;
- }
- }
- return false; // Exact match
- }
-
- /**
- * Return <code>true</code> if this <code>DeweyDec=
imal</code> is greater
- * than or equal to the other <code>DeweyDecimal</code>.
- *
- * @param other the other DeweyDecimal
- * @return true if greater than or equal to other DeweyDecimal, fals=
e
- * otherwise
- */
- public boolean isGreaterThanOrEqual( final DeweyDecimal other )
- {
- final int max =3D Math.max( other.m_components.length,
- m_components.length );
- for( int i =3D 0; i < max; i++ )
- {
- final int component1 =3D ( i < m_components.length ) ?
- m_components[ i ] :
- 0;
- final int component2 =3D ( i < other.m_components.length =
) ?
- other.m_components[ i ] :
- 0;
- if( component2 > component1 )
- {
- return false;
- }
- if( component2 < component1 )
- {
- return true;
- }
- }
- return true; // Exact match
- }
-
- /**
- * Return string representation of <code>DeweyDecimal</code=
>.
- *
- * @return the string representation of DeweyDecimal.
- */
- public String toString()
- {
- final StringBuffer sb =3D new StringBuffer();
- for( int i =3D 0; i < m_components.length; i++ )
- {
- if( i !=3D 0 )
- {
- sb.append( '.' );
- }
- sb.append( m_components[ i ] );
- }
- return sb.toString();
- }
-}
</pre></div>
<hr /><a name=3D"file12" /><div class=3D"file">
<span class=3D"pathname" id=3D"removed"><a href=3D"http://xstream.cvs.cod=
ehaus.org/jcontainer">jcontainer</a>/<a href=3D"http://xstream.cvs.codeha=
us.org/jcontainer/loom">loom</a>/<a href=3D"http://xstream.cvs.codehaus.o=
rg/jcontainer/loom/support">support</a>/<a href=3D"http://xstream.cvs.cod=
ehaus.org/jcontainer/loom/support/extension">extension</a>/<a href=3D"htt=
p://xstream.cvs.codehaus.org/jcontainer/loom/support/extension/src">src</=
a>/<a href=3D"http://xstream.cvs.codehaus.org/jcontainer/loom/support/ext=
ension/src/java">java</a>/<a href=3D"http://xstream.cvs.codehaus.org/jcon=
tainer/loom/support/extension/src/java/org">org</a>/<a href=3D"http://xst=
ream.cvs.codehaus.org/jcontainer/loom/support/extension/src/java/org/jcon=
tainer">jcontainer</a>/<a href=3D"http://xstream.cvs.codehaus.org/jcontai=
ner/loom/support/extension/src/java/org/jcontainer/loom">loom</a>/<a href=
=3D"http://xstream.cvs.codehaus.org/jcontainer/loom/support/extension/src=
/java/org/jcontainer/loom/extension">extension</a><br /></span>
<div class=3D"fileheader" id=3D"removed"><big><b>Specification.java</b></=
big> <small id=3D"info">removed after <a href=3D"http://xstream.cvs.codeh=
aus.org/jcontainer/loom/support/extension/src/java/org/jcontainer/loom/ex=
tension/Specification.java?rev=3D1.1&content-type=3Dtext/vnd.viewcvs-=
markup">1.1</a></small></div>
<pre class=3D"diff"><small id=3D"info">diff -N Specification.java
--- Specification.java 31 Mar 2004 03:13:43 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,614 +0,0 @@
</small></pre><pre class=3D"diff" id=3D"removed">-/*
- * Copyright (C) The Spice Group. All rights reserved.
- *
- * This software is published under the terms of the Spice
- * Software License version 1.1, a copy of which has been included
- * with this distribution in the LICENSE.txt file.
- */
-package org.jcontainer.loom.extension;
-
-import java.text.ParseException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.jar.Attributes;
-import java.util.jar.Manifest;
-
-/**
- * <p>Utility class that represents either an available "Optional =
Package"
- * (formerly known as "Standard Extension") as described in the manifest=
of a
- * JAR file, or the requirement for such an optional package.</p>
- *
- * <p>For more information about optional packages, see the docume=
nt
- * <em>Optional Package Versioning</em> in the documentation=
bundle for your
- * Java2 Standard Edition package, in file <code>guide/extensions/=
versioning.html</code>.</p>
- *
- * @author Peter Donald
- * @version $Revision: 1.1 $ $Date: 2004/03/31 03:13:43 $
- */
-public final class Specification
-{
- /**
- * Manifest Attribute Name object for SPECIFICATION_TITLE.
- *
- * @see Attributes.Name#SPECIFICATION_TITLE
- */
- public static final Attributes.Name SPECIFICATION_TITLE =3D Attribut=
es.Name.SPECIFICATION_TITLE;
- /**
- * Manifest Attribute Name object for SPECIFICATION_VERSION.
- *
- * @see Attributes.Name#SPECIFICATION_VERSION
- */
- public static final Attributes.Name SPECIFICATION_VERSION =3D Attrib=
utes.Name.SPECIFICATION_VERSION;
- /**
- * Manifest Attribute Name object for SPECIFICATION_VENDOR.
- *
- * @see Attributes.Name#SPECIFICATION_VENDOR
- */
- public static final Attributes.Name SPECIFICATION_VENDOR =3D Attribu=
tes.Name.SPECIFICATION_VENDOR;
- /**
- * Manifest Attribute Name object for IMPLEMENTATION_TITLE.
- *
- * @see Attributes.Name#IMPLEMENTATION_TITLE
- */
- public static final Attributes.Name IMPLEMENTATION_TITLE =3D Attribu=
tes.Name.IMPLEMENTATION_TITLE;
- /**
- * Manifest Attribute Name object for IMPLEMENTATION_VERSION.
- *
- * @see Attributes.Name#IMPLEMENTATION_VERSION
- */
- public static final Attributes.Name IMPLEMENTATION_VERSION =3D Attri=
butes.Name.IMPLEMENTATION_VERSION;
- /**
- * Manifest Attribute Name object for IMPLEMENTATION_VENDOR.
- *
- * @see Attributes.Name#IMPLEMENTATION_VENDOR
- */
- public static final Attributes.Name IMPLEMENTATION_VENDOR =3D Attrib=
utes.Name.IMPLEMENTATION_VENDOR;
- /**
- * Enum indicating that extension is compatible with other Package
- * Specification.
- */
- public static final Compatability COMPATIBLE =3D
- new Compatability( "COMPATIBLE" );
- /**
- * Enum indicating that extension requires an upgrade of specificati=
on to be
- * compatible with other Package Specification.
- */
- public static final Compatability REQUIRE_SPECIFICATION_UPGRADE =3D
- new Compatability( "REQUIRE_SPECIFICATION_UPGRADE" );
- /**
- * Enum indicating that extension requires a vendor switch to be com=
patible
- * with other Package Specification.
- */
- public static final Compatability REQUIRE_VENDOR_SWITCH =3D
- new Compatability( "REQUIRE_VENDOR_SWITCH" );
- /**
- * Enum indicating that extension requires an upgrade of implementat=
ion to
- * be compatible with other Package Specification.
- */
- public static final Compatability REQUIRE_IMPLEMENTATION_CHANGE =3D
- new Compatability( "REQUIRE_IMPLEMENTATION_CHANGE" );
- /**
- * Enum indicating that extension is incompatible with other Package
- * Specification in ways other than other enums indicate). ie For ex=
ample
- * the other Package Specification may have a different ID.
- */
- public static final Compatability INCOMPATIBLE =3D
- new Compatability( "INCOMPATIBLE" );
- /** The name of the Package Specification. */
- private String m_specificationTitle;
- /**
- * The version number (dotted decimal notation) of the specification=
to
- * which this optional package conforms.
- */
- private DeweyDecimal m_specificationVersion;
- /**
- * The name of the company or organization that originated the speci=
fication
- * to which this specification conforms.
- */
- private String m_specificationVendor;
- /** The title of implementation. */
- private String m_implementationTitle;
- /**
- * The name of the company or organization that produced this implem=
entation
- * of this specification.
- */
- private String m_implementationVendor;
- /**
- * The version string for implementation. The version string is opaq=
ue.
- */
- private String m_implementationVersion;
- /** The sections of jar that the specification applies to. */
- private String[] m_sections;
-
- /**
- * Return an array of <code>Package Specification</code>=
objects. If there
- * are no such optional packages, a zero-length array is returned.
- *
- * @param manifest Manifest to be parsed
- * @return the Package Specifications extensions in specified manife=
st
- */
- public static Specification[] getSpecifications( final Manifest mani=
fest )
- throws ParseException
- {
- if( null =3D=3D manifest )
- {
- return new Specification[ 0 ];
- }
- final ArrayList results =3D new ArrayList();
- final Map entries =3D manifest.getEntries();
- final Iterator keys =3D entries.keySet().iterator();
- while( keys.hasNext() )
- {
- final String key =3D (String)keys.next();
- final Attributes attributes =3D (Attributes)entries.get( key=
);
- final Specification specification =3D getSpecification( key,
- attrib=
utes );
- if( null !=3D specification )
- {
- results.add( specification );
- }
- }
- final ArrayList trimmedResults =3D removeDuplicates( results );
- return (Specification[])trimmedResults.toArray( new Specificatio=
n[ 0 ] );
- }
-
- /**
- * The constructor to create Package Specification object. Note that=
every
- * component is allowed to be specified but only the specificationTi=
tle is
- * mandatory.
- *
- * @param specificationTitle the name of specification.
- * @param specificationVersion the specification Version.
- * @param specificationVendor the specification Vendor.
- * @param implementationTitle the title of implementation.
- * @param implementationVersion the implementation Version.
- * @param implementationVendor the implementation Vendor.
- */
- public Specification( final String specificationTitle,
- final String specificationVersion,
- final String specificationVendor,
- final String implementationTitle,
- final String implementationVersion,
- final String implementationVendor )
- {
- this( specificationTitle, specificationVersion, specificationVen=
dor,
- implementationTitle, implementationVersion, implementation=
Vendor,
- null );
- }
-
- /**
- * The constructor to create Package Specification object. Note that=
every
- * component is allowed to be specified but only the specificationTi=
tle is
- * mandatory.
- *
- * @param specificationTitle the name of specification.
- * @param specificationVersion the specification Version.
- * @param specificationVendor the specification Vendor.
- * @param implementationTitle the title of implementation.
- * @param implementationVersion the implementation Version.
- * @param implementationVendor the implementation Vendor.
- * @param sections the sections/packages that Specification applies =
to.
- */
- public Specification( final String specificationTitle,
- final String specificationVersion,
- final String specificationVendor,
- final String implementationTitle,
- final String implementationVersion,
- final String implementationVendor,
- final String[] sections )
- {
- if( null =3D=3D specificationTitle )
- {
- throw new NullPointerException( "specificationTitle" );
- }
- m_specificationTitle =3D specificationTitle;
- m_specificationVendor =3D specificationVendor;
- if( null !=3D specificationVersion )
- {
- try
- {
- m_specificationVersion =3D
- new DeweyDecimal( specificationVersion );
- }
- catch( final NumberFormatException nfe )
- {
- final String error =3D "Bad specification version format=
'" +
- specificationVersion +
- "' in '" + specificationTitle + "'. (Reason: " + nfe=
+ ")";
- throw new IllegalArgumentException( error );
- }
- }
- m_implementationTitle =3D implementationTitle;
- m_implementationVendor =3D implementationVendor;
- m_implementationVersion =3D implementationVersion;
- String[] copy =3D null;
- if( null !=3D sections )
- {
- copy =3D new String[ sections.length ];
- System.arraycopy( sections, 0, copy, 0, sections.length );
- }
- m_sections =3D copy;
- }
-
- /**
- * Get the title of the specification.
- *
- * @return the title of speciication
- */
- public String getSpecificationTitle()
- {
- return m_specificationTitle;
- }
-
- /**
- * Get the vendor of the specification.
- *
- * @return the vendor of the specification.
- */
- public String getSpecificationVendor()
- {
- return m_specificationVendor;
- }
-
- /**
- * Get the title of the specification.
- *
- * @return the title of the specification.
- */
- public String getImplementationTitle()
- {
- return m_implementationTitle;
- }
-
- /**
- * Get the version of the specification.
- *
- * @return the version of the specification.
- */
- public DeweyDecimal getSpecificationVersion()
- {
- return m_specificationVersion;
- }
-
- /**
- * Get the vendor of the extensions implementation.
- *
- * @return the vendor of the extensions implementation.
- */
- public String getImplementationVendor()
- {
- return m_implementationVendor;
- }
-
- /**
- * Get the version of the implementation.
- *
- * @return the version of the implementation.
- */
- public String getImplementationVersion()
- {
- return m_implementationVersion;
- }
-
- /**
- * Return an array containing sections to which specification applie=
s or
- * null if relevant to no sections.
- *
- * @return an array containing sections to which specification appli=
es or
- * null if relevant to no sections.
- */
- public String[] getSections()
- {
- if( null =3D=3D m_sections )
- {
- return null;
- }
- else
- {
- final String[] sections =3D new String[ m_sections.length ];
- System.arraycopy( m_sections, 0, sections, 0, m_sections.len=
gth );
- return sections;
- }
- }
-
- /**
- * Return a Compatibility enum indicating the relationship of this
- * <code>Package Specification</code> with the specified
- * <code>Extension</code>.
- *
- * @param other the other specification
- * @return the enum indicating the compatability (or lack thereof) o=
f
- * specifed Package Specification
- */
- public Compatability getCompatibilityWith( final Specification other=
)
- {
- // Specification Name must match
- if( !m_specificationTitle.equals( other.getSpecificationTitle() =
) )
- {
- return INCOMPATIBLE;
- }
- // Available specification version must be >=3D required
- final DeweyDecimal specificationVersion =3D other.getSpecificati=
onVersion();
- if( null !=3D specificationVersion )
- {
- if( null =3D=3D m_specificationVersion ||
- !isCompatible( m_specificationVersion, specificationVers=
ion ) )
- {
- return REQUIRE_SPECIFICATION_UPGRADE;
- }
- }
- // Implementation Vendor ID must match
- final String implementationVendor =3D other.getImplementationVen=
dor();
- if( null !=3D implementationVendor )
- {
- if( null =3D=3D m_implementationVendor ||
- !m_implementationVendor.equals( implementationVendor ) )
- {
- return REQUIRE_VENDOR_SWITCH;
- }
- }
- // Implementation version must be >=3D required
- final String implementationVersion =3D other.getImplementationVe=
rsion();
- if( null !=3D implementationVersion )
- {
- if( null =3D=3D m_implementationVersion ||
- !m_implementationVersion.equals( implementationVersion )=
)
- {
- return REQUIRE_IMPLEMENTATION_CHANGE;
- }
- }
- // This available optional package satisfies the requirements
- return COMPATIBLE;
- }
-
- /**
- * Return <code>true</code> if the specified <code>=
;package</code> is
- * satisfied by this <code>Specification</code>. Otherwi=
se, return
- * <code>false</code>.
- *
- * @param other the specification
- * @return true if the specification is compatible with this specifi=
cation
- */
- public boolean isCompatibleWith( final Specification other )
- {
- return ( COMPATIBLE =3D=3D getCompatibilityWith( other ) );
- }
-
- /**
- * Return a String representation of this object.
- *
- * @return string representation of object.
- */
- public String toString()
- {
- final String lineSeparator =3D System.getProperty( "line.separat=
or" );
- final String brace =3D ": ";
- final StringBuffer sb =3D new StringBuffer(
- SPECIFICATION_TITLE.toString() );
- sb.append( brace );
- sb.append( m_specificationTitle );
- sb.append( lineSeparator );
- if( null !=3D m_specificationVersion )
- {
- sb.append( SPECIFICATION_VERSION );
- sb.append( brace );
- sb.append( m_specificationVersion );
- sb.append( lineSeparator );
- }
- if( null !=3D m_specificationVendor )
- {
- sb.append( SPECIFICATION_VENDOR );
- sb.append( brace );
- sb.append( m_specificationVendor );
- sb.append( lineSeparator );
- }
- if( null !=3D m_implementationTitle )
- {
- sb.append( IMPLEMENTATION_TITLE );
- sb.append( brace );
- sb.append( m_implementationTitle );
- sb.append( lineSeparator );
- }
- if( null !=3D m_implementationVersion )
- {
- sb.append( IMPLEMENTATION_VERSION );
- sb.append( brace );
- sb.append( m_implementationVersion );
- sb.append( lineSeparator );
- }
- if( null !=3D m_implementationVendor )
- {
- sb.append( IMPLEMENTATION_VENDOR );
- sb.append( brace );
- sb.append( m_implementationVendor );
- sb.append( lineSeparator );
- }
- return sb.toString();
- }
-
- /**
- * Return <code>true</code> if the first version number =
is greater than or
- * equal to the second; otherwise return <code>false</code&=
gt;.
- *
- * @param first First version number (dotted decimal)
- * @param second Second version number (dotted decimal)
- */
- private boolean isCompatible( final DeweyDecimal first,
- final DeweyDecimal second )
- {
- return first.isGreaterThanOrEqual( second );
- }
-
- /**
- * Combine all specifications objects that are identical except for =
the
- * sections.
- *
- * <p>Note this is very inefficent and should probably be fixe=
d in the
- * future.</p>
- *
- * @param list the array of results to trim
- * @return an array list with all duplicates removed
- */
- private static ArrayList removeDuplicates( final ArrayList list )
- {
- final ArrayList results =3D new ArrayList();
- final ArrayList sections =3D new ArrayList();
- while( list.size() > 0 )
- {
- final Specification specification =3D (Specification)list.re=
move( 0 );
- final Iterator iterator =3D list.iterator();
- while( iterator.hasNext() )
- {
- final Specification other =3D (Specification)iterator.ne=
xt();
- if( isEqual( specification, other ) )
- {
- final String[] otherSections =3D other.getSections()=
;
- if( null !=3D sections )
- {
- sections.addAll( Arrays.asList( otherSections ) =
);
- }
- iterator.remove();
- }
- }
- final Specification merged =3D
- mergeInSections( specification, sections );
- results.add( merged );
- //Reset list of sections
- sections.clear();
- }
- return results;
- }
-
- /**
- * Test if two specifications are equal except for their sections.
- *
- * @param specification one specificaiton
- * @param other the ohter specification
- * @return true if two specifications are equal except for their sec=
tions,
- * else false
- */
- private static boolean isEqual( final Specification specification,
- final Specification other )
- {
- return
- specification.getSpecificationTitle().equals(
- other.getSpecificationTitle() ) &&
- specification.getSpecificationVersion().isEqual(
- other.getSpecificationVersion() ) &&
- specification.getSpecificationVendor().equals(
- other.getSpecificationVendor() ) &&
- specification.getImplementationTitle().equals(
- other.getImplementationTitle() ) &&
- specification.getImplementationVersion().equals(
- other.getImplementationVersion() ) &&
- specification.getImplementationVendor().equals(
- other.getImplementationVendor() );
- }
-
- /**
- * Merge the specified sections into specified section and return re=
sult. If
- * no sections to be added then just return original specification.
- *
- * @param specification the specification
- * @param sectionsToAdd the list of sections to merge
- * @return the merged specification
- */
- private static Specification mergeInSections(
- final Specification specification,
- final ArrayList sectionsToAdd )
- {
- if( 0 =3D=3D sectionsToAdd.size() )
- {
- return specification;
- }
- else
- {
- sectionsToAdd.addAll( Arrays.asList( specification.getSectio=
ns() ) );
- final String[] sections =3D
- (String[])sectionsToAdd.toArray(
- new String[ sectionsToAdd.size() ] );
- return new Specification( specification.getSpecificationTitl=
e(),
- specification.getSpecificationVers=
ion()
- .toString(),
- specification.getSpecificationVend=
or(),
- specification.getImplementationTit=
le(),
- specification.getImplementationVer=
sion(),
- specification.getImplementationVen=
dor(),
- sections );
- }
- }
-
- /**
- * Trim the supplied string if the string is non-null
- *
- * @param value the string to trim or null
- * @return the trimmed string or null
- */
- private static String getTrimmedString( final String value )
- {
- if( null =3D=3D value )
- {
- return null;
- }
- else
- {
- return value.trim();
- }
- }
-
- /**
- * Extract an Package Specification from Attributes.
- *
- * @param attributes Attributes to searched
- * @return the new Specification object, or null
- */
- private static Specification getSpecification( final String section,
- final Attributes attr=
ibutes )
- throws ParseException
- {
- //WARNING: We trim the values of all the attributes because
- //Some extension declarations are badly defined (ie have spaces
- //after version or vendor)
- final String name =3D getTrimmedString(
- attributes.getValue( SPECIFICATION_TITLE ) );
- if( null =3D=3D name )
- {
- return null;
- }
- final String specVendor =3D getTrimmedString(
- attributes.getValue( SPECIFICATION_VENDOR ) );
- if( null =3D=3D specVendor )
- {
- throw new ParseException( "Missing " + SPECIFICATION_VENDOR,=
0 );
- }
- final String specVersion =3D getTrimmedString(
- attributes.getValue( SPECIFICATION_VERSION ) );
- if( null =3D=3D specVersion )
- {
- throw new ParseException( "Missing " + SPECIFICATION_VERSION=
, 0 );
- }
- final String impTitle =3D getTrimmedString(
- attributes.getValue( IMPLEMENTATION_TITLE ) );
- if( null =3D=3D impTitle )
- {
- throw new ParseException( "Missing " + IMPLEMENTATION_TITLE,=
0 );
- }
- final String impVersion =3D getTrimmedString(
- attributes.getValue( IMPLEMENTATION_VERSION ) );
- if( null =3D=3D impVersion )
- {
- throw new ParseException( "Missing " + IMPLEMENTATION_VERSIO=
N, 0 );
- }
- final String impVendor =3D getTrimmedString(
- attributes.getValue( IMPLEMENTATION_VENDOR ) );
- if( null =3D=3D impVendor )
- {
- throw new ParseException( "Missing " + IMPLEMENTATION_VENDOR=
, 0 );
- }
- return new Specification( name, specVersion, specVendor,
- impTitle, impVersion, impVendor,
- new String[]{section} );
- }
-}
</pre></div>
<hr /><a name=3D"file13" /><div class=3D"file">
<span class=3D"pathname" id=3D"removed"><a href=3D"http://xstream.cvs.cod=
ehaus.org/jcontainer">jcontainer</a>/<a href=3D"http://xstream.cvs.codeha=
us.org/jcontainer/loom">loom</a>/<a href=3D"http://xstream.cvs.codehaus.o=
rg/jcontainer/loom/support">support</a>/<a href=3D"http://xstream.cvs.cod=
ehaus.org/jcontainer/loom/support/extension">extension</a>/<a href=3D"htt=
p://xstream.cvs.codehaus.org/jcontainer/loom/support/extension/src">src</=
a>/<a href=3D"http://xstream.cvs.codehaus.org/jcontainer/loom/support/ext=
ension/src/test">test</a>/<a href=3D"http://xstream.cvs.codehaus.org/jcon=
tainer/loom/support/extension/src/test/org">org</a>/<a href=3D"http://xst=
ream.cvs.codehaus.org/jcontainer/loom/support/extension/src/test/org/jcon=
tainer">jcontainer</a>/<a href=3D"http://xstream.cvs.codehaus.org/jcontai=
ner/loom/support/extension/src/test/org/jcontainer/loom">loom</a>/<a href=
=3D"http://xstream.cvs.codehaus.org/jcontainer/loom/support/extension/src=
/test/org/jcontainer/loom/extension">extension</a><br /></span>
<div class=3D"fileheader" id=3D"removed"><big><b>ExtensionTestCase.java</=
b></big> <small id=3D"info">removed after <a href=3D"http://xstream.cvs.c=
odehaus.org/jcontainer/loom/support/extension/src/test/org/jcontainer/loo=
m/extension/ExtensionTestCase.java?rev=3D1.1&content-type=3Dtext/vnd.=
viewcvs-markup">1.1</a></small></div>
<pre class=3D"diff"><small id=3D"info">diff -N ExtensionTestCase.java
--- ExtensionTestCase.java 31 Mar 2004 03:13:43 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,381 +0,0 @@
</small></pre><pre class=3D"diff" id=3D"removed">-/*
- * Copyright (C) The Spice Group. All rights reserved.
- *
- * This software is published under the terms of the Spice
- * Software License version 1.1, a copy of which has been included
- * with this distribution in the LICENSE.txt file.
- */
-package org.jcontainer.loom.extension;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.util.jar.Manifest;
-import junit.framework.TestCase;
-
-/**
- * TestCases for Extension.
- *
- * @author Peter Donald
- * @version $Revision: 1.1 $ $Date: 2004/03/31 03:13:43 $
- */
-public class ExtensionTestCase
- extends TestCase
-{
- public void testAvailable()
- throws Exception
- {
- final String manifestString =3D
- "Manifest-Version: 1.0\n" +
- "Extension-Name: spice-configkit\n" +
- "Specification-Version: 1.0\n" +
- "Specification-Vendor: Spice Group\n" +
- "Implementation-Vendor-Id: org.realityforge.spice\n" +
- "Implementation-Vendor: Spice Group\n" +
- "Implementation-Version: 2.8Alpha\n";
- final Manifest manifest =3D getManifest( manifestString );
-
- final Extension[] required =3D Extension.getRequired( manifest )=
;
- assertEquals( "required Count", 0, required.length );
-
- final Extension[] available =3D Extension.getAvailable( manifest=
);
-
- assertEquals( "Available Count", 1, available.length );
- assertEquals( "Available Name", "spice-configkit",
- available[ 0 ].getExtensionName() );
- assertEquals( "Available SpecVendor", "Spice Group",
- available[ 0 ].getSpecificationVendor() );
- assertEquals( "Available SpecVersion", "1.0",
- available[ 0 ].getSpecificationVersion().toString(=
) );
- assertEquals( "Available URL",
- null,
- available[ 0 ].getImplementationURL() );
- assertEquals( "Available ImpVendor", "Spice Group",
- available[ 0 ].getImplementationVendor() );
- assertEquals( "Available ImpVendorId", "org.realityforge.spice",
- available[ 0 ].getImplementationVendorID() );
- assertEquals( "Available ImpVersion", "2.8Alpha",
- available[ 0 ].getImplementationVersion().toString=
() );
- }
-
- public void testRequired()
- throws Exception
- {
- final String manifestString =3D
- "Manifest-Version: 1.0\n" +
- "Extension-List: required1\n" +
- "required1-Extension-Name: spice.required1\n" +
- "required1-Specification-Version: 1.0\n" +
- "required1-Implementation-Version: 1.0.2\n" +
- "required1-Implementation-Vendor-Id: org.realityforge.spice\=
n" +
- "required1-Implementation-URL: http://spice.codehaus.org/req=
uired1.jar\n";
- final Manifest manifest =3D getManifest( manifestString );
-
- final Extension[] available =3D Extension.getAvailable( manifest=
);
- assertEquals( "available Count", 0, available.length );
-
- final Extension[] required =3D Extension.getRequired( manifest )=
;
-
- assertEquals( "required Count", 1, required.length );
- assertEquals( "required Name", "spice.required1",
- required[ 0 ].getExtensionName() );
- assertEquals( "required SpecVendor", null,
- required[ 0 ].getSpecificationVendor() );
- assertEquals( "required SpecVersion", "1.0",
- required[ 0 ].getSpecificationVersion().toString()=
);
- assertEquals( "required URL", "http://spice.codehaus.org/require=
d1.jar",
- required[ 0 ].getImplementationURL() );
- assertEquals( "required ImpVendor", null,
- required[ 0 ].getImplementationVendor() );
- assertEquals( "required ImpVendorId", "org.realityforge.spice",
- required[ 0 ].getImplementationVendorID() );
- assertEquals( "required ImpVersion", "1.0.2",
- required[ 0 ].getImplementationVersion().toString(=
) );
- }
-
- public void testMultiRequired()
- throws Exception
- {
- final String manifestString =3D
- "Manifest-Version: 1.0\n" +
- "Extension-List: required1 required2\n" +
- "required1-Extension-Name: spice.required1\n" +
- "required1-Specification-Version: 1.0\n" +
- "required1-Implementation-Version: 1.0.2\n" +
- "required1-Implementation-Vendor-Id: org.realityforge.spice\=
n" +
- "required1-Implementation-URL: http://spice.codehaus.org/req=
uired1.jar\n" +
- "required2-Extension-Name: spice.required2\n" +
- "required2-Specification-Version: 1.0\n" +
- "required2-Implementation-Version: 1.0.2\n" +
- "required2-Implementation-Vendor-Id: org.realityforge.spice\=
n" +
- "required2-Implementation-URL: http://spice.codehaus.org/req=
uired2.jar\n";
- final Manifest manifest =3D getManifest( manifestString );
-
- final Extension[] available =3D Extension.getAvailable( manifest=
);
- assertEquals( "available Count", 0, available.length );
-
- final Extension[] required =3D Extension.getRequired( manifest )=
;
- assertEquals( "required Count", 2, required.length );
- assertEquals( "required Name", "spice.required1",
- required[ 0 ].getExtensionName() );
- assertEquals( "required SpecVendor", null,
- required[ 0 ].getSpecificationVendor() );
- assertEquals( "required SpecVersion", "1.0",
- required[ 0 ].getSpecificationVersion().toString()=
);
- assertEquals( "required URL", "http://spice.codehaus.org/require=
d1.jar",
- required[ 0 ].getImplementationURL() );
- assertEquals( "required ImpVendor", null,
- required[ 0 ].getImplementationVendor() );
- assertEquals( "required ImpVendorId", "org.realityforge.spice",
- required[ 0 ].getImplementationVendorID() );
- assertEquals( "required ImpVersion", "1.0.2",
- required[ 0 ].getImplementationVersion().toString(=
) );
-
- assertEquals( "required Name", "spice.required2",
- required[ 1 ].getExtensionName() );
- assertEquals( "required SpecVendor", null,
- required[ 1 ].getSpecificationVendor() );
- assertEquals( "required SpecVersion", "1.0",
- required[ 1 ].getSpecificationVersion().toString()=
);
- assertEquals( "required URL", "http://spice.codehaus.org/require=
d2.jar",
- required[ 1 ].getImplementationURL() );
- assertEquals( "required ImpVendor", null,
- required[ 1 ].getImplementationVendor() );
- assertEquals( "required ImpVendorId", "org.realityforge.spice",
- required[ 1 ].getImplementationVendorID() );
- assertEquals( "required ImpVersion", "1.0.2",
- required[ 1 ].getImplementationVersion().toString(=
) );
- }
-
- public void testAvailableAndRequired()
- throws Exception
- {
- final String manifestString =3D
- "Manifest-Version: 1.0\n" +
- "Extension-Name: spice-configkit\n" +
- "Specification-Version: 1.0\n" +
- "Specification-Vendor: Spice Group\n" +
- "Implementation-Vendor-Id: org.realityforge.spice\n" +
- "Implementation-Vendor: Spice Group\n" +
- "Implementation-Version: 2.8Alpha\n" +
- "Extension-List: required1\n" +
- "required1-Extension-Name: spice.required1\n" +
- "required1-Specification-Version: 1.0\n" +
- "required1-Implementation-Version: 1.0.2\n" +
- "required1-Implementation-Vendor-Id: org.realityforge.spice\=
n" +
- "required1-Implementation-URL: http://spice.codehaus.org/req=
uired1.jar\n";
- final Manifest manifest =3D getManifest( manifestString );
-
- final Extension[] available =3D Extension.getAvailable( manifest=
);
- assertEquals( "Available Count", 1, available.length );
- assertEquals( "Available Name", "spice-configkit",
- available[ 0 ].getExtensionName() );
- assertEquals( "Available SpecVendor", "Spice Group",
- available[ 0 ].getSpecificationVendor() );
- assertEquals( "Available SpecVersion", "1.0",
- available[ 0 ].getSpecificationVersion().toString(=
) );
- assertEquals( "Available URL",
- null,
- available[ 0 ].getImplementationURL() );
- assertEquals( "Available ImpVendor", "Spice Group",
- available[ 0 ].getImplementationVendor() );
- assertEquals( "Available ImpVendorId", "org.realityforge.spice",
- available[ 0 ].getImplementationVendorID() );
- assertEquals( "Available ImpVersion", "2.8Alpha",
- available[ 0 ].getImplementationVersion().toString=
() );
-
- final Extension[] required =3D Extension.getRequired( manifest )=
;
- assertEquals( "required Count", 1, required.length );
- assertEquals( "required Name", "spice.required1",
- required[ 0 ].getExtensionName() );
- assertEquals( "required SpecVendor", null,
- required[ 0 ].getSpecificationVendor() );
- assertEquals( "required SpecVersion", "1.0",
- required[ 0 ].getSpecificationVersion().toString()=
);
- assertEquals( "required URL", "http://spice.codehaus.org/require=
d1.jar",
- required[ 0 ].getImplementationURL() );
- assertEquals( "required ImpVendor", null,
- required[ 0 ].getImplementationVendor() );
- assertEquals( "required ImpVendorId", "org.realityforge.spice",
- required[ 0 ].getImplementationVendorID() );
- assertEquals( "required ImpVersion", "1.0.2",
- required[ 0 ].getImplementationVersion().toString(=
) );
- }
-
- public void testRequiredWithSpacesAfterAttributes()
- throws Exception
- {
- final String manifestString =3D
- "Manifest-Version: 1.0 \n" +
- "Extension-List: required1 \n" +
- "required1-Extension-Name: spice.required1 \n" +
- "required1-Specification-Version: 1.0 \n" +
- "required1-Implementation-Version: 1.0.2 \n" +
- "required1-Implementation-Vendor-Id: org.realityforge.spice =
\n" +
- "required1-Implementation-URL: http://spice.codehaus.org/req=
uired1.jar \n";
- final Manifest manifest =3D getManifest( manifestString );
-
- final Extension[] available =3D Extension.getAvailable( manifest=
);
- assertEquals( "available Count", 0, available.length );
-
- final Extension[] required =3D Extension.getRequired( manifest )=
;
-
- assertEquals( "required Count", 1, required.length );
- assertEquals( "required Name", "spice.required1",
- required[ 0 ].getExtensionName() );
- assertEquals( "required SpecVendor", null,
- required[ 0 ].getSpecificationVendor() );
- assertEquals( "required SpecVersion", "1.0",
- required[ 0 ].getSpecificationVersion().toString()=
);
- assertEquals( "required URL", "http://spice.codehaus.org/require=
d1.jar",
- required[ 0 ].getImplementationURL() );
- assertEquals( "required ImpVendor", null,
- required[ 0 ].getImplementationVendor() );
- assertEquals( "required ImpVendorId", "org.realityforge.spice",
- required[ 0 ].getImplementationVendorID() );
- assertEquals( "required ImpVersion", "1.0.2",
- required[ 0 ].getImplementationVersion().toString(=
) );
- }
-
- public void testAvailableWithSpacesAfterAttributes()
- throws Exception
- {
- final String manifestString =3D
- "Manifest-Version: 1.0\n" +
- "Extension-Name: spice-configkit \n" +
- "Specification-Version: 1.0 \n" +
- "Specification-Vendor: Spice Group \n" +
- "Implementation-Vendor-Id: org.realityforge.spice \n" +
- "Implementation-Vendor: Spice Group \n" +
- "Implementation-Version: 2.8Alpha \n";
- final Manifest manifest =3D getManifest( manifestString );
-
- final Extension[] required =3D Extension.getRequired( manifest )=
;
- assertEquals( "required Count", 0, required.length );
-
- final Extension[] available =3D Extension.getAvailable( manifest=
);
-
- assertEquals( "Available Count", 1, available.length );
- assertEquals( "Available Name", "spice-configkit",
- available[ 0 ].getExtensionName() );
- assertEquals( "Available SpecVendor", "Spice Group",
- available[ 0 ].getSpecificationVendor() );
- assertEquals( "Available SpecVersion", "1.0",
- available[ 0 ].getSpecificationVersion().toString(=
) );
- assertEquals( "Available URL",
- null,
- available[ 0 ].getImplementationURL() );
- assertEquals( "Available ImpVendor", "Spice Group",
- available[ 0 ].getImplementationVendor() );
- assertEquals( "Available ImpVendorId", "org.realityforge.spice",
- available[ 0 ].getImplementationVendorID() );
- assertEquals( "Available ImpVersion", "2.8Alpha",
- available[ 0 ].getImplementationVersion().toString=
() );
- }
-
- public void testCompatabilityRezultsIncompatability()
- throws Exception
- {
- final Extension extension1 =3D
- new Extension( "baz", null, null, null, null, null, null );
- final Extension extension2 =3D
- new Extension( "foo", null, null, null, null, null, null );
- assertEquals( Extension.INCOMPATIBLE,
- extension1.getCompatibilityWith( extension2 ) );
- }
-
- public void testCompatabilityRezultsNeedSpecUpgrade()
- throws Exception
- {
- final Extension extension1 =3D
- new Extension( "baz", "1.0", null, null, null, null, null );
- final Extension extension2 =3D
- new Extension( "baz", "1.1", null, null, null, null, null );
- assertEquals( Extension.REQUIRE_SPECIFICATION_UPGRADE,
- extension1.getCompatibilityWith( extension2 ) );
- }
-
- public void testCompatabilityRezultsCompatLowerVersion()
- throws Exception
- {
- final Extension extension1 =3D
- new Extension( "baz", "1.0", null, null, null, null, null );
- final Extension extension2 =3D
- new Extension( "baz", "0.9", null, null, null, null, null );
- assertEquals( Extension.COMPATIBLE,
- extension1.getCompatibilityWith( extension2 ) );
- }
-
- public void testCompatabilityRezultsCompatEqVersion()
- throws Exception
- {
- final Extension extension1 =3D
- new Extension( "baz", "1.0", null, null, null, null, null );
- final Extension extension2 =3D
- new Extension( "baz", "1.0", null, null, null, null, null );
- assertEquals( Extension.COMPATIBLE,
- extension1.getCompatibilityWith( extension2 ) );
- }
-
- public void testCompatabilityRezultsInCompatWIthNonNullSpecVersion()
- throws Exception
- {
- final Extension extension1 =3D
- new Extension( "baz", null, null, null, null, null, null );
- final Extension extension2 =3D
- new Extension( "baz", "1.0", null, null, null, null, null );
- assertEquals( Extension.REQUIRE_SPECIFICATION_UPGRADE,
- extension1.getCompatibilityWith( extension2 ) );
- }
-
- public void testCompatabilityRezultsInCompatWIthNullSpecVersion()
- throws Exception
- {
- final Extension extension1 =3D
- new Extension( "baz", "1.0", null, null, null, null, null );
- final Extension extension2 =3D
- new Extension( "baz", null, null, null, null, null, null );
- assertEquals( Extension.COMPATIBLE,
- extension1.getCompatibilityWith( extension2 ) );
- }
-
- public void testCompatabilityRezultsInCompatForVendorID()
- throws Exception
- {
- final Extension extension1 =3D
- new Extension( "baz", null, null, null, null, "Bob", null );
- final Extension extension2 =3D
- new Extension( "baz", null, null, null, null, "Bob", null );
- assertEquals( Extension.COMPATIBLE,
- extension1.getCompatibilityWith( extension2 ) );
- }
-
- public void testCompatabilityRezultsInCompatForNullVendorID()
- throws Exception
- {
- final Extension extension1 =3D
- new Extension( "baz", null, null, null, null, null, null );
- final Extension extension2 =3D
- new Extension( "baz", null, null, null, null, "Bob", null );
- assertEquals( Extension.REQUIRE_VENDOR_SWITCH,
- extension1.getCompatibilityWith( extension2 ) );
- }
-
- public void testCompatabilityRezultsInIncompatForNullVendorID()
- throws Exception
- {
- final Extension extension1 =3D
- new Extension( "baz", null, null, null, null, null, null );
- final Extension extension2 =3D
- new Extension( "baz", null, null, null, null, "Bob", null );
- assertEquals( Extension.REQUIRE_VENDOR_SWITCH,
- extension1.getCompatibilityWith( extension2 ) );
- }
-
- private Manifest getManifest( final String manifestString )
- throws IOException
- {
- final ByteArrayInputStream stream =3D
- new ByteArrayInputStream( manifestString.getBytes() );
- return new Manifest( stream );
- }
-}
</pre><pre class=3D"diff"><small id=3D"info">\ No newline at end of file
</small></pre></div>
<hr /><a name=3D"file14" /><div class=3D"file">
<span class=3D"pathname" id=3D"removed"><a href=3D"http://xstream.cvs.cod=
ehaus.org/jcontainer">jcontainer</a>/<a href=3D"http://xstream.cvs.codeha=
us.org/jcontainer/loom">loom</a>/<a href=3D"http://xstream.cvs.codehaus.o=
rg/jcontainer/loom/support">support</a>/<a href=3D"http://xstream.cvs.cod=
ehaus.org/jcontainer/loom/support/extension">extension</a>/<a href=3D"htt=
p://xstream.cvs.codehaus.org/jcontainer/loom/support/extension/src">src</=
a>/<a href=3D"http://xstream.cvs.codehaus.org/jcontainer/loom/support/ext=
ension/src/test">test</a>/<a href=3D"http://xstream.cvs.codehaus.org/jcon=
tainer/loom/support/extension/src/test/org">org</a>/<a href=3D"http://xst=
ream.cvs.codehaus.org/jcontainer/loom/support/extension/src/test/org/jcon=
tainer">jcontainer</a>/<a href=3D"http://xstream.cvs.codehaus.org/jcontai=
ner/loom/support/extension/src/test/org/jcontainer/loom">loom</a>/<a href=
=3D"http://xstream.cvs.codehaus.org/jcontainer/loom/support/extension/src=
/test/org/jcontainer/loom/extension">extension</a><br /></span>
<div class=3D"fileheader" id=3D"removed"><big><b>DeweyDecimalTestCase.jav=
a</b></big> <small id=3D"info">removed after <a href=3D"http://xstream.cv=
s.codehaus.org/jcontainer/loom/support/extension/src/test/org/jcontainer/=
loom/extension/DeweyDecimalTestCase.java?rev=3D1.1&content-type=3Dtex=
t/vnd.viewcvs-markup">1.1</a></small></div>
<pre class=3D"diff"><small id=3D"info">diff -N DeweyDecimalTestCase.java
--- DeweyDecimalTestCase.java 31 Mar 2004 03:13:43 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,263 +0,0 @@
</small></pre><pre class=3D"diff" id=3D"removed">-/*
- * Copyright (C) The Spice Group. All rights reserved.
- *
- * This software is published under the terms of the Spice
- * Software License version 1.1, a copy of which has been included
- * with this distribution in the LICENSE.txt file.
- */
-package org.jcontainer.loom.extension;
-
-import junit.framework.TestCase;
-
-/**
- * TestCases for DeweyDecimal.
- *
- * @author Peter Donald
- * @version $Revision: 1.1 $ $Date: 2004/03/31 03:13:43 $
- */
-public class DeweyDecimalTestCase
- extends TestCase
-{
- private static final String DD1 =3D "1";
- private static final String DD2 =3D "1.0.1";
- private static final String DD3 =3D "1.0.2";
- private static final String DD4 =3D "0.9.0.2";
- private static final String DD5 =3D "2.0.9";
- private static final String DD6 =3D "2..9";
- private static final String DD7 =3D ".9";
- private static final String DD8 =3D "9.";
-
- public void testParse()
- throws Exception
- {
- final DeweyDecimal dd1 =3D new DeweyDecimal( DD1 );
- final DeweyDecimal dd2 =3D new DeweyDecimal( DD2 );
- final DeweyDecimal dd3 =3D new DeweyDecimal( DD3 );
- final DeweyDecimal dd4 =3D new DeweyDecimal( DD4 );
- final DeweyDecimal dd5 =3D new DeweyDecimal( DD5 );
- assertEquals( "DeweyDecimal 1", DD1, dd1.toString() );
- assertEquals( "DeweyDecimal 2", DD2, dd2.toString() );
- assertEquals( "DeweyDecimal 3", DD3, dd3.toString() );
- assertEquals( "DeweyDecimal 4", DD4, dd4.toString() );
- assertEquals( "DeweyDecimal 5", DD5, dd5.toString() );
- }
-
- public void testMalParse()
- throws Exception
- {
- try
- {
- new DeweyDecimal( DD6 );
- fail( "DeweyDecimal 6 parsed!" );
- }
- catch( final NumberFormatException nfe )
- {
- }
- try
- {
- new DeweyDecimal( DD7 );
- fail( "DeweyDecimal 7 parsed!" );
- }
- catch( final NumberFormatException nfe )
- {
- }
- try
- {
- new DeweyDecimal( DD8 );
- fail( "DeweyDecimal 8 parsed!" );
- }
- catch( final NumberFormatException nfe )
- {
- }
- }
-
- public void testGreaterThan()
- throws Exception
- {
- final DeweyDecimal dd1 =3D new DeweyDecimal( DD1 );
- final DeweyDecimal dd2 =3D new DeweyDecimal( DD2 );
- final DeweyDecimal dd3 =3D new DeweyDecimal( DD3 );
- final DeweyDecimal dd4 =3D new DeweyDecimal( DD4 );
- final DeweyDecimal dd5 =3D new DeweyDecimal( DD5 );
- assertTrue( "Bad: " + DD1 + " > " + DD1, !dd1.isGreaterThan( =
dd1 ) );
- assertTrue( "Bad: " + DD1 + " > " + DD2, !dd1.isGreaterThan( =
dd2 ) );
- assertTrue( "Bad: " + DD1 + " > " + DD3, !dd1.isGreaterThan( =
dd3 ) );
- assertTrue( "Bad: " + DD1 + " < " + DD4, dd1.isGreaterThan( d=
d4 ) );
- assertTrue( "Bad: " + DD1 + " > " + DD5, !dd1.isGreaterThan( =
dd5 ) );
- assertTrue( "Bad: " + DD2 + " < " + DD1, dd2.isGreaterThan( d=
d1 ) );
- assertTrue( "Bad: " + DD2 + " > " + DD2, !dd2.isGreaterThan( =
dd2 ) );
- assertTrue( "Bad: " + DD2 + " > " + DD3, !dd2.isGreaterThan( =
dd3 ) );
- assertTrue( "Bad: " + DD2 + " < " + DD4, dd2.isGreaterThan( d=
d4 ) );
- assertTrue( "Bad: " + DD2 + " > " + DD5, !dd2.isGreaterThan( =
dd5 ) );
- assertTrue( "Bad: " + DD3 + " < " + DD1, dd3.isGreaterThan( d=
d1 ) );
- assertTrue( "Bad: " + DD3 + " < " + DD2, dd3.isGreaterThan( d=
d2 ) );
- assertTrue( "Bad: " + DD3 + " > " + DD3, !dd3.isGreaterThan( =
dd3 ) );
- assertTrue( "Bad: " + DD3 + " < " + DD4, dd3.isGreaterThan( d=
d4 ) );
- assertTrue( "Bad: " + DD3 + " > " + DD5, !dd3.isGreaterThan( =
dd5 ) );
- assertTrue( "Bad: " + DD4 + " > " + DD1, !dd4.isGreaterThan( =
dd1 ) );
- assertTrue( "Bad: " + DD4 + " > " + DD2, !dd4.isGreaterThan( =
dd2 ) );
- assertTrue( "Bad: " + DD4 + " > " + DD3, !dd4.isGreaterThan( =
dd3 ) );
- assertTrue( "Bad: " + DD4 + " > " + DD4, !dd4.isGreaterThan( =
dd4 ) );
- assertTrue( "Bad: " + DD4 + " > " + DD5, !dd4.isGreaterThan( =
dd5 ) );
- assertTrue( "Bad: " + DD5 + " < " + DD1, dd5.isGreaterThan( d=
d1 ) );
- assertTrue( "Bad: " + DD5 + " < " + DD2, dd5.isGreaterThan( d=
d2 ) );
- assertTrue( "Bad: " + DD5 + " < " + DD3, dd5.isGreaterThan( d=
d3 ) );
- assertTrue( "Bad: " + DD5 + " < " + DD4, dd5.isGreaterThan( d=
d4 ) );
- assertTrue( "Bad: " + DD5 + " > " + DD5, !dd5.isGreaterThan( =
dd5 ) );
- }
-
- public void testGreaterThanOrEqual()
- throws Exception
- {
- final DeweyDecimal dd1 =3D new DeweyDecimal( DD1 );
- final DeweyDecimal dd2 =3D new DeweyDecimal( DD2 );
- final DeweyDecimal dd3 =3D new DeweyDecimal( DD3 );
- final DeweyDecimal dd4 =3D new DeweyDecimal( DD4 );
- final DeweyDecimal dd5 =3D new DeweyDecimal( DD5 );
- assertTrue( "Bad: " + DD1 + " < " + DD1,
- dd1.isGreaterThanOrEqual( dd1 ) );
- assertTrue( "Bad: " + DD1 + " > " + DD2,
- !dd1.isGreaterThanOrEqual( dd2 ) );
- assertTrue( "Bad: " + DD1 + " > " + DD3,
- !dd1.isGreaterThanOrEqual( dd3 ) );
- assertTrue( "Bad: " + DD1 + " < " + DD4,
- dd1.isGreaterThanOrEqual( dd4 ) );
- assertTrue( "Bad: " + DD1 + " > " + DD5,
- !dd1.isGreaterThanOrEqual( dd5 ) );
- assertTrue( "Bad: " + DD2 + " < " + DD1,
- dd2.isGreaterThanOrEqual( dd1 ) );
- assertTrue( "Bad: " + DD2 + " < " + DD2,
- dd2.isGreaterThanOrEqual( dd2 ) );
- assertTrue( "Bad: " + DD2 + " > " + DD3,
- !dd2.isGreaterThanOrEqual( dd3 ) );
- assertTrue( "Bad: " + DD2 + " < " + DD4,
- dd2.isGreaterThanOrEqual( dd4 ) );
- assertTrue( "Bad: " + DD2 + " > " + DD5,
- !dd2.isGreaterThanOrEqual( dd5 ) );
- assertTrue( "Bad: " + DD3 + " < " + DD1,
- dd3.isGreaterThanOrEqual( dd1 ) );
- assertTrue( "Bad: " + DD3 + " < " + DD2,
- dd3.isGreaterThanOrEqual( dd2 ) );
- assertTrue( "Bad: " + DD3 + " < " + DD3,
- dd3.isGreaterThanOrEqual( dd3 ) );
- assertTrue( "Bad: " + DD3 + " < " + DD4,
- dd3.isGreaterThanOrEqual( dd4 ) );
- assertTrue( "Bad: " + DD3 + " > " + DD5,
- !dd3.isGreaterThanOrEqual( dd5 ) );
- assertTrue( "Bad: " + DD4 + " > " + DD1,
- !dd4.isGreaterThanOrEqual( dd1 ) );
- assertTrue( "Bad: " + DD4 + " > " + DD2,
- !dd4.isGreaterThanOrEqual( dd2 ) );
- assertTrue( "Bad: " + DD4 + " > " + DD3,
- !dd4.isGreaterThanOrEqual( dd3 ) );
- assertTrue( "Bad: " + DD4 + " < " + DD4,
- dd4.isGreaterThanOrEqual( dd4 ) );
- assertTrue( "Bad: " + DD4 + " > " + DD5,
- !dd4.isGreaterThanOrEqual( dd5 ) );
- assertTrue( "Bad: " + DD5 + " < " + DD1,
- dd5.isGreaterThanOrEqual( dd1 ) );
- assertTrue( "Bad: " + DD5 + " < " + DD2,
- dd5.isGreaterThanOrEqual( dd2 ) );
- assertTrue( "Bad: " + DD5 + " < " + DD3,
- dd5.isGreaterThanOrEqual( dd3 ) );
- assertTrue( "Bad: " + DD5 + " < " + DD4,
- dd5.isGreaterThanOrEqual( dd4 ) );
- assertTrue( "Bad: " + DD5 + " < " + DD5,
- dd5.isGreaterThanOrEqual( dd5 ) );
- }
-
- public void testLessThan()
- throws Exception
- {
- final DeweyDecimal dd1 =3D new DeweyDecimal( DD1 );
- final DeweyDecimal dd2 =3D new DeweyDecimal( DD2 );
- final DeweyDecimal dd3 =3D new DeweyDecimal( DD3 );
- final DeweyDecimal dd4 =3D new DeweyDecimal( DD4 );
- final DeweyDecimal dd5 =3D new DeweyDecimal( DD5 );
- assertTrue( "Bad: " + DD1 + " <=3D " + DD1, !dd1.isLessThan( =
dd1 ) );
- assertTrue( "Bad: " + DD1 + " <=3D " + DD2, dd1.isLessThan( d=
d2 ) );
- assertTrue( "Bad: " + DD1 + " <=3D " + DD3, dd1.isLessThan( d=
d3 ) );
- assertTrue( "Bad: " + DD1 + " >=3D " + DD4, !dd1.isLessThan( =
dd4 ) );
- assertTrue( "Bad: " + DD1 + " <=3D " + DD5, dd1.isLessThan( d=
d5 ) );
- assertTrue( "Bad: " + DD2 + " >=3D " + DD1, !dd2.isLessThan( =
dd1 ) );
- assertTrue( "Bad: " + DD2 + " <=3D " + DD2, !dd2.isLessThan( =
dd2 ) );
- assertTrue( "Bad: " + DD2 + " <=3D " + DD3, dd2.isLessThan( d=
d3 ) );
- assertTrue( "Bad: " + DD2 + " >=3D " + DD4, !dd2.isLessThan( =
dd4 ) );
- assertTrue( "Bad: " + DD2 + " <=3D " + DD5, dd2.isLessThan( d=
d5 ) );
- assertTrue( "Bad: " + DD3 + " >=3D " + DD1, !dd3.isLessThan( =
dd1 ) );
- assertTrue( "Bad: " + DD3 + " >=3D " + DD2, !dd3.isLessThan( =
dd2 ) );
- assertTrue( "Bad: " + DD3 + " <=3D " + DD3, !dd3.isLessThan( =
dd3 ) );
- assertTrue( "Bad: " + DD3 + " >=3D " + DD4, !dd3.isLessThan( =
dd4 ) );
- assertTrue( "Bad: " + DD3 + " <=3D " + DD5, dd3.isLessThan( d=
d5 ) );
- assertTrue( "Bad: " + DD4 + " <=3D " + DD1, dd4.isLessThan( d=
d1 ) );
- assertTrue( "Bad: " + DD4 + " <=3D " + DD2, dd4.isLessThan( d=
d2 ) );
- assertTrue( "Bad: " + DD4 + " <=3D " + DD3, dd4.isLessThan( d=
d3 ) );
- assertTrue( "Bad: " + DD4 + " <=3D " + DD4, !dd4.isLessThan( =
dd4 ) );
- assertTrue( "Bad: " + DD4 + " <=3D " + DD5, dd4.isLessThan( d=
d5 ) );
- assertTrue( "Bad: " + DD5 + " >=3D " + DD1, !dd5.isLessThan( =
dd1 ) );
- assertTrue( "Bad: " + DD5 + " >=3D " + DD2, !dd5.isLessThan( =
dd2 ) );
- assertTrue( "Bad: " + DD5 + " >=3D " + DD3, !dd5.isLessThan( =
dd3 ) );
- assertTrue( "Bad: " + DD5 + " >=3D " + DD4, !dd5.isLessThan( =
dd4 ) );
- assertTrue( "Bad: " + DD5 + " <=3D " + DD5, !dd5.isLessThan( =
dd5 ) );
- }
-
- public void testLessThanOrEqual()
- throws Exception
- {
- final DeweyDecimal dd1 =3D new DeweyDecimal( DD1 );
- final DeweyDecimal dd2 =3D new DeweyDecimal( DD2 );
- final DeweyDecimal dd3 =3D new DeweyDecimal( DD3 );
- final DeweyDecimal dd4 =3D new DeweyDecimal( DD4 );
- final DeweyDecimal dd5 =3D new DeweyDecimal( DD5 );
- assertTrue( "Bad: " + DD1 + " >=3D " + DD1,
- dd1.isLessThanOrEqual( dd1 ) );
- assertTrue( "Bad: " + DD1 + " <=3D " + DD2,
- dd1.isLessThanOrEqual( dd2 ) );
- assertTrue( "Bad: " + DD1 + " <=3D " + DD3,
- dd1.isLessThanOrEqual( dd3 ) );
- assertTrue( "Bad: " + DD1 + " >=3D " + DD4,
- !dd1.isLessThanOrEqual( dd4 ) );
- assertTrue( "Bad: " + DD1 + " <=3D " + DD5,
- dd1.isLessThanOrEqual( dd5 ) );
- assertTrue( "Bad: " + DD2 + " >=3D " + DD1,
- !dd2.isLessThanOrEqual( dd1 ) );
- assertTrue( "Bad: " + DD2 + " >=3D " + DD2,
- dd2.isLessThanOrEqual( dd2 ) );
- assertTrue( "Bad: " + DD2 + " <=3D " + DD3,
- dd2.isLessThanOrEqual( dd3 ) );
- assertTrue( "Bad: " + DD2 + " >=3D " + DD4,
- !dd2.isLessThanOrEqual( dd4 ) );
- assertTrue( "Bad: " + DD2 + " <=3D " + DD5,
- dd2.isLessThanOrEqual( dd5 ) );
- assertTrue( "Bad: " + DD3 + " >=3D " + DD1,
- !dd3.isLessThanOrEqual( dd1 ) );
- assertTrue( "Bad: " + DD3 + " >=3D " + DD2,
- !dd3.isLessThanOrEqual( dd2 ) );
- assertTrue( "Bad: " + DD3 + " >=3D " + DD3,
- dd3.isLessThanOrEqual( dd3 ) );
- assertTrue( "Bad: " + DD3 + " >=3D " + DD4,
- !dd3.isLessThanOrEqual( dd4 ) );
- assertTrue( "Bad: " + DD3 + " <=3D " + DD5,
- dd3.isLessThanOrEqual( dd5 ) );
- assertTrue( "Bad: " + DD4 + " <=3D " + DD1,
- dd4.isLessThanOrEqual( dd1 ) );
- assertTrue( "Bad: " + DD4 + " <=3D " + DD2,
- dd4.isLessThanOrEqual( dd2 ) );
- assertTrue( "Bad: " + DD4 + " <=3D " + DD3,
- dd4.isLessThanOrEqual( dd3 ) );
- assertTrue( "Bad: " + DD4 + " >=3D " + DD4,
- dd4.isLessThanOrEqual( dd4 ) );
- assertTrue( "Bad: " + DD4 + " <=3D " + DD5,
- dd4.isLessThanOrEqual( dd5 ) );
- assertTrue( "Bad: " + DD5 + " >=3D " + DD1,
- !dd5.isLessThanOrEqual( dd1 ) );
- assertTrue( "Bad: " + DD5 + " >=3D " + DD2,
- !dd5.isLessThanOrEqual( dd2 ) );
- assertTrue( "Bad: " + DD5 + " >=3D " + DD3,
- !dd5.isLessThanOrEqual( dd3 ) );
- assertTrue( "Bad: " + DD5 + " >=3D " + DD4,
- !dd5.isLessThanOrEqual( dd4 ) );
- assertTrue( "Bad: " + DD5 + " >=3D " + DD5,
- dd5.isLessThanOrEqual( dd5 ) );
- }
-}
</pre></div>
<hr /><a name=3D"file15" /><div class=3D"file">
<span class=3D"pathname" id=3D"removed"><a href=3D"http://xstream.cvs.cod=
ehaus.org/jcontainer">jcontainer</a>/<a href=3D"http://xstream.cvs.codeha=
us.org/jcontainer/loom">loom</a>/<a href=3D"http://xstream.cvs.codehaus.o=
rg/jcontainer/loom/support">support</a>/<a href=3D"http://xstream.cvs.cod=
ehaus.org/jcontainer/loom/support/extension">extension</a>/<a href=3D"htt=
p://xstream.cvs.codehaus.org/jcontainer/loom/support/extension/src">src</=
a>/<a href=3D"http://xstream.cvs.codehaus.org/jcontainer/loom/support/ext=
ension/src/test">test</a>/<a href=3D"http://xstream.cvs.codehaus.org/jcon=
tainer/loom/support/extension/src/test/org">org</a>/<a href=3D"http://xst=
ream.cvs.codehaus.org/jcontainer/loom/support/extension/src/test/org/jcon=
tainer">jcontainer</a>/<a href=3D"http://xstream.cvs.codehaus.org/jcontai=
ner/loom/support/extension/src/test/org/jcontainer/loom">loom</a>/<a href=
=3D"http://xstream.cvs.codehaus.org/jcontainer/loom/support/extension/src=
/test/org/jcontainer/loom/extension">extension</a><br /></span>
<div class=3D"fileheader" id=3D"removed"><big><b>SpecificationTestCase.ja=
va</b></big> <small id=3D"info">removed after <a href=3D"http://xstream.c=
vs.codehaus.org/jcontainer/loom/support/extension/src/test/org/jcontainer=
/loom/extension/SpecificationTestCase.java?rev=3D1.1&content-type=3Dt=
ext/vnd.viewcvs-markup">1.1</a></small></div>
<pre class=3D"diff"><small id=3D"info">diff -N SpecificationTestCase.java
--- SpecificationTestCase.java 31 Mar 2004 03:13:43 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,451 +0,0 @@
</small></pre><pre class=3D"diff" id=3D"removed">-/*
- * Copyright (C) The Spice Group. All rights reserved.
- *
- * This software is published under the terms of the Spice
- * Software License version 1.1, a copy of which has been included
- * with this distribution in the LICENSE.txt file.
- */
-package org.jcontainer.loom.extension;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.jar.Manifest;
-import junit.framework.TestCase;
-
-/**
- * TestCases for Specification.
- *
- * @author Peter Donald
- * @version $Revision: 1.1 $ $Date: 2004/03/31 03:13:43 $
- */
-public class SpecificationTestCase
- extends TestCase
-{
- public void testSingleSpecification()
- throws Exception
- {
- final String manifest =3D
- "Manifest-Version: 1.0\n" +
- "\n" +
- "Name: org/realityforge/dve\n" +
- "Specification-Title: org.realityforge.dve\n" +
- "Specification-Version: 1.0.2\n" +
- "Specification-Vendor: Peter Donald\n" +
- "Implementation-Title: DVE vi OS3P\n" +
- "Implementation-Vendor: Peter Donald\n" +
- "Implementation-Version: 1.0.2Alpha\n";
- final Specification[] specifications =3D getSpecifications( mani=
fest );
-
- assertEquals( "Count", 1, specifications.length );
- assertEquals( "Name", "org.realityforge.dve",
- specifications[ 0 ].getSpecificationTitle() );
- assertEquals( "SpecVendor", "Peter Donald",
- specifications[ 0 ].getSpecificationVendor() );
- assertEquals( "SpecVersion",
- "1.0.2",
- specifications[ 0 ].getSpecificationVersion().toSt=
ring() );
- assertEquals( "ImpVendor", "Peter Donald",
- specifications[ 0 ].getImplementationVendor() );
- assertEquals( "ImpTitle", "DVE vi OS3P",
- specifications[ 0 ].getImplementationTitle() );
- assertEquals( "ImpVersion",
- "1.0.2Alpha",
- specifications[ 0 ].getImplementationVersion().toS=
tring() );
- }
-
- public void testSingleSpecificationWithSpacesAtEOL()
- throws Exception
- {
- final String manifest =3D
- "Manifest-Version: 1.0\n" +
- "\n" +
- "Name: org/realityforge/dve \n" +
- "Specification-Title: org.realityforge.dve \n" +
- "Specification-Version: 1.0.2 \n" +
- "Specification-Vendor: Peter Donald \n" +
- "Implementation-Title: DVE vi OS3P \n" +
- "Implementation-Vendor: Peter Donald \n" +
- "Implementation-Version: 1.0.2Alpha \n";
- final Specification[] specifications =3D getSpecifications( mani=
fest );
-
- assertEquals( "Count", 1, specifications.length );
- assertEquals( "Name", "org.realityforge.dve",
- specifications[ 0 ].getSpecificationTitle() );
- assertEquals( "SpecVendor", "Peter Donald",
- specifications[ 0 ].getSpecificationVendor() );
- assertEquals( "SpecVersion",
- "1.0.2",
- specifications[ 0 ].getSpecificationVersion().toSt=
ring() );
- assertEquals( "ImpVendor", "Peter Donald",
- specifications[ 0 ].getImplementationVendor() );
- assertEquals( "ImpTitle", "DVE vi OS3P",
- specifications[ 0 ].getImplementationTitle() );
- assertEquals( "ImpVersion",
- "1.0.2Alpha",
- specifications[ 0 ].getImplementationVersion().toS=
tring() );
- }
-
- public void testSingleSpecificationWithMissingSpecificationVersion()
- throws Exception
- {
- final String manifestString =3D
- "Manifest-Version: 1.0\n" +
- "\n" +
- "Name: org/realityforge/dve\n" +
- "Specification-Title: org.realityforge.dve\n" +
- "Specification-Vendor: Peter Donald\n" +
- "Implementation-Title: DVE vi OS3P\n" +
- "Implementation-Vendor: Peter Donald\n" +
- "Implementation-Version: 1.0.2Alpha\n";
- final Manifest manifest =3D getManifest( manifestString );
- try
- {
- Specification.getSpecifications( manifest );
- }
- catch( final Throwable t )
- {
- return;
- }
- fail( "Missing SpecificationVersion parsed" );
- }
-
- public void testSingleSpecificationWithMissingSpecificationVendor()
- throws Exception
- {
- final String manifestString =3D
- "Manifest-Version: 1.0\n" +
- "\n" +
- "Name: org/realityforge/dve\n" +
- "Specification-Title: org.realityforge.dve\n" +
- "Specification-Version: 1.0.2\n" +
- "Implementation-Title: DVE vi OS3P\n" +
- "Implementation-Vendor: Peter Donald\n" +
- "Implementation-Version: 1.0.2Alpha\n";
- final Manifest manifest =3D getManifest( manifestString );
- try
- {
- Specification.getSpecifications( manifest );
- }
- catch( final Throwable t )
- {
- return;
- }
- fail( "Missing SpecificationVendor parsed" );
- }
-
- public void testSingleSpecificationMissingImplementationTitle()
- throws Exception
- {
- final String manifestString =3D
- "Manifest-Version: 1.0\n" +
- "\n" +
- "Name: org/realityforge/dve\n" +
- "Specification-Title: org.realityforge.dve\n" +
- "Specification-Version: 1.0.2\n" +
- "Specification-Vendor: Peter Donald\n" +
- "Implementation-Vendor: Peter Donald\n" +
- "Implementation-Version: 1.0.2Alpha\n";
- final Manifest manifest =3D getManifest( manifestString );
- try
- {
- Specification.getSpecifications( manifest );
- }
- catch( final Throwable t )
- {
- return;
- }
- fail( "Missing ImplementationTitle parsed" );
- }
-
- public void testSingleSpecificationMissingImplementationVendor()
- throws Exception
- {
- final String manifestString =3D
- "Manifest-Version: 1.0\n" +
- "\n" +
- "Name: org/realityforge/dve\n" +
- "Specification-Title: org.realityforge.dve\n" +
- "Specification-Version: 1.0.2\n" +
- "Specification-Vendor: Peter Donald\n" +
- "Implementation-Title: DVE vi OS3P\n" +
- "Implementation-Version: 1.0.2Alpha\n";
- final Manifest manifest =3D getManifest( manifestString );
- try
- {
- Specification.getSpecifications( manifest );
- }
- catch( final Throwable t )
- {
- return;
- }
- fail( "Missing ImplementationVendor parsed" );
- }
-
- public void testSingleSpecificationMissingImplementationVersion()
- throws Exception
- {
- final String manifestString =3D
- "Manifest-Version: 1.0\n" +
- "\n" +
- "Name: org/realityforge/dve\n" +
- "Specification-Title: org.realityforge.dve\n" +
- "Specification-Version: 1.0.2\n" +
- "Specification-Vendor: Peter Donald\n" +
- "Implementation-Title: DVE vi OS3P\n" +
- "Implementation-Vendor: Peter Donald\n";
- final Manifest manifest =3D getManifest( manifestString );
- try
- {
- Specification.getSpecifications( manifest );
- }
- catch( final Throwable t )
- {
- return;
- }
- fail( "Missing ImplementationVersion parsed" );
- }
-
- public void testSingleSpecificationWithMultipleSections()
- throws Exception
- {
- final String manifestString =3D
- "Manifest-Version: 1.0\n" +
- "\n" +
- "Name: org/realityforge/dve\n" +
- "Specification-Title: org.realityforge.dve\n" +
- "Specification-Version: 1.0.2\n" +
- "Specification-Vendor: Peter Donald\n" +
- "Implementation-Title: DVE vi OS3P\n" +
- "Implementation-Vendor: Peter Donald\n" +
- "Implementation-Version: 1.0.2Alpha\n" +
- "\n" +
- "Name: org/realityforge/dve/input\n" +
- "Specification-Title: org.realityforge.dve\n" +
- "Specification-Version: 1.0.2\n" +
- "Specification-Vendor: Peter Donald\n" +
- "Implementation-Title: DVE vi OS3P\n" +
- "Implementation-Vendor: Peter Donald\n" +
- "Implementation-Version: 1.0.2Alpha\n" +
- "\n" +
- "Name: org/realityforge/dve/sim\n" +
- "Specification-Title: org.realityforge.dve\n" +
- "Specification-Version: 1.0.2\n" +
- "Specification-Vendor: Peter Donald\n" +
- "Implementation-Title: DVE vi OS3P\n" +
- "Implementation-Vendor: Peter Donald\n" +
- "Implementation-Version: 1.0.2Alpha\n";
- final Specification[] specifications =3D getSpecifications(
- manifestString );
-
- assertEquals( "Count", 1, specifications.length );
- final String[] sections =3D specifications[ 0 ].getSections();
- assertEquals( "sections.length", 3, sections.length );
- final HashSet set =3D new HashSet();
- set.addAll( Arrays.asList( sections ) );
- assertTrue( "sections.contains(org/realityforge/dve)",
- set.contains( "org/realityforge/dve" ) );
- assertTrue( "sections.contains(org/realityforge/dve/input)",
- set.contains( "org/realityforge/dve/input" ) );
- assertTrue( "sections.contains(org/realityforge/dve/sim)",
- set.contains( "org/realityforge/dve/sim" ) );
- assertEquals( "Name", "org.realityforge.dve",
- specifications[ 0 ].getSpecificationTitle() );
- assertEquals( "SpecVendor", "Peter Donald",
- specifications[ 0 ].getSpecificationVendor() );
- assertEquals( "SpecVersion",
- "1.0.2",
- specifications[ 0 ].getSpecificationVersion().toSt=
ring() );
- assertEquals( "ImpVendor", "Peter Donald",
- specifications[ 0 ].getImplementationVendor() );
- assertEquals( "ImpTitle", "DVE vi OS3P",
- specifications[ 0 ].getImplementationTitle() );
- assertEquals( "ImpVersion",
- "1.0.2Alpha",
- specifications[ 0 ].getImplementationVersion().toS=
tring() );
- }
-
- public void testMultipleSpecificationWithMultipleSections()
- throws Exception
- {
- final String manifestString =3D
- "Manifest-Version: 1.0\n" +
- "\n" +
- "Name: org/realityforge/dve\n" +
- "Specification-Title: org.realityforge.dve\n" +
- "Specification-Version: 1.0.2\n" +
- "Specification-Vendor: Peter Donald\n" +
- "Implementation-Title: DVE vi OS3P\n" +
- "Implementation-Vendor: Peter Donald\n" +
- "Implementation-Version: 1.0.2Alpha\n" +
- "\n" +
- "Name: org/realityforge/dve/input\n" +
- "Specification-Title: org.realityforge.dve\n" +
- "Specification-Version: 1.0.2\n" +
- "Specification-Vendor: Peter Donald\n" +
- "Implementation-Title: DVE vi OS3P\n" +
- "Implementation-Vendor: Peter Donald\n" +
- "Implementation-Version: 1.0.2Alpha\n" +
- "\n" +
- "Name: org/realityforge/dve/sim\n" +
- "Specification-Title: org.realityforge.dve\n" +
- "Specification-Version: 1.0.2\n" +
- "Specification-Vendor: Peter Donald\n" +
- "Implementation-Title: DVE vi OS3P\n" +
- "Implementation-Vendor: Peter Donald\n" +
- "Implementation-Version: 1.0.2Alpha\n" +
- "\n" +
- "Name: com/biz/foo\n" +
- "Specification-Title: com.biz.foo\n" +
- "Specification-Version: 1.0.2\n" +
- "Specification-Vendor: Peter Donald\n" +
- "Implementation-Title: DVE vi OS3P\n" +
- "Implementation-Vendor: Peter Donald\n" +
- "Implementation-Version: 1.0.2Alpha\n";
- final Specification[] specifications =3D getSpecifications(
- manifestString );
-
- assertEquals( "Count", 2, specifications.length );
- Specification dveSpecification;
- Specification fooSpecification;
- if( 3 =3D=3D specifications[ 0 ].getSections().length )
- {
- dveSpecification =3D specifications[ 0 ];
- fooSpecification =3D specifications[ 1 ];
- }
- else
- {
- dveSpecification =3D specifications[ 1 ];
- fooSpecification =3D specifications[ 0 ];
- }
-
- final String[] sections =3D dveSpecification.getSections();
- assertEquals( "sections.length", 3, sections.length );
- assertEquals( "sections.length", 3, sections.length );
- final HashSet set =3D new HashSet();
- set.addAll( Arrays.asList( sections ) );
- assertTrue( "sections.contains(org/realityforge/dve)",
- set.contains( "org/realityforge/dve" ) );
- assertTrue( "sections.contains(org/realityforge/dve/input)",
- set.contains( "org/realityforge/dve/input" ) );
- assertTrue( "sections.contains(org/realityforge/dve/sim)",
- set.contains( "org/realityforge/dve/sim" ) );
- assertEquals( "Name", "org.realityforge.dve",
- dveSpecification.getSpecificationTitle() );
- assertEquals( "SpecVendor", "Peter Donald",
- dveSpecification.getSpecificationVendor() );
- assertEquals( "SpecVersion", "1.0.2",
- dveSpecification.getSpecificationVersion().toStrin=
g() );
- assertEquals( "ImpVendor", "Peter Donald",
- dveSpecification.getImplementationVendor() );
- assertEquals( "ImpTitle", "DVE vi OS3P",
- dveSpecification.getImplementationTitle() );
- assertEquals( "ImpVersion", "1.0.2Alpha",
- dveSpecification.getImplementationVersion().toStri=
ng() );
-
- assertEquals( "sections.length",
- 1,
- fooSpecification.getSections().length );
- assertEquals( "sections[0]",
- "com/biz/foo",
- fooSpecification.getSections()[ 0 ] );
- assertEquals( "Name", "com.biz.foo",
- fooSpecification.getSpecificationTitle() );
- assertEquals( "SpecVendor", "Peter Donald",
- fooSpecification.getSpecificationVendor() );
- assertEquals( "SpecVersion", "1.0.2",
- fooSpecification.getSpecificationVersion().toStrin=
g() );
- assertEquals( "ImpVendor", "Peter Donald",
- fooSpecification.getImplementationVendor() );
- assertEquals( "ImpTitle", "DVE vi OS3P",
- fooSpecification.getImplementationTitle() );
- assertEquals( "ImpVersion", "1.0.2Alpha",
- fooSpecification.getImplementationVersion().toStri=
ng() );
- }
-
- public void testCompatible()
- throws Exception
- {
- final String title =3D "org.realityforge.dve";
- final String version =3D "1.0.2";
- final String vendor =3D "Peter Donald";
- final String implTitle =3D "DVE vi OS3P";
- final String implVendor =3D "Peter Donald";
- final String implVersion =3D "1.0.2Alpha";
-
- final Specification req1 =3D
- new Specification( title, version, vendor,
- implTitle, implVersion, implVendor );
- final Specification req2 =3D
- new Specification( title, version, vendor,
- null, null, null );
- final Specification req3 =3D
- new Specification( title, "1.0.1", vendor,
- null, null, null );
- final Specification req4 =3D
- new Specification( title, version, null,
- null, null, null );
- final Specification req5 =3D
- new Specification( "another title", version, vendor,
- implTitle, implVersion, implVendor );
-
- final Specification avail1 =3D
- new Specification( title, version, vendor,
- implTitle, implVersion, implVendor );
- final Specification avail2 =3D
- new Specification( title, version, vendor,
- implTitle, "another version", implVendor =
);
- final Specification avail3 =3D
- new Specification( title, version, vendor,
- implTitle, implVersion, "another vendor" =
);
-
- assertTrue( "avail1.isCompatibleWith( req1 )",
- avail1.isCompatibleWith( req1 ) );
- assertTrue( "avail1.isCompatibleWith( req2 )",
- avail1.isCompatibleWith( req2 ) );
- assertTrue( "avail1.isCompatibleWith( req3 )",
- avail1.isCompatibleWith( req3 ) );
- assertTrue( "avail1.isCompatibleWith( req4 )",
- avail1.isCompatibleWith( req4 ) );
- assertTrue( "!avail1.isCompatibleWith( req5 )",
- !avail1.isCompatibleWith( req5 ) );
-
- assertTrue( "!avail2.isCompatibleWith( req1 )",
- !avail2.isCompatibleWith( req1 ) );
- assertTrue( "avail2.isCompatibleWith( req2 )",
- avail2.isCompatibleWith( req2 ) );
- assertTrue( "avail2.isCompatibleWith( req3 )",
- avail2.isCompatibleWith( req3 ) );
- assertTrue( "avail2.isCompatibleWith( req4 )",
- avail2.isCompatibleWith( req4 ) );
- assertTrue( "!avail2.isCompatibleWith( req5 )",
- !avail2.isCompatibleWith( req5 ) );
-
- assertTrue( "!avail3.isCompatibleWith( req1 )",
- !avail3.isCompatibleWith( req1 ) );
- assertTrue( "avail3.isCompatibleWith( req2 )",
- avail3.isCompatibleWith( req2 ) );
- assertTrue( "avail3.isCompatibleWith( req3 )",
- avail3.isCompatibleWith( req3 ) );
- assertTrue( "avail3.isCompatibleWith( req4 )",
- avail3.isCompatibleWith( req4 ) );
- assertTrue( "!avail3.isCompatibleWith( req5 )",
- !avail3.isCompatibleWith( req5 ) );
- }
-
- private Specification[] getSpecifications( final String input )
- throws Exception
- {
- final Manifest manifest =3D getManifest( input );
- return Specification.getSpecifications( manifest );
- }
-
- private Manifest getManifest( final String manifestString )
- throws IOException
- {
- final ByteArrayInputStream stream =3D
- new ByteArrayInputStream( manifestString.getBytes() );
- return new Manifest( stream );
- }
-}
</pre><pre class=3D"diff"><small id=3D"info">\ No newline at end of file
</small></pre></div>
<center><small><a href=3D"http://www.badgers-in-foil.co.uk/projects/cvssp=
am/" title=3D"commit -> email">CVSspam</a> 0.2.8</small></center>
</body></html>