ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hi...@apache.org
Subject svn commit: r1056291 - in /ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2: ./ P2Artifact.java P2ArtifactParser.java P2Descriptor.java P2MetadataParser.java PropertiesParser.java XMLInputParser.java
Date Fri, 07 Jan 2011 12:41:05 GMT
Author: hibou
Date: Fri Jan  7 12:41:04 2011
New Revision: 1056291

URL: http://svn.apache.org/viewvc?rev=1056291&view=rev
Log:
Add a first implementaition of a parser of an Eclipse P2 repository

Added:
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2Artifact.java   (with props)
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2ArtifactParser.java   (with props)
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2Descriptor.java   (with props)
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2MetadataParser.java   (with props)
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/PropertiesParser.java   (with props)
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/XMLInputParser.java   (with props)

Added: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2Artifact.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2Artifact.java?rev=1056291&view=auto
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2Artifact.java (added)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2Artifact.java Fri Jan  7 12:41:04
2011
@@ -0,0 +1,47 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.ivy.osgi.p2;
+
+import org.apache.ivy.osgi.util.Version;
+
+public class P2Artifact {
+
+    private String id;
+
+    private Version version;
+
+    private String classifier;
+
+    public P2Artifact(String id, Version version, String classifier) {
+        this.id = id;
+        this.version = version;
+        this.classifier = classifier;
+    }
+
+    public String getClassifier() {
+        return classifier;
+    }
+
+    public String getId() {
+        return id;
+    }
+
+    public Version getVersion() {
+        return version;
+    }
+}

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2Artifact.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2Artifact.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2Artifact.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2ArtifactParser.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2ArtifactParser.java?rev=1056291&view=auto
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2ArtifactParser.java (added)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2ArtifactParser.java Fri Jan  7 12:41:04
2011
@@ -0,0 +1,201 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.ivy.osgi.p2;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.text.ParseException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.apache.ivy.osgi.p2.PropertiesParser.PropertiesHandler;
+import org.apache.ivy.osgi.util.DelegetingHandler;
+import org.apache.ivy.osgi.util.Version;
+import org.xml.sax.Attributes;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+import org.xml.sax.helpers.XMLReaderFactory;
+
+public class P2ArtifactParser implements XMLInputParser {
+
+    private final P2Descriptor p2Descriptor;
+
+    public P2ArtifactParser(P2Descriptor p2Descriptor) {
+        this.p2Descriptor = p2Descriptor;
+    }
+
+    public void parse(InputStream in) throws ParseException, IOException, SAXException {
+        XMLReader reader = XMLReaderFactory.createXMLReader();
+        RepositoryHandler handler = new RepositoryHandler(p2Descriptor);
+        reader.setContentHandler(handler);
+        reader.parse(new InputSource(in));
+    }
+
+    static class RepositoryHandler extends DelegetingHandler {
+
+        private static final String REPOSITORY = "repository";
+
+        // private static final String NAME = "name";
+        //
+        // private static final String TYPE = "type";
+        //
+        // private static final String VERSION = "version";
+
+        private Map/* <String, String> */patternsByClassifier = new HashMap();
+
+        public RepositoryHandler(final P2Descriptor p2Descriptor) {
+            super(REPOSITORY);
+            // addChild(new PropertiesHandler(), new ChildElementHandler() {
+            // public void childHanlded(DelegetingHandler child) {
+            // }
+            // });
+            addChild(new MappingsHandler(), new ChildElementHandler() {
+                public void childHanlded(DelegetingHandler child) {
+                    Iterator it = ((MappingsHandler) child).outputByFilter.entrySet().iterator();
+                    while (it.hasNext()) {
+                        Entry entry = (Entry) it.next();
+                        String filter = (String) entry.getKey();
+                        if (filter.startsWith("(& (classifier=") && filter.endsWith(""))
{
+                            String classifier = filter.substring(15, filter.length() - 2);
+                            patternsByClassifier.put(classifier, entry.getValue());
+                        } else {
+                            throw new IllegalStateException();
+                        }
+
+                    }
+                }
+            });
+            addChild(new ArtifactsHandler(p2Descriptor, patternsByClassifier),
+                new ChildElementHandler() {
+                    public void childHanlded(DelegetingHandler child) {
+                        // nothing to do
+                    }
+                });
+        }
+        // protected void handleAttributes(Attributes atts) {
+        // String name = atts.getValue(NAME);
+        // String type = atts.getValue(TYPE);
+        // String version = atts.getValue(VERSION);
+        // }
+    }
+
+    static class MappingsHandler extends DelegetingHandler {
+
+        private static final String MAPPINGS = "mappings";
+
+        private static final String SIZE = "size";
+
+        Map/* <String, String> */outputByFilter;
+
+        public MappingsHandler() {
+            super(MAPPINGS);
+            addChild(new RuleHandler(), new ChildElementHandler() {
+                public void childHanlded(DelegetingHandler child) {
+                    outputByFilter.put(((RuleHandler) child).filter, ((RuleHandler) child).output);
+                }
+            });
+        }
+
+        protected void handleAttributes(Attributes atts) {
+            int size = Integer.parseInt(atts.getValue(SIZE));
+            outputByFilter = new HashMap(size);
+        }
+
+    }
+
+    static class RuleHandler extends DelegetingHandler {
+
+        private static final String RULE = "rule";
+
+        private static final String FILTER = "filter";
+
+        private static final String OUTPUT = "output";
+
+        private String filter;
+
+        private String output;
+
+        public RuleHandler() {
+            super(RULE);
+        }
+
+        protected void handleAttributes(Attributes atts) {
+            filter = atts.getValue(FILTER);
+            output = atts.getValue(OUTPUT);
+        }
+
+    }
+
+    static class ArtifactsHandler extends DelegetingHandler {
+
+        private static final String ARTIFACTS = "artifacts";
+
+        // private static final String SIZE = "size";
+
+        public ArtifactsHandler(final P2Descriptor p2Descriptor,
+                final Map/* <String, String> */patternsByClassifier) {
+            super(ARTIFACTS);
+            addChild(new ArtifactHandler(), new ChildElementHandler() {
+                public void childHanlded(DelegetingHandler child) {
+                    P2Artifact a = ((ArtifactHandler) child).p2Artifact;
+                    String url = (String) patternsByClassifier.get(a.getClassifier());
+                    p2Descriptor.addArtifactUrl(a.getId(), a.getVersion(), url);
+                }
+            });
+        }
+
+        // protected void handleAttributes(Attributes atts) {
+        // int size = Integer.parseInt(atts.getValue(SIZE));
+        // artifacts = new ArrayList(size);
+        // }
+
+    }
+
+    static class ArtifactHandler extends DelegetingHandler {
+
+        private static final String ARTIFACT = "artifact";
+
+        private static final String CLASSIFIER = "classifier";
+
+        private static final String ID = "id";
+
+        private static final String VERSION = "version";
+
+        P2Artifact p2Artifact;
+
+        public ArtifactHandler() {
+            super(ARTIFACT);
+            addChild(new PropertiesHandler(), new ChildElementHandler() {
+                public void childHanlded(DelegetingHandler child) {
+                }
+            });
+        }
+
+        protected void handleAttributes(Attributes atts) {
+            String id = atts.getValue(ID);
+            Version version = new Version(atts.getValue(VERSION));
+            String classifier = atts.getValue(CLASSIFIER);
+
+            p2Artifact = new P2Artifact(id, version, classifier);
+        }
+    }
+
+}

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2ArtifactParser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2ArtifactParser.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2ArtifactParser.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2Descriptor.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2Descriptor.java?rev=1056291&view=auto
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2Descriptor.java (added)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2Descriptor.java Fri Jan  7 12:41:04
2011
@@ -0,0 +1,65 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.ivy.osgi.p2;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.ivy.osgi.core.BundleInfo;
+import org.apache.ivy.osgi.core.ExecutionEnvironmentProfileProvider;
+import org.apache.ivy.osgi.repo.RepoDescriptor;
+import org.apache.ivy.osgi.util.Version;
+
+public class P2Descriptor extends RepoDescriptor {
+
+    private long timestamp;
+
+    private Map/* <String, Map<Version, String>> */artifactUrls = new HashMap();
+
+    public P2Descriptor(ExecutionEnvironmentProfileProvider profileProvider) {
+        super(profileProvider);
+    }
+
+    public void setTimestamp(long timestamp) {
+        this.timestamp = timestamp;
+    }
+
+    public void addBundle(BundleInfo bundleInfo) {
+        // before transforming it and adding it into the repo, let's add the artifacts
+
+        Map/* <Version, String> */urlsByVersion = (Map) artifactUrls.get(bundleInfo
+                .getSymbolicName());
+        if (urlsByVersion != null) {
+            String url = (String) urlsByVersion.get(bundleInfo.getVersion());
+            if (url != null) {
+                bundleInfo.setUri(url);
+            }
+        }
+
+        super.addBundle(bundleInfo);
+    }
+
+    public void addArtifactUrl(String id, Version version, String url) {
+        Map/* <Version, String> */byVersion = (Map) artifactUrls.get(id);
+        if (byVersion == null) {
+            byVersion = new HashMap();
+            artifactUrls.put(id, byVersion);
+        }
+        byVersion.put(version, url);
+    }
+}

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2Descriptor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2Descriptor.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2Descriptor.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2MetadataParser.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2MetadataParser.java?rev=1056291&view=auto
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2MetadataParser.java (added)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2MetadataParser.java Fri Jan  7 12:41:04
2011
@@ -0,0 +1,766 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.ivy.osgi.p2;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.ivy.osgi.core.BundleCapability;
+import org.apache.ivy.osgi.core.BundleInfo;
+import org.apache.ivy.osgi.core.BundleRequirement;
+import org.apache.ivy.osgi.core.ExportPackage;
+import org.apache.ivy.osgi.p2.PropertiesParser.PropertiesHandler;
+import org.apache.ivy.osgi.util.DelegetingHandler;
+import org.apache.ivy.osgi.util.Version;
+import org.apache.ivy.osgi.util.VersionRange;
+import org.xml.sax.Attributes;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+import org.xml.sax.helpers.XMLReaderFactory;
+
+public class P2MetadataParser implements XMLInputParser {
+
+    private final P2Descriptor p2Descriptor;
+
+    public P2MetadataParser(P2Descriptor p2Descriptor) {
+        this.p2Descriptor = p2Descriptor;
+    }
+
+    public void parse(InputStream in) throws ParseException, IOException, SAXException {
+        XMLReader reader = XMLReaderFactory.createXMLReader();
+        RepositoryHandler handler = new RepositoryHandler(p2Descriptor);
+        reader.setContentHandler(handler);
+        reader.parse(new InputSource(in));
+    }
+
+    static class RepositoryHandler extends DelegetingHandler {
+
+        private static final String REPOSITORY = "repository";
+
+        // private static final String NAME = "name";
+        //
+        // private static final String TYPE = "type";
+        //
+        // private static final String VERSION = "version";
+        //
+        // private static final String DESCRIPTION = "description";
+        //
+        // private static final String PROVIDER = "provider";
+
+        public RepositoryHandler(final P2Descriptor p2Descriptor) {
+            super(REPOSITORY);
+            addChild(new PropertiesHandler(), new ChildElementHandler() {
+                public void childHanlded(DelegetingHandler child) {
+                    Map properties = ((PropertiesHandler) child).properties;
+                    String timestamp = (String) properties.get("p2.timestamp");
+                    if (timestamp != null) {
+                        p2Descriptor.setTimestamp(Long.parseLong(timestamp));
+                    }
+                }
+            });
+            addChild(new UnitsHandler(), new ChildElementHandler() {
+                public void childHanlded(DelegetingHandler child) {
+                    Iterator it = ((UnitsHandler) child).bundles.iterator();
+                    while (it.hasNext()) {
+                        p2Descriptor.addBundle((BundleInfo) it.next());
+                    }
+                }
+            });
+            addChild(new ReferencesHandler(), new ChildElementHandler() {
+                public void childHanlded(DelegetingHandler child) {
+                }
+            });
+        }
+
+        // protected void handleAttributes(Attributes atts) {
+        // String name = atts.getValue(NAME);
+        // String type = atts.getValue(TYPE);
+        // String version = atts.getValue(VERSION);
+        // String description = atts.getValue(DESCRIPTION);
+        // String provider = atts.getValue(PROVIDER);
+        // }
+    }
+
+    static class ReferencesHandler extends DelegetingHandler {
+
+        private static final String REFERENCES = "references";
+
+        private static final String SIZE = "size";
+
+        List/* <URI> */repositoryUris;
+
+        public ReferencesHandler() {
+            super(REFERENCES);
+            addChild(new RepositoryReferenceHandler(), new ChildElementHandler() {
+                public void childHanlded(DelegetingHandler child) {
+                    repositoryUris.add(((RepositoryReferenceHandler) child).uri);
+                }
+            });
+        }
+
+        protected void handleAttributes(Attributes atts) throws SAXException {
+            int size = Integer.parseInt(atts.getValue(SIZE));
+            repositoryUris = new ArrayList(size);
+        }
+    }
+
+    static class RepositoryReferenceHandler extends DelegetingHandler {
+
+        private static final String REPOSITORY = "repository";
+
+        private static final String TYPE = "type";
+
+        private static final String OPTIONS = "options";
+
+        private static final String NAME = "name";
+
+        private static final String URI = "uri";
+
+        private static final String URL = "url";
+
+        public RepositoryReferenceHandler() {
+            super(REPOSITORY);
+        }
+
+        int type;
+
+        int options;
+
+        String name;
+
+        URI uri;
+
+        protected void handleAttributes(Attributes atts) throws SAXException {
+            type = Integer.parseInt(atts.getValue(TYPE));
+            options = Integer.parseInt(atts.getValue(OPTIONS));
+            name = atts.getValue(NAME);
+
+            try {
+                String uriAtt = atts.getValue(URI);
+                String url = atts.getValue(URL);
+                if (uri != null) {
+                    uri = new URI(uriAtt);
+                } else if (url != null) {
+                    uri = new URI(url);
+                }
+            } catch (URISyntaxException e) {
+                // TODO Auto-generated catch block
+                e.printStackTrace();
+            }
+        }
+    }
+
+    static class UnitsHandler extends DelegetingHandler {
+
+        private static final String UNITS = "units";
+
+        private static final String SIZE = "size";
+
+        List bundles;
+
+        public UnitsHandler() {
+            super(UNITS);
+            addChild(new UnitHandler(), new ChildElementHandler() {
+                public void childHanlded(DelegetingHandler child) {
+                    bundles.add(((UnitHandler) child).bundleInfo);
+                }
+            });
+        }
+
+        protected void handleAttributes(Attributes atts) {
+            int size = Integer.parseInt(atts.getValue(SIZE));
+            bundles = new ArrayList(size);
+        }
+
+    }
+
+    static class UnitHandler extends DelegetingHandler {
+
+        private static final String UNIT = "unit";
+
+        private static final String ID = "id";
+
+        private static final String VERSION = "version";
+
+        private static final String SINGLETON = "singleton";
+
+        BundleInfo bundleInfo;
+
+        public UnitHandler() {
+            super(UNIT);
+            // addChild(new UpdateHandler(), new ChildElementHandler() {
+            // public void childHanlded(DelegetingHandler child) {
+            // }
+            // });
+            addChild(new PropertiesHandler(), new ChildElementHandler() {
+                public void childHanlded(DelegetingHandler child) {
+                    Map properties = ((PropertiesHandler) child).properties;
+                    String category = (String) properties
+                            .get("org.eclipse.equinox.p2.type.category");
+                    if (category != null && Boolean.valueOf(category).booleanValue())
{
+                        // this is a category definition, this is useless, skip this unit
+                        child.getParent().skip();
+                    }
+                }
+            });
+            addChild(new ProvidesHandler(), new ChildElementHandler() {
+                public void childHanlded(DelegetingHandler child) {
+                    Iterator it = ((ProvidesHandler) child).capabilities.iterator();
+                    while (it.hasNext()) {
+                        bundleInfo.addCapability((BundleCapability) it.next());
+                    }
+                }
+            });
+            addChild(new FilterHandler(), new ChildElementHandler() {
+                public void childHanlded(DelegetingHandler child) {
+                }
+            });
+            addChild(new RequiresHandler(), new ChildElementHandler() {
+                public void childHanlded(DelegetingHandler child) {
+                    Iterator it = ((RequiresHandler) child).requirements.iterator();
+                    while (it.hasNext()) {
+                        bundleInfo.addRequirement((BundleRequirement) it.next());
+                    }
+                }
+            });
+            addChild(new HostRequirementsHandler(), new ChildElementHandler() {
+                public void childHanlded(DelegetingHandler child) {
+                }
+            });
+            addChild(new MetaRequirementsHandler(), new ChildElementHandler() {
+                public void childHanlded(DelegetingHandler child) {
+                }
+            });
+            addChild(new ArtifactsHandler(), new ChildElementHandler() {
+                public void childHanlded(DelegetingHandler child) {
+                }
+            });
+            // addChild(new TouchpointHandler(), new ChildElementHandler() {
+            // public void childHanlded(DelegetingHandler child) {
+            // }
+            // });
+            // addChild(new TouchpointDataHandler(), new ChildElementHandler() {
+            // public void childHanlded(DelegetingHandler child) {
+            // }
+            // });
+            // addChild(new LicensesHandler(), new ChildElementHandler() {
+            // public void childHanlded(DelegetingHandler child) {
+            // }
+            // });
+            // addChild(new CopyrightHandler(), new ChildElementHandler() {
+            // public void childHanlded(DelegetingHandler child) {
+            // }
+            // });
+            addChild(new ChangesHandler(), new ChildElementHandler() {
+                public void childHanlded(DelegetingHandler child) {
+                }
+            });
+
+        }
+
+        protected void handleAttributes(Attributes atts) {
+            String id = atts.getValue(ID);
+            Version version = new Version(atts.getValue(VERSION));
+            boolean singleton = Boolean.getBoolean(atts.getValue(SINGLETON));
+            bundleInfo = new BundleInfo(id, version);
+        }
+
+    }
+
+    // static class UpdateHandler extends DelegetingHandler {
+    //
+    // private static final String UPDATE = "update";
+    //
+    // private static final String ID = "id";
+    //
+    // private static final String RANGE = "range";
+    //
+    // private static final String SEVERITY = "severity";
+    //
+    // public UpdateHandler() {
+    // super(UPDATE);
+    // }
+    //
+    // protected void handleAttributes(Attributes atts) {
+    // String id = atts.getValue(ID);
+    // String range = atts.getValue(RANGE);
+    // String severity = atts.getValue(SEVERITY);
+    // }
+    //
+    // }
+
+    static class FilterHandler extends DelegetingHandler {
+
+        private static final String FILTER = "filter";
+
+        public FilterHandler() {
+            super(FILTER);
+            setBufferingChar(true);
+        }
+
+    }
+
+    private static String namespace2Type(String namespace) {
+        if (namespace.equals("java.package")) {
+            return BundleInfo.PACKAGE_TYPE;
+        }
+        if (namespace.equals("osgi.bundle")) {
+            return BundleInfo.BUNDLE_TYPE;
+        }
+        return null;
+    }
+
+    static class ProvidesHandler extends DelegetingHandler {
+
+        private static final String PROVIDES = "provides";
+
+        private static final String SIZE = "size";
+
+        List capabilities;
+
+        public ProvidesHandler() {
+            super(PROVIDES);
+            addChild(new ProvidedHandler(), new ChildElementHandler() {
+                public void childHanlded(DelegetingHandler child) {
+                    String name = ((ProvidedHandler) child).name;
+                    Version version = ((ProvidedHandler) child).version;
+                    String type = namespace2Type(((ProvidedHandler) child).namespace);
+                    BundleCapability capability;
+                    if (type == BundleInfo.PACKAGE_TYPE) {
+                        capability = new ExportPackage(name, version);
+                    } else {
+                        capability = new BundleCapability(type, name, version);
+                    }
+                    capabilities.add(capability);
+                }
+            });
+        }
+
+        protected void handleAttributes(Attributes atts) {
+            int size = Integer.parseInt(atts.getValue(SIZE));
+            capabilities = new ArrayList(size);
+        }
+
+    }
+
+    static class ProvidedHandler extends DelegetingHandler {
+
+        private static final String PROVIDED = "provided";
+
+        private static final String NAMESPACE = "namespace";
+
+        private static final String NAME = "name";
+
+        private static final String VERSION = "version";
+
+        String namespace;
+
+        String name;
+
+        Version version;
+
+        public ProvidedHandler() {
+            super(PROVIDED);
+        }
+
+        protected void handleAttributes(Attributes atts) {
+            namespace = atts.getValue(NAMESPACE);
+            name = atts.getValue(NAME);
+            version = new Version(atts.getValue(VERSION));
+        }
+
+    }
+
+    static abstract class AbstractRequirementHandler extends DelegetingHandler {
+
+        private static final String SIZE = "size";
+
+        List requirements;
+
+        public AbstractRequirementHandler(String name) {
+            super(name);
+            addChild(new RequiredHandler(), new ChildElementHandler() {
+                public void childHanlded(DelegetingHandler child) {
+                    String name = ((RequiredHandler) child).name;
+                    VersionRange range = ((RequiredHandler) child).range;
+                    String type = namespace2Type(((RequiredHandler) child).namespace);
+                    requirements.add(new BundleRequirement(type, name, range, null));
+                }
+            });
+        }
+
+        protected void handleAttributes(Attributes atts) {
+            int size = Integer.parseInt(atts.getValue(SIZE));
+            requirements = new ArrayList(size);
+        }
+
+    }
+
+    static class RequiresHandler extends AbstractRequirementHandler {
+
+        private static final String REQUIRES = "provides";
+
+        public RequiresHandler() {
+            super(REQUIRES);
+        }
+
+    }
+
+    static class RequiredHandler extends DelegetingHandler {
+
+        private static final String REQUIRED = "required";
+
+        private static final String NAMESPACE = "namespace";
+
+        private static final String NAME = "name";
+
+        private static final String RANGE = "range";
+
+        String namespace;
+
+        String name;
+
+        VersionRange range;
+
+        String filter;
+
+        public RequiredHandler() {
+            super(REQUIRED);
+            addChild(new FilterHandler(), new ChildElementHandler() {
+                public void childHanlded(DelegetingHandler child) {
+                    filter = child.getBufferedChars().trim();
+                }
+            });
+        }
+
+        protected void handleAttributes(Attributes atts) {
+            namespace = atts.getValue(NAMESPACE);
+            name = atts.getValue(NAME);
+            try {
+                range = new VersionRange(atts.getValue(RANGE));
+            } catch (ParseException e) {
+                throw new RuntimeException(e);
+            }
+        }
+
+    }
+
+    static class HostRequirementsHandler extends AbstractRequirementHandler {
+
+        private static final String HOST_REQUIREMENTS = "hostRequirements";
+
+        public HostRequirementsHandler() {
+            super(HOST_REQUIREMENTS);
+        }
+
+    }
+
+    static class MetaRequirementsHandler extends AbstractRequirementHandler {
+
+        private static final String META_REQUIREMENTS = "metaRequirements";
+
+        public MetaRequirementsHandler() {
+            super(META_REQUIREMENTS);
+        }
+
+    }
+
+    static class ArtifactsHandler extends DelegetingHandler {
+
+        private static final String ARTIFACTS = "artifacts";
+
+        private static final String SIZE = "size";
+
+        List artifacts;
+
+        public ArtifactsHandler() {
+            super(ARTIFACTS);
+            addChild(new ArtifactHandler(), new ChildElementHandler() {
+                public void childHanlded(DelegetingHandler child) {
+                    artifacts.add(((ArtifactHandler) child).artifact);
+                }
+            });
+        }
+
+        protected void handleAttributes(Attributes atts) {
+            int size = Integer.parseInt(atts.getValue(SIZE));
+            artifacts = new ArrayList(size);
+        }
+
+    }
+
+    static class ArtifactHandler extends DelegetingHandler/* <ArtifactsHandler> */{
+
+        private static final String ARTIFACT = "artifact";
+
+        private static final String ID = "id";
+
+        private static final String VERSION = "version";
+
+        private static final String CLASSIFIER = "classifier";
+
+        P2Artifact artifact;
+
+        public ArtifactHandler() {
+            super(ARTIFACT);
+        }
+
+        protected void handleAttributes(Attributes atts) {
+            String id = atts.getValue(ID);
+            Version version = new Version(atts.getValue(VERSION));
+            String classifier = atts.getValue(CLASSIFIER);
+            artifact = new P2Artifact(id, version, classifier);
+        }
+
+    }
+
+    //
+    // static class TouchpointHandler extends DelegetingHandler {
+    //
+    // private static final String TOUCHPOINT = "touchpoint";
+    //
+    // private static final String ID = "id";
+    //
+    // private static final String VERSION = "version";
+    //
+    // public TouchpointHandler() {
+    // super(TOUCHPOINT);
+    // }
+    //
+    // protected void handleAttributes(Attributes atts) {
+    // String id = atts.getValue(ID);
+    // String version = atts.getValue(VERSION);
+    // }
+    //
+    // }
+    //
+    // static class TouchpointDataHandler extends DelegetingHandler {
+    //
+    // private static final String TOUCHPOINTDATA = "touchpointData";
+    //
+    // private static final String SIZE = "size";
+    //
+    // public TouchpointDataHandler() {
+    // super(TOUCHPOINTDATA);
+    // addChild(new InstructionsHandler(), new ChildElementHandler() {
+    // public void childHanlded(DelegetingHandler child) {
+    // }
+    // });
+    // }
+    //
+    // protected void handleAttributes(Attributes atts) {
+    // String size = atts.getValue(SIZE);
+    // }
+    //
+    // }
+    //
+    // static class InstructionsHandler extends DelegetingHandler {
+    //
+    // private static final String INSTRUCTIONS = "instructions";
+    //
+    // private static final String SIZE = "size";
+    //
+    // public InstructionsHandler() {
+    // super(INSTRUCTIONS);
+    // addChild(new InstructionHandler(), new ChildElementHandler() {
+    // public void childHanlded(DelegetingHandler child) {
+    // }
+    // });
+    // }
+    //
+    // protected void handleAttributes(Attributes atts) {
+    // String size = atts.getValue(SIZE);
+    // }
+    //
+    // }
+    //
+    // static class InstructionHandler extends DelegetingHandler {
+    //
+    // private static final String INSTRUCTION = "instruction";
+    //
+    // private static final String KEY = "key";
+    //
+    // public InstructionHandler() {
+    // super(INSTRUCTION);
+    // setBufferingChar(true);
+    // }
+    //
+    // protected void handleAttributes(Attributes atts) {
+    // String size = atts.getValue(KEY);
+    // }
+    //
+    // }
+    //
+    // static class LicensesHandler extends DelegetingHandler {
+    //
+    // private static final String LICENSES = "licenses";
+    //
+    // private static final String SIZE = "size";
+    //
+    // public LicensesHandler() {
+    // super(LICENSES);
+    // addChild(new LicenseHandler(), new ChildElementHandler() {
+    // public void childHanlded(DelegetingHandler child) {
+    // }
+    // });
+    // }
+    //
+    // protected void handleAttributes(Attributes atts) {
+    // String size = atts.getValue(SIZE);
+    // }
+    //
+    // }
+    //
+    // static class LicenseHandler extends DelegetingHandler {
+    //
+    // private static final String LICENSE = "license";
+    //
+    // private static final String URI = "uri";
+    //
+    // private static final String URL = "url";
+    //
+    // public LicenseHandler() {
+    // super(LICENSE);
+    // setBufferingChar(true);
+    // }
+    //
+    // protected void handleAttributes(Attributes atts) {
+    // String uri = atts.getValue(URI);
+    // String url = atts.getValue(URL);
+    // }
+    //
+    // }
+    //
+    // static class CopyrightHandler extends DelegetingHandler {
+    //
+    // private static final String COPYRIGHT = "copyright";
+    //
+    // private static final String URI = "uri";
+    //
+    // private static final String URL = "url";
+    //
+    // public CopyrightHandler() {
+    // super(COPYRIGHT);
+    // }
+    //
+    // protected void handleAttributes(Attributes atts) {
+    // String uri = atts.getValue(URI);
+    // String url = atts.getValue(URL);
+    // }
+    //
+    // }
+
+    static class ChangesHandler extends DelegetingHandler {
+
+        private static final String CHANGES = "changes";
+
+        private static final String SIZE = "size";
+
+        public ChangesHandler() {
+            super(CHANGES);
+            addChild(new ChangeHandler(), new ChildElementHandler() {
+                public void childHanlded(DelegetingHandler child) {
+                }
+            });
+        }
+
+        protected void handleAttributes(Attributes atts) {
+            int size = Integer.parseInt(atts.getValue(SIZE));
+        }
+    }
+
+    static class ChangeHandler extends DelegetingHandler {
+
+        private static final String CHANGE = "change";
+
+        public ChangeHandler() {
+            super(CHANGE);
+        }
+    }
+
+    static class FromHandler extends AbstractRequirementHandler {
+
+        private static final String FROM = "from";
+
+        public FromHandler() {
+            super(FROM);
+        }
+
+    }
+
+    static class ToHandler extends AbstractRequirementHandler {
+
+        private static final String TO = "to";
+
+        public ToHandler() {
+            super(TO);
+        }
+
+    }
+
+    static class PatchScopeHandler extends DelegetingHandler {
+
+        private static final String PATCH_SCOPE = "patchScope";
+
+        private static final String SIZE = "size";
+
+        public PatchScopeHandler() {
+            super(PATCH_SCOPE);
+            addChild(new PatchScopeHandler(), new ChildElementHandler() {
+                public void childHanlded(DelegetingHandler child) {
+                }
+            });
+        }
+
+        protected void handleAttributes(Attributes atts) {
+            int size = Integer.parseInt(atts.getValue(SIZE));
+        }
+    }
+
+    static class ScopeHandler extends DelegetingHandler {
+
+        private static final String SCOPE = "scope";
+
+        public ScopeHandler() {
+            super(SCOPE);
+            addChild(new RequiresHandler(), new ChildElementHandler() {
+                public void childHanlded(DelegetingHandler child) {
+                }
+            });
+        }
+    }
+
+    static class LifeCycleHandler extends AbstractRequirementHandler {
+
+        private static final String LIFE_CYCLE = "lifeCycle";
+
+        public LifeCycleHandler() {
+            super(LIFE_CYCLE);
+        }
+    }
+
+}

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2MetadataParser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2MetadataParser.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2MetadataParser.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/PropertiesParser.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/PropertiesParser.java?rev=1056291&view=auto
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/PropertiesParser.java (added)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/PropertiesParser.java Fri Jan  7 12:41:04
2011
@@ -0,0 +1,75 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.ivy.osgi.p2;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.ivy.osgi.util.DelegetingHandler;
+import org.xml.sax.Attributes;
+
+public class PropertiesParser {
+
+    static class PropertiesHandler extends DelegetingHandler {
+
+        private static final String PROPERTIES = "properties";
+
+        private static final String SIZE = "size";
+
+        Map properties;
+
+        public PropertiesHandler() {
+            super(PROPERTIES);
+            addChild(new PropertyHandler(), new ChildElementHandler() {
+                public void childHanlded(DelegetingHandler child) {
+                    properties.put(((PropertyHandler) child).name, ((PropertyHandler) child).value);
+                }
+            });
+        }
+
+        protected void handleAttributes(Attributes atts) {
+            int size = Integer.parseInt(atts.getValue(SIZE));
+            properties = new HashMap(size);
+        }
+
+    }
+
+    static class PropertyHandler extends DelegetingHandler {
+
+        private static final String PROPERTY = "property";
+
+        private static final String NAME = "name";
+
+        private static final String VALUE = "value";
+
+        String name;
+
+        String value;
+
+        public PropertyHandler() {
+            super(PROPERTY);
+        }
+
+        protected void handleAttributes(Attributes atts) {
+            name = atts.getValue(NAME);
+            value = atts.getValue(VALUE);
+        }
+
+    }
+
+}

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/PropertiesParser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/PropertiesParser.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/PropertiesParser.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/XMLInputParser.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/XMLInputParser.java?rev=1056291&view=auto
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/XMLInputParser.java (added)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/XMLInputParser.java Fri Jan  7 12:41:04
2011
@@ -0,0 +1,30 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.ivy.osgi.p2;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.text.ParseException;
+
+import org.xml.sax.SAXException;
+
+public interface XMLInputParser {
+
+    public void parse(InputStream in) throws ParseException, IOException, SAXException;
+
+}

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/XMLInputParser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/XMLInputParser.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/XMLInputParser.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message