You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by ds...@apache.org on 2009/09/11 22:51:13 UTC

svn commit: r814023 [1/2] - in /felix/trunk/sigil: ./ bldcommon/ common/core.tests/ common/core.tests/src/org/apache/felix/sigil/core/ common/core/ common/core/src/org/apache/felix/sigil/bnd/ common/core/src/org/apache/felix/sigil/config/ common/core/s...

Author: dsavage
Date: Fri Sep 11 20:50:48 2009
New Revision: 814023

URL: http://svn.apache.org/viewvc?rev=814023&view=rev
Log:
patch for FELIX-1583 - refactored LDAP and VersionRange classes into own bundle

Added:
    felix/trunk/sigil/common/osgi/   (with props)
    felix/trunk/sigil/common/osgi/.classpath
    felix/trunk/sigil/common/osgi/.project
    felix/trunk/sigil/common/osgi/build.xml
    felix/trunk/sigil/common/osgi/ivy.xml
    felix/trunk/sigil/common/osgi/sigil.properties
    felix/trunk/sigil/common/osgi/src/
    felix/trunk/sigil/common/osgi/src/org/
    felix/trunk/sigil/common/osgi/src/org/apache/
    felix/trunk/sigil/common/osgi/src/org/apache/felix/
    felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/
    felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/
    felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/
    felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/And.java
    felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Cardinality.java
    felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/ExprVisitor.java
    felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Expressions.java
    felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/FilterValidator.java
    felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/LDAPExpr.java
    felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/LDAPParseException.java
    felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/LDAPParser.java
    felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Not.java
    felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Ops.java
    felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Or.java
    felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/ParseState.java
    felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/SimpleTerm.java
    felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Utils.java
    felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/VersionRange.java
    felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/VersionRangeBoundingRule.java
Removed:
    felix/trunk/sigil/common/core/src/org/apache/felix/sigil/model/common/
Modified:
    felix/trunk/sigil/bldcommon/common.xml
    felix/trunk/sigil/build.xml
    felix/trunk/sigil/common/core.tests/sigil.properties
    felix/trunk/sigil/common/core.tests/src/org/apache/felix/sigil/core/BundleModelElementTest.java
    felix/trunk/sigil/common/core.tests/src/org/apache/felix/sigil/core/ConfigTest.java
    felix/trunk/sigil/common/core/sigil.properties
    felix/trunk/sigil/common/core/src/org/apache/felix/sigil/bnd/BundleBuilder.java
    felix/trunk/sigil/common/core/src/org/apache/felix/sigil/config/BldConverter.java
    felix/trunk/sigil/common/core/src/org/apache/felix/sigil/config/BldProject.java
    felix/trunk/sigil/common/core/src/org/apache/felix/sigil/core/internal/model/eclipse/LibraryImport.java
    felix/trunk/sigil/common/core/src/org/apache/felix/sigil/core/internal/model/osgi/PackageImport.java
    felix/trunk/sigil/common/core/src/org/apache/felix/sigil/core/internal/model/osgi/RequiredBundle.java
    felix/trunk/sigil/common/core/src/org/apache/felix/sigil/model/eclipse/ILibraryImport.java
    felix/trunk/sigil/common/core/src/org/apache/felix/sigil/model/osgi/IRequiredBundle.java
    felix/trunk/sigil/common/core/src/org/apache/felix/sigil/model/osgi/IVersionRangeModelElement.java
    felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/AbstractBundleRepository.java
    felix/trunk/sigil/common/obr/build.xml
    felix/trunk/sigil/common/obr/sigil.properties
    felix/trunk/sigil/common/obr/src/org/apache/felix/sigil/obr/impl/OBRHandler.java
    felix/trunk/sigil/common/obr/src/org/apache/felix/sigil/obr/impl/VersionRangeHelper.java
    felix/trunk/sigil/eclipse/core/sigil.properties
    felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/util/JavaHelper.java
    felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/preferences/SigilPreferencesInitializer.java
    felix/trunk/sigil/eclipse/search/sigil.properties
    felix/trunk/sigil/eclipse/search/src/org/apache/felix/sigil/search/index/Index.java
    felix/trunk/sigil/eclipse/ui/sigil.properties
    felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/editors/project/DependencyManagementSection.java
    felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/editors/project/ExportPackagesSection.java
    felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/editors/project/NewResourceSelectionDialog.java
    felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/editors/project/ResourceImportDialog.java
    felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/editors/project/SigilProjectEditorPart.java
    felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/editors/project/VersionRangeComponent.java
    felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/editors/project/VersionsChangeListener.java
    felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/preferences/LibraryConfigurationDialog.java
    felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/preferences/VersionsPreferencePage.java
    felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/quickfix/ImportPackageProposal.java
    felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/quickfix/ImportSearchResultProposal.java
    felix/trunk/sigil/ivy/resolver/sigil.properties
    felix/trunk/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/ProjectRepository.java
    felix/trunk/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/SigilParser.java
    felix/trunk/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/SigilResolver.java

Modified: felix/trunk/sigil/bldcommon/common.xml
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/bldcommon/common.xml?rev=814023&r1=814022&r2=814023&view=diff
==============================================================================
--- felix/trunk/sigil/bldcommon/common.xml (original)
+++ felix/trunk/sigil/bldcommon/common.xml Fri Sep 11 20:50:48 2009
@@ -57,7 +57,7 @@
     <!-- ================================= 
           target: build (default target)
          ================================= -->
-    <target name="build" depends="publish-local, composites" />
+    <target name="build" depends="publish-local" />
 
     <target name="ident">
       <echo message="${ant.project.name}"/>
@@ -145,36 +145,12 @@
     </target>
 
     <!-- ================================= 
-          target: composites              
-         ================================= -->
-    <available file="${composite.dir}" type="dir"
-               property="composite.dir.present"/>
-
-    <target name="composites" if="composite.dir.present"
-    	description="--> filter xml composites replacing ${VERSION} etc.">
-	<mkdir dir="${build.etc.dir}"/>
-	<copy todir="${build.etc.dir}">
-	  <fileset dir="${composite.dir}">
-	    <exclude name="*-template.composite"/>
-	    <include name="*.composite"/>
-	    <include name="*.system"/>
-	  </fileset>
-	  <filterset begintoken="@" endtoken="@">
-	    <filter token="VERSION" value="${bundle.version}"/>
-	    <filter token="COMMUNITY_VERSION" value="${community.version}"/>
-	    <filter token="JINI_VERSION" value="${jini.version}"/>
-	    <filter token="PAREMUS_VERSION" value="${paremus.version}"/>
-	  </filterset>
-	</copy>
-    </target>
-
-    <!-- ================================= 
           target: install              
 	  install-bin, install-etc deprecated in favour of single
 	  assemble/bin, assemble/etc dirs
          ================================= -->
     <target name="install"
-    	 depends="install-lib, install-composites"/>
+    	 depends="install-lib"/>
 
     <available file="bin" type="dir"
                property="bin.dir.present"/>
@@ -196,19 +172,6 @@
 	</copy>
     </target>
 
-    <target name="composites-available">
-      <available file="${build.etc.dir}" type="dir"
-               property="build.etc.dir.present"/>
-    </target>
-
-    <target name="install-composites"
-	 depends="composites, composites-available"
-	      if="build.etc.dir.present">
-	<copy todir="${install.dir}/etc">
-	  <fileset dir="${build.etc.dir}" />
-	</copy>
-    </target>
-
     <target name="libs-available">
       <available file="${build.lib.dir}" type="dir"
                property="build.lib.dir.present"/>
@@ -297,6 +260,16 @@
     </target>
 
     <!-- ================================= 
+          target: report-list
+         ================================= -->
+    <target name="report-list"
+	  description="--> report all projects">
+      <antcall target="build-list">
+        <param name="target" value="report"/>
+      </antcall>
+    </target>
+
+    <!-- ================================= 
           target: install-list
          ================================= -->
     <target name="install-list"

Modified: felix/trunk/sigil/build.xml
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/build.xml?rev=814023&r1=814022&r2=814023&view=diff
==============================================================================
--- felix/trunk/sigil/build.xml (original)
+++ felix/trunk/sigil/build.xml Fri Sep 11 20:50:48 2009
@@ -37,11 +37,14 @@
 
   <target name="build" depends="build-list" />
 
