Author: jochen
Date: Fri Aug 19 14:12:51 2005
New Revision: 233558

URL: http://svn.apache.org/viewcvs?rev=233558&view=rev
Log:
Merged in changes from trunk.

Added:
    
webservices/jaxme/branches/MAVEN/projects/jm/src/main/java/org/apache/ws/jaxme/impl/Java5REHandler.java
    
webservices/jaxme/branches/MAVEN/projects/jm/src/main/java/org/apache/ws/jaxme/impl/REFactory.java
    
webservices/jaxme/branches/MAVEN/projects/jm/src/main/java/org/apache/ws/jaxme/impl/REHandler.java
    
webservices/jaxme/branches/MAVEN/projects/jm/src/main/java/org/apache/ws/jaxme/impl/XercesREHandler.java

Added: 
webservices/jaxme/branches/MAVEN/projects/jm/src/main/java/org/apache/ws/jaxme/impl/Java5REHandler.java
URL: 
http://svn.apache.org/viewcvs/webservices/jaxme/branches/MAVEN/projects/jm/src/main/java/org/apache/ws/jaxme/impl/Java5REHandler.java?rev=233558&view=auto
==============================================================================
--- 
webservices/jaxme/branches/MAVEN/projects/jm/src/main/java/org/apache/ws/jaxme/impl/Java5REHandler.java
 (added)
+++ 
webservices/jaxme/branches/MAVEN/projects/jm/src/main/java/org/apache/ws/jaxme/impl/Java5REHandler.java
 Fri Aug 19 14:12:51 2005
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2003, 2004  The Apache Software Foundation
+ * 
+ * Licensed 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.ws.jaxme.impl;
+
+import com.sun.org.apache.xerces.internal.impl.xpath.regex.RegularExpression;
+
+
+/** Default implementation of [EMAIL PROTECTED] REHandler}, using
+ * the builtin Xerces from Java 5.
+ */
+public class Java5REHandler implements REHandler {
+       public Matcher getMatcher(final String pPattern) {
+               final RegularExpression re = new RegularExpression(pPattern, 
"X");
+               return new Matcher(){
+                       public String getPattern() { return pPattern; }
+                       public synchronized boolean matches(String pValue) {
+                               return re.matches(pValue);
+                       }
+               };
+       }
+}

Added: 
webservices/jaxme/branches/MAVEN/projects/jm/src/main/java/org/apache/ws/jaxme/impl/REFactory.java
URL: 
http://svn.apache.org/viewcvs/webservices/jaxme/branches/MAVEN/projects/jm/src/main/java/org/apache/ws/jaxme/impl/REFactory.java?rev=233558&view=auto
==============================================================================
--- 
webservices/jaxme/branches/MAVEN/projects/jm/src/main/java/org/apache/ws/jaxme/impl/REFactory.java
 (added)
+++ 
webservices/jaxme/branches/MAVEN/projects/jm/src/main/java/org/apache/ws/jaxme/impl/REFactory.java
 Fri Aug 19 14:12:51 2005
@@ -0,0 +1,87 @@
+/*
+ * Copyright 2003, 2004  The Apache Software Foundation
+ * 
+ * Licensed 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.ws.jaxme.impl;
+
+
+/** The REFactory is used for creating instances of
+ * [EMAIL PROTECTED] REHandler.Matcher}. It provides access to a single
+ * instance of [EMAIL PROTECTED] REHandler}.
+ */
+public class REFactory {
+       private static final REHandler reHandler;
+
+       static {
+               REHandler reh = null;
+               String p = System.getProperty(REFactory.class.getName() + 
".Implementation");
+               if (p != null) {
+                       try {
+                               Class c = Class.forName(p);
+                               reh = (REHandler) c.newInstance();
+                       } catch (Throwable t) {
+                       }
+               }
+               if (p == null) {
+                       p = REFactory.class.getName();
+                       p = p.substring(0, p.lastIndexOf('.')+1);
+                       try {
+                               Class c = Class.forName(p + "Java5REHandler");
+                               reh = (REHandler) c.newInstance();
+                       } catch (Throwable t1) {
+                               try {
+                                       Class c = Class.forName(p + 
"XercerREHandler");
+                                       reh = (REHandler) c.newInstance();
+                               } catch (Throwable t2) {
+                                       reh = new DummyREHandler();
+                               }
+                       }
+               }
+               reHandler = reh;
+       }
+
+       /** Returns the singleton [EMAIL PROTECTED] REHandler}. The instance is
+        * created as follows:
+        * <ol>
+        *   <li>If the system property
+        *     <code>org.apache.ws.jaxme.impl.REFactory.Implementation</code>
+        *     is set, and contains the name of a valid REHandler class,
+        *     then that class is instantiated.</li>
+        *   <li>An instance of [EMAIL PROTECTED] Java5REHandler} is created,
+        *     if possible. This is the case, when running under
+        *     Java 5.</li>
+        *   <li>Otherwise, an instance of [EMAIL PROTECTED] XercesREHandler}
+        *     is created, if possible. This is the case, when
+        *     Xerces-J is available.</li>
+        *   <li>Otherwise, an instance of [EMAIL PROTECTED] DummyREHandler}
+        *     is created. This is an REHandler, which matches
+        *     always. In other words, patterns are ignored.</li>
+        * </ol>
+        */
+       public static REHandler getREHandler() { return reHandler; }
+
+       /** Dummy implementation of an [EMAIL PROTECTED] REHandler},
+        * which accepts any string as matching for any pattern.
+        * Used as a fallback, if no other implementations are
+        * available.
+        */
+       public static class DummyREHandler implements REHandler {
+               public Matcher getMatcher(final String pPattern) {
+                       return new REHandler.Matcher() {
+                               public String getPattern() { return pPattern; }
+                               public boolean matches(String pValue) { return 
true; }
+                       };
+               }
+       }
+}

