The classes are no longer needed.


git-svn-id: https://svn.apache.org/repos/asf/incubator/felix/trunk@499818 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/src/main/java/org/apache/felix/framework/util/manifestparser/R4Export.java b/framework/src/main/java/org/apache/felix/framework/util/manifestparser/R4Export.java
deleted file mode 100644
index 59e0924..0000000
--- a/framework/src/main/java/org/apache/felix/framework/util/manifestparser/R4Export.java
+++ /dev/null
@@ -1,289 +0,0 @@
-/* 
- * 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;
-
-import java.util.*;
-
-import org.apache.felix.framework.util.Util;
-import org.osgi.framework.Constants;
-import org.osgi.framework.Version;
-
-public class R4Export extends R4Package
-{
-    private String[] m_uses = null;
-    private String[][] m_includeFilter = null;
-    private String[][] m_excludeFilter = null;
-
-    public R4Export(String name, R4Directive[] directives, R4Attribute[] attrs)
-    {
-        super(name, directives, attrs);
-
-        // Find all export directives: uses, mandatory, include, and exclude.
-        String mandatory = "", uses = "";
-        for (int i = 0; i < m_directives.length; i++)
-        {
-            if (m_directives[i].getName().equals(Constants.USES_DIRECTIVE))
-            {
-                uses = m_directives[i].getValue();
-            }
-            else if (m_directives[i].getName().equals(Constants.MANDATORY_DIRECTIVE))
-            {
-                mandatory = m_directives[i].getValue();
-            }
-            else if (m_directives[i].getName().equals(Constants.INCLUDE_DIRECTIVE))
-            {
-                String[] ss = ManifestParser.parseDelimitedString(m_directives[i].getValue(), ",");
-                m_includeFilter = new String[ss.length][];
-                for (int filterIdx = 0; filterIdx < ss.length; filterIdx++)
-                {
-                    m_includeFilter[filterIdx] = parseSubstring(ss[filterIdx]);
-                }
-            }
-            else if (m_directives[i].getName().equals(Constants.EXCLUDE_DIRECTIVE))
-            {
-                String[] ss = ManifestParser.parseDelimitedString(m_directives[i].getValue(), ",");
-                m_excludeFilter = new String[ss.length][];
-                for (int filterIdx = 0; filterIdx < ss.length; filterIdx++)
-                {
-                    m_excludeFilter[filterIdx] = parseSubstring(ss[filterIdx]);
-                }
-            }
-        }
-
-        // Parse these uses directive.
-        StringTokenizer tok = new StringTokenizer(uses, ",");
-        m_uses = new String[tok.countTokens()];
-        for (int i = 0; i < m_uses.length; i++)
-        {
-            m_uses[i] = tok.nextToken().trim();
-        }
-
-        // Parse mandatory directive and mark specified
-        // attributes as mandatory.
-        tok = new StringTokenizer(mandatory, ",");
-        while (tok.hasMoreTokens())
-        {
-            // Get attribute name.
-            String attrName = tok.nextToken().trim();
-            // Find attribute and mark it as mandatory.
-            boolean found = false;
-            for (int i = 0; (!found) && (i < m_attrs.length); i++)
-            {
-                if (m_attrs[i].getName().equals(attrName))
-                {
-                    m_attrs[i] = new R4Attribute(
-                        m_attrs[i].getName(),
-                        m_attrs[i].getValue(), true);
-                    found = true;
-                }
-            }
-            // If a specified mandatory attribute was not found,
-            // then error.
-            if (!found)
-            {
-                throw new IllegalArgumentException(
-                    "Mandatory attribute '" + attrName + "' does not exist.");
-            }
-        }
-
-        // Cache version, if present.
-        for (int i = 0; i < m_attrs.length; i++)
-        {
-            if (m_attrs[i].getName().equals(Constants.VERSION_ATTRIBUTE))
-            {
-                m_version = (Version) m_attrs[i].getValue();
-                break;
-            }
-        }
-    }
-
-    public String[] getUses()
-    {
-        return m_uses;
-    }
-
-    public boolean isIncluded(String name)
-    {
-        if ((m_includeFilter == null) && (m_excludeFilter == null))
-        {
-            return true;
-        }
-
-        // Get the class name portion of the target class.
-        String className = Util.getClassName(name);
-
-        // If there are no include filters then all classes are included
-        // 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);
-            i++)
-        {
-            included = checkSubstring(m_includeFilter[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);
-            i++)
-        {
-            excluded = checkSubstring(m_excludeFilter[i], className);
-        }
-        return included && !excluded;
-    }
-
-    //
-    // The following substring-related code was lifted and modified
-    // from the LDAP parser code.
-    //
-
-    private static String[] parseSubstring(String target)
-    {
-        List pieces = new ArrayList();
-        StringBuffer ss = new StringBuffer();
-        // int kind = SIMPLE; // assume until proven otherwise
-        boolean wasStar = false; // indicates last piece was a star
-        boolean leftstar = false; // track if the initial piece is a star
-        boolean rightstar = false; // track if the final piece is a star
-
-        int idx = 0;
-
-        // We assume (sub)strings can contain leading and trailing blanks
-        for (;;)
-        {
-            if (idx >= target.length())
-            {
-                if (wasStar)
-                {
-                    // insert last piece as "" to handle trailing star
-                    rightstar = true;
-                }
-                else
-                {
-                    pieces.add(ss.toString());
-                    // accumulate the last piece
-                    // note that in the case of
-                    // (cn=); this might be
-                    // the string "" (!=null)
-                }
-                ss.setLength(0);
-                break;
-            }
-
-            char c = target.charAt(idx++);
-            if (c == '*')
-            {
-                if (wasStar)
-                {
-                    // encountered two successive stars;
-                    // I assume this is illegal
-                    throw new IllegalArgumentException("Invalid filter string: " + target);
-                }
-                if (ss.length() > 0)
-                {
-                    pieces.add(ss.toString()); // accumulate the pieces
-                    // between '*' occurrences
-                }
-                ss.setLength(0);
-                // if this is a leading star, then track it
-                if (pieces.size() == 0)
-                {
-                    leftstar = true;
-                }
-                ss.setLength(0);
-                wasStar = true;
-            }
-            else
-            {
-                wasStar = false;
-                ss.append(c);
-            }
-        }
-        if (leftstar || rightstar || pieces.size() > 1)
-        {
-            // insert leading and/or trailing "" to anchor ends
-            if (rightstar)
-            {
-                pieces.add("");
-            }
-            if (leftstar)
-            {
-                pieces.add(0, "");
-            }
-        }
-        return (String[]) pieces.toArray(new String[pieces.size()]);
-    }
-
-    private static boolean checkSubstring(String[] pieces, String s)
-    {
-        // Walk the pieces to match the string
-        // There are implicit stars between each piece,
-        // and the first and last pieces might be "" to anchor the match.
-        // assert (pieces.length > 1)
-        // minimal case is <string>*<string>
-
-        boolean result = false;
-        int len = pieces.length;
-        int index = 0;
-
-        for (int i = 0; i < len; i++)
-        {
-            String piece = (String) pieces[i];
-            if (i == len - 1)
-            {
-                // this is the last piece
-                if (s.endsWith(piece))
-                {
-                    result = true;
-                }
-                else
-                {
-                    result = false;
-                }
-                break;
-            }
-            // initial non-star; assert index == 0
-            else if (i == 0)
-            {
-                if (!s.startsWith(piece))
-                {
-                    result = false;
-                    break;
-                }
-            }
-            // assert i > 0 && i < len-1
-            else
-            {
-                // Sure wish stringbuffer supported e.g. indexOf
-                index = s.indexOf(piece, index);
-                if (index < 0)
-                {
-                    result = false;
-                    break;
-                }
-            }
-            // start beyond the matching piece
-            index += piece.length();
-        }
-
-        return result;
-    }
-}
\ No newline at end of file
diff --git a/framework/src/main/java/org/apache/felix/framework/util/manifestparser/R4Import.java b/framework/src/main/java/org/apache/felix/framework/util/manifestparser/R4Import.java
deleted file mode 100644
index f4490f8..0000000
--- a/framework/src/main/java/org/apache/felix/framework/util/manifestparser/R4Import.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/* 
- * 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;
-
-import org.apache.felix.framework.util.VersionRange;
-import org.osgi.framework.Constants;
-import org.osgi.framework.Version;
-
-public class R4Import extends R4Package
-{
-    private VersionRange m_versionRange = null;
-    private boolean m_isOptional = false;
-
-    public R4Import(String name, R4Directive[] directives, R4Attribute[] attrs)
-    {
-        super(name, directives, attrs);
-
-        // Find all import directives: resolution.
-        for (int i = 0; i < m_directives.length; i++)
-        {
-            if (m_directives[i].getName().equals(Constants.RESOLUTION_DIRECTIVE))
-            {
-                m_isOptional = m_directives[i].getValue().equals(Constants.RESOLUTION_OPTIONAL);
-            }
-        }
-
-        // Cache version and version range, if present.
-        m_versionRange = VersionRange.parse(Version.emptyVersion.toString());
-        m_version = m_versionRange.getLow();
-        for (int i = 0; i < m_attrs.length; i++)
-        {
-            if (m_attrs[i].getName().equals(Constants.VERSION_ATTRIBUTE))
-            {
-                m_versionRange = (VersionRange) m_attrs[i].getValue();
-                m_version = m_versionRange.getLow();
-                break;
-            }
-        }
-    }
-
-    public Version getVersionHigh()
-    {
-        return m_versionRange.getHigh();
-    }
-
-    public boolean isLowInclusive()
-    {
-        return m_versionRange.isLowInclusive();
-    }
-
-    public boolean isHighInclusive()
-    {
-        return m_versionRange.isHighInclusive();
-    }
-
-    public boolean isOptional()
-    {
-        return m_isOptional;
-    }
-
-    public boolean isSatisfied(R4Export export)
-    {
-        // For packages to be compatible, they must have the
-        // same name.
-        if (!getName().equals(export.getName()))
-        {
-            return false;
-        }
-        
-        return m_versionRange.isInRange(export.getVersion())
-            && doAttributesMatch(export);
-    }
-
-    private boolean doAttributesMatch(R4Export export)
-    {
-        // Cycle through all attributes of this import package
-        // and make sure its values match the attribute values
-        // of the specified export package.
-        for (int impAttrIdx = 0; impAttrIdx < getAttributes().length; impAttrIdx++)
-        {
-            // Get current attribute from this import package.
-            R4Attribute impAttr = getAttributes()[impAttrIdx];
-
-            // Ignore version attribute, since it is a special case that
-            // has already been compared using isVersionInRange() before
-            // the call to this method was made.
-            if (impAttr.getName().equals(Constants.VERSION_ATTRIBUTE))
-            {
-                continue;
-            }
-
-            // Check if the export package has the same attribute.
-            boolean found = false;
-            for (int expAttrIdx = 0;
-                (!found) && (expAttrIdx < export.getAttributes().length);
-                expAttrIdx++)
-            {
-                // Get current attribute for the export package.
-                R4Attribute expAttr = export.getAttributes()[expAttrIdx];
-                // Check if the attribute names are equal.
-                if (impAttr.getName().equals(expAttr.getName()))
-                {
-                    // We only recognize version types. If the value of the
-                    // attribute is a version/version range, then we use the
-                    // "in range" comparison, otherwise we simply use equals().
-                    if (expAttr.getValue() instanceof Version)
-                    {
-                        if (!((VersionRange) impAttr.getValue()).isInRange((Version) expAttr.getValue()))
-                        {
-                            return false;
-                        }
-                    }
-                    else if (!impAttr.getValue().equals(expAttr.getValue()))
-                    {
-                        return false;
-                    }
-                    found = true;
-                }
-            }
-            // If the attribute was not found, then return false.
-            if (!found)
-            {
-                return false;
-            }
-        }
-
-        // Now, cycle through all attributes of the export package and verify that
-        // all mandatory attributes are present in this import package.
-        for (int expAttrIdx = 0; expAttrIdx < export.getAttributes().length; expAttrIdx++)
-        {
-            // Get current attribute for this package.
-            R4Attribute expAttr = export.getAttributes()[expAttrIdx];
-            
-            // If the export attribute is mandatory, then make sure
-            // this import package has the attribute.
-            if (expAttr.isMandatory())
-            {
-                boolean found = false;
-                for (int impAttrIdx = 0;
-                    (!found) && (impAttrIdx < getAttributes().length);
-                    impAttrIdx++)
-                {
-                    // Get current attribute from specified package.
-                    R4Attribute impAttr = getAttributes()[impAttrIdx];
-        
-                    // Check if the attribute names are equal
-                    // and set found flag.
-                    if (expAttr.getName().equals(impAttr.getName()))
-                    {
-                        found = true;
-                    }
-                }
-                // If not found, then return false.
-                if (!found)
-                {
-                    return false;
-                }
-            }
-        }
-
-        return true;
-    }
-}
\ No newline at end of file
diff --git a/framework/src/main/java/org/apache/felix/framework/util/manifestparser/R4Package.java b/framework/src/main/java/org/apache/felix/framework/util/manifestparser/R4Package.java
deleted file mode 100755
index e6480cc..0000000
--- a/framework/src/main/java/org/apache/felix/framework/util/manifestparser/R4Package.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * 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;
-
-import org.osgi.framework.Version;
-
-public class R4Package
-{
-    private String m_name = "";
-    protected R4Directive[] m_directives = null;
-    protected R4Attribute[] m_attrs = null;
-    protected Version m_version = new Version("0.0.0");
-
-    public R4Package(String name, R4Directive[] directives, R4Attribute[] attrs)
-    {
-        m_name = name;
-        m_directives = (directives == null)
-            ? new R4Directive[0] : (R4Directive[]) directives.clone();
-        m_attrs = (attrs == null)
-            ? new R4Attribute[0] : (R4Attribute[]) attrs.clone();
-    }
-
-    public String getName()
-    {
-        return m_name;
-    }
-
-    public R4Directive[] getDirectives()
-    {
-        return m_directives;
-    }
-
-    public R4Attribute[] getAttributes()
-    {
-        return m_attrs;
-    }
-
-    public Version getVersion()
-    {
-        return m_version;
-    }
-
-    public String toString()
-    {
-        String msg = getName();
-        for (int i = 0; (m_directives != null) && (i < m_directives.length); i++)
-        {
-            msg = msg + " [" + m_directives[i].getName() + ":="+ m_directives[i].getValue() + "]";
-        }
-        for (int i = 0; (m_attrs != null) && (i < m_attrs.length); i++)
-        {
-            msg = msg + " [" + m_attrs[i].getName() + "="+ m_attrs[i].getValue() + "]";
-        }
-        return msg;
-    }
-}
\ No newline at end of file