+  <target name="report" depends="report-list" />
+
   <target name="site" depends="common-init">
     <!-- eclipse -->
     <ivy:retrieve organisation="org.apache" module="felix.sigil.common.core" revision="latest.integration" inline="true" pattern="${site.dir}/plugins/[artifact].[ext]" transitive="false"/>
     <ivy:retrieve organisation="org.apache" module="felix.sigil.common.junit" revision="latest.integration" inline="true" pattern="${site.dir}/plugins/[artifact].[ext]" transitive="false"/>
     <ivy:retrieve organisation="org.apache" module="felix.sigil.common.obr" revision="latest.integration" inline="true" pattern="${site.dir}/plugins/[artifact].[ext]" transitive="false"/>
+    <ivy:retrieve organisation="org.apache" module="felix.sigil.common.osgi" revision="latest.integration" inline="true" pattern="${site.dir}/plugins/[artifact].[ext]" transitive="false"/>
     <ivy:retrieve organisation="org.apache" module="felix.sigil.common.runtime" revision="latest.integration" inline="true" pattern="${site.dir}/plugins/[artifact].[ext]" transitive="false"/>
     <ivy:retrieve organisation="org.apache" module="felix.sigil.eclipse.core" revision="latest.integration" inline="true" pattern="${site.dir}/plugins/[artifact].[ext]" transitive="false"/>
     <ivy:retrieve organisation="org.apache" module="felix.sigil.eclipse.help" revision="latest.integration" inline="true" pattern="${site.dir}/plugins/[artifact].[ext]" transitive="false"/>

Modified: felix/trunk/sigil/common/core.tests/sigil.properties
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core.tests/sigil.properties?rev=814023&r1=814022&r2=814023&view=diff
==============================================================================
--- felix/trunk/sigil/common/core.tests/sigil.properties (original)
+++ felix/trunk/sigil/common/core.tests/sigil.properties Fri Sep 11 20:50:48 2009
@@ -12,6 +12,7 @@
 
 -imports: \
 	junit.framework, \
+	org.apache.felix.sigil.common.osgi, \
 	org.osgi.framework, \
 
 # end

Modified: felix/trunk/sigil/common/core.tests/src/org/apache/felix/sigil/core/BundleModelElementTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core.tests/src/org/apache/felix/sigil/core/BundleModelElementTest.java?rev=814023&r1=814022&r2=814023&view=diff
==============================================================================
--- felix/trunk/sigil/common/core.tests/src/org/apache/felix/sigil/core/BundleModelElementTest.java (original)
+++ felix/trunk/sigil/common/core.tests/src/org/apache/felix/sigil/core/BundleModelElementTest.java Fri Sep 11 20:50:48 2009
@@ -22,10 +22,10 @@
 
 import java.util.Arrays;
 
+import org.apache.felix.sigil.common.osgi.VersionRange;
 import org.apache.felix.sigil.core.internal.model.osgi.BundleModelElement;
 import org.apache.felix.sigil.core.internal.model.osgi.PackageImport;
 import org.apache.felix.sigil.core.internal.model.osgi.RequiredBundle;
-import org.apache.felix.sigil.model.common.VersionRange;
 
 import junit.framework.TestCase;
 

Modified: felix/trunk/sigil/common/core.tests/src/org/apache/felix/sigil/core/ConfigTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core.tests/src/org/apache/felix/sigil/core/ConfigTest.java?rev=814023&r1=814022&r2=814023&view=diff
==============================================================================
--- felix/trunk/sigil/common/core.tests/src/org/apache/felix/sigil/core/ConfigTest.java (original)
+++ felix/trunk/sigil/common/core.tests/src/org/apache/felix/sigil/core/ConfigTest.java Fri Sep 11 20:50:48 2009
@@ -26,10 +26,10 @@
 
 import junit.framework.TestCase;
 
+import org.apache.felix.sigil.common.osgi.VersionRange;
 import org.apache.felix.sigil.config.BldFactory;
 import org.apache.felix.sigil.config.IBldProject;
 import org.apache.felix.sigil.core.internal.model.osgi.PackageImport;
-import org.apache.felix.sigil.model.common.VersionRange;
 import org.apache.felix.sigil.model.eclipse.ISigilBundle;
 import org.apache.felix.sigil.model.osgi.IBundleModelElement;
 import org.apache.felix.sigil.model.osgi.IPackageImport;

Modified: felix/trunk/sigil/common/core/sigil.properties
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/sigil.properties?rev=814023&r1=814022&r2=814023&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/sigil.properties (original)
+++ felix/trunk/sigil/common/core/sigil.properties Fri Sep 11 20:50:48 2009
@@ -29,7 +29,6 @@
 	org.apache.felix.sigil.core.licence, \
 	org.apache.felix.sigil.core.repository, \
 	org.apache.felix.sigil.model, \
-	org.apache.felix.sigil.model.common, \
 	org.apache.felix.sigil.model.eclipse, \
 	org.apache.felix.sigil.model.osgi, \
 	org.apache.felix.sigil.repository, \
@@ -37,12 +36,12 @@
 -imports: \
 	aQute.lib.osgi, \
 	org.apache.felix.sigil.bnd, \
+	org.apache.felix.sigil.common.osgi, \
 	org.apache.felix.sigil.config, \
 	org.apache.felix.sigil.core, \
 	org.apache.felix.sigil.core.licence, \
 	org.apache.felix.sigil.core.repository, \
 	org.apache.felix.sigil.model, \
-	org.apache.felix.sigil.model.common, \
 	org.apache.felix.sigil.model.eclipse, \
 	org.apache.felix.sigil.model.osgi, \
 	org.apache.felix.sigil.repository, \

Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/bnd/BundleBuilder.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/bnd/BundleBuilder.java?rev=814023&r1=814022&r2=814023&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/bnd/BundleBuilder.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/bnd/BundleBuilder.java Fri Sep 11 20:50:48 2009
@@ -33,11 +33,11 @@
 import java.util.Set;
 import java.util.jar.Attributes;
 
+import org.apache.felix.sigil.common.osgi.VersionRange;
 import org.apache.felix.sigil.config.BldAttr;
 import org.apache.felix.sigil.config.IBldProject;
 import org.apache.felix.sigil.config.IBldProject.IBldBundle;
 import org.apache.felix.sigil.core.repository.SystemRepositoryProvider;
-import org.apache.felix.sigil.model.common.VersionRange;
 import org.apache.felix.sigil.model.osgi.IPackageExport;
 import org.apache.felix.sigil.model.osgi.IPackageImport;
 import org.apache.felix.sigil.model.osgi.IRequiredBundle;

Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/config/BldConverter.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/config/BldConverter.java?rev=814023&r1=814022&r2=814023&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/config/BldConverter.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/config/BldConverter.java Fri Sep 11 20:50:48 2009
@@ -31,11 +31,11 @@
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+import org.apache.felix.sigil.common.osgi.VersionRange;
 import org.apache.felix.sigil.config.IBldProject.IBldBundle;
 import org.apache.felix.sigil.core.BldCore;
 import org.apache.felix.sigil.core.internal.model.eclipse.SigilBundle;
 import org.apache.felix.sigil.core.internal.model.osgi.BundleModelElement;
-import org.apache.felix.sigil.model.common.VersionRange;
 import org.apache.felix.sigil.model.eclipse.ISigilBundle;
 import org.apache.felix.sigil.model.osgi.IBundleModelElement;
 import org.apache.felix.sigil.model.osgi.IPackageExport;

Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/config/BldProject.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/config/BldProject.java?rev=814023&r1=814022&r2=814023&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/config/BldProject.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/config/BldProject.java Fri Sep 11 20:50:48 2009
@@ -42,12 +42,12 @@
 import java.util.Properties;
 import java.util.TreeSet;
 
+import org.apache.felix.sigil.common.osgi.VersionRange;
 import org.apache.felix.sigil.core.internal.model.osgi.BundleModelElement;
 import org.apache.felix.sigil.core.internal.model.osgi.PackageExport;
 import org.apache.felix.sigil.core.internal.model.osgi.PackageImport;
 import org.apache.felix.sigil.core.internal.model.osgi.RequiredBundle;
 import org.apache.felix.sigil.model.IModelElement;
