You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jaxme-dev@ws.apache.org by jo...@apache.org on 2005/08/18 23:35:09 UTC
svn commit: r233384 - in /webservices/jaxme/trunk: ./
src/jaxme/org/apache/ws/jaxme/generator/sg/
src/jaxme/org/apache/ws/jaxme/generator/sg/impl/
src/jaxme/org/apache/ws/jaxme/generator/sg/impl/ccsg/
src/jaxme/org/apache/ws/jaxme/generator/types/ src/...
Author: jochen
Date: Thu Aug 18 14:34:47 2005
New Revision: 233384
URL: http://svn.apache.org/viewcvs?rev=233384&view=rev
Log:
Added support for xs:pattern.
Added:
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/impl/Java5REHandler.java
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/impl/REFactory.java
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/impl/REHandler.java
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/impl/XercesREHandler.java
Modified:
webservices/jaxme/trunk/.classpath
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/sg/AtomicTypeSG.java
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/sg/SimpleTypeSG.java
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/AtomicTypeSGImpl.java
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/ccsg/HandlerSGImpl.java
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/types/ListTypeSGImpl.java
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/types/SimpleTypeSGImpl.java
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/types/StringSG.java
webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/impl/PassThroughXMLWriter.java
webservices/jaxme/trunk/src/test/jaxb/types.xsd
webservices/jaxme/trunk/src/xs/org/apache/ws/jaxme/xs/XSAtomicType.java
webservices/jaxme/trunk/src/xs/org/apache/ws/jaxme/xs/impl/XSAtomicTypeRestrictionImpl.java
webservices/jaxme/trunk/src/xs/org/apache/ws/jaxme/xs/types/AbstractAtomicType.java
Modified: webservices/jaxme/trunk/.classpath
URL: http://svn.apache.org/viewcvs/webservices/jaxme/trunk/.classpath?rev=233384&r1=233383&r2=233384&view=diff
==============================================================================
--- webservices/jaxme/trunk/.classpath (original)
+++ webservices/jaxme/trunk/.classpath Thu Aug 18 14:34:47 2005
@@ -19,5 +19,6 @@
<classpathentry kind="src" path="src/webapp/java"/>
<classpathentry exported="true" kind="lib" path="prerequisites/servlet.jar"/>
<classpathentry exported="true" kind="lib" path="prerequisites/antlr.jar"/>
+ <classpathentry kind="lib" path="prerequisites/xercesImpl.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Modified: webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/sg/AtomicTypeSG.java
URL: http://svn.apache.org/viewcvs/webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/sg/AtomicTypeSG.java?rev=233384&r1=233383&r2=233384&view=diff
==============================================================================
--- webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/sg/AtomicTypeSG.java (original)
+++ webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/sg/AtomicTypeSG.java Thu Aug 18 14:34:47 2005
@@ -56,4 +56,8 @@
* is not set.</p>
*/
public Long getTotalDigits();
+ /** Returns the values of the "pattern" facets. Null,
+ * if the facet is not set.
+ */
+ public String[] getPatterns();
}
Modified: webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/sg/SimpleTypeSG.java
URL: http://svn.apache.org/viewcvs/webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/sg/SimpleTypeSG.java?rev=233384&r1=233383&r2=233384&view=diff
==============================================================================
--- webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/sg/SimpleTypeSG.java (original)
+++ webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/sg/SimpleTypeSG.java Thu Aug 18 14:34:47 2005
@@ -156,6 +156,11 @@
*/
public void addValidation(JavaMethod pMethod, DirectAccessible pValue) throws SAXException;
+ /** Adds code for validating the value <code>pValue</code> within the
+ * handler.
+ */
+ public void addHandlerValidation(JavaMethod pJm, TypedValue pValue) throws SAXException;
+
/** Returns, whether the simple type is an instance of
* <code>xs:id</code>.
*/
Modified: webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/AtomicTypeSGImpl.java
URL: http://svn.apache.org/viewcvs/webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/AtomicTypeSGImpl.java?rev=233384&r1=233383&r2=233384&view=diff
==============================================================================
--- webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/AtomicTypeSGImpl.java (original)
+++ webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/AtomicTypeSGImpl.java Thu Aug 18 14:34:47 2005
@@ -23,30 +23,34 @@
* @author <a href="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
*/
public class AtomicTypeSGImpl implements AtomicTypeSG {
- private final String maxExclusive, maxInclusive;
- private final String minExclusive, minInclusive;
- private final Long fractionDigits, totalDigits;
- private final Long length, maxLength, minLength;
+ private final String maxExclusive, maxInclusive;
+ private final String minExclusive, minInclusive;
+ private final Long fractionDigits, totalDigits;
+ private final Long length, maxLength, minLength;
+ private final String[] patterns;
- public AtomicTypeSGImpl(XSAtomicType xsAtomicType) {
- maxExclusive = xsAtomicType.getMaxExclusive();
- maxInclusive = xsAtomicType.getMaxInclusive();
- minExclusive = xsAtomicType.getMinExclusive();
- minInclusive = xsAtomicType.getMinInclusive();
- fractionDigits = xsAtomicType.getFractionDigits();
- totalDigits = xsAtomicType.getTotalDigits();
- length = xsAtomicType.getLength();
- maxLength = xsAtomicType.getMaxLength();
- minLength = xsAtomicType.getMinLength();
- }
+ public AtomicTypeSGImpl(XSAtomicType xsAtomicType) {
+ maxExclusive = xsAtomicType.getMaxExclusive();
+ maxInclusive = xsAtomicType.getMaxInclusive();
+ minExclusive = xsAtomicType.getMinExclusive();
+ minInclusive = xsAtomicType.getMinInclusive();
+ fractionDigits = xsAtomicType.getFractionDigits();
+ totalDigits = xsAtomicType.getTotalDigits();
+ length = xsAtomicType.getLength();
+ maxLength = xsAtomicType.getMaxLength();
+ minLength = xsAtomicType.getMinLength();
+ String[] myPatterns = xsAtomicType.getPatterns();
+ patterns = (myPatterns == null || myPatterns.length == 0) ? null : myPatterns;
+ }
- public String getMaxExclusive() { return maxExclusive; }
- public String getMaxInclusive() { return maxInclusive; }
- public String getMinExclusive() { return minExclusive; }
- public String getMinInclusive() { return minInclusive; }
- public Long getFractionDigits() { return fractionDigits; }
- public Long getTotalDigits() { return totalDigits; }
- public Long getLength() { return length; }
- public Long getMaxLength() { return maxLength; }
- public Long getMinLength() { return minLength; }
+ public String getMaxExclusive() { return maxExclusive; }
+ public String getMaxInclusive() { return maxInclusive; }
+ public String getMinExclusive() { return minExclusive; }
+ public String getMinInclusive() { return minInclusive; }
+ public Long getFractionDigits() { return fractionDigits; }
+ public Long getTotalDigits() { return totalDigits; }
+ public Long getLength() { return length; }
+ public Long getMaxLength() { return maxLength; }
+ public Long getMinLength() { return minLength; }
+ public String[] getPatterns() { return patterns; }
}
Modified: webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/ccsg/HandlerSGImpl.java
URL: http://svn.apache.org/viewcvs/webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/ccsg/HandlerSGImpl.java?rev=233384&r1=233383&r2=233384&view=diff
==============================================================================
--- webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/ccsg/HandlerSGImpl.java (original)
+++ webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/ccsg/HandlerSGImpl.java Thu Aug 18 14:34:47 2005
@@ -39,7 +39,6 @@
import org.apache.ws.jaxme.js.Parameter;
import org.apache.ws.jaxme.js.TypedValue;
import org.apache.ws.jaxme.js.impl.TypedValueImpl;
-import org.apache.ws.jaxme.xs.xml.XsQName;
import org.xml.sax.Attributes;
import org.xml.sax.Locator;
import org.xml.sax.SAXException;
@@ -286,14 +285,17 @@
pJm.addTry();
}
Object s = new Object[]{"(", StringSG.STRING_TYPE, ") ", pValue};
+ pType.getSimpleTypeSG().addHandlerValidation(pJm, pValue);
TypedValue result = new TypedValueImpl(pType.getSimpleTypeSG().getCastFromString(pJm, s, "getHandler()"),
pType.getSimpleTypeSG().getRuntimeType());
pPropertySG.addValue(pJm, pElement, result, null);
if (causingParseConversionEvent) {
DirectAccessible e = pJm.addCatch(Exception.class);
pJm.addLine("getHandler().parseConversionEvent(",
- JavaSource.getQuoted("Failed to convert value of " + pName + ": "),
- " + ", pValue, ", ", e, ");");
+ JavaSource.getQuoted("Failed to convert value "),
+ " + ", pValue, " + ",
+ JavaSource.getQuoted(" for " + pName + ": "),
+ " + ", e, ".getMessage(), ", e, ");");
pJm.addEndTry();
}
}
Modified: webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/types/ListTypeSGImpl.java
URL: http://svn.apache.org/viewcvs/webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/types/ListTypeSGImpl.java?rev=233384&r1=233383&r2=233384&view=diff
==============================================================================
--- webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/types/ListTypeSGImpl.java (original)
+++ webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/types/ListTypeSGImpl.java Thu Aug 18 14:34:47 2005
@@ -198,4 +198,8 @@
public boolean isCausingParseConversionEvent(SimpleTypeSG pController) {
return itemType.getSimpleTypeSG().isCausingParseConversionEvent();
}
+
+ public void addHandlerValidation(SimpleTypeSG pController, JavaMethod pJm, TypedValue pValue) throws SAXException {
+ itemType.getSimpleTypeSG().addHandlerValidation(pJm, pValue);
+ }
}
Modified: webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/types/SimpleTypeSGImpl.java
URL: http://svn.apache.org/viewcvs/webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/types/SimpleTypeSGImpl.java?rev=233384&r1=233383&r2=233384&view=diff
==============================================================================
--- webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/types/SimpleTypeSGImpl.java (original)
+++ webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/types/SimpleTypeSGImpl.java Thu Aug 18 14:34:47 2005
@@ -29,6 +29,7 @@
import org.apache.ws.jaxme.js.JavaMethod;
import org.apache.ws.jaxme.js.JavaQNameImpl;
import org.apache.ws.jaxme.js.JavaSource;
+import org.apache.ws.jaxme.js.TypedValue;
import org.apache.ws.jaxme.xs.XSType;
import org.xml.sax.Locator;
import org.xml.sax.SAXException;
@@ -128,4 +129,8 @@
public void addValidation(SimpleTypeSG pController, JavaMethod pMethod, DirectAccessible pValue) throws SAXException {
}
+
+ public void addHandlerValidation(SimpleTypeSG pController, JavaMethod pJm, TypedValue pValue)
+ throws SAXException {
+ }
}
Modified: webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/types/StringSG.java
URL: http://svn.apache.org/viewcvs/webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/types/StringSG.java?rev=233384&r1=233383&r2=233384&view=diff
==============================================================================
--- webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/types/StringSG.java (original)
+++ webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/generator/types/StringSG.java Thu Aug 18 14:34:47 2005
@@ -21,7 +21,10 @@
import org.apache.ws.jaxme.generator.sg.SGlet;
import org.apache.ws.jaxme.generator.sg.SchemaSG;
import org.apache.ws.jaxme.generator.sg.SimpleTypeSG;
+import org.apache.ws.jaxme.impl.REFactory;
+import org.apache.ws.jaxme.impl.REHandler;
import org.apache.ws.jaxme.js.DirectAccessible;
+import org.apache.ws.jaxme.js.JavaField;
import org.apache.ws.jaxme.js.JavaMethod;
import org.apache.ws.jaxme.js.JavaQName;
import org.apache.ws.jaxme.js.JavaQNameImpl;
@@ -83,7 +86,36 @@
*/
return atomicType.getLength() != null
|| atomicType.getMinLength() != null
- || atomicType.getMaxLength() != null;
+ || atomicType.getMaxLength() != null
+ || atomicType.getPatterns() != null;
+ }
+
+ public void addHandlerValidation(SimpleTypeSG pController, JavaMethod pJm, TypedValue pValue)
+ throws SAXException {
+ String[] patterns = pController.getAtomicType().getPatterns();
+ if (patterns == null) {
+ return;
+ }
+ JavaSource js = pJm.getJavaSource();
+ int i = 0;
+ for (;;) {
+ String name = "_re_" + i;
+ JavaField jf = js.getField(name);
+ if (jf == null) {
+ break;
+ }
+ }
+ for (int j = 0; j < patterns.length; j++) {
+ String name = "_re_" + i++;
+ JavaField jf = js.newJavaField(name, REHandler.Matcher.class);
+ jf.addLine(REFactory.class, ".getREHandler().getMatcher(",
+ JavaSource.getQuoted(patterns[j]), ")");
+ pJm.addIf("!", jf, ".matches(", pValue, ")");
+ pJm.addThrowNew(IllegalArgumentException.class,
+ JavaSource.getQuoted("Value doesn't match pattern "),
+ " + ", jf, ".getPattern()");
+ pJm.addEndIf();
+ }
}
public void addValidation(SimpleTypeSG pController, JavaMethod pMethod, DirectAccessible pValue)
Added: webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/impl/Java5REHandler.java
URL: http://svn.apache.org/viewcvs/webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/impl/Java5REHandler.java?rev=233384&view=auto
==============================================================================
--- webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/impl/Java5REHandler.java (added)
+++ webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/impl/Java5REHandler.java Thu Aug 18 14:34:47 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 {@link 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);
+ }
+ };
+ }
+}
Modified: webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/impl/PassThroughXMLWriter.java
URL: http://svn.apache.org/viewcvs/webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/impl/PassThroughXMLWriter.java?rev=233384&r1=233383&r2=233384&view=diff
==============================================================================
--- webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/impl/PassThroughXMLWriter.java (original)
+++ webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/impl/PassThroughXMLWriter.java Thu Aug 18 14:34:47 2005
@@ -12,7 +12,6 @@
* 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;
Added: webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/impl/REFactory.java
URL: http://svn.apache.org/viewcvs/webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/impl/REFactory.java?rev=233384&view=auto
==============================================================================
--- webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/impl/REFactory.java (added)
+++ webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/impl/REFactory.java Thu Aug 18 14:34:47 2005
@@ -0,0 +1,82 @@
+/*
+ * 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
+ * {@link REHandler.Matcher}. It provides access to a single
+ * instance of {@link 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 {@link 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 {@link Java5REHandler} is created,
+ * if possible. This is the case, when running under
+ * Java 5.</li>
+ * <li>Otherwise, an instance of {@link XercesREHandler}
+ * is created, if possible. This is the case, when
+ * Xerces-J is available.</li>
+ * <li>Otherwise, an instance of {@link DummyREHandler}
+ * is created. This is an REHandler, which matches
+ * always. In other words, patterns are ignored.</li>
+ * </ol>
+ */
+ public static REHandler getREHandler() { return reHandler; }
+
+ private 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/trunk/src/jaxme/org/apache/ws/jaxme/impl/REHandler.java
URL: http://svn.apache.org/viewcvs/webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/impl/REHandler.java?rev=233384&view=auto
==============================================================================
--- webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/impl/REHandler.java (added)
+++ webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/impl/REHandler.java Thu Aug 18 14:34:47 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/trunk/src/jaxme/org/apache/ws/jaxme/impl/XercesREHandler.java
URL: http://svn.apache.org/viewcvs/webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/impl/XercesREHandler.java?rev=233384&view=auto
==============================================================================
--- webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/impl/XercesREHandler.java (added)
+++ webservices/jaxme/trunk/src/jaxme/org/apache/ws/jaxme/impl/XercesREHandler.java Thu Aug 18 14:34:47 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 {@link 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);
+ }
+ };
+ }
+}
Modified: webservices/jaxme/trunk/src/test/jaxb/types.xsd
URL: http://svn.apache.org/viewcvs/webservices/jaxme/trunk/src/test/jaxb/types.xsd?rev=233384&r1=233383&r2=233384&view=diff
==============================================================================
Binary files - no diff available.
Modified: webservices/jaxme/trunk/src/xs/org/apache/ws/jaxme/xs/XSAtomicType.java
URL: http://svn.apache.org/viewcvs/webservices/jaxme/trunk/src/xs/org/apache/ws/jaxme/xs/XSAtomicType.java?rev=233384&r1=233383&r2=233384&view=diff
==============================================================================
--- webservices/jaxme/trunk/src/xs/org/apache/ws/jaxme/xs/XSAtomicType.java (original)
+++ webservices/jaxme/trunk/src/xs/org/apache/ws/jaxme/xs/XSAtomicType.java Thu Aug 18 14:34:47 2005
@@ -68,4 +68,8 @@
* replacing.</p>
*/
public boolean isCollapsing();
+
+ /** Returns the patterns, which are restricting this type.
+ */
+ public String[] getPatterns();
}
Modified: webservices/jaxme/trunk/src/xs/org/apache/ws/jaxme/xs/impl/XSAtomicTypeRestrictionImpl.java
URL: http://svn.apache.org/viewcvs/webservices/jaxme/trunk/src/xs/org/apache/ws/jaxme/xs/impl/XSAtomicTypeRestrictionImpl.java?rev=233384&r1=233383&r2=233384&view=diff
==============================================================================
--- webservices/jaxme/trunk/src/xs/org/apache/ws/jaxme/xs/impl/XSAtomicTypeRestrictionImpl.java (original)
+++ webservices/jaxme/trunk/src/xs/org/apache/ws/jaxme/xs/impl/XSAtomicTypeRestrictionImpl.java Thu Aug 18 14:34:47 2005
@@ -26,6 +26,7 @@
import org.apache.ws.jaxme.xs.xml.XsEMinExclusive;
import org.apache.ws.jaxme.xs.xml.XsEMinInclusive;
import org.apache.ws.jaxme.xs.xml.XsEMinLength;
+import org.apache.ws.jaxme.xs.xml.XsEPattern;
import org.apache.ws.jaxme.xs.xml.XsETotalDigits;
import org.apache.ws.jaxme.xs.xml.XsEWhiteSpace;
import org.apache.ws.jaxme.xs.xml.XsGSimpleRestrictionModel;
@@ -35,7 +36,8 @@
* @author <a href="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
*/
public class XSAtomicTypeRestrictionImpl extends XSSimpleTypeRestrictionImpl implements XSAtomicType {
- private final XSAtomicType atomicBaseType;
+ private static final String[] ZERO_PATTERNS = new String[0];
+ private final XSAtomicType atomicBaseType;
/** Creates a new atomic type restricting <code>pBaseType</code>
* with the constraints <code>pRestriction</code>.
@@ -150,5 +152,18 @@
} else {
return whiteSpace.isCollapsing();
}
+ }
+
+ public String[] getPatterns() {
+ XsEPattern[] patterns = getRestriction().getPatterns();
+ if (patterns == null || patterns.length == 0) {
+ return ZERO_PATTERNS;
+ } else {
+ String[] result = new String[patterns.length];
+ for (int i = 0; i < patterns.length; i++) {
+ result[i] = patterns[i].getValue();
+ }
+ return result;
+ }
}
}
Modified: webservices/jaxme/trunk/src/xs/org/apache/ws/jaxme/xs/types/AbstractAtomicType.java
URL: http://svn.apache.org/viewcvs/webservices/jaxme/trunk/src/xs/org/apache/ws/jaxme/xs/types/AbstractAtomicType.java?rev=233384&r1=233383&r2=233384&view=diff
==============================================================================
--- webservices/jaxme/trunk/src/xs/org/apache/ws/jaxme/xs/types/AbstractAtomicType.java (original)
+++ webservices/jaxme/trunk/src/xs/org/apache/ws/jaxme/xs/types/AbstractAtomicType.java Thu Aug 18 14:34:47 2005
@@ -23,7 +23,8 @@
* @author <a href="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
*/
public abstract class AbstractAtomicType extends AbstractSimpleType implements XSAtomicType {
- public boolean isAtomic() { return true; }
+ private static final String[] ZERO_PATTERNS = new String[0];
+ public boolean isAtomic() { return true; }
public XSAtomicType getAtomicType() { return this; }
@@ -39,4 +40,5 @@
public boolean isReplacing() { return false; }
public boolean isCollapsing() { return false; }
public boolean isBuiltin() { return true; }
+ public String[] getPatterns() { return ZERO_PATTERNS; }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: jaxme-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: jaxme-dev-help@ws.apache.org