You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by ri...@apache.org on 2010/03/03 15:58:22 UTC

svn commit: r918498 [1/3] - in /felix/trunk/framework/src/main/java/org/apache/felix: framework/capabilityset/ framework/util/manifestparser/ moduleloader/

Author: rickhall
Date: Wed Mar  3 14:58:21 2010
New Revision: 918498

URL: http://svn.apache.org/viewvc?rev=918498&view=rev
Log:
Improve generic capability/requirement abstraction and prepare for
for new resolver implementation. (FELIX-2036, FELIX-2035)

Added:
    felix/trunk/framework/src/main/java/org/apache/felix/framework/capabilityset/Attribute.java
      - copied, changed from r915677, felix/trunk/framework/src/main/java/org/apache/felix/framework/util/manifestparser/R4Attribute.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/capabilityset/Capability.java
      - copied, changed from r915677, felix/trunk/framework/src/main/java/org/apache/felix/moduleloader/ICapability.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/capabilityset/Directive.java
      - copied, changed from r915677, felix/trunk/framework/src/main/java/org/apache/felix/framework/util/manifestparser/R4Directive.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/capabilityset/Requirement.java
      - copied, changed from r915677, felix/trunk/framework/src/main/java/org/apache/felix/moduleloader/IRequirement.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/util/manifestparser/CapabilityImpl.java
      - copied, changed from r915677, felix/trunk/framework/src/main/java/org/apache/felix/framework/util/manifestparser/Capability.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/util/manifestparser/ParsedHeaderClause.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/util/manifestparser/RequirementImpl.java
      - copied, changed from r915677, felix/trunk/framework/src/main/java/org/apache/felix/framework/util/manifestparser/Requirement.java
Removed:
    felix/trunk/framework/src/main/java/org/apache/felix/framework/util/manifestparser/Capability.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/util/manifestparser/R4Attribute.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/util/manifestparser/R4Directive.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/util/manifestparser/Requirement.java
    felix/trunk/framework/src/main/java/org/apache/felix/moduleloader/ICapability.java
    felix/trunk/framework/src/main/java/org/apache/felix/moduleloader/IRequirement.java
Modified:
    felix/trunk/framework/src/main/java/org/apache/felix/framework/util/manifestparser/ManifestParser.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/util/manifestparser/R4Library.java

Copied: felix/trunk/framework/src/main/java/org/apache/felix/framework/capabilityset/Attribute.java (from r915677, felix/trunk/framework/src/main/java/org/apache/felix/framework/util/manifestparser/R4Attribute.java)
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/capabilityset/Attribute.java?p2=felix/trunk/framework/src/main/java/org/apache/felix/framework/capabilityset/Attribute.java&p1=felix/trunk/framework/src/main/java/org/apache/felix/framework/util/manifestparser/R4Attribute.java&r1=915677&r2=918498&rev=918498&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/util/manifestparser/R4Attribute.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/capabilityset/Attribute.java Wed Mar  3 14:58:21 2010
@@ -1,30 +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.
+ *  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.felix.framework.util.manifestparser;
+package org.apache.felix.framework.capabilityset;
 