-import org.apache.felix.sigil.model.common.VersionRange;
 import org.apache.felix.sigil.model.eclipse.ISigilBundle;
 import org.apache.felix.sigil.model.osgi.IBundleModelElement;
 import org.apache.felix.sigil.model.osgi.IPackageExport;

Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/core/internal/model/eclipse/LibraryImport.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/core/internal/model/eclipse/LibraryImport.java?rev=814023&r1=814022&r2=814023&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/core/internal/model/eclipse/LibraryImport.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/core/internal/model/eclipse/LibraryImport.java Fri Sep 11 20:50:48 2009
@@ -20,8 +20,8 @@
 package org.apache.felix.sigil.core.internal.model.eclipse;
 
 
+import org.apache.felix.sigil.common.osgi.VersionRange;
 import org.apache.felix.sigil.model.AbstractModelElement;
-import org.apache.felix.sigil.model.common.VersionRange;
 import org.apache.felix.sigil.model.eclipse.ILibraryImport;
 
 

Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/core/internal/model/osgi/PackageImport.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/core/internal/model/osgi/PackageImport.java?rev=814023&r1=814022&r2=814023&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/core/internal/model/osgi/PackageImport.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/core/internal/model/osgi/PackageImport.java Fri Sep 11 20:50:48 2009
@@ -20,10 +20,10 @@
 package org.apache.felix.sigil.core.internal.model.osgi;
 
 
+import org.apache.felix.sigil.common.osgi.VersionRange;
 import org.apache.felix.sigil.model.AbstractModelElement;
 import org.apache.felix.sigil.model.IModelElement;
 import org.apache.felix.sigil.model.InvalidModelException;
-import org.apache.felix.sigil.model.common.VersionRange;
 import org.apache.felix.sigil.model.osgi.IPackageExport;
 import org.apache.felix.sigil.model.osgi.IPackageImport;
 

Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/core/internal/model/osgi/RequiredBundle.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/core/internal/model/osgi/RequiredBundle.java?rev=814023&r1=814022&r2=814023&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/core/internal/model/osgi/RequiredBundle.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/core/internal/model/osgi/RequiredBundle.java Fri Sep 11 20:50:48 2009
@@ -20,9 +20,9 @@
 package org.apache.felix.sigil.core.internal.model.osgi;
 
 
+import org.apache.felix.sigil.common.osgi.VersionRange;
 import org.apache.felix.sigil.model.AbstractModelElement;
 import org.apache.felix.sigil.model.IModelElement;
-import org.apache.felix.sigil.model.common.VersionRange;
 import org.apache.felix.sigil.model.osgi.IBundleModelElement;
 import org.apache.felix.sigil.model.osgi.IRequiredBundle;
 

Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/model/eclipse/ILibraryImport.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/model/eclipse/ILibraryImport.java?rev=814023&r1=814022&r2=814023&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/model/eclipse/ILibraryImport.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/model/eclipse/ILibraryImport.java Fri Sep 11 20:50:48 2009
@@ -20,8 +20,8 @@
 package org.apache.felix.sigil.model.eclipse;
 
 
+import org.apache.felix.sigil.common.osgi.VersionRange;
 import org.apache.felix.sigil.model.IModelElement;
-import org.apache.felix.sigil.model.common.VersionRange;
 
 
 public interface ILibraryImport extends IModelElement

Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/model/osgi/IRequiredBundle.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/model/osgi/IRequiredBundle.java?rev=814023&r1=814022&r2=814023&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/model/osgi/IRequiredBundle.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/model/osgi/IRequiredBundle.java Fri Sep 11 20:50:48 2009
@@ -20,9 +20,9 @@
 package org.apache.felix.sigil.model.osgi;
 
 
+import org.apache.felix.sigil.common.osgi.VersionRange;
 import org.apache.felix.sigil.model.IModelElement;
 import org.apache.felix.sigil.model.IRequirementModelElement;
-import org.apache.felix.sigil.model.common.VersionRange;
 
 
 public interface IRequiredBundle extends IModelElement, IRequirementModelElement, Comparable<IRequiredBundle>

Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/model/osgi/IVersionRangeModelElement.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/model/osgi/IVersionRangeModelElement.java?rev=814023&r1=814022&r2=814023&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/model/osgi/IVersionRangeModelElement.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/model/osgi/IVersionRangeModelElement.java Fri Sep 11 20:50:48 2009
@@ -19,9 +19,7 @@
 
 package org.apache.felix.sigil.model.osgi;
 