Added: 
webservices/jaxme/branches/MAVEN/projects/jm/src/main/java/org/apache/ws/jaxme/impl/REHandler.java
URL: 
http://svn.apache.org/viewcvs/webservices/jaxme/branches/MAVEN/projects/jm/src/main/java/org/apache/ws/jaxme/impl/REHandler.java?rev=233558&view=auto
==============================================================================
--- 
webservices/jaxme/branches/MAVEN/projects/jm/src/main/java/org/apache/ws/jaxme/impl/REHandler.java
 (added)
+++ 
webservices/jaxme/branches/MAVEN/projects/jm/src/main/java/org/apache/ws/jaxme/impl/REHandler.java
 Fri Aug 19 14:12:51 2005
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2003, 2004  The Apache Software Foundation
+ * 
+ * Licensed 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.ws.jaxme.impl;
+
+/** An instance of RE is able to evaluate, whether
+ * a given regular expression is matched by a
+ * certain string.<br>
+ * JaxMe doesn't actually implement RE handling. It supports
+ * a set of implementations, basically Xerces and Java 5.
+ * Upon startup, an attempt is made to load an RE implementation.
+ */
+public interface REHandler {
+       /** An RE matcher is a compiled regular expression.
+        * Its method
+        */
+       public interface Matcher {
+               /** Returns the regular expressions pattern.
+                */
+               String getPattern();
+               /** Returns, whether the given string is matched
+                * by the regular expression.
+                */
+               boolean matches(String pValue);
+       }
+
+       /** Creates a thread safe RE matcher.
+        */
+       Matcher getMatcher(String pPattern);
+}

Added: 
webservices/jaxme/branches/MAVEN/projects/jm/src/main/java/org/apache/ws/jaxme/impl/XercesREHandler.java
URL: 
http://svn.apache.org/viewcvs/webservices/jaxme/branches/MAVEN/projects/jm/src/main/java/org/apache/ws/jaxme/impl/XercesREHandler.java?rev=233558&view=auto
==============================================================================
--- 
webservices/jaxme/branches/MAVEN/projects/jm/src/main/java/org/apache/ws/jaxme/impl/XercesREHandler.java
 (added)
+++ 
webservices/jaxme/branches/MAVEN/projects/jm/src/main/java/org/apache/ws/jaxme/impl/XercesREHandler.java
 Fri Aug 19 14:12:51 2005
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2003, 2004  The Apache Software Foundation
+ * 
+ * Licensed 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.ws.jaxme.impl;
+
+import org.apache.xerces.impl.xpath.regex.RegularExpression;
+
+
+/** Default implementation of [EMAIL PROTECTED] REHandler}, using
+ * the builtin Xerces from Java 5.
+ */
+public class XercesREHandler implements REHandler {
+       public Matcher getMatcher(final String pPattern) {
+               final RegularExpression re = new RegularExpression(pPattern, 
"X");
+               return new Matcher(){
+                       public String getPattern() { return pPattern; }
+                       public synchronized boolean matches(String pValue) {
+                               return re.matches(pValue);
+                       }
+               };
+       }
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to