Author: veithen
Date: Sun Nov 15 19:30:57 2015
New Revision: 1714491
URL: http://svn.apache.org/viewvc?rev=1714491&view=rev
Log:
Initial datatype library code.
Added:
webservices/axiom/branches/datatypes/aspects/core-aspects/src/main/java/org/apache/axiom/core/ContextAccessorImpl.java
(with props)
webservices/axiom/branches/datatypes/datatypes/ (with props)
webservices/axiom/branches/datatypes/datatypes/pom.xml (with props)
webservices/axiom/branches/datatypes/datatypes/src/
webservices/axiom/branches/datatypes/datatypes/src/main/
webservices/axiom/branches/datatypes/datatypes/src/main/java/
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/AbstractInvariantType.java
(with props)
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/ContextAccessor.java
(with props)
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/DOMContextAccessor.java
(with props)
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/DOMHelper.java
(with props)
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/InvariantType.java
(with props)
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/Type.java
(with props)
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/UnexpectedCharacterException.java
(with props)
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/UnexpectedEndOfStringException.java
(with props)
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/AbstractWhitespaceCollapsingInvariantType.java
(with props)
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/NoTimeZoneException.java
(with props)
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/SimpleTimeZone.java
(with props)
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/Temporal.java
(with props)
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/TemporalImpl.java
(with props)
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/TemporalType.java
(with props)
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/Util.java
(with props)
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDate.java
(with props)
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDateImpl.java
(with props)
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDateTime.java
(with props)
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDateTimeImpl.java
(with props)
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDateTimeType.java
(with props)
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDateTimeTypeImpl.java
(with props)
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDateType.java
(with props)
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDateTypeImpl.java
(with props)
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSQNameType.java
(with props)
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSQNameTypeImpl.java
(with props)
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSStringType.java
(with props)
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSStringTypeImpl.java
(with props)
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSTime.java
(with props)
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSTimeImpl.java
(with props)
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSTimeType.java
(with props)
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSTimeTypeImpl.java
(with props)
webservices/axiom/branches/datatypes/datatypes/src/main/resources/
webservices/axiom/branches/datatypes/datatypes/src/test/
webservices/axiom/branches/datatypes/datatypes/src/test/java/
webservices/axiom/branches/datatypes/datatypes/src/test/java/org/
webservices/axiom/branches/datatypes/datatypes/src/test/java/org/apache/
webservices/axiom/branches/datatypes/datatypes/src/test/java/org/apache/axiom/
webservices/axiom/branches/datatypes/datatypes/src/test/java/org/apache/axiom/datatype/
webservices/axiom/branches/datatypes/datatypes/src/test/java/org/apache/axiom/datatype/DOMHelperTest.java
(with props)
webservices/axiom/branches/datatypes/datatypes/src/test/java/org/apache/axiom/datatype/xsd/
webservices/axiom/branches/datatypes/datatypes/src/test/java/org/apache/axiom/datatype/xsd/XSDateTimeTypeTest.java
(with props)
webservices/axiom/branches/datatypes/datatypes/src/test/resources/
Removed:
webservices/axiom/branches/datatypes/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/TextTransformer.java
Modified:
webservices/axiom/branches/datatypes/aspects/core-aspects/pom.xml
webservices/axiom/branches/datatypes/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreElement.java
webservices/axiom/branches/datatypes/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreElementSupport.aj
webservices/axiom/branches/datatypes/aspects/fom-aspects/pom.xml
webservices/axiom/branches/datatypes/aspects/fom-aspects/src/main/java/org/apache/axiom/fom/AbderaDateTimeMixin.aj
webservices/axiom/branches/datatypes/implementations/pom.xml
webservices/axiom/branches/datatypes/pom.xml
webservices/axiom/branches/datatypes/testing/soap-testsuite/pom.xml
webservices/axiom/branches/datatypes/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/ConvertedSOAPSampleContent.java
Modified: webservices/axiom/branches/datatypes/aspects/core-aspects/pom.xml
URL:
http://svn.apache.org/viewvc/webservices/axiom/branches/datatypes/aspects/core-aspects/pom.xml?rev=1714491&r1=1714490&r2=1714491&view=diff
==============================================================================
--- webservices/axiom/branches/datatypes/aspects/core-aspects/pom.xml (original)
+++ webservices/axiom/branches/datatypes/aspects/core-aspects/pom.xml Sun Nov
15 19:30:57 2015
@@ -40,6 +40,11 @@
<version>${project.version}</version>
</dependency>
<dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>datatypes</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
</dependency>
Added:
webservices/axiom/branches/datatypes/aspects/core-aspects/src/main/java/org/apache/axiom/core/ContextAccessorImpl.java
URL:
http://svn.apache.org/viewvc/webservices/axiom/branches/datatypes/aspects/core-aspects/src/main/java/org/apache/axiom/core/ContextAccessorImpl.java?rev=1714491&view=auto
==============================================================================
---
webservices/axiom/branches/datatypes/aspects/core-aspects/src/main/java/org/apache/axiom/core/ContextAccessorImpl.java
(added)
+++
webservices/axiom/branches/datatypes/aspects/core-aspects/src/main/java/org/apache/axiom/core/ContextAccessorImpl.java
Sun Nov 15 19:30:57 2015
@@ -0,0 +1,35 @@
+/*
+ * 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.axiom.core;
+
+import org.apache.axiom.datatype.ContextAccessor;
+
+final class ContextAccessorImpl implements
ContextAccessor<CoreElement,Semantics> {
+ public static final ContextAccessorImpl INSTANCE = new
ContextAccessorImpl();
+
+ private ContextAccessorImpl() {}
+
+ public String lookupNamespaceURI(CoreElement element, Semantics semantics,
String prefix) {
+ return element.coreLookupNamespaceURI(prefix, semantics);
+ }
+
+ public String lookupPrefix(CoreElement element, Semantics semantics,
String namespaceURI) {
+ return element.coreLookupPrefix(namespaceURI, semantics);
+ }
+}
Propchange:
webservices/axiom/branches/datatypes/aspects/core-aspects/src/main/java/org/apache/axiom/core/ContextAccessorImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
webservices/axiom/branches/datatypes/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreElement.java
URL:
http://svn.apache.org/viewvc/webservices/axiom/branches/datatypes/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreElement.java?rev=1714491&r1=1714490&r2=1714491&view=diff
==============================================================================
---
webservices/axiom/branches/datatypes/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreElement.java
(original)
+++
webservices/axiom/branches/datatypes/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreElement.java
Sun Nov 15 19:30:57 2015
@@ -18,8 +18,11 @@
*/
package org.apache.axiom.core;
+import java.text.ParseException;
import java.util.Iterator;
+import org.apache.axiom.datatype.Type;
+
public interface CoreElement extends CoreChildNode, CoreMixedContentContainer,
CoreNamedNode, DeferringParentNode {
/**
* Get the first attribute of this element.
@@ -153,4 +156,6 @@ public interface CoreElement extends Cor
// TODO: wrong Javadoc: null vs. empty string
// TODO: we can support default namespaces!
String coreLookupPrefix(String namespaceURI, Semantics semantics);
+
+ <T> T coreGetValue(Type<T> type, Semantics semantics) throws
ParseException;
}
Modified:
webservices/axiom/branches/datatypes/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreElementSupport.aj
URL:
http://svn.apache.org/viewvc/webservices/axiom/branches/datatypes/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreElementSupport.aj?rev=1714491&r1=1714490&r2=1714491&view=diff
==============================================================================
---
webservices/axiom/branches/datatypes/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreElementSupport.aj
(original)
+++
webservices/axiom/branches/datatypes/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreElementSupport.aj
Sun Nov 15 19:30:57 2015
@@ -18,8 +18,11 @@
*/
package org.apache.axiom.core;
+import java.text.ParseException;
import java.util.Iterator;
+import org.apache.axiom.datatype.Type;
+
public aspect CoreElementSupport {
private CoreAttribute CoreElement.firstAttribute;
@@ -220,4 +223,18 @@ public aspect CoreElementSupport {
// This is basically a hook for OMSourcedElement
public <T> void CoreElement.initSource(ClonePolicy<T> policy, T options,
CoreElement other) {
}
+
+ public final <T> T CoreElement.coreGetValue(Type<T> type, Semantics
semantics) throws ParseException {
+ Object characterData = coreGetCharacterData(ElementAction.RETURN_NULL);
+ if (characterData == null) {
+ throw new ParseException("Element has mixed content", 0);
+ } else {
+ return type.parse(characterData.toString(),
ContextAccessorImpl.INSTANCE, this, semantics);
+ }
+ }
+
+ public final <T> void CoreElement.coreSetValue(Type<T> type, T value,
Semantics semantics) {
+ // TODO: actually set value
+ type.format(value, ContextAccessorImpl.INSTANCE, this, semantics);
+ }
}
Modified: webservices/axiom/branches/datatypes/aspects/fom-aspects/pom.xml
URL:
http://svn.apache.org/viewvc/webservices/axiom/branches/datatypes/aspects/fom-aspects/pom.xml?rev=1714491&r1=1714490&r2=1714491&view=diff
==============================================================================
--- webservices/axiom/branches/datatypes/aspects/fom-aspects/pom.xml (original)
+++ webservices/axiom/branches/datatypes/aspects/fom-aspects/pom.xml Sun Nov 15
19:30:57 2015
@@ -43,6 +43,11 @@
<version>${project.version}</version>
</dependency>
<dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>datatypes</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
</dependency>
Modified:
webservices/axiom/branches/datatypes/aspects/fom-aspects/src/main/java/org/apache/axiom/fom/AbderaDateTimeMixin.aj
URL:
http://svn.apache.org/viewvc/webservices/axiom/branches/datatypes/aspects/fom-aspects/src/main/java/org/apache/axiom/fom/AbderaDateTimeMixin.aj?rev=1714491&r1=1714490&r2=1714491&view=diff
==============================================================================
---
webservices/axiom/branches/datatypes/aspects/fom-aspects/src/main/java/org/apache/axiom/fom/AbderaDateTimeMixin.aj
(original)
+++
webservices/axiom/branches/datatypes/aspects/fom-aspects/src/main/java/org/apache/axiom/fom/AbderaDateTimeMixin.aj
Sun Nov 15 19:30:57 2015
@@ -17,19 +17,35 @@
*/
package org.apache.axiom.fom;
+import java.text.ParseException;
import java.util.Calendar;
import java.util.Date;
import org.apache.abdera.model.AtomDate;
import org.apache.abdera.model.DateTime;
+import org.apache.axiom.datatype.xsd.XSDateTime;
+import org.apache.axiom.datatype.xsd.XSDateTimeType;
import org.apache.axiom.fom.AbderaDateTime;
public aspect AbderaDateTimeMixin {
private AtomDate AbderaDateTime.value;
+ private XSDateTime AbderaDateTime.getXSDateTime() {
+ XSDateTime dateTime;
+ try {
+ dateTime = coreGetValue(XSDateTimeType.INSTANCE,
FOMSemantics.INSTANCE);
+ } catch (ParseException ex) {
+ throw new IllegalArgumentException("Invalid Date Format", ex);
+ }
+ if (!dateTime.hasTimeZone()) {
+ throw new IllegalArgumentException("Not a valid RFC3339 date/time
value: no time zone");
+ }
+ return dateTime;
+ }
+
public final AtomDate AbderaDateTime.getValue() {
if (value == null) {
- value = AtomDate.valueOf(getText());
+ value = new AtomDate(getXSDateTime().getDate(null));
}
return value;
}
Propchange: webservices/axiom/branches/datatypes/datatypes/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sun Nov 15 19:30:57 2015
@@ -0,0 +1,4 @@
+.classpath
+.project
+.settings
+target
Added: webservices/axiom/branches/datatypes/datatypes/pom.xml
URL:
http://svn.apache.org/viewvc/webservices/axiom/branches/datatypes/datatypes/pom.xml?rev=1714491&view=auto
==============================================================================
--- webservices/axiom/branches/datatypes/datatypes/pom.xml (added)
+++ webservices/axiom/branches/datatypes/datatypes/pom.xml Sun Nov 15 19:30:57
2015
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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 xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.ws.commons.axiom</groupId>
+ <artifactId>axiom</artifactId>
+ <version>1.2.16-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>datatypes</artifactId>
+ <packaging>bundle</packaging>
+
+ <url>http://ws.apache.org/axiom/</url>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.google.truth</groupId>
+ <artifactId>truth</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Export-Package>*;-noimport:=true</Export-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Propchange: webservices/axiom/branches/datatypes/datatypes/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added:
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/AbstractInvariantType.java
URL:
http://svn.apache.org/viewvc/webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/AbstractInvariantType.java?rev=1714491&view=auto
==============================================================================
---
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/AbstractInvariantType.java
(added)
+++
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/AbstractInvariantType.java
Sun Nov 15 19:30:57 2015
@@ -0,0 +1,31 @@
+/*
+ * 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.axiom.datatype;
+
+import java.text.ParseException;
+
+public abstract class AbstractInvariantType<T> implements InvariantType<T> {
+ public final <S,O> T parse(String literal, ContextAccessor<S,O>
contextAccessor, S contextObject, O options) throws ParseException {
+ return parse(literal);
+ }
+
+ public final <S,O> String format(T value, ContextAccessor<S,O>
contextAccessor, S contextObject, O options) {
+ return format(value);
+ }
+}
Propchange:
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/AbstractInvariantType.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/ContextAccessor.java
URL:
http://svn.apache.org/viewvc/webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/ContextAccessor.java?rev=1714491&view=auto
==============================================================================
---
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/ContextAccessor.java
(added)
+++
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/ContextAccessor.java
Sun Nov 15 19:30:57 2015
@@ -0,0 +1,24 @@
+/*
+ * 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.axiom.datatype;
+
+public interface ContextAccessor<T,O> {
+ String lookupNamespaceURI(T contextObject, O options, String prefix);
+ String lookupPrefix(T contextObject, O options, String namespaceURI);
+}
Propchange:
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/ContextAccessor.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/DOMContextAccessor.java
URL:
http://svn.apache.org/viewvc/webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/DOMContextAccessor.java?rev=1714491&view=auto
==============================================================================
---
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/DOMContextAccessor.java
(added)
+++
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/DOMContextAccessor.java
Sun Nov 15 19:30:57 2015
@@ -0,0 +1,38 @@
+/*
+ * 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.axiom.datatype;
+
+import org.w3c.dom.Element;
+
+final class DOMContextAccessor implements ContextAccessor<Element,Void> {
+ static final DOMContextAccessor INSTANCE = new DOMContextAccessor();
+
+ public String lookupNamespaceURI(Element element, Void options, String
prefix) {
+ String namespaceURI = element.lookupNamespaceURI(prefix.length() == 0
? null : prefix);
+ if (namespaceURI != null) {
+ return namespaceURI;
+ } else {
+ return prefix.length() == 0 ? "" : null;
+ }
+ }
+
+ public String lookupPrefix(Element element, Void options, String
namespaceURI) {
+ return element.lookupPrefix(namespaceURI.length() == 0 ? null :
namespaceURI);
+ }
+}
Propchange:
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/DOMContextAccessor.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/DOMHelper.java
URL:
http://svn.apache.org/viewvc/webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/DOMHelper.java?rev=1714491&view=auto
==============================================================================
---
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/DOMHelper.java
(added)
+++
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/DOMHelper.java
Sun Nov 15 19:30:57 2015
@@ -0,0 +1,36 @@
+/*
+ * 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.axiom.datatype;
+
+import java.text.ParseException;
+
+import org.w3c.dom.Element;
+
+public final class DOMHelper {
+ private DOMHelper() {}
+
+ public static <T> T getValue(Element element, Type<T> type) throws
ParseException {
+ // TODO: using getTextContent here is actually incorrect because it
extracts text recursively
+ return type.parse(element.getTextContent(),
DOMContextAccessor.INSTANCE, element, null);
+ }
+
+ public static <T> void setValue(Element element, Type<T> type, T value) {
+ element.setTextContent(type.format(value, DOMContextAccessor.INSTANCE,
element, null));
+ }
+}
Propchange:
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/DOMHelper.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/InvariantType.java
URL:
http://svn.apache.org/viewvc/webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/InvariantType.java?rev=1714491&view=auto
==============================================================================
---
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/InvariantType.java
(added)
+++
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/InvariantType.java
Sun Nov 15 19:30:57 2015
@@ -0,0 +1,26 @@
+/*
+ * 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.axiom.datatype;
+
+import java.text.ParseException;
+
+public interface InvariantType<T> extends Type<T> {
+ T parse(String literal) throws ParseException;
+ String format(T value);
+}
Propchange:
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/InvariantType.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/Type.java
URL:
http://svn.apache.org/viewvc/webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/Type.java?rev=1714491&view=auto
==============================================================================
---
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/Type.java
(added)
+++
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/Type.java
Sun Nov 15 19:30:57 2015
@@ -0,0 +1,26 @@
+/*
+ * 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.axiom.datatype;
+
+import java.text.ParseException;
+
+public interface Type<T> {
+ <S,O> T parse(String literal, ContextAccessor<S,O> contextAccessor, S
contextObject, O options) throws ParseException;
+ <S,O> String format(T value, ContextAccessor<S,O> contextAccessor, S
contextObject, O options);
+}
Propchange:
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/Type.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/UnexpectedCharacterException.java
URL:
http://svn.apache.org/viewvc/webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/UnexpectedCharacterException.java?rev=1714491&view=auto
==============================================================================
---
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/UnexpectedCharacterException.java
(added)
+++
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/UnexpectedCharacterException.java
Sun Nov 15 19:30:57 2015
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axiom.datatype;
+
+import java.text.ParseException;
+
+public class UnexpectedCharacterException extends ParseException {
+ private static final long serialVersionUID = 1L;
+
+ public UnexpectedCharacterException(String literal, int errorOffset) {
+ super("Unexpected character '" + literal.charAt(errorOffset) + "'",
errorOffset);
+ }
+}
Propchange:
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/UnexpectedCharacterException.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/UnexpectedEndOfStringException.java
URL:
http://svn.apache.org/viewvc/webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/UnexpectedEndOfStringException.java?rev=1714491&view=auto
==============================================================================
---
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/UnexpectedEndOfStringException.java
(added)
+++
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/UnexpectedEndOfStringException.java
Sun Nov 15 19:30:57 2015
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axiom.datatype;
+
+import java.text.ParseException;
+
+public class UnexpectedEndOfStringException extends ParseException {
+ private static final long serialVersionUID = 1L;
+
+ public UnexpectedEndOfStringException(String literal) {
+ super("Unexpected end of string", literal.length());
+ }
+}
Propchange:
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/UnexpectedEndOfStringException.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/AbstractWhitespaceCollapsingInvariantType.java
URL:
http://svn.apache.org/viewvc/webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/AbstractWhitespaceCollapsingInvariantType.java?rev=1714491&view=auto
==============================================================================
---
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/AbstractWhitespaceCollapsingInvariantType.java
(added)
+++
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/AbstractWhitespaceCollapsingInvariantType.java
Sun Nov 15 19:30:57 2015
@@ -0,0 +1,46 @@
+/*
+ * 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.axiom.datatype.xsd;
+
+import java.text.ParseException;
+
+import org.apache.axiom.datatype.AbstractInvariantType;
+import org.apache.axiom.datatype.UnexpectedEndOfStringException;
+
+abstract class AbstractWhitespaceCollapsingInvariantType<T> extends
AbstractInvariantType<T> {
+ public final T parse(String literal) throws ParseException {
+ final int len = literal.length();
+ if (len == 0) {
+ throw new UnexpectedEndOfStringException(literal);
+ }
+ int begin = 0;
+ while (Util.isWhitespace(literal.charAt(begin))) {
+ if (++begin == len) {
+ throw new UnexpectedEndOfStringException(literal);
+ }
+ }
+ int end = len;
+ while (Util.isWhitespace(literal.charAt(end-1))) {
+ end--;
+ }
+ return parse(literal, begin, end);
+ }
+
+ protected abstract T parse(String literal, int begin, int end) throws
ParseException;
+}
Propchange:
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/AbstractWhitespaceCollapsingInvariantType.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/NoTimeZoneException.java
URL:
http://svn.apache.org/viewvc/webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/NoTimeZoneException.java?rev=1714491&view=auto
==============================================================================
---
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/NoTimeZoneException.java
(added)
+++
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/NoTimeZoneException.java
Sun Nov 15 19:30:57 2015
@@ -0,0 +1,23 @@
+/*
+ * 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.axiom.datatype.xsd;
+
+public class NoTimeZoneException extends RuntimeException {
+ private static final long serialVersionUID = 1L;
+}
Propchange:
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/NoTimeZoneException.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/SimpleTimeZone.java
URL:
http://svn.apache.org/viewvc/webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/SimpleTimeZone.java?rev=1714491&view=auto
==============================================================================
---
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/SimpleTimeZone.java
(added)
+++
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/SimpleTimeZone.java
Sun Nov 15 19:30:57 2015
@@ -0,0 +1,95 @@
+/*
+ * 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.axiom.datatype.xsd;
+
+import java.util.Date;
+import java.util.TimeZone;
+
+final class SimpleTimeZone extends TimeZone {
+ private static final long serialVersionUID = 1L;
+
+ private static final SimpleTimeZone[] instances;
+
+ static {
+ instances = new SimpleTimeZone[57];
+ for (int i=0; i<instances.length; i++) {
+ instances[i] = new SimpleTimeZone(30*(-28 + i));
+ }
+ }
+
+ private final int delta;
+
+ SimpleTimeZone(int delta) {
+ this.delta = delta;
+ if (delta == 0) {
+ super.setID("GMT");
+ } else {
+ StringBuilder buffer = new StringBuilder("GMT");
+ buffer.append(delta < 0 ? '-' : '+');
+ delta = Math.abs(delta);
+ append2Digits(buffer, delta/60);
+ buffer.append(':');
+ append2Digits(buffer, delta % 60);
+ super.setID(buffer.toString());
+ }
+ }
+
+ private static void append2Digits(StringBuilder buffer, int value) {
+ buffer.append((char)('0' + value/10));
+ buffer.append((char)('0' + value%10));
+ }
+
+ static SimpleTimeZone getInstance(int delta) {
+ return delta % 30 == 0 ? instances[delta/30 + 28] : new
SimpleTimeZone(delta);
+ }
+
+ @Override
+ public int getOffset(int era, int year, int month, int day, int dayOfWeek,
int milliseconds) {
+ return getRawOffset();
+ }
+
+ @Override
+ public void setRawOffset(int offsetMillis) {
+ if (getRawOffset() != offsetMillis) {
+ throw new UnsupportedOperationException("Immutable time zone
object");
+ }
+ }
+
+ @Override
+ public int getRawOffset() {
+ return delta * 60000;
+ }
+
+ @Override
+ public boolean useDaylightTime() {
+ return false;
+ }
+
+ @Override
+ public boolean inDaylightTime(Date date) {
+ return false;
+ }
+
+ @Override
+ public void setID(String ID) {
+ if (!getID().equals(ID)) {
+ throw new UnsupportedOperationException("Immutable time zone
object");
+ }
+ }
+}
Propchange:
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/SimpleTimeZone.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/Temporal.java
URL:
http://svn.apache.org/viewvc/webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/Temporal.java?rev=1714491&view=auto
==============================================================================
---
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/Temporal.java
(added)
+++
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/Temporal.java
Sun Nov 15 19:30:57 2015
@@ -0,0 +1,43 @@
+/*
+ * 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.axiom.datatype.xsd;
+
+import java.util.GregorianCalendar;
+import java.util.TimeZone;
+
+public interface Temporal {
+ /**
+ *
+ * @param defaultTimeZone
+ * the time zone to use if this temporal object has no time
zone; may be
+ * <code>null</code>
+ * @return
+ * @throws NoTimeZoneException
+ * if this temporal object doesn't have a time zone and no
default time zone was
+ * specified
+ */
+ GregorianCalendar getCalendar(TimeZone defaultTimeZone);
+
+ /**
+ * Determine if this temporal object has a time zone.
+ *
+ * @return <code>true</code> if the object has a time zone,
<code>false</code> otherwise
+ */
+ boolean hasTimeZone();
+}
Propchange:
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/Temporal.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/TemporalImpl.java
URL:
http://svn.apache.org/viewvc/webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/TemporalImpl.java?rev=1714491&view=auto
==============================================================================
---
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/TemporalImpl.java
(added)
+++
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/TemporalImpl.java
Sun Nov 15 19:30:57 2015
@@ -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.axiom.datatype.xsd;
+
+import java.util.GregorianCalendar;
+import java.util.TimeZone;
+
+abstract class TemporalImpl implements Temporal {
+ abstract boolean hasDatePart();
+ abstract boolean hasTimePart();
+ abstract boolean isBC();
+ abstract String getAeon();
+ abstract int getYear();
+ abstract int getMonth();
+ abstract int getDay();
+ abstract int getHour();
+ abstract int getMinute();
+ abstract int getSecond();
+ abstract int getNanoSecond();
+ abstract SimpleTimeZone getTimeZone();
+ abstract String getNanoSecondFraction();
+
+ public final GregorianCalendar getCalendar(TimeZone defaultTimeZone) {
+ // TODO: check aeon
+ TimeZone timeZone = getTimeZone();
+ if (timeZone == null) {
+ if (defaultTimeZone == null) {
+ throw new NoTimeZoneException();
+ }
+ timeZone = defaultTimeZone;
+ }
+ GregorianCalendar calendar = new GregorianCalendar(timeZone);
+ if (hasDatePart()) {
+ // TODO: BC
+ // TODO: throw exception if aeon is not null
+ calendar.set(GregorianCalendar.YEAR, getYear());
+ calendar.set(GregorianCalendar.MONTH, getMonth()-1);
+ calendar.set(GregorianCalendar.DAY_OF_MONTH, getDay());
+ }
+ if (hasTimePart()) {
+ calendar.set(GregorianCalendar.HOUR_OF_DAY, getHour());
+ calendar.set(GregorianCalendar.MINUTE, getMinute());
+ calendar.set(GregorianCalendar.SECOND, getSecond());
+ calendar.set(GregorianCalendar.MILLISECOND,
getNanoSecond()/1000000);
+ }
+ return calendar;
+ }
+
+ public boolean hasTimeZone() {
+ return getTimeZone() != null;
+ }
+}
Propchange:
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/TemporalImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/TemporalType.java
URL:
http://svn.apache.org/viewvc/webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/TemporalType.java?rev=1714491&view=auto
==============================================================================
---
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/TemporalType.java
(added)
+++
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/TemporalType.java
Sun Nov 15 19:30:57 2015
@@ -0,0 +1,245 @@
+/*
+ * 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.axiom.datatype.xsd;
+
+import java.text.ParseException;
+
+import org.apache.axiom.datatype.UnexpectedCharacterException;
+import org.apache.axiom.datatype.UnexpectedEndOfStringException;
+
+abstract class TemporalType<T> extends
AbstractWhitespaceCollapsingInvariantType<T> {
+ abstract boolean hasDatePart();
+ abstract boolean hasTimePart();
+ abstract T createInstance(boolean bc, String aeon, int year, int month,
int day, int hour,
+ int minute, int second, int nanoSecond, String nanoSecondFraction,
+ SimpleTimeZone timeZone);
+
+ @Override
+ protected final T parse(String literal, int begin, int end) throws
ParseException {
+ int index = begin;
+ boolean bc;
+ String aeon;
+ int year;
+ int month;
+ int day;
+ if (hasDatePart()) {
+ if (literal.charAt(0) == '-') {
+ bc = true;
+ index++;
+ } else {
+ bc = false;
+ }
+ {
+ int digits = countDigits(literal, index, "-", false);
+ if (digits < 4) {
+ throw new UnexpectedCharacterException(literal,
index+digits);
+ }
+ if (digits > 4 && literal.charAt(index) == '0') {
+ throw new UnexpectedCharacterException(literal, index);
+ }
+ if (digits > 9) {
+ aeon = literal.substring(index, index+digits-9);
+ index += digits-9;
+ digits = 9;
+ } else {
+ aeon = null;
+ }
+ year = parseDigitsUnchecked(literal, index, digits);
+ if (year == 0) {
+ throw new ParseException("Year can't be zero", index);
+ }
+ index += digits + 1;
+ }
+ month = parseDigitsChecked(literal, index, 2);
+ index += 2;
+ if (index == end) {
+ throw new UnexpectedEndOfStringException(literal);
+ }
+ if (literal.charAt(index) != '-') {
+ throw new UnexpectedCharacterException(literal, index);
+ }
+ index++;
+ day = parseDigitsChecked(literal, index, 2);
+ index += 2;
+ } else {
+ bc = false;
+ aeon = null;
+ year = 0;
+ month = 0;
+ day = 0;
+ }
+ if (hasDatePart() && hasTimePart()) {
+ if (index == end) {
+ throw new UnexpectedEndOfStringException(literal);
+ }
+ if (literal.charAt(index) != 'T') {
+ throw new UnexpectedCharacterException(literal, index);
+ }
+ index++;
+ }
+ int hour;
+ int minute;
+ int second;
+ int nanoSecond;
+ String nanoSecondFraction;
+ if (hasTimePart()) {
+ hour = parseDigitsChecked(literal, index, 2);
+ index += 2;
+ if (index == end) {
+ throw new UnexpectedEndOfStringException(literal);
+ }
+ if (literal.charAt(index) != ':') {
+ throw new UnexpectedCharacterException(literal, index);
+ }
+ index++;
+ minute = parseDigitsChecked(literal, index, 2);
+ index += 2;
+ if (index == end) {
+ throw new UnexpectedEndOfStringException(literal);
+ }
+ if (literal.charAt(index) != ':') {
+ throw new UnexpectedCharacterException(literal, index);
+ }
+ index++;
+ second = parseDigitsChecked(literal, index, 2);
+ index += 2;
+ if (index < end && literal.charAt(index) == '.') {
+ index++;
+ if (index == end) {
+ throw new UnexpectedEndOfStringException(literal);
+ }
+ int digits = countDigits(literal, index, "Z+-", true);
+ if (digits == 0) {
+ if (index == end) {
+ throw new UnexpectedEndOfStringException(literal);
+ } else {
+ throw new UnexpectedCharacterException(literal, index);
+ }
+ }
+ // TODO: we should remove trailing zeros
+ nanoSecond = parseDigitsUnchecked(literal, index,
Math.min(digits, 9));
+ if (digits > 9) {
+ nanoSecondFraction = literal.substring(index+9,
index+digits-9);
+ } else {
+ for (int i = digits; i < 9; i++) {
+ nanoSecond *= 10;
+ }
+ nanoSecondFraction = null;
+ }
+ index += digits;
+ } else {
+ nanoSecond = 0;
+ nanoSecondFraction = null;
+ }
+ } else {
+ hour = 0;
+ minute = 0;
+ second = 0;
+ nanoSecond = 0;
+ nanoSecondFraction = null;
+ }
+ SimpleTimeZone timeZone;
+ if (index == end) {
+ timeZone = null;
+ } else {
+ int delta;
+ char c = literal.charAt(index);
+ index++;
+ if (c == 'Z') {
+ delta = 0;
+ } else {
+ boolean negative = c == '-';
+ int deltaHours = parseDigitsChecked(literal, index, 2);
+ index += 2;
+ if (index == end) {
+ throw new UnexpectedEndOfStringException(literal);
+ }
+ if (literal.charAt(index) != ':') {
+ throw new UnexpectedCharacterException(literal, index);
+ }
+ index++;
+ int deltaMinutes = parseDigitsChecked(literal, index, 2);
+ index += 2;
+ delta = 60*deltaHours + deltaMinutes;
+ if (negative) {
+ delta = -delta;
+ }
+ }
+ timeZone = SimpleTimeZone.getInstance(delta);
+ }
+ if (index != end) {
+ throw new UnexpectedCharacterException(literal, index);
+ }
+ return createInstance(bc, aeon, year, month, day, hour, minute,
second, nanoSecond,
+ nanoSecondFraction, timeZone);
+ }
+
+ private static int countDigits(String literal, int index, String
stopChars, boolean allowEndOfString) throws ParseException {
+ final int len = literal.length();
+ int count = 0;
+ while (true) {
+ if (index == len) {
+ if (allowEndOfString) {
+ return count;
+ } else {
+ throw new UnexpectedEndOfStringException(literal);
+ }
+ }
+ char c = literal.charAt(index);
+ if ('0' <= c && c <= '9') {
+ index++;
+ count++;
+ } else if (stopChars.indexOf(c) != -1) {
+ return count;
+ } else {
+ throw new UnexpectedCharacterException(literal, index);
+ }
+ }
+ }
+
+ private static int parseDigitsUnchecked(String literal, int index, int
count) {
+ int value = 0;
+ for (; count > 0; count--) {
+ value = 10*value + literal.charAt(index++) - '0';
+ }
+ return value;
+ }
+
+ private static int parseDigitsChecked(String literal, int index, int
count) throws ParseException {
+ final int len = literal.length();
+ int value = 0;
+ for (; count > 0; count--) {
+ if (index == len) {
+ throw new UnexpectedEndOfStringException(literal);
+ }
+ char c = literal.charAt(index);
+ if ('0' <= c && c <= '9') {
+ value = 10*value + c - '0';
+ } else {
+ throw new UnexpectedCharacterException(literal, index);
+ }
+ index++;
+ }
+ return value;
+ }
+
+ public final String format(T value) {
+ return value.toString();
+ }
+}
Propchange:
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/TemporalType.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/Util.java
URL:
http://svn.apache.org/viewvc/webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/Util.java?rev=1714491&view=auto
==============================================================================
---
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/Util.java
(added)
+++
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/Util.java
Sun Nov 15 19:30:57 2015
@@ -0,0 +1,27 @@
+/*
+ * 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.axiom.datatype.xsd;
+
+final class Util {
+ private Util() {}
+
+ static boolean isWhitespace(char c) {
+ return c == ' ' || c == '\r' || c == '\n' || c == '\t';
+ }
+}
Propchange:
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/Util.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDate.java
URL:
http://svn.apache.org/viewvc/webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDate.java?rev=1714491&view=auto
==============================================================================
---
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDate.java
(added)
+++
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDate.java
Sun Nov 15 19:30:57 2015
@@ -0,0 +1,23 @@
+/*
+ * 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.axiom.datatype.xsd;
+
+public interface XSDate extends Temporal {
+ XSDateTime getDayStart();
+}
Propchange:
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDate.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDateImpl.java
URL:
http://svn.apache.org/viewvc/webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDateImpl.java?rev=1714491&view=auto
==============================================================================
---
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDateImpl.java
(added)
+++
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDateImpl.java
Sun Nov 15 19:30:57 2015
@@ -0,0 +1,106 @@
+/*
+ * 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.axiom.datatype.xsd;
+
+final class XSDateImpl extends TemporalImpl implements XSDate {
+ private final boolean bc;
+ private final String aeon;
+ private final int year;
+ private final int month;
+ private final int day;
+ private final SimpleTimeZone timeZone;
+
+ XSDateImpl(boolean bc, String aeon, int year, int month, int day,
SimpleTimeZone timeZone) {
+ this.bc = bc;
+ this.aeon = aeon;
+ this.year = year;
+ this.month = month;
+ this.day = day;
+ this.timeZone = timeZone;
+ }
+
+ @Override
+ boolean hasDatePart() {
+ return true;
+ }
+
+ @Override
+ boolean hasTimePart() {
+ return false;
+ }
+
+ @Override
+ boolean isBC() {
+ return bc;
+ }
+
+ @Override
+ String getAeon() {
+ return aeon;
+ }
+
+ @Override
+ int getYear() {
+ return year;
+ }
+
+ @Override
+ int getMonth() {
+ return month;
+ }
+
+ @Override
+ int getDay() {
+ return day;
+ }
+
+ @Override
+ int getHour() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ int getMinute() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ int getSecond() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ int getNanoSecond() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ String getNanoSecondFraction() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ SimpleTimeZone getTimeZone() {
+ return timeZone;
+ }
+
+ public XSDateTime getDayStart() {
+ return new XSDateTimeImpl(bc, aeon, year, month, day, 0, 0, 0, 0,
null, timeZone);
+ }
+}
Propchange:
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDateImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDateTime.java
URL:
http://svn.apache.org/viewvc/webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDateTime.java?rev=1714491&view=auto
==============================================================================
---
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDateTime.java
(added)
+++
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDateTime.java
Sun Nov 15 19:30:57 2015
@@ -0,0 +1,38 @@
+/*
+ * 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.axiom.datatype.xsd;
+
+import java.util.Date;
+import java.util.TimeZone;
+
+public interface XSDateTime extends Temporal {
+ XSDate getDate();
+ XSTime getTime();
+
+ /**
+ * Convert this date/time to a {@link Date} object.
+ *
+ * @param defaultTimeZone
+ * the time zone to use if this date/time has no time zone; may
be <code>null</code>
+ * @return the {@link Date} object
+ * @throws NoTimeZoneException
+ * if this date/time doesn't have a time zone and no default
time zone was specified
+ */
+ Date getDate(TimeZone defaultTimeZone);
+}
Propchange:
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDateTime.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDateTimeImpl.java
URL:
http://svn.apache.org/viewvc/webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDateTimeImpl.java?rev=1714491&view=auto
==============================================================================
---
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDateTimeImpl.java
(added)
+++
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDateTimeImpl.java
Sun Nov 15 19:30:57 2015
@@ -0,0 +1,129 @@
+/*
+ * 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.axiom.datatype.xsd;
+
+import java.util.Date;
+import java.util.TimeZone;
+
+final class XSDateTimeImpl extends TemporalImpl implements XSDateTime {
+ private final boolean bc;
+ private final String aeon;
+ private final int year;
+ private final int month;
+ private final int day;
+ private final int hour;
+ private final int minute;
+ private final int second;
+ private final int nanoSecond;
+ private final String nanoSecondFraction;
+ private final SimpleTimeZone timeZone;
+
+ XSDateTimeImpl(boolean bc, String aeon, int year, int month, int day, int
hour, int minute,
+ int second, int nanoSecond, String nanoSecondFraction,
SimpleTimeZone timeZone) {
+ this.bc = bc;
+ this.aeon = aeon;
+ this.year = year;
+ this.month = month;
+ this.day = day;
+ this.hour = hour;
+ this.minute = minute;
+ this.second = second;
+ this.nanoSecond = nanoSecond;
+ this.nanoSecondFraction = nanoSecondFraction;
+ this.timeZone = timeZone;
+ }
+
+ @Override
+ boolean hasDatePart() {
+ return true;
+ }
+
+ @Override
+ boolean hasTimePart() {
+ return true;
+ }
+
+ @Override
+ boolean isBC() {
+ return bc;
+ }
+
+ @Override
+ String getAeon() {
+ return aeon;
+ }
+
+ @Override
+ int getYear() {
+ return year;
+ }
+
+ @Override
+ int getMonth() {
+ return month;
+ }
+
+ @Override
+ int getDay() {
+ return day;
+ }
+
+ @Override
+ int getHour() {
+ return hour;
+ }
+
+ @Override
+ int getMinute() {
+ return minute;
+ }
+
+ @Override
+ int getSecond() {
+ return second;
+ }
+
+ @Override
+ int getNanoSecond() {
+ return nanoSecond;
+ }
+
+ @Override
+ String getNanoSecondFraction() {
+ return nanoSecondFraction;
+ }
+
+ @Override
+ SimpleTimeZone getTimeZone() {
+ return timeZone;
+ }
+
+ public XSDate getDate() {
+ return new XSDateImpl(bc, aeon, year, month, day, timeZone);
+ }
+
+ public XSTime getTime() {
+ return new XSTimeImpl(hour, minute, second, nanoSecond,
nanoSecondFraction, timeZone);
+ }
+
+ public Date getDate(TimeZone defaultTimeZone) {
+ // TODO: fast path for dates in the 20th and 21st century
+ return getCalendar(defaultTimeZone).getTime();
+ }
+}
Propchange:
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDateTimeImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDateTimeType.java
URL:
http://svn.apache.org/viewvc/webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDateTimeType.java?rev=1714491&view=auto
==============================================================================
---
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDateTimeType.java
(added)
+++
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDateTimeType.java
Sun Nov 15 19:30:57 2015
@@ -0,0 +1,25 @@
+/*
+ * 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.axiom.datatype.xsd;
+
+import org.apache.axiom.datatype.InvariantType;
+
+public interface XSDateTimeType extends InvariantType<XSDateTime> {
+ XSDateTimeType INSTANCE = new XSDateTimeTypeImpl();
+}
Propchange:
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDateTimeType.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDateTimeTypeImpl.java
URL:
http://svn.apache.org/viewvc/webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDateTimeTypeImpl.java?rev=1714491&view=auto
==============================================================================
---
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDateTimeTypeImpl.java
(added)
+++
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDateTimeTypeImpl.java
Sun Nov 15 19:30:57 2015
@@ -0,0 +1,39 @@
+/*
+ * 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.axiom.datatype.xsd;
+
+final class XSDateTimeTypeImpl extends TemporalType<XSDateTime> implements
XSDateTimeType {
+ @Override
+ boolean hasDatePart() {
+ return true;
+ }
+
+ @Override
+ boolean hasTimePart() {
+ return true;
+ }
+
+ @Override
+ XSDateTime createInstance(boolean bc, String aeon, int year, int month,
int day, int hour,
+ int minute, int second, int nanoSecond, String nanoSecondFraction,
+ SimpleTimeZone timeZone) {
+ return new XSDateTimeImpl(bc, aeon, year, month, day, hour, minute,
second, nanoSecond,
+ nanoSecondFraction, timeZone);
+ }
+}
Propchange:
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDateTimeTypeImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDateType.java
URL:
http://svn.apache.org/viewvc/webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDateType.java?rev=1714491&view=auto
==============================================================================
---
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDateType.java
(added)
+++
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDateType.java
Sun Nov 15 19:30:57 2015
@@ -0,0 +1,25 @@
+/*
+ * 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.axiom.datatype.xsd;
+
+import org.apache.axiom.datatype.InvariantType;
+
+public interface XSDateType extends InvariantType<XSDate> {
+
+}
Propchange:
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDateType.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDateTypeImpl.java
URL:
http://svn.apache.org/viewvc/webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDateTypeImpl.java?rev=1714491&view=auto
==============================================================================
---
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDateTypeImpl.java
(added)
+++
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDateTypeImpl.java
Sun Nov 15 19:30:57 2015
@@ -0,0 +1,38 @@
+/*
+ * 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.axiom.datatype.xsd;
+
+final class XSDateTypeImpl extends TemporalType<XSDate> implements XSDateType {
+ @Override
+ boolean hasDatePart() {
+ return true;
+ }
+
+ @Override
+ boolean hasTimePart() {
+ return false;
+ }
+
+ @Override
+ XSDate createInstance(boolean bc, String aeon, int year, int month, int
day, int hour,
+ int minute, int second, int nanoSecond, String nanoSecondFraction,
+ SimpleTimeZone timeZone) {
+ return new XSDateImpl(bc, aeon, year, month, day, timeZone);
+ }
+}
Propchange:
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDateTypeImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSQNameType.java
URL:
http://svn.apache.org/viewvc/webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSQNameType.java?rev=1714491&view=auto
==============================================================================
---
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSQNameType.java
(added)
+++
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSQNameType.java
Sun Nov 15 19:30:57 2015
@@ -0,0 +1,27 @@
+/*
+ * 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.axiom.datatype.xsd;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.datatype.Type;
+
+public interface XSQNameType extends Type<QName> {
+ XSQNameType INSTANCE = new XSQNameTypeImpl();
+}
Propchange:
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSQNameType.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSQNameTypeImpl.java
URL:
http://svn.apache.org/viewvc/webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSQNameTypeImpl.java?rev=1714491&view=auto
==============================================================================
---
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSQNameTypeImpl.java
(added)
+++
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSQNameTypeImpl.java
Sun Nov 15 19:30:57 2015
@@ -0,0 +1,97 @@
+/*
+ * 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.axiom.datatype.xsd;
+
+import java.text.ParseException;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.datatype.ContextAccessor;
+import org.apache.axiom.datatype.UnexpectedCharacterException;
+import org.apache.axiom.datatype.UnexpectedEndOfStringException;
+
+final class XSQNameTypeImpl implements XSQNameType {
+ public <S,O> QName parse(String literal, ContextAccessor<S,O>
contextAccessor, S contextObject, O options)
+ throws ParseException {
+ int len = literal.length();
+ int start = -1;
+ int end = -1;
+ int colonIndex = -1;
+ for (int index = 0; index<len; index++) {
+ char c = literal.charAt(index);
+ if (Util.isWhitespace(c)) {
+ if (start != -1 && end == -1) {
+ end = index;
+ }
+ } else {
+ if (start == -1) {
+ start = index;
+ } else if (end != -1) {
+ throw new UnexpectedCharacterException(literal, index);
+ }
+ // TODO: we should check that the literal is a valid NCName
+ if (literal.charAt(index) == ':') {
+ if (colonIndex != -1) {
+ throw new UnexpectedCharacterException(literal, index);
+ }
+ colonIndex = index;
+ }
+ }
+ }
+ if (start == -1) {
+ throw new UnexpectedEndOfStringException(literal);
+ }
+ if (end == -1) {
+ end = len;
+ }
+ String prefix;
+ String localPart;
+ if (colonIndex == -1) {
+ prefix = "";
+ localPart = literal.toString();
+ } else {
+ prefix = literal.substring(start, colonIndex);
+ localPart = literal.substring(colonIndex+1, end);
+ }
+ String namespaceURI =
contextAccessor.lookupNamespaceURI(contextObject, options, prefix);
+ if (namespaceURI == null) {
+ throw new ParseException("Unbound namespace prefix \"" + prefix +
"\"", 0);
+ }
+ return new QName(namespaceURI, localPart, prefix);
+ }
+
+ public <S,O> String format(QName value, ContextAccessor<S,O>
contextAccessor, S contextObject, O options) {
+ String prefix = value.getPrefix();
+ String namespaceURI = value.getNamespaceURI();
+ if
(!namespaceURI.equals(contextAccessor.lookupNamespaceURI(contextObject,
options, prefix))) {
+ String existingPrefix =
contextAccessor.lookupPrefix(contextObject, options, namespaceURI);
+ if (existingPrefix != null) {
+ prefix = existingPrefix;
+ } else {
+ // TODO
+ throw new RuntimeException();
+ }
+ }
+ if (prefix.length() == 0) {
+ return value.getLocalPart();
+ } else {
+ return prefix + ":" + value.getLocalPart();
+ }
+ }
+}
Propchange:
webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSQNameTypeImpl.java
------------------------------------------------------------------------------
svn:eol-style = native