-
-import org.apache.felix.sigil.model.common.VersionRange;
-
+import org.apache.felix.sigil.common.osgi.VersionRange;
 
 public interface IVersionRangeModelElement
 {

Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/AbstractBundleRepository.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/AbstractBundleRepository.java?rev=814023&r1=814022&r2=814023&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/AbstractBundleRepository.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/AbstractBundleRepository.java Fri Sep 11 20:50:48 2009
@@ -29,6 +29,7 @@
 import java.util.jar.Attributes;
 import java.util.jar.Manifest;
 
+import org.apache.felix.sigil.common.osgi.VersionRange;
 import org.apache.felix.sigil.core.BldCore;
 import org.apache.felix.sigil.core.licence.ILicenseManager;
 import org.apache.felix.sigil.core.licence.ILicensePolicy;
@@ -36,7 +37,6 @@
 import org.apache.felix.sigil.model.IModelElement;
 import org.apache.felix.sigil.model.ModelElementFactory;
 import org.apache.felix.sigil.model.ModelElementFactoryException;
-import org.apache.felix.sigil.model.common.VersionRange;
 import org.apache.felix.sigil.model.eclipse.ILibrary;
 import org.apache.felix.sigil.model.eclipse.ISigilBundle;
 import org.apache.felix.sigil.model.osgi.IBundleModelElement;

Modified: felix/trunk/sigil/common/obr/build.xml
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/obr/build.xml?rev=814023&r1=814022&r2=814023&view=diff
==============================================================================
--- felix/trunk/sigil/common/obr/build.xml (original)
+++ felix/trunk/sigil/common/obr/build.xml Fri Sep 11 20:50:48 2009
@@ -17,6 +17,6 @@
   specific language governing permissions and limitations
   under the License.
 -->
-<project name="core" default="build">
+<project name="common.obr" default="build">
       <import file="../build.xml"/>
 </project>

Modified: felix/trunk/sigil/common/obr/sigil.properties
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/obr/sigil.properties?rev=814023&r1=814022&r2=814023&view=diff
==============================================================================
--- felix/trunk/sigil/common/obr/sigil.properties (original)
+++ felix/trunk/sigil/common/obr/sigil.properties Fri Sep 11 20:50:48 2009
@@ -11,8 +11,8 @@
 	org.apache.felix.sigil.obr, \
 
 -imports: \
+	org.apache.felix.sigil.common.osgi;version=0.9.0, \
 	org.apache.felix.sigil.model, \
-	org.apache.felix.sigil.model.common, \
 	org.apache.felix.sigil.model.eclipse, \
 	org.apache.felix.sigil.model.osgi, \
 	org.apache.felix.sigil.obr, \

Modified: felix/trunk/sigil/common/obr/src/org/apache/felix/sigil/obr/impl/OBRHandler.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/obr/src/org/apache/felix/sigil/obr/impl/OBRHandler.java?rev=814023&r1=814022&r2=814023&view=diff
==============================================================================
--- felix/trunk/sigil/common/obr/src/org/apache/felix/sigil/obr/impl/OBRHandler.java (original)
+++ felix/trunk/sigil/common/obr/src/org/apache/felix/sigil/obr/impl/OBRHandler.java Fri Sep 11 20:50:48 2009
@@ -29,12 +29,12 @@
 import java.util.HashSet;
 import java.util.List;
 
+import org.apache.felix.sigil.common.osgi.LDAPExpr;
+import org.apache.felix.sigil.common.osgi.LDAPParseException;
+import org.apache.felix.sigil.common.osgi.LDAPParser;
+import org.apache.felix.sigil.common.osgi.SimpleTerm;
+import org.apache.felix.sigil.common.osgi.VersionRange;
 import org.apache.felix.sigil.model.ModelElementFactory;
-import org.apache.felix.sigil.model.common.LDAPExpr;
-import org.apache.felix.sigil.model.common.LDAPParseException;
-import org.apache.felix.sigil.model.common.LDAPParser;
-import org.apache.felix.sigil.model.common.SimpleTerm;
-import org.apache.felix.sigil.model.common.VersionRange;
 import org.apache.felix.sigil.model.eclipse.ISigilBundle;
 import org.apache.felix.sigil.model.osgi.IBundleModelElement;
 import org.apache.felix.sigil.model.osgi.IPackageExport;

Modified: felix/trunk/sigil/common/obr/src/org/apache/felix/sigil/obr/impl/VersionRangeHelper.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/obr/src/org/apache/felix/sigil/obr/impl/VersionRangeHelper.java?rev=814023&r1=814022&r2=814023&view=diff
==============================================================================
--- felix/trunk/sigil/common/obr/src/org/apache/felix/sigil/obr/impl/VersionRangeHelper.java (original)
+++ felix/trunk/sigil/common/obr/src/org/apache/felix/sigil/obr/impl/VersionRangeHelper.java Fri Sep 11 20:50:48 2009
@@ -23,13 +23,13 @@
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.felix.sigil.model.common.LDAPExpr;
-import org.apache.felix.sigil.model.common.LDAPParseException;
-import org.apache.felix.sigil.model.common.LDAPParser;
-import org.apache.felix.sigil.model.common.Not;
-import org.apache.felix.sigil.model.common.Ops;
-import org.apache.felix.sigil.model.common.SimpleTerm;
-import org.apache.felix.sigil.model.common.VersionRange;
+import org.apache.felix.sigil.common.osgi.LDAPExpr;
+import org.apache.felix.sigil.common.osgi.LDAPParseException;
+import org.apache.felix.sigil.common.osgi.LDAPParser;
+import org.apache.felix.sigil.common.osgi.Not;
+import org.apache.felix.sigil.common.osgi.Ops;
+import org.apache.felix.sigil.common.osgi.SimpleTerm;
+import org.apache.felix.sigil.common.osgi.VersionRange;
 import org.osgi.framework.Version;
 
 

Propchange: felix/trunk/sigil/common/osgi/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Sep 11 20:50:48 2009
@@ -0,0 +1 @@
+build

Added: felix/trunk/sigil/common/osgi/.classpath
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/osgi/.classpath?rev=814023&view=auto
==============================================================================
--- felix/trunk/sigil/common/osgi/.classpath (added)
+++ felix/trunk/sigil/common/osgi/.classpath Fri Sep 11 20:50:48 2009
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="con" path="org.apache.felix.sigil.classpathContainer"/>
+	<classpathentry kind="output" path="build/classes"/>
+</classpath>

Added: felix/trunk/sigil/common/osgi/.project
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/osgi/.project?rev=814023&view=auto
==============================================================================
--- felix/trunk/sigil/common/osgi/.project (added)
+++ felix/trunk/sigil/common/osgi/.project Fri Sep 11 20:50:48 2009
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>org.apache.felix.sigil.common.osgi</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.apache.felix.sigil.eclipse.core.sigilBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.apache.felix.sigil.sigilnature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>

Added: felix/trunk/sigil/common/osgi/build.xml
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/osgi/build.xml?rev=814023&view=auto
==============================================================================
--- felix/trunk/sigil/common/osgi/build.xml (added)
+++ felix/trunk/sigil/common/osgi/build.xml Fri Sep 11 20:50:48 2009
@@ -0,0 +1,22 @@
+<?xml version="1.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.
+-->
+<project name="common.osgi" default="build">
+      <import file="../build.xml"/>
+</project>

Added: felix/trunk/sigil/common/osgi/ivy.xml
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/osgi/ivy.xml?rev=814023&view=auto
==============================================================================
--- felix/trunk/sigil/common/osgi/ivy.xml (added)
+++ felix/trunk/sigil/common/osgi/ivy.xml Fri Sep 11 20:50:48 2009
@@ -0,0 +1,28 @@
+<?xml version="1.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.
+-->
+<ivy-module version="1.0">
+  <info 
+        organisation="org.apache"
+        module="felix.sigil.common.osgi"
+        status="integration"/>
+   <publications>
+     <artifact name="org.apache.felix.sigil.common.osgi" />
+   </publications>
+</ivy-module>

Added: felix/trunk/sigil/common/osgi/sigil.properties
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/osgi/sigil.properties?rev=814023&view=auto
==============================================================================
--- felix/trunk/sigil/common/osgi/sigil.properties (added)
+++ felix/trunk/sigil/common/osgi/sigil.properties Fri Sep 11 20:50:48 2009
@@ -0,0 +1,17 @@
+
+# sigil project file, saved by plugin.
+
+-bundles: \
+	org.apache.felix.sigil.common.osgi, \
+
+-sourcedirs: \
+	src, \
+
+-exports: \
+	org.apache.felix.sigil.common.osgi, \
+
+-imports: \
+	org.apache.felix.sigil.common.osgi, \
+	org.osgi.framework, \
+
+# end

Added: felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/And.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/And.java?rev=814023&view=auto
==============================================================================
--- felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/And.java (added)
+++ felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/And.java Fri Sep 11 20:50:48 2009
@@ -0,0 +1,148 @@
+/*
+ * 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.sigil.common.osgi;
+
+
+import java.util.Map;
+
+
+public class And implements LDAPExpr
+{
+
+    /**
+     */
+    private static final long serialVersionUID = 1L;
+    private LDAPExpr[] children;
+
+
+    public static LDAPExpr apply( LDAPExpr... terms )
+    {
+        if ( terms == null )
+        {
+            throw new NullPointerException( "terms cannot be null" );
+        }
+        else if ( terms.length == 0 )
+        {
+            return Expressions.T;
+        }
+        else if ( terms.length == 1 )
+        {
+            return terms[0];
+        }
+        LDAPExpr[] filtered = new LDAPExpr[terms.length];
+        int ctr = 0;
+        for ( int i = 0; i < terms.length; i++ )
+        {
+            if ( terms[i].equals( Expressions.F ) )
+                return Expressions.F;
+            if ( terms[i].equals( Expressions.T ) )
+                continue;
+            filtered[ctr] = terms[i];
+            ctr++;
+        }
+        if ( ctr == 0 )
+        {
+            return Expressions.T;
+        }
+        else if ( ctr == 1 )
+        {
+            return filtered[0];
+        }
+        LDAPExpr[] andTerms = new LDAPExpr[ctr];
+        System.arraycopy( filtered, 0, andTerms, 0, ctr );
+
+        return new And( andTerms );
+    }
+
+
+    private And( LDAPExpr... children )
+    {
+        this.children = children;
+    }
+
+
+    public boolean eval( Map<String, ?> map )
+    {
+        for ( int i = 0; i < children.length; i++ )
+        {
+            if ( !children[i].eval( map ) )
+            {
+                return false;
+            }
+        }
+        return true;
+    }
+
+
+    public void visit( ExprVisitor v )
+    {
+        v.visitAnd( this );
+    }
+
+
+    public LDAPExpr[] getChildren()
+    {
+        return children;
+    }
+
+
+    public void setChildren( LDAPExpr[] children )
+    {
+        this.children = children;
+    }
+
+
+    @Override
+    public boolean equals( Object other )
+    {
+        if ( other instanceof And )
+        {
+            And that = ( And ) other;
+            if ( children.length != that.children.length )
+            {
+                return false;
+            }
+            for ( int i = 0; i < children.length; i++ )
+            {
+                if ( !children[i].equals( that.children[i] ) )
+                {
+                    return false;
+                }
+            }
+            return true;
+        }
+        return false;
+    }
+
+
+    @Override
+    public String toString()
+    {
+        StringBuffer buf = new StringBuffer( 256 );
+        buf.append( "(&" );
+        for ( int i = 0; i < children.length; i++ )
+        {
+            buf.append( " " ).append( children[i] ).append( " " );
+        }
+        buf.append( ")" );
+        return buf.toString();
+    }
+
+}

