You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by ma...@apache.org on 2011/01/04 15:36:49 UTC
svn commit: r1055062 - in /ant/ivy/core/trunk: src/java/org/apache/ivy/ant/
src/java/org/apache/ivy/osgi/obr/xml/ src/java/org/apache/ivy/osgi/repo/
src/java/org/apache/ivy/osgi/util/ test/java/org/apache/ivy/osgi/repo/
Author: maartenc
Date: Tue Jan 4 14:36:49 2011
New Revision: 1055062
URL: http://svn.apache.org/viewvc?rev=1055062&view=rev
Log:
More changes to let the osgi code compile with JDK 1.4
Modified:
ant/ivy/core/trunk/src/java/org/apache/ivy/ant/BuildBundleRepoDescriptorTask.java
ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/xml/OBRXMLParser.java
ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/xml/OBRXMLWriter.java
ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/AbstractFSManifestIterable.java
ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/BundleRepo.java
ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/RepositoryManifestIterable.java
ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/ResolverManifestIterable.java
ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/util/DelegetingHandler.java
ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/util/VersionRange.java
ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/repo/BundleRepoTest.java
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/ant/BuildBundleRepoDescriptorTask.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/ant/BuildBundleRepoDescriptorTask.java?rev=1055062&r1=1055061&r2=1055062&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/ant/BuildBundleRepoDescriptorTask.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/ant/BuildBundleRepoDescriptorTask.java Tue Jan 4 14:36:49 2011
@@ -22,6 +22,7 @@ import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
+import java.util.Iterator;
import javax.xml.transform.TransformerConfigurationException;
@@ -104,7 +105,7 @@ public class BuildBundleRepoDescriptorTa
throw new BuildException("No output file specified: use the attribute 'out'");
}
- Iterable/* <ManifestAndLocation> */it;
+ Iterator/* <ManifestAndLocation> */it;
if (resolverName != null) {
if (baseDir != null) {
throw new BuildException("specify only one of 'resolver' or 'baseDir'");
@@ -123,9 +124,9 @@ public class BuildBundleRepoDescriptorTa
}
if (!(resolver instanceof BasicResolver)) {
throw new BuildException("the type of resolver '"
- + resolver.getClass().getCanonicalName() + "' is not supported.");
+ + resolver.getClass().getName() + "' is not supported.");
}
- it = new ResolverManifestIterable((BasicResolver) resolver);
+ it = new ResolverManifestIterable((BasicResolver) resolver).iterator();
} else if (baseDir != null) {
if (cacheName != null) {
throw new BuildException("specify only one of 'baseDir' or 'cache'");
@@ -133,17 +134,17 @@ public class BuildBundleRepoDescriptorTa
if (!baseDir.isDirectory()) {
throw new BuildException(baseDir + " is not a directory");
}
- it = new FSManifestIterable(baseDir, basePath);
+ it = new FSManifestIterable(baseDir, basePath).iterator();
} else if (cacheName != null) {
Ivy ivy = getIvyInstance();
RepositoryCacheManager cacheManager = ivy.getSettings().getRepositoryCacheManager(
cacheName);
if (!(cacheManager instanceof DefaultRepositoryCacheManager)) {
throw new BuildException("the type of cache '"
- + cacheManager.getClass().getCanonicalName() + "' is not supported.");
+ + cacheManager.getClass().getName() + "' is not supported.");
}
File basedir = ((DefaultRepositoryCacheManager) cacheManager).getBasedir();
- it = new FSManifestIterable(basedir, basedir.getAbsolutePath() + File.separator);
+ it = new FSManifestIterable(basedir, basedir.getAbsolutePath() + File.separator).iterator();
} else {
throw new BuildException(
"No resolver, cache or basedir specified: "
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/xml/OBRXMLParser.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/xml/OBRXMLParser.java?rev=1055062&r1=1055061&r2=1055062&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/xml/OBRXMLParser.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/xml/OBRXMLParser.java Tue Jan 4 14:36:49 2011
@@ -19,19 +19,24 @@ package org.apache.ivy.osgi.obr.xml;
import java.io.IOException;
import java.io.InputStream;
+import java.net.URL;
import java.text.ParseException;
+import javax.xml.parsers.ParserConfigurationException;
+
import org.apache.ivy.osgi.core.BundleInfo;
import org.apache.ivy.osgi.obr.filter.RequirementFilterParser;
import org.apache.ivy.osgi.repo.BundleRepo;
import org.apache.ivy.osgi.util.DelegetingHandler;
import org.apache.ivy.osgi.util.Version;
import org.apache.ivy.util.Message;
+import org.apache.ivy.util.XMLHelper;
import org.xml.sax.Attributes;
import org.xml.sax.InputSource;
import org.xml.sax.Locator;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
+import org.xml.sax.ext.LexicalHandler;
import org.xml.sax.helpers.XMLReaderFactory;
public class OBRXMLParser {
@@ -83,15 +88,14 @@ public class OBRXMLParser {
static final String FALSE = "false";
public static BundleRepo parse(InputStream in) throws ParseException, IOException, SAXException {
- XMLReader reader;
+ RepositoryHandler handler = new RepositoryHandler();
try {
- reader = XMLReaderFactory.createXMLReader();
- } catch (SAXException e) {
- throw new ParseException(e.getMessage(), 0);
+ XMLHelper.parse(in, null, handler, null);
+ } catch (ParserConfigurationException e) {
+ ParseException exc = new ParseException(e.getMessage(), 0);
+ exc.initCause(e);
+ throw exc;
}
- RepositoryHandler handler = new RepositoryHandler();
- reader.setContentHandler(handler);
- reader.parse(new InputSource(in));
return handler.repo;
}
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/xml/OBRXMLWriter.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/xml/OBRXMLWriter.java?rev=1055062&r1=1055061&r2=1055062&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/xml/OBRXMLWriter.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/xml/OBRXMLWriter.java Tue Jan 4 14:36:49 2011
@@ -57,7 +57,7 @@ public class OBRXMLWriter {
return hd;
}
- public static void writeManifests(Iterable/* <ManifestAndLocation> */it,
+ public static void writeManifests(Iterator/* <ManifestAndLocation> */it,
ContentHandler handler, boolean quiet) throws SAXException {
int level = quiet ? Message.MSG_DEBUG : Message.MSG_WARN;
handler.startDocument();
@@ -65,9 +65,8 @@ public class OBRXMLWriter {
handler.startElement("", OBRXMLParser.REPOSITORY, OBRXMLParser.REPOSITORY, atts);
int nbOk = 0;
int nbRejected = 0;
- Iterator iterator = it.iterator();
- while (iterator.hasNext()) {
- ManifestAndLocation manifestAndLocation = (ManifestAndLocation) iterator.next();
+ while (it.hasNext()) {
+ ManifestAndLocation manifestAndLocation = (ManifestAndLocation) it.next();
BundleInfo bundleInfo;
try {
bundleInfo = ManifestParser.parseManifest(manifestAndLocation.getManifest());
@@ -91,14 +90,13 @@ public class OBRXMLWriter {
+ (nbRejected > 1 ? "s" : "") + " rejected.");
}
- public static void writeBundles(Iterable/* <BundleInfo> */it, ContentHandler handler)
+ public static void writeBundles(Iterator/* <BundleInfo> */it, ContentHandler handler)
throws SAXException {
handler.startDocument();
AttributesImpl atts = new AttributesImpl();
handler.startElement("", OBRXMLParser.REPOSITORY, OBRXMLParser.REPOSITORY, atts);
- Iterator iterator = it.iterator();
- while (iterator.hasNext()) {
- BundleInfo bundleInfo = (BundleInfo) iterator.next();
+ while (it.hasNext()) {
+ BundleInfo bundleInfo = (BundleInfo) it.next();
saxBundleInfo(bundleInfo, handler);
}
handler.endElement("", OBRXMLParser.REPOSITORY, OBRXMLParser.REPOSITORY);
@@ -144,7 +142,7 @@ public class OBRXMLWriter {
}
Set/* <String> */uses = ((ExportPackage) capability).getUses();
if (uses != null && !uses.isEmpty()) {
- StringBuilder builder = new StringBuilder();
+ StringBuffer builder = new StringBuffer();
Iterator itUse = uses.iterator();
while (itUse.hasNext()) {
String use = (String) itUse.next();
@@ -201,7 +199,7 @@ public class OBRXMLWriter {
}
private static String buildFilter(BundleRequirement requirement) {
- StringBuilder filter = new StringBuilder();
+ StringBuffer filter = new StringBuffer();
VersionRange v = requirement.getVersion();
if (v != null) {
appendVersion(filter, v);
@@ -217,7 +215,7 @@ public class OBRXMLWriter {
return filter.toString();
}
- private static void appendVersion(StringBuilder filter, VersionRange v) {
+ private static void appendVersion(StringBuffer filter, VersionRange v) {
filter.append("(&");
Version start = v.getStartVersion();
if (start != null) {
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/AbstractFSManifestIterable.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/AbstractFSManifestIterable.java?rev=1055062&r1=1055061&r2=1055062&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/AbstractFSManifestIterable.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/AbstractFSManifestIterable.java Tue Jan 4 14:36:49 2011
@@ -30,7 +30,7 @@ import java.util.jar.Manifest;
import org.apache.ivy.util.Message;
-public abstract class AbstractFSManifestIterable implements Iterable/* <ManifestAndLocation> */{
+public abstract class AbstractFSManifestIterable { //implements Iterable/* <ManifestAndLocation> */{
public Iterator/* <ManifestAndLocation> */iterator() {
return new FSManifestIterator();
@@ -116,7 +116,7 @@ public abstract class AbstractFSManifest
dirs.add(listDirs(currentDir).iterator());
} catch (IOException e) {
Message.warn("Unlistable dir: " + currentDir + " (" + e + ")");
- dirs.add(Collections./* <String> */emptyList().iterator());
+ dirs.add(Collections.EMPTY_LIST.iterator());
}
currentDir = null;
}
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/BundleRepo.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/BundleRepo.java?rev=1055062&r1=1055061&r2=1055062&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/BundleRepo.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/BundleRepo.java Tue Jan 4 14:36:49 2011
@@ -56,7 +56,7 @@ public class BundleRepo {
// default constructor
}
- public BundleRepo(Iterable/* <ManifestAndLocation> */it) {
+ public BundleRepo(Iterator/* <ManifestAndLocation> */it) {
populate(it);
}
@@ -76,10 +76,9 @@ public class BundleRepo {
return lastModified;
}
- public void populate(Iterable/* <ManifestAndLocation> */it) {
- Iterator iterator = it.iterator();
- while (iterator.hasNext()) {
- ManifestAndLocation manifestAndLocation = (ManifestAndLocation) iterator.next();
+ public void populate(Iterator/* <ManifestAndLocation> */it) {
+ while (it.hasNext()) {
+ ManifestAndLocation manifestAndLocation = (ManifestAndLocation) it.next();
try {
BundleInfo bundleInfo = ManifestParser.parseManifest(manifestAndLocation
.getManifest());
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/RepositoryManifestIterable.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/RepositoryManifestIterable.java?rev=1055062&r1=1055061&r2=1055062&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/RepositoryManifestIterable.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/RepositoryManifestIterable.java Tue Jan 4 14:36:49 2011
@@ -53,7 +53,7 @@ public class RepositoryManifestIterable
}
private List/* <String> */asList(String[] array) {
- return array == null ? Collections./* <String> */emptyList() : Arrays
+ return array == null ? Collections.EMPTY_LIST : Arrays
./* <String> */asList(array);
}
}
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/ResolverManifestIterable.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/ResolverManifestIterable.java?rev=1055062&r1=1055061&r2=1055062&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/ResolverManifestIterable.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/ResolverManifestIterable.java Tue Jan 4 14:36:49 2011
@@ -43,7 +43,7 @@ import org.apache.ivy.plugins.resolver.B
import org.apache.ivy.plugins.resolver.util.ResolvedResource;
import org.apache.ivy.util.Message;
-public class ResolverManifestIterable implements Iterable/* <ManifestAndLocation> */{
+public class ResolverManifestIterable { //implements Iterable/* <ManifestAndLocation> */{
// We should support the interface DependencyResolver, but the API is not convenient to get
// references to artifact
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/util/DelegetingHandler.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/util/DelegetingHandler.java?rev=1055062&r1=1055061&r2=1055062&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/util/DelegetingHandler.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/util/DelegetingHandler.java Tue Jan 4 14:36:49 2011
@@ -28,8 +28,9 @@ import org.xml.sax.ErrorHandler;
import org.xml.sax.Locator;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
+import org.xml.sax.helpers.DefaultHandler;
-public class DelegetingHandler/* <P extends DelegetingHandler<?>> */implements DTDHandler,
+public class DelegetingHandler/* <P extends DelegetingHandler<?>> */ extends DefaultHandler implements DTDHandler,
ContentHandler, ErrorHandler {
private DelegetingHandler/* <?> */delegate = null;
@@ -48,7 +49,7 @@ public class DelegetingHandler/* <P exte
private boolean skip = false;
- private StringBuilder charBuffer = new StringBuilder();
+ private StringBuffer charBuffer = new StringBuffer();
private boolean bufferingChar = false;
@@ -162,9 +163,9 @@ public class DelegetingHandler/* <P exte
if (!started) { // first time called ?
// just for the root, check the expected element name
// not need to check the delegated as the mapping is already taking care of it
- if (parent == null && !localName.equals(tagName)) {
+ if (parent == null && !n.equals(tagName)) {
// we are at the root and the saxed element doesn't match
- throw new SAXException("The root element of the parsed document '" + localName
+ throw new SAXException("The root element of the parsed document '" + n
+ "' didn't matched the expected one: '" + tagName + "'");
}
handleAttributes(atts);
@@ -175,7 +176,7 @@ public class DelegetingHandler/* <P exte
return;
}
// time now to delegate for a new element
- delegate = (DelegetingHandler) mapping.get(localName);
+ delegate = (DelegetingHandler) mapping.get(n);
if (delegate != null) {
delegate.startElement(uri, localName, n, atts);
}
@@ -211,7 +212,7 @@ public class DelegetingHandler/* <P exte
if (!skip) {
doEndElement(uri, localName, n);
}
- if (parent != null && tagName.equals(localName)) {
+ if (parent != null && tagName.equals(n)) {
// the current element is closed, let's tell the parent to stop delegating
stopDelegating();
}
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/util/VersionRange.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/util/VersionRange.java?rev=1055062&r1=1055061&r2=1055062&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/util/VersionRange.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/util/VersionRange.java Tue Jan 4 14:36:49 2011
@@ -147,17 +147,17 @@ public class VersionRange {
if (major == null) {
return null;
}
- Integer minor = Integer.valueOf(0);
- Integer patch = Integer.valueOf(0);
+ Integer minor = new Integer(0);
+ Integer patch = new Integer(0);
String qualififer = null;
if (parseNumberSeparator()) {
minor = parseNumber();
if (minor == null) {
- minor = Integer.valueOf(0);
+ minor = new Integer(0);
} else if (parseNumberSeparator()) {
patch = parseNumber();
if (patch == null) {
- patch = Integer.valueOf(0);
+ patch = new Integer(0);
} else if (parseNumberSeparator()) {
qualififer = parseQualifier();
}
@@ -183,7 +183,7 @@ public class VersionRange {
case '7':
case '8':
case '9':
- n = Integer.valueOf((n == null ? 0 : n.intValue() * 10) + c - '0');
+ n = new Integer((n == null ? 0 : n.intValue() * 10) + c - '0');
break;
default:
unread();
@@ -215,7 +215,7 @@ public class VersionRange {
}
private String parseQualifier() {
- StringBuilder q = new StringBuilder();
+ StringBuffer q = new StringBuffer();
do {
readNext();
if (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c >= '0' && c <= '9'
@@ -262,7 +262,7 @@ public class VersionRange {
}
public String toIvyRevision() {
- StringBuilder buffer = new StringBuilder();
+ StringBuffer buffer = new StringBuffer();
buffer.append(startExclusive ? "(" : "[");
buffer.append(startVersion);
if (endVersion == null) {
Modified: ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/repo/BundleRepoTest.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/repo/BundleRepoTest.java?rev=1055062&r1=1055061&r2=1055062&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/repo/BundleRepoTest.java (original)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/repo/BundleRepoTest.java Tue Jan 4 14:36:49 2011
@@ -44,7 +44,7 @@ public class BundleRepoTest extends Test
public void testFS() throws Exception {
FSManifestIterable it = new FSManifestIterable(new File("test/test-repo/bundlerepo"), "");
BundleRepo repo = new BundleRepo();
- repo.populate(it);
+ repo.populate(it.iterator());
BundleRepo repo2 = OBRXMLParser.parse(new FileInputStream(
"test/test-repo/bundlerepo/repo.xml"));
@@ -56,7 +56,7 @@ public class BundleRepoTest extends Test
RepositoryManifestIterable it = new RepositoryManifestIterable(new FileRepository(new File(
"test/test-repo/bundlerepo").getAbsoluteFile()));
BundleRepo repo = new BundleRepo();
- repo.populate(it);
+ repo.populate(it.iterator());
BundleRepo repo2 = OBRXMLParser.parse(new FileInputStream(
"test/test-repo/bundlerepo/repo.xml"));
@@ -75,7 +75,7 @@ public class BundleRepoTest extends Test
fileSystemResolver.setSettings(new IvySettings());
ResolverManifestIterable it = new ResolverManifestIterable(fileSystemResolver);
BundleRepo repo = new BundleRepo();
- repo.populate(it);
+ repo.populate(it.iterator());
BundleRepo repo2 = OBRXMLParser
.parse(new FileInputStream("test/test-repo/ivyrepo/repo.xml"));
@@ -86,7 +86,7 @@ public class BundleRepoTest extends Test
public void testXMLSerialisation() throws SAXException, ParseException, IOException {
FSManifestIterable it = new FSManifestIterable(new File("test/test-repo/bundlerepo"), "");
BundleRepo repo = new BundleRepo();
- repo.populate(it);
+ repo.populate(it.iterator());
SAXTransformerFactory tf = (SAXTransformerFactory) SAXTransformerFactory.newInstance();
TransformerHandler hd;
@@ -100,7 +100,7 @@ public class BundleRepoTest extends Test
StreamResult stream = new StreamResult(out);
hd.setResult(stream);
- OBRXMLWriter.writeBundles(repo.getBundles(), hd);
+ OBRXMLWriter.writeBundles(repo.getBundles().iterator(), hd);
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
BundleRepo repo2 = OBRXMLParser.parse(in);