-public class R4Attribute
+public class Attribute
 {
     private final String m_name;
     private final Object m_value;
     private final boolean m_isMandatory;
 
-    public R4Attribute(String name, Object value, boolean isMandatory)
+    public Attribute(String name, Object value, boolean isMandatory)
     {
         m_name = name;
         m_value = value;
@@ -45,4 +45,9 @@
     {
         return m_isMandatory;
     }
+
+    public String toString()
+    {
+        return m_name + "=" + m_value;
+    }
 }
\ No newline at end of file

Copied: felix/trunk/framework/src/main/java/org/apache/felix/framework/capabilityset/Capability.java (from r915677, felix/trunk/framework/src/main/java/org/apache/felix/moduleloader/ICapability.java)
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/capabilityset/Capability.java?p2=felix/trunk/framework/src/main/java/org/apache/felix/framework/capabilityset/Capability.java&p1=felix/trunk/framework/src/main/java/org/apache/felix/moduleloader/ICapability.java&r1=915677&r2=918498&rev=918498&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/moduleloader/ICapability.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/capabilityset/Capability.java Wed Mar  3 14:58:21 2010
@@ -1,35 +1,40 @@
-/* 
- * 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.
+/*
+ *  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.felix.moduleloader;
+package org.apache.felix.framework.capabilityset;
 
-import java.util.Map;
+import org.apache.felix.framework.resolver.Module;
+import java.util.List;
 
-public interface ICapability
+public interface Capability
 {
-    public static final String MODULE_NAMESPACE = "module";
-    public static final String HOST_NAMESPACE = "host";
-    public static final String PACKAGE_NAMESPACE = "package";
+    static final String MODULE_NAMESPACE = "module";
+    static final String HOST_NAMESPACE = "host";
+    static final String PACKAGE_NAMESPACE = "package";
 
-    public static final String PACKAGE_PROPERTY = "package";
-    public static final String VERSION_PROPERTY = "version";
+    public static final String PACKAGE_ATTR = "package";
+    public static final String VERSION_ATTR = "version";
 
-    IModule getModule();
+    Module getModule();
     String getNamespace();
-    Map getProperties();
+    Directive getDirective(String name);
+    List<Directive> getDirectives();
+    Attribute getAttribute(String name);
+    List<Attribute> getAttributes();
+    List<String> getUses();
 }
\ No newline at end of file

Copied: felix/trunk/framework/src/main/java/org/apache/felix/framework/capabilityset/Directive.java (from r915677, felix/trunk/framework/src/main/java/org/apache/felix/framework/util/manifestparser/R4Directive.java)
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/capabilityset/Directive.java?p2=felix/trunk/framework/src/main/java/org/apache/felix/framework/capabilityset/Directive.java&p1=felix/trunk/framework/src/main/java/org/apache/felix/framework/util/manifestparser/R4Directive.java&r1=915677&r2=918498&rev=918498&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/util/manifestparser/R4Directive.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/capabilityset/Directive.java Wed Mar  3 14:58:21 2010
@@ -1,29 +1,29 @@
 /*
- * 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.
+ *  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.felix.framework.util.manifestparser;
+package org.apache.felix.framework.capabilityset;
 
-public class R4Directive
+public class Directive
 {
     private final String m_name;
-    private final String m_value;
+    private final Object m_value;
 
-    public R4Directive(String name, String value)
+    public Directive(String name, Object value)
     {
         m_name = name;
         m_value = value;
@@ -34,8 +34,13 @@
         return m_name;
     }
 
-    public String getValue()
+    public Object getValue()
     {
         return m_value;
     }
+
+    public String toString()
+    {
+        return m_name + "=" + m_value;
+    }
 }
\ No newline at end of file

Copied: felix/trunk/framework/src/main/java/org/apache/felix/framework/capabilityset/Requirement.java (from r915677, felix/trunk/framework/src/main/java/org/apache/felix/moduleloader/IRequirement.java)
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/capabilityset/Requirement.java?p2=felix/trunk/framework/src/main/java/org/apache/felix/framework/capabilityset/Requirement.java&p1=felix/trunk/framework/src/main/java/org/apache/felix/moduleloader/IRequirement.java&r1=915677&r2=918498&rev=918498&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/moduleloader/IRequirement.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/capabilityset/Requirement.java Wed Mar  3 14:58:21 2010
@@ -1,31 +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.
+/*
+ *  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.felix.moduleloader;
+package org.apache.felix.framework.capabilityset;
 
-import org.osgi.framework.Filter;
+import java.util.List;
 
-public interface IRequirement
+public interface Requirement
 {
     String getNamespace();
-    Filter getFilter();
-    boolean isMultiple();
+    SimpleFilter getFilter();
     boolean isOptional();
-    String getComment();
-    boolean isSatisfied(ICapability capability);
+    Directive getDirective(String name);
+    List<Directive> getDirectives();
 }
\ No newline at end of file

Copied: felix/trunk/framework/src/main/java/org/apache/felix/framework/util/manifestparser/CapabilityImpl.java (from r915677, felix/trunk/framework/src/main/java/org/apache/felix/framework/util/manifestparser/Capability.java)
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/util/manifestparser/CapabilityImpl.java?p2=felix/trunk/framework/src/main/java/org/apache/felix/framework/util/manifestparser/CapabilityImpl.java&p1=felix/trunk/framework/src/main/java/org/apache/felix/framework/util/manifestparser/Capability.java&r1=915677&r2=918498&rev=918498&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/util/manifestparser/Capability.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/util/manifestparser/CapabilityImpl.java Wed Mar  3 14:58:21 2010
@@ -1,89 +1,99 @@
 /*
- * 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
+ *  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
+ *    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.
+ *  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.felix.framework.util.manifestparser;
 
-import java.util.*;
-
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.StringTokenizer;
+import org.apache.felix.framework.capabilityset.Attribute;
+import org.apache.felix.framework.capabilityset.Capability;
+import org.apache.felix.framework.capabilityset.Directive;
+import org.apache.felix.framework.resolver.Module;
 import org.apache.felix.framework.util.Util;
-import org.apache.felix.moduleloader.ICapability;
-import org.apache.felix.moduleloader.IModule;
 import org.osgi.framework.Constants;
-import org.osgi.framework.Version;
 
-public class Capability implements ICapability, Comparable
+public class CapabilityImpl implements Capability
 {
-    private final IModule m_module;
+    private final Module m_module;
     private final String m_namespace;
-    private final R4Directive[] m_directives;
-    private final R4Attribute[] m_attributes;
-    private final String[] m_uses;
-    private final String[][] m_includeFilter;
-    private final String[][] m_excludeFilter;
-    private volatile Map m_attrMap;
-
-    // Cached properties for performance reasons.
-    private final String m_pkgName;
-    private final Version m_pkgVersion;
+    private final List<Directive> m_dirs;
+    private final List<Directive> m_dirsConst;
+    private final List<Attribute> m_attrs;
+    private final List<Attribute> m_attrsConst;
+    private final List<String> m_uses;
+    private final List<List<String>> m_includeFilter;
+    private final List<List<String>> m_excludeFilter;
 
-    public Capability(IModule module, String namespace, R4Directive[] dirs, R4Attribute[] attrs)
+    public CapabilityImpl(Module module, String namespace,
+        List<Directive> dirs, List<Attribute> attrs)
     {
-        m_module = module;
         m_namespace = namespace;
-        m_directives = dirs;
-        m_attributes = attrs;
+        m_module = module;
+        m_dirs = dirs;
+        m_dirsConst = Collections.unmodifiableList(m_dirs);
+        m_attrs = attrs;
+        m_attrsConst = Collections.unmodifiableList(m_attrs);
 
         // Find all export directives: uses, mandatory, include, and exclude.
         String mandatory = "";
-        String[] uses = new String[0];
-        String[][] includeFilter = null, excludeFilter = null;
-        for (int dirIdx = 0; (m_directives != null) && (dirIdx < m_directives.length); dirIdx++)
+        List<String> uses = new ArrayList(0);
+        List<List<String>> includeFilter = null, excludeFilter = null;
+        for (int dirIdx = 0; dirIdx < m_dirs.size(); dirIdx++)
         {
-            if (m_directives[dirIdx].getName().equals(Constants.USES_DIRECTIVE))
+            if (m_dirs.get(dirIdx).getName().equals(Constants.USES_DIRECTIVE))
             {
                 // Parse these uses directive.
-                StringTokenizer tok = new StringTokenizer(m_directives[dirIdx].getValue(), ",");
-                uses = new String[tok.countTokens()];
-                for (int i = 0; i < uses.length; i++)
+                StringTokenizer tok = new StringTokenizer(
+                    (String) m_dirs.get(dirIdx).getValue(), ",");
+                uses = new ArrayList<String>(tok.countTokens());
+                while (tok.hasMoreTokens())
                 {
-                    uses[i] = tok.nextToken().trim();
+                    uses.add(tok.nextToken().trim());
                 }
             }
-            else if (m_directives[dirIdx].getName().equals(Constants.MANDATORY_DIRECTIVE))
+            else if (m_dirs.get(dirIdx).getName().equals(Constants.MANDATORY_DIRECTIVE))
             {
-                mandatory = m_directives[dirIdx].getValue();
+                mandatory = (String) m_dirs.get(dirIdx).getValue();
             }
-            else if (m_directives[dirIdx].getName().equals(Constants.INCLUDE_DIRECTIVE))
+            else if (m_dirs.get(dirIdx).getName().equals(Constants.INCLUDE_DIRECTIVE)
+                || m_dirs.get(dirIdx).getName().equals(Constants.EXCLUDE_DIRECTIVE))
             {
-                String[] ss = ManifestParser.parseDelimitedString(m_directives[dirIdx].getValue(), ",");
-                includeFilter = new String[ss.length][];
-                for (int filterIdx = 0; filterIdx < ss.length; filterIdx++)
+                List<List<String>> filterList = null;
+
+                List<String> filters = ManifestParser.parseDelimitedString(
+                    (String) m_dirs.get(dirIdx).getValue(), ",");
+                filterList = new ArrayList<List<String>>(filters.size());
+
+                for (int filterIdx = 0; filterIdx < filters.size(); filterIdx++)
                 {
-                    includeFilter[filterIdx] = Util.parseSubstring(ss[filterIdx]);
+                    List<String> substrings = Util.parseSubstring(filters.get(filterIdx));
+                    filterList.add(substrings);
                 }
-            }
-            else if (m_directives[dirIdx].getName().equals(Constants.EXCLUDE_DIRECTIVE))
-            {
-                String[] ss = ManifestParser.parseDelimitedString(m_directives[dirIdx].getValue(), ",");
-                excludeFilter = new String[ss.length][];
-                for (int filterIdx = 0; filterIdx < ss.length; filterIdx++)
+
+                if (m_dirs.get(dirIdx).getName().equals(Constants.INCLUDE_DIRECTIVE))
+                {
+                    includeFilter = filterList;
+                }
+                else
                 {
-                    excludeFilter[filterIdx] = Util.parseSubstring(ss[filterIdx]);
+                    excludeFilter = filterList;
                 }
             }
         }
@@ -102,13 +112,13 @@
             String attrName = tok.nextToken().trim();
             // Find attribute and mark it as mandatory.
             boolean found = false;
-            for (int i = 0; (!found) && (i < m_attributes.length); i++)
+            for (int i = 0; (!found) && (i < m_attrs.size()); i++)
             {
-                if (m_attributes[i].getName().equals(attrName))
+                if (m_attrs.get(i).getName().equals(attrName))
                 {
-                    m_attributes[i] = new R4Attribute(
-                        m_attributes[i].getName(),
-                        m_attributes[i].getValue(), true);
+                    m_attrs.set(i, new Attribute(
+                        m_attrs.get(i).getName(),
+                        m_attrs.get(i).getValue(), true));
                     found = true;
                 }
             }
@@ -120,28 +130,9 @@
                     "Mandatory attribute '" + attrName + "' does not exist.");
             }
         }
-
-        // For performance reasons, find the package name and version properties.
-        String pkgName = null;
-        Version pkgVersion = Version.emptyVersion;
-        for (int i = 0; i < m_attributes.length; i++)
-        {
-            if (m_attributes[i].getName().equals(ICapability.PACKAGE_PROPERTY))
-            {
-                pkgName = (String) m_attributes[i].getValue();
-            }
-            else if (m_attributes[i].getName().equals(ICapability.VERSION_PROPERTY))
-            {
-                pkgVersion = (Version) m_attributes[i].getValue();
-            }
-        }
-
-        // Set final values.
-        m_pkgName = pkgName;
-        m_pkgVersion = pkgVersion;
     }
 
-    public IModule getModule()
+    public Module getModule()
     {
         return m_module;
     }
@@ -151,33 +142,42 @@
         return m_namespace;
     }
 
-// TODO: RB - Determine how to eliminate these non-generic methods;
-//            at least make sure they are not used in the generic resolver.
-    public String getPackageName()
+    public Directive getDirective(String name)
     {
-        return m_pkgName;
+        for (int i = 0; i < m_dirs.size(); i++)
+        {
+            if (m_dirs.get(i).getName().equals(name))
+            {
+                return m_dirs.get(i);
+            }
+        }
+        return null;
     }
 
-    public Version getPackageVersion()
+    public List<Directive> getDirectives()
     {
-        return m_pkgVersion;
+        return m_dirsConst;
     }
 
-    public R4Directive[] getDirectives()
+    public Attribute getAttribute(String name)
     {
-        // TODO: RB - We should return copies of the arrays probably.
-        return m_directives;
+        for (int i = 0; i < m_attrs.size(); i++)
+        {
+            if (m_attrs.get(i).getName().equals(name))
+            {
+                return m_attrs.get(i);
+            }
+        }
+        return null;
     }
 
-    public R4Attribute[] getAttributes()
+    public List<Attribute> getAttributes()
     {
-        // TODO: RB - We should return copies of the arrays probably.
-        return m_attributes;
+        return m_attrsConst;
     }
 
-    public String[] getUses()
+    public List<String> getUses()
     {
-        // TODO: RB - We should return copies of the arrays probably.
         return m_uses;
     }
 
@@ -195,211 +195,35 @@
         // by default, otherwise try to find one match.
         boolean included = (m_includeFilter == null);
         for (int i = 0;
-            (!included) && (m_includeFilter != null) && (i < m_includeFilter.length);
+            (!included) && (m_includeFilter != null) && (i < m_includeFilter.size());
             i++)
         {
-            included = Util.checkSubstring(m_includeFilter[i], className);
+            included = Util.checkSubstring(m_includeFilter.get(i), className);
         }
 
         // If there are no exclude filters then no classes are excluded
         // by default, otherwise try to find one match.
         boolean excluded = false;
         for (int i = 0;
-            (!excluded) && (m_excludeFilter != null) && (i < m_excludeFilter.length);
+            (!excluded) && (m_excludeFilter != null) && (i < m_excludeFilter.size());
             i++)
         {
-            excluded = Util.checkSubstring(m_excludeFilter[i], className);
+            excluded = Util.checkSubstring(m_excludeFilter.get(i), className);
         }
         return included && !excluded;
     }
 
-// TODO: RB - Terminology mismatch property vs. attribute.
-    public Map getProperties()
-    {
-        if (m_attrMap == null)
-        {
-            m_attrMap = new Map() {
-
-                public int size()
-                {
-                    // A name and version attribute is always present, since it has a
-                    // default value.
-                    return m_attributes.length + 2;
-                }
-
-                public boolean isEmpty()
-                {
-                    // A version attribute is always present, since it has a
-                    // default value.
-                    return false;
-                }
-
-                public boolean containsKey(Object key)
-                {
-                    return (get(key) != null);
-                }
-
-                public boolean containsValue(Object value)
-                {
-                    // Check the package name.
-                    if (m_pkgName.equals(value))
-                    {
-                        return true;
-                    }
-
-                    // Check the package version.
-                    if (m_pkgVersion.equals(value))
-                    {
-                        return true;
-                    }
-
-                    // Check all attributes.
-                    for (int i = 0; i < m_attributes.length; i++)
-                    {
-                        if (m_attributes[i].getValue().equals(value))
-                        {
-                            return true;
-                        }
-                    }
-
-                    return false;
-                }
-
-                public Object get(Object key)
-                {
-                    if (ICapability.PACKAGE_PROPERTY.equals(key))
-                    {
-                        return m_pkgName;
-                    }
-                    else if (ICapability.VERSION_PROPERTY.equals(key))
-                    {
-                        return m_pkgVersion;
-                    }
-
-                    for (int i = 0; i < m_attributes.length; i++)
-                    {
-                        if (m_attributes[i].getName().equals(key))
-                        {
-                            return m_attributes[i].getValue();
-                        }
-                    }
-
-                    return null;
-                }
-
-                public Object put(Object key, Object value)
-                {
-                    throw new UnsupportedOperationException("Map.put() not implemented.");
-                }
-
-                public Object remove(Object key)
-                {
-                    throw new UnsupportedOperationException("Map.remove() not implemented.");
-                }
-
-                public void putAll(Map t)
-                {
-                    throw new UnsupportedOperationException("Map.putAll() not implemented.");
-                }
-
-                public void clear()
-                {
-                    throw new UnsupportedOperationException("Map.clear() not implemented.");
-                }
-
-                public Set keySet()
-                {
-                    Set set = new HashSet();
-                    set.add(ICapability.PACKAGE_PROPERTY);
-                    set.add(ICapability.VERSION_PROPERTY);
-                    for (int i = 0; i < m_attributes.length; i++)
-                    {
-                        set.add(m_attributes[i].getName());
-                    }
-                    return set;
-                }
-
-                public Collection values()
-                {
-                    throw new UnsupportedOperationException("Map.values() not implemented.");
-                }
-
-                public Set entrySet()
-                {
-                    throw new UnsupportedOperationException("Map.entrySet() not implemented.");
-                }
-            };
-        }
-        return m_attrMap;
-    }
-
-    public int compareTo(Object o)
-    {
-        Capability cap = (Capability) o;
-        Version thisVersion = null;
-        Version version = null;
-        if (getNamespace().equals(ICapability.PACKAGE_NAMESPACE))
-        {
-            thisVersion = getPackageVersion();
-            version = cap.getPackageVersion();
-        }
-        else if (getNamespace().equals(ICapability.MODULE_NAMESPACE))
-        {
-            thisVersion = (Version) getProperties().get(Constants.BUNDLE_VERSION_ATTRIBUTE);
-            version = (Version) cap.getProperties().get(Constants.BUNDLE_VERSION_ATTRIBUTE);
-        }
-        if ((thisVersion != null) && (version != null))
-        {
-            int cmp = thisVersion.compareTo(version);
-            if (cmp < 0)
-            {
-                return 1;
-            }
-            else if (cmp > 0)
-            {
-                return -1;
-            }
-            else
-            {
-                long thisId = m_module.getBundle().getBundleId();
-                long id = cap.getModule().getBundle().getBundleId();
-                if (thisId < id)
-                {
-                    return -1;
-                }
-                else if (thisId > id)
-                {
-                    return 1;
-                }
-                return 0;
-            }
-        }
-        else
-        {
-            return -1;
-        }
-    }
-
     public String toString()
     {
-        StringBuffer sb = new StringBuffer();
-        sb.append(getNamespace());
-        for (int i = 0; (m_directives != null) && (i < m_directives.length); i++)
+        if (m_module == null)
         {
-            sb.append(";");
-            sb.append(m_directives[i].getName());
-            sb.append(":=\"");
-            sb.append(m_directives[i].getValue());
-            sb.append("\"");
+            return m_attrs.toString();
         }
-        for (int i = 0; (m_attributes != null) && (i < m_attributes.length); i++)
+        if (m_namespace.equals(Capability.PACKAGE_NAMESPACE))
         {
-            sb.append(";");
-            sb.append(m_attributes[i].getName());
-            sb.append("=\"");
-            sb.append(m_attributes[i].getValue());
-            sb.append("\"");
+            return "[" + m_module + "] "
+                + m_namespace + "; " + getAttribute(Capability.PACKAGE_ATTR);
         }
-        return sb.toString();
+        return "[" + m_module + "] " + m_namespace + "; " + m_attrs;
     }
 }
\ No newline at end of file