Added: felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Cardinality.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Cardinality.java?rev=814023&view=auto
==============================================================================
--- felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Cardinality.java (added)
+++ felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Cardinality.java Fri Sep 11 20:50:48 2009
@@ -0,0 +1,192 @@
+/*
+ * 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.sigil.common.osgi;
+
+
+import java.io.Serializable;
+
+
+/**
+ * Immutable class representing cardinality constraints between two entities.
+ * 
+ */
+public class Cardinality implements Serializable
+{
+
+    /**
+     * 
+     */
+    private static final long serialVersionUID = 1L;
+    public static final Cardinality ZERO_TO_MANY = new Cardinality( 0, -1 );
+    public static final Cardinality ONE_TO_MANY = new Cardinality( 1, -1 );
+    public static final Cardinality ZERO_TO_ONE = new Cardinality( 0, 1 );
+    public static final Cardinality ONE_TO_ONE = new Cardinality( 1, 1 );
+
+    private int min;
+    private int max;
+
+
+    /**
+     * @param min
+     *            >=0 (usually 0 or 1)
+     * @param max
+     *            >=min or -1 to indicate an unbounded maximum
+     */
+    public Cardinality( int min, int max )
+    {
+        if ( min < 0 )
+        {
+            throw new IllegalArgumentException( "Min cannot be less than 0" );
+        }
+
+        if ( ( max < min ) && ( max != -1 ) )
+        {
+            throw new IllegalArgumentException( "Max cannot be less than min" );
+        }
+
+        this.min = min;
+        this.max = max;
+    }
+
+
+    public int getMin()
+    {
+        return min;
+    }
+
+
+    public int getMax()
+    {
+        return max;
+    }
+
+
+    public String toString()
+    {
+        return min + ".." + ( ( max == -1 ) ? ( "n" ) : ( Integer.toString( max ) ) );
+    }
+
+
+    public boolean isDefined( Cardinality cardinality )
+    {
+        return ( min <= cardinality.min ) && ( ( max == -1 ) || ( max >= cardinality.max ) );
+    }
+
+
+    public boolean isSingleton()
+    {
+        return ( min == 1 ) && ( max == 1 );
+    }
+
+
+    public static Cardinality parse( String stringRep ) throws IllegalArgumentException
+    {
+        stringRep = stringRep.trim();
+
+        int dotdot = stringRep.indexOf( ".." );
+
+        if ( dotdot == -1 )
+        {
+            throw new IllegalArgumentException( "Invalid cardinality string representation, expected .." );
+        }
+
+        String minStr = stringRep.substring( 0, dotdot );
+        String maxStr = stringRep.substring( dotdot + 2 );
+
+        int min = Integer.parseInt( minStr );
+        int max = min;
+
+        if ( "n".equals( maxStr ) )
+        {
+            max = -1;
+        }
+        else
+        {
+            max = Integer.parseInt( maxStr );
+        }
+
+        return cardinality( min, max );
+    }
+
+
+    public static Cardinality cardinality( int min, int max )
+    {
+        Cardinality c = null;
+
+        if ( min == 0 )
+        {
+            if ( max == 1 )
+            {
+                c = ZERO_TO_ONE;
+            }
+            else if ( max == -1 )
+            {
+                c = ZERO_TO_MANY;
+            }
+        }
+        else if ( min == 1 )
+        {
+            if ( max == 1 )
+            {
+                c = ONE_TO_ONE;
+            }
+            else if ( max == -1 )
+            {
+                c = ONE_TO_MANY;
+            }
+        }
+
+        if ( c == null )
+            c = new Cardinality( min, max );
+
+        return c;
+    }
+
+
+    public int hashCode()
+    {
+        return max ^ min;
+    }
+
+
+    public boolean equals( Object o )
+    {
+        if ( o == this )
+        {
+            return true;
+        }
+
+        if ( o == null )
+        {
+            return false;
+        }
+
+        try
+        {
+            Cardinality c = ( Cardinality ) o;
+
+            return ( min == c.min ) && ( max == c.max );
+        }
+        catch ( ClassCastException cce )
+        {
+            return false;
+        }
+    }
+}

Added: felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/ExprVisitor.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/ExprVisitor.java?rev=814023&view=auto
==============================================================================
--- felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/ExprVisitor.java (added)
+++ felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/ExprVisitor.java Fri Sep 11 20:50:48 2009
@@ -0,0 +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.
+ */
+
+package org.apache.felix.sigil.common.osgi;
+
+
+public interface ExprVisitor
+{
+
+    void visitAnd( And a );
+
+
+    void visitOr( Or o );
+
+
+    void visitNot( Not n );
+
+
+    void visitSimple( SimpleTerm st );
+
+
+    // if none of the above matches use this
+    void visitAny( LDAPExpr ex );
+}

Added: felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Expressions.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Expressions.java?rev=814023&view=auto
==============================================================================
--- felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Expressions.java (added)
+++ felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Expressions.java Fri Sep 11 20:50:48 2009
@@ -0,0 +1,100 @@
+/*
+ * 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.sigil.common.osgi;
+
+
+import java.util.Map;
+
+
+public class Expressions
+{
+
+    public static LDAPExpr and( LDAPExpr... terms )
+    {
+        return And.apply( terms );
+    }
+
+
+    public static LDAPExpr or( LDAPExpr... terms )
+    {
+        return Or.apply( terms );
+    }
+
+
+    public static LDAPExpr not( LDAPExpr e )
+    {
+        return Not.apply( e );
+    }
+
+    public static LDAPExpr T = Bool.TRUE;
+    public static LDAPExpr F = Bool.FALSE;
+
+
+    // supports direct use of wildcards for ease of testing, but not literal *s
+    public static SimpleTerm ex( String name, Ops op, String rhs )
+    {
+
+        rhs = rhs.replace( '*', SimpleTerm.WILDCARD );
+        return new SimpleTerm( name, op, rhs );
+    }
+
+}
+
+class Bool implements LDAPExpr
+{
+
+    /**
+     * 
+     */
+    private static final long serialVersionUID = 1L;
+    public static final Bool TRUE = new Bool( true );
+    public static final Bool FALSE = new Bool( false );
+
+    private boolean bool;
+
+
+    public Bool( boolean bool )
+    {
+        this.bool = bool;
+    }
+
+
+    public boolean eval( Map<String, ?> map )
+    {
+        return bool;
+    }
+
+
+    public void visit( ExprVisitor v )
+    {
+    }
+
+
+    public LDAPExpr[] getChildren()
+    {
+        return CHILDLESS;
+    }
+
+
+    public String toString()
+    {
+        return "(" + bool + ")";
+    }
+}

Added: felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/FilterValidator.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/FilterValidator.java?rev=814023&view=auto
==============================================================================
--- felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/FilterValidator.java (added)
+++ felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/FilterValidator.java Fri Sep 11 20:50:48 2009
@@ -0,0 +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.
+ */
+
+package org.apache.felix.sigil.common.osgi;
+
+
+public interface FilterValidator
+{
+
+    public static FilterValidator ACCEPT_ALL = new AcceptEverythingValidator();
+
+
+    boolean validate( LDAPExpr filter );
+
+    static class AcceptEverythingValidator implements FilterValidator
+    {
+
+        public boolean validate( LDAPExpr filter )
+        {
+            return true;
+        }
+
+    }
+}

Added: felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/LDAPExpr.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/LDAPExpr.java?rev=814023&view=auto
==============================================================================
--- felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/LDAPExpr.java (added)
+++ felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/LDAPExpr.java Fri Sep 11 20:50:48 2009
@@ -0,0 +1,48 @@
+/*
+ * 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.sigil.common.osgi;
+
+
+import java.io.Serializable;
+import java.util.Map;
+
+
+public interface LDAPExpr extends Serializable
+{
+
+    public static final LDAPExpr[] CHILDLESS = new LDAPExpr[]
+        {};
+    public static LDAPExpr ACCEPT_ALL = Expressions.T;
+
+
+    LDAPExpr[] getChildren();
+
+
+    void visit( ExprVisitor v );
+
+
+    boolean equals( Object other );
+
+
+    int hashCode();
+
+
+    boolean eval( Map<String, ?> map );
+}

Added: felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/LDAPParseException.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/LDAPParseException.java?rev=814023&view=auto
==============================================================================
--- felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/LDAPParseException.java (added)
+++ felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/LDAPParseException.java Fri Sep 11 20:50:48 2009
@@ -0,0 +1,68 @@
+/*
+ * 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.sigil.common.osgi;
+
+
+public class LDAPParseException extends Exception
+{
+
+    /**
+     * 
+     */
+    private static final long serialVersionUID = 1L;
+
+    private ParseState ps;
+    private static final String LINE_SEPARATOR = System.getProperty( "line.separator", "\\r\\n" );
+
+
+    public LDAPParseException( String message, ParseState ps )
+    {
+        super( message );
+        this.ps = ps;
+    }
+
+
+    public LDAPParseException( String message )
+    {
+        super( message );
+    }
+
+
+    @Override
+    public String getMessage()
+    {
+        if ( ps == null )
+        {
+            return super.getMessage();
+        }
+
+        String basicMessage = super.getMessage();
+        StringBuffer buf = new StringBuffer( basicMessage.length() + ps.str.length() * 2 );
+        buf.append( basicMessage ).append( LINE_SEPARATOR );
+        buf.append( ps.str ).append( LINE_SEPARATOR );
+        for ( int i = 0; i < ps.pos; i++ )
+        {
+            buf.append( " " );
+        }
+        buf.append( "^" );
+        return buf.toString();
+    }
+
+}

Added: felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/LDAPParser.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/LDAPParser.java?rev=814023&view=auto
==============================================================================
--- felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/LDAPParser.java (added)
+++ felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/LDAPParser.java Fri Sep 11 20:50:48 2009
@@ -0,0 +1,276 @@
+/*
+ * 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.sigil.common.osgi;
+
+
+import static org.apache.felix.sigil.common.osgi.Expressions.and;
+import static org.apache.felix.sigil.common.osgi.Expressions.not;
+import static org.apache.felix.sigil.common.osgi.Expressions.or;
+import static org.apache.felix.sigil.common.osgi.Ops.APPROX;
+import static org.apache.felix.sigil.common.osgi.Ops.EQ;
+import static org.apache.felix.sigil.common.osgi.Ops.GE;
+import static org.apache.felix.sigil.common.osgi.Ops.GT;
+import static org.apache.felix.sigil.common.osgi.Ops.LE;
+import static org.apache.felix.sigil.common.osgi.Ops.LT;
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+public class LDAPParser
+{
+
+    private static final LDAPParser parser = new LDAPParser();
+
+
+    public static LDAPExpr parseExpression( String strExpr ) throws LDAPParseException
+    {
+        return parser.parse( strExpr );
+    }
+
+
+    public static void main( String[] args )
+    {
+        for ( String arg : args )
+        {
+            try
+            {
+                System.out.println( parseExpression( arg ) );
+            }
+            catch ( LDAPParseException e )
+            {
+                System.out.println( "Failed to parse " + arg );
+                e.printStackTrace();
+            }
+        }
+    }
+
+
+    public LDAPExpr parse( String strExpr ) throws LDAPParseException
+    {
+
+        if ( strExpr == null || strExpr.trim().length() == 0 )
+        {
+            return LDAPExpr.ACCEPT_ALL;
+        }
+
+        ParseState ps = new ParseState( strExpr );
+        LDAPExpr expr = parseExpr( ps );
+        ps.skipWhitespace();
+        if ( !ps.isEndOfString() )
+        {
+            error( "expected end of expression ", ps );
+        }
+        return expr;
+    }
+
+
+    public LDAPExpr parseExpr( ParseState ps ) throws LDAPParseException
+    {
+        ps.skipWhitespace();
+        if ( !( ps.peek() == '(' ) )
+        {
+            error( "expected (", ps );
+        }
+        ps.read();
+        LDAPExpr expr = null;
+        ps.skipWhitespace();
+        char ch = ps.peek();
+        switch ( ch )
+        {
+            case '&':
+                ps.readAndSkipWhiteSpace();
+                List<LDAPExpr> andList = new ArrayList<LDAPExpr>();
+                while ( ps.peek() == '(' )
+                {
+                    andList.add( parseExpr( ps ) );
+                    ps.skipWhitespace();
+                }
+                LDAPExpr[] andArr = andList.toArray( new LDAPExpr[andList.size()] );
+                expr = and( andArr );
+                break;
+            case '|':
+                ps.readAndSkipWhiteSpace();
+                List<LDAPExpr> orList = new ArrayList<LDAPExpr>();
+                while ( ps.peek() == '(' )
+                {
+                    orList.add( parseExpr( ps ) );
+                    ps.skipWhitespace();
+                }
+                LDAPExpr[] orArray = orList.toArray( new LDAPExpr[orList.size()] );
+                expr = or( orArray );
+                break;
+            case '!':
+                ps.readAndSkipWhiteSpace();
+                expr = not( parseExpr( ps ) );
+                break;
+            default:
+                if ( isNameChar( ch ) )
+                {
+                    expr = parseSimple( ps );
+                }
+                else
+                {
+                    error( "unexpected character: '" + ch + "'", ps );
+                }
+        }
+        ps.skipWhitespace();
+        if ( ps.peek() != ')' )
+        {
+            error( "expected )", ps );
+        }
+        ps.read();
+        return expr;
+
+    }
+
+
+    void error( String message, ParseState ps ) throws LDAPParseException
+    {
+        throw new LDAPParseException( message, ps );
+    }
+
+
+    private SimpleTerm parseSimple( ParseState ps ) throws LDAPParseException
+    {
+        // read name
+        StringBuffer name = new StringBuffer( 16 );
+        for ( char c = ps.peek(); !ps.isEndOfString() && isNameChar( c ); c = ps.peek() )
+        {
+            ps.read();
+            name.append( c );
+        }
+        ps.skipWhitespace();
+        Ops op = null;
+        // read op
+        if ( ps.lookingAt( "=" ) )
+        {
+            op = EQ;
+            ps.skip( 1 );
+        }
+        else if ( ps.lookingAt( ">=" ) )
+        {
+            op = GE;
+            ps.skip( 2 );
+        }
+        else if ( ps.lookingAt( "<=" ) )
+        {
+            op = LE;
+            ps.skip( 2 );
+        }
+        else if ( ps.lookingAt( ">" ) )
+        {
+            op = GT;
+            ps.skip( 1 );
+        }
+        else if ( ps.lookingAt( "<" ) )
+        {
+            op = LT;
+            ps.skip( 1 );
+        }
+        else if ( ps.lookingAt( "-=" ) )
+        {
+            op = APPROX;
+            ps.skip( 2 );
+        }
+        else if ( ps.isEndOfString() )
+        {
+            error( "unexpected end of expression", ps );
+        }
+        else
+        {
+            error( "unexpected character: '" + ps.peek() + "'", ps );
+        }
+        ps.skipWhitespace();
+
+        boolean escaped = false;
+        StringBuffer value = new StringBuffer( 16 );
+
+        while ( !ps.isEndOfString() && !Character.isWhitespace( ps.peek() ) && !( ps.peek() == ')' && !escaped ) )
+        {
+
+            char ch = ps.peek();
+
+            if ( ch == '\\' )
+            {
+                escaped = true;
+                ps.read();
+            }
+            else if ( ch == '*' )
+            {
+                if ( escaped )
+                {
+                    value.append( ch );
+                    escaped = false;
+                }
+                else
+                {
+                    value.append( SimpleTerm.WILDCARD );
+                }
+                ps.read();
+            }
+            else if ( isLiteralValue( ch ) )
+            {
+                if ( escaped )
+                {
+                    error( "incorrectly applied escape of '" + ch + "'", ps );
+                }
+                value.append( ps.read() );
+            }
+            else if ( isEscapedValue( ch ) )
+            {
+                if ( !escaped )
+                {
+                    error( "missing escape for '" + ch + "'", ps );
+                }
+                value.append( ps.read() );
+                escaped = false;
+            }
+            else
+            {
+                error( "unexpected character: '" + ps.peek() + "'", ps );
+            }
+        }
+        ps.skipWhitespace();
+
+        SimpleTerm expr = new SimpleTerm( name.toString(), op, value.toString() );
+
+        return expr;
+    }
+
+
+    private boolean isNameChar( int ch )
+    {
+        return !( Character.isWhitespace( ch ) || ( ch == '(' ) || ( ch == ')' ) || ( ch == '<' ) || ( ch == '>' )
+            || ( ch == '=' ) || ( ch == '~' ) || ( ch == '*' ) || ( ch == '\\' ) );
+    }
+
+
+    private boolean isLiteralValue( int ch )
+    {
+        return !( Character.isWhitespace( ch ) || ( ch == '(' ) || ( ch == ')' ) || ( ch == '*' ) );
+    }
+
+
+    private boolean isEscapedValue( int ch )
+    {
+        return ( ch == '(' ) || ( ch == ')' ) || ( ch == '*' );
+    }
+}

Added: felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Not.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Not.java?rev=814023&view=auto
==============================================================================
--- felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Not.java (added)
+++ felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Not.java Fri Sep 11 20:50:48 2009
@@ -0,0 +1,114 @@
+/*
+ * 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.sigil.common.osgi;
+
+
+import java.util.Map;
+
+
+public class Not implements LDAPExpr
+{
+
+    /**
+     * 
+     */
+    private static final long serialVersionUID = 1L;
+    private LDAPExpr[] children;
+
+
+    public static LDAPExpr apply( LDAPExpr e )
+    {
+        if ( e == null )
+        {
+            throw new NullPointerException( "cannot apply Not to a null expression" );
+        }
+        if ( e.equals( Expressions.T ) )
+        {
+            return Expressions.F;
+        }
+        if ( e.equals( Expressions.F ) )
+        {
+            return Expressions.T;
+        }
+        return new Not( e );
+    }
+
+
+    private Not( LDAPExpr child )
+    {
+        this.children = new LDAPExpr[]
+            { child };
+    }
+
+
+    public boolean eval( Map<String, ?> map )
+    {
+        return !children[0].eval( map );
+    }
+
+
+    public LDAPExpr getEx()
+    {
+        return children[0];
+    }
+
+
+    public void visit( ExprVisitor v )
+    {
+        v.visitNot( this );
+    }
+
+
+    public LDAPExpr[] getChildren()
+    {
+        return children;
+    }
+
+
+    public void setChild( LDAPExpr child )
+    {
+        this.children = new LDAPExpr[]
+            { child };
+    }
+
+
+    @Override
+    public boolean equals( Object other )
+    {
+        if ( other instanceof Not )
+        {
+            Not that = ( Not ) other;
+            return children[0].equals( that.children[0] );
+        }
+        return false;
+    }
+
+
+    @Override
+    public String toString()
+    {
+        StringBuffer buf = new StringBuffer( 256 );
+        buf.append( "(!" );
+        buf.append( " " ).append( children[0] ).append( " " );
+        buf.append( ")" );
+        return buf.toString();
+    }
+
+}

Added: felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Ops.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Ops.java?rev=814023&view=auto
==============================================================================
--- felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Ops.java (added)
+++ felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Ops.java Fri Sep 11 20:50:48 2009
@@ -0,0 +1,49 @@
+/*
+ * 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.sigil.common.osgi;
+
+
+public enum Ops
+{
+    EQ, GE, LE, GT, LT, APPROX;
+
+    @Override
+    public String toString()
+    {
+        switch ( this )
+        {
+            case EQ:
+                return "=";
+            case GE:
+                return ">=";
+            case LE:
+                return "<=";
+            case GT:
+                return ">";
+            case LT:
+                return "<";
+            case APPROX:
+                return "~=";
+            default:
+                return super.toString();
+        }
+    }
+
+}

Added: felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Or.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Or.java?rev=814023&view=auto
==============================================================================
--- felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Or.java (added)
+++ felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Or.java Fri Sep 11 20:50:48 2009
@@ -0,0 +1,149 @@
+/*
+ * 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.sigil.common.osgi;
+
+
+import java.util.Map;
+
+
+public class Or implements LDAPExpr
+{
+
+    /**
+     * 
+     */
+    private static final long serialVersionUID = 1L;
+    private LDAPExpr[] children;
+
+
+    public static LDAPExpr apply( LDAPExpr... terms )
+    {
+        if ( terms == null )
+        {
+            throw new NullPointerException( "terms cannot be null" );
+        }
+        else if ( terms.length == 0 )
+        {
+            return Expressions.T;
+        }
+        else if ( terms.length == 1 )
+        {
+            return terms[0];
+        }
+        LDAPExpr[] filtered = new LDAPExpr[terms.length];
+        int ctr = 0;
+        for ( int i = 0; i < terms.length; i++ )
+        {
+            if ( terms[i].equals( Expressions.T ) )
+                return Expressions.T;
+            if ( terms[i].equals( Expressions.F ) )
+                continue;
+            filtered[ctr] = terms[i];
+            ctr++;
+        }
+        if ( ctr == 0 )
+        {
+            return Expressions.F;
+        }
+        else if ( ctr == 1 )
+        {
+            return filtered[0];
+        }
+        LDAPExpr[] orTerms = new LDAPExpr[ctr];
+        System.arraycopy( filtered, 0, orTerms, 0, ctr );
+
+        return new Or( orTerms );
+    }
+
+
+    private Or( LDAPExpr... children )
+    {
+        this.children = children;
+    }
+
+
+    public boolean eval( Map<String, ?> map )
+    {
+        for ( int i = 0; i < children.length; i++ )
+        {
+            if ( children[i].eval( map ) )
+            {
+                return true;
+            }
+        }
+        return false;
+    }
+
+
+    public void visit( ExprVisitor v )
+    {
+        v.visitOr( this );
+    }
+
+
+    public LDAPExpr[] getChildren()
+    {
+        return children;
+    }
+
+
+    public void setChildren( LDAPExpr[] children )
+    {
+        this.children = children;
+    }
+
+
+    @Override
+    public boolean equals( Object other )
+    {
+        if ( other instanceof Or )
+        {
+            Or that = ( Or ) other;
+            if ( children.length != that.children.length )
+            {
+                return false;
+            }
+            for ( int i = 0; i < children.length; i++ )
+            {
+                if ( children[i].equals( that.children[i] ) )
+                {
+                    return true;
+                }
+            }
+            return false;
+        }
+        return false;
+    }
+
+
+    @Override
+    public String toString()
+    {
+        StringBuffer buf = new StringBuffer( 256 );
+        buf.append( "(|" );
+        for ( int i = 0; i < children.length; i++ )
+        {
+            buf.append( " " ).append( children[i] ).append( " " );
+        }
+        buf.append( ")" );
+        return buf.toString();
+    }
+
+}

Added: felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/ParseState.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/ParseState.java?rev=814023&view=auto
==============================================================================
--- felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/ParseState.java (added)
+++ felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/ParseState.java Fri Sep 11 20:50:48 2009
@@ -0,0 +1,105 @@
+/*
+ * 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.sigil.common.osgi;
+
+
+import java.io.Serializable;
+
+
+/**
+ * @author dave
+ * 
+ */
+class ParseState implements Serializable
+{
+    /**
+     * 
+     */
+    private static final long serialVersionUID = 1L;
+
+    int pos;
+
+    String str;
+
+
+    ParseState( String str )
+    {
+        this.str = str;
+    }
+
+
+    public boolean lookingAt( String start )
+    {
+        return str.substring( pos ).startsWith( start );
+    }
+
+
+    public CharSequence skip( int n )
+    {
+        int end = pos + n < str.length() ? pos + n : str.length();
+        int start = pos;
+        pos = end;
+        return str.subSequence( start, end );
+    }
+
+
+    public char read()
+    {
+        char ch = str.charAt( pos );
+        if ( pos < str.length() )
+        {
+            pos++;
+        }
+        return ch;
+    }
+
+
+    public char readAndSkipWhiteSpace()
+    {
+        char ch = read();
+        skipWhitespace();
+        return ch;
+    }
+
+
+    char peek()
+    {
+        if ( isEndOfString() )
+        {
+            return ( char ) -1;
+        }
+        return str.charAt( pos );
+    }
+
+
+    boolean isEndOfString()
+    {
+        return pos == str.length();
+    }
+
+
+    void skipWhitespace()
+    {
+        while ( pos < str.length() && Character.isWhitespace( str.charAt( pos ) ) )
+        {
+            pos++;
+        }
+    }
+}

Added: felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/SimpleTerm.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/SimpleTerm.java?rev=814023&view=auto
==============================================================================
--- felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/SimpleTerm.java (added)
+++ felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/SimpleTerm.java Fri Sep 11 20:50:48 2009
@@ -0,0 +1,353 @@
+/*
+ * 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.sigil.common.osgi;
+
+
+import java.lang.reflect.Constructor;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Vector;
+
+
+public class SimpleTerm implements LDAPExpr
+{
+
+    /**
+     * 
+     */
+    private static final long serialVersionUID = 1L;
+    public static final char WILDCARD = 2 ^ 16 - 1;
+    private static final String WILDCARD_STRING = new String( new char[]
+        { SimpleTerm.WILDCARD } );
+
+    private Ops op;
+    private String name;
+    private String rval;
+
+
+    public SimpleTerm( String name, Ops op, String value )
+    {
+        this.op = op;
+        this.name = name.intern();
+        this.rval = value.intern();
+    }
+
+
+    public String getName()
+    {
+        return name;
+    }
+
+
+    public Ops getOp()
+    {
+        return op;
+    }
+
+
+    public String getRval()
+    {
+        return rval;
+    }
+
+
+    public boolean eval( Map<String, ?> map )
+    {
+
+        Object lval = map.get( name );
+        if ( lval == null )
+        {
+            return false;
+        }
+        else if ( Ops.EQ == op && WILDCARD_STRING.equals( lval ) )
+        {
+            return true;
+        }
+        // any match in the vector will do
+        else if ( lval instanceof Vector<?> )
+        {
+            Vector<?> vec = ( Vector<?> ) lval;
+            for ( Iterator<?> i = vec.iterator(); i.hasNext(); )
+            {
+                if ( check( i.next() ) )
+                {
+                    return true;
+                }
+            }
+            return false;
+        }
+        // any match in the array will do
+        else if ( lval instanceof Object[] )
+        {
+            Object[] arr = ( Object[] ) lval;
+            for ( int i = 0; i < arr.length; i++ )
+            {
+                if ( check( arr[i] ) )
+                {
+                    return true;
+                }
+            }
+            return false;
+        }
+        return check( lval );
+    }
+
+
+    @SuppressWarnings("unchecked")
+    private boolean check( Object lval )
+    {
+        if ( lval == null )
+        {
+            return false;
+        }
+        else if ( Ops.EQ == op && WILDCARD_STRING.equals( lval ) )
+        {
+            return true;
+        }
+
+        Object rhs = null;
+
+        if ( lval instanceof String )
+        {
+
+            if ( Ops.APPROX == op )
+            {
+                rhs = collapseWhiteSpace( rval );
+                lval = collapseWhiteSpace( ( String ) lval );
+            }
+
+            if ( Ops.EQ == op || Ops.APPROX == op )
+            {
+                return stringCheck( ( String ) lval );
+            }
+            // rhs already a string
+
+        }
+        else if ( lval.getClass() == Byte.class )
+        {
+            rhs = Byte.valueOf( rval );
+        }
+        else if ( lval.getClass() == Short.class )
+        {
+            rhs = Short.valueOf( rval );
+        }
+        else if ( lval.getClass() == Integer.class )
+        {
+            rhs = Integer.valueOf( rval );
+        }
+        else if ( lval.getClass() == Long.class )
+        {
+            rhs = Long.valueOf( rval );
+        }
+        else if ( lval.getClass() == Float.class )
+        {
+            rhs = Float.valueOf( rval );
+        }
+        else if ( lval.getClass() == Double.class )
+        {
+            rhs = Double.valueOf( rval );
+        }
+        else
+        {
+            try
+            {
+                Constructor<?> stringCtor = lval.getClass().getConstructor( new Class[]
+                    { String.class } );
+                rhs = stringCtor.newInstance( rval );
+            }
+            catch ( Exception e )
+            {
+                // log it
+                e.printStackTrace();
+                return false;
+            }
+        }
+
+        if ( !( lval instanceof Comparable ) )
+        {
+            return Ops.EQ == op && lval.equals( rval );
+        }
+        else
+        {
+
+            Comparable<? super Object> lhs = ( Comparable<? super Object> ) lval;
+
+            int compare = lhs.compareTo( rhs );
+
+            switch ( op )
+            {
+                case EQ:
+                    return compare == 0;
+                case APPROX:
+                    return compare == 0;
+                case GE:
+                    return compare >= 0;
+                case LE:
+                    return compare <= 0;
+                case GT:
+                    return compare > 0;
+                case LT:
+                    return compare < 0;
+            }
+        }
+
+        return false;
+    }
+
+
+    private boolean stringCheck( String lhs )
+    {
+
+        String rhs;
+        switch ( op )
+        {
+            case EQ:
+            case APPROX:
+                rhs = rval;
+                break;
+            default:
+                return false;
+        }
+
+        int valLength = lhs.length();
+        int patLength = rval.length();
+
+        if ( valLength == 0 && patLength == 0 )
+        {
+            return true;
+        }
+
+        boolean wc = false;
+        int j = 0;
+        for ( int i = 0; i < patLength; i++ )
+        {
+            // trailing wildcards
+            char pc = rhs.charAt( i );
+            if ( j == valLength )
+            {
+                if ( pc != SimpleTerm.WILDCARD )
+                {
+                    return false;
+                }
+                continue;
+            }
+            if ( pc == SimpleTerm.WILDCARD )
+            {
+                wc = true;
+                continue;
+            }
+            while ( wc && j < valLength - 1 && lhs.charAt( j ) != pc )
+            {
+                j++;
+            }
+            if ( lhs.charAt( j ) != pc )
+            {
+                return false;
+            }
+            else
+            {
+                wc = false;
+                j++;
+            }
+        }
+        return ( wc || j == valLength );
+
+    }
+
+
+    private String collapseWhiteSpace( String in )
+    {
+        StringBuffer out = new StringBuffer( in.trim().length() );
+        boolean white = false;
+        for ( int i = 0; i < in.length(); i++ )
+        {
+            char ch = in.charAt( i );
+            if ( Character.isWhitespace( ch ) )
+            {
+                white = true;
+            }
+            else
+            {
+                if ( white )
+                {
+                    out.append( " " );
+                    white = false;
+                }
+                out.append( ch );
+            }
+        }
+        return out.toString();
+    }
+
+
+    public void visit( ExprVisitor v )
+    {
+        v.visitSimple( this );
+    }
+
+
+    public LDAPExpr[] getChildren()
+    {
+        return CHILDLESS;
+    }
+
+
+    @Override
+    public boolean equals( Object other )
+    {
+        if ( other instanceof SimpleTerm )
+        {
+            SimpleTerm that = ( SimpleTerm ) other;
+            return name.equals( that.name ) && op.equals( that.op ) && rval.equals( that.rval );
+        }
+        return false;
+    }
+
+
+    @Override
+    public String toString()
+    {
+        return "(" + name + " " + op.toString() + " " + escape( rval ) + ")";
+    }
+
+
+    private String escape( String raw )
+    {
+        StringBuffer buf = new StringBuffer( raw.length() + 10 );
+        for ( int i = 0; i < raw.length(); i++ )
+        {
+            char ch = raw.charAt( i );
+            switch ( ch )
+            {
+                case SimpleTerm.WILDCARD:
+                    buf.append( "*" );
+                    break;
+                case '(':
+                case ')':
+                case '*':
+                    buf.append( "\\" ).append( ch );
+                    break;
+                default:
+                    buf.append( ch );
+            }
+        }
+        return buf.toString();
+    }
+}

Added: felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Utils.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Utils.java?rev=814023&view=auto
==============================================================================
--- felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Utils.java (added)
+++ felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Utils.java Fri Sep 11 20:50:48 2009
@@ -0,0 +1,85 @@
+/*
+ * 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.sigil.common.osgi;
+
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+
+public class Utils
+{
+    public static MapBuilder map( String name, Object value )
+    {
+        return new MapBuilder().put( name, value );
+    }
+
+
+    public static String toString( Map<String, Object> attrs )
+    {
+        if ( attrs == null )
+        {
+            return "NULL";
+        }
+
+        StringBuffer buf = new StringBuffer( 128 );
+        List<String> keys = new ArrayList<String>( attrs.keySet() );
+        Collections.sort( keys );
+        buf.append( "{" );
+
+        for ( int i = 0; i < keys.size(); i++ )
+        {
+            Object name = keys.get( i );
+            Object value = attrs.get( name );
+            buf.append( name ).append( "=" ).append( value ).append( "," );
+        }
+
+        if ( buf.length() > 1 )
+        {
+            buf.delete( buf.length() - 1, buf.length() );
+        }
+
+        buf.append( "}" );
+
+        return buf.toString();
+    }
+
+    public static class MapBuilder
+    {
+        private Map<String, Object> map = new HashMap<String, Object>();
+
+
+        public MapBuilder put( String name, Object value )
+        {
+            map.put( name, value );
+
+            return this;
+        }
+
+
+        public Map<String, Object> toMap()
+        {
+            return map;
+        }
+    }
+}