You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by dk...@apache.org on 2019/10/31 14:49:00 UTC
[ws-axiom] 23/25: Simplify class hierarchy.
This is an automated email from the ASF dual-hosted git repository.
dkulp pushed a commit to branch datatypes
in repository https://gitbox.apache.org/repos/asf/ws-axiom.git
commit f4bf05788080d4a77f126599d1f52e0057d576ae
Author: Andreas Veithen <ve...@apache.org>
AuthorDate: Sun Dec 6 01:00:02 2015 +0000
Simplify class hierarchy.
---
.../axiom/soap/impl/intf/SOAP11BooleanType.java | 4 +-
.../axiom/datatype/AbstractInvariantType.java | 31 -----
.../org/apache/axiom/datatype/InvariantType.java | 14 ++-
.../org/apache/axiom/datatype/xsd/Temporal.java | 48 +++++++-
.../apache/axiom/datatype/xsd/TemporalImpl.java | 68 -----------
.../apache/axiom/datatype/xsd/TemporalType.java | 4 +-
.../apache/axiom/datatype/xsd/XSBooleanType.java | 45 ++++++-
.../axiom/datatype/xsd/XSBooleanTypeImpl.java | 62 ----------
.../java/org/apache/axiom/datatype/xsd/XSDate.java | 87 +++++++++++++-
.../org/apache/axiom/datatype/xsd/XSDateImpl.java | 106 -----------------
.../org/apache/axiom/datatype/xsd/XSDateTime.java | 108 ++++++++++++++++-
.../apache/axiom/datatype/xsd/XSDateTimeImpl.java | 129 ---------------------
.../apache/axiom/datatype/xsd/XSDateTimeType.java | 24 +++-
.../axiom/datatype/xsd/XSDateTimeTypeImpl.java | 39 -------
.../org/apache/axiom/datatype/xsd/XSDateType.java | 21 +++-
.../apache/axiom/datatype/xsd/XSDateTypeImpl.java | 38 ------
.../org/apache/axiom/datatype/xsd/XSQNameType.java | 75 +++++++++++-
.../apache/axiom/datatype/xsd/XSQNameTypeImpl.java | 93 ---------------
.../apache/axiom/datatype/xsd/XSStringType.java | 16 ++-
.../axiom/datatype/xsd/XSStringTypeImpl.java | 33 ------
.../java/org/apache/axiom/datatype/xsd/XSTime.java | 83 ++++++++++++-
.../org/apache/axiom/datatype/xsd/XSTimeImpl.java | 103 ----------------
.../org/apache/axiom/datatype/xsd/XSTimeType.java | 21 +++-
.../apache/axiom/datatype/xsd/XSTimeTypeImpl.java | 38 ------
24 files changed, 519 insertions(+), 771 deletions(-)
diff --git a/aspects/om-aspects/src/main/java/org/apache/axiom/soap/impl/intf/SOAP11BooleanType.java b/aspects/om-aspects/src/main/java/org/apache/axiom/soap/impl/intf/SOAP11BooleanType.java
index c2b113f..8b87134 100644
--- a/aspects/om-aspects/src/main/java/org/apache/axiom/soap/impl/intf/SOAP11BooleanType.java
+++ b/aspects/om-aspects/src/main/java/org/apache/axiom/soap/impl/intf/SOAP11BooleanType.java
@@ -20,10 +20,10 @@ package org.apache.axiom.soap.impl.intf;
import java.text.ParseException;
-import org.apache.axiom.datatype.AbstractInvariantType;
+import org.apache.axiom.datatype.InvariantType;
import org.apache.axiom.datatype.TypeHelper;
-final class SOAP11BooleanType extends AbstractInvariantType<Boolean> {
+final class SOAP11BooleanType extends InvariantType<Boolean> {
static final SOAP11BooleanType INSTANCE = new SOAP11BooleanType();
private SOAP11BooleanType() {}
diff --git a/datatypes/src/main/java/org/apache/axiom/datatype/AbstractInvariantType.java b/datatypes/src/main/java/org/apache/axiom/datatype/AbstractInvariantType.java
deleted file mode 100644
index 30a4a97..0000000
--- a/datatypes/src/main/java/org/apache/axiom/datatype/AbstractInvariantType.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.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);
- }
-}
diff --git a/datatypes/src/main/java/org/apache/axiom/datatype/InvariantType.java b/datatypes/src/main/java/org/apache/axiom/datatype/InvariantType.java
index 88faefe..62414d3 100644
--- a/datatypes/src/main/java/org/apache/axiom/datatype/InvariantType.java
+++ b/datatypes/src/main/java/org/apache/axiom/datatype/InvariantType.java
@@ -20,7 +20,15 @@ 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);
+public abstract class InvariantType<T> implements Type<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);
+ }
+
+ public abstract T parse(String literal) throws ParseException;
+ public abstract String format(T value);
}
diff --git a/datatypes/src/main/java/org/apache/axiom/datatype/xsd/Temporal.java b/datatypes/src/main/java/org/apache/axiom/datatype/xsd/Temporal.java
index c971da9..ce6850d 100644
--- a/datatypes/src/main/java/org/apache/axiom/datatype/xsd/Temporal.java
+++ b/datatypes/src/main/java/org/apache/axiom/datatype/xsd/Temporal.java
@@ -22,10 +22,24 @@ import java.util.GregorianCalendar;
import java.util.TimeZone;
/**
- * A temporal value. This is the base interface for {@link XSDate}, {@link XSTime} and
+ * A temporal value. This is the base class for {@link XSDate}, {@link XSTime} and
* {@link XSDateTime}.
*/
-public interface Temporal {
+public abstract class 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();
+
/**
* Convert this value to a calendar. For {@link XSDate} and {@link XSTime}, only the
* corresponding fields are filled in and all other fields are left unspecified.
@@ -38,12 +52,38 @@ public interface Temporal {
* if this temporal object doesn't have a time zone and no default time zone was
* specified
*/
- GregorianCalendar getCalendar(TimeZone defaultTimeZone);
+ 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;
+ }
/**
* Determine if this temporal value has a time zone.
*
* @return <code>true</code> if the object has a time zone, <code>false</code> otherwise
*/
- boolean hasTimeZone();
+ public final boolean hasTimeZone() {
+ return getTimeZone() != null;
+ }
}
diff --git a/datatypes/src/main/java/org/apache/axiom/datatype/xsd/TemporalImpl.java b/datatypes/src/main/java/org/apache/axiom/datatype/xsd/TemporalImpl.java
deleted file mode 100644
index 5e381c2..0000000
--- a/datatypes/src/main/java/org/apache/axiom/datatype/xsd/TemporalImpl.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.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;
- }
-}
diff --git a/datatypes/src/main/java/org/apache/axiom/datatype/xsd/TemporalType.java b/datatypes/src/main/java/org/apache/axiom/datatype/xsd/TemporalType.java
index cbb25ae..5ac445b 100644
--- a/datatypes/src/main/java/org/apache/axiom/datatype/xsd/TemporalType.java
+++ b/datatypes/src/main/java/org/apache/axiom/datatype/xsd/TemporalType.java
@@ -20,12 +20,12 @@ package org.apache.axiom.datatype.xsd;
import java.text.ParseException;
-import org.apache.axiom.datatype.AbstractInvariantType;
+import org.apache.axiom.datatype.InvariantType;
import org.apache.axiom.datatype.TypeHelper;
import org.apache.axiom.datatype.UnexpectedCharacterException;
import org.apache.axiom.datatype.UnexpectedEndOfStringException;
-abstract class TemporalType<T> extends AbstractInvariantType<T> {
+public abstract class TemporalType<T> extends InvariantType<T> {
abstract boolean hasDatePart();
abstract boolean hasTimePart();
abstract T createInstance(boolean bc, String aeon, int year, int month, int day, int hour,
diff --git a/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSBooleanType.java b/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSBooleanType.java
index df66daf..3e945d4 100644
--- a/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSBooleanType.java
+++ b/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSBooleanType.java
@@ -18,8 +18,49 @@
*/
package org.apache.axiom.datatype.xsd;
+import java.text.ParseException;
+
import org.apache.axiom.datatype.InvariantType;
+import org.apache.axiom.datatype.TypeHelper;
+
+public final class XSBooleanType extends InvariantType<Boolean> {
+ public static final XSBooleanType INSTANCE = new XSBooleanType();
+
+ private XSBooleanType() {}
+
+ private static boolean equals(String s1, int start, String s2) {
+ for (int i=0, len=s2.length(); i<len; i++) {
+ if (s1.charAt(start+i) != s2.charAt(i)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public Boolean parse(String literal) throws ParseException {
+ int start = TypeHelper.getStartIndex(literal);
+ int end = TypeHelper.getEndIndex(literal);
+ switch (end-start) {
+ case 1:
+ switch (literal.charAt(start)) {
+ case '0': return Boolean.FALSE;
+ case '1': return Boolean.TRUE;
+ }
+ break;
+ case 4:
+ if (equals(literal, start, "true")) {
+ return Boolean.TRUE;
+ }
+ break;
+ case 5:
+ if (equals(literal, start, "false")) {
+ return Boolean.FALSE;
+ }
+ }
+ throw new ParseException("Unexpected boolean literal", start);
+ }
-public interface XSBooleanType extends InvariantType<Boolean> {
- XSBooleanType INSTANCE = new XSBooleanTypeImpl();
+ public String format(Boolean value) {
+ return value.toString();
+ }
}
diff --git a/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSBooleanTypeImpl.java b/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSBooleanTypeImpl.java
deleted file mode 100644
index 8912274..0000000
--- a/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSBooleanTypeImpl.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.axiom.datatype.xsd;
-
-import java.text.ParseException;
-
-import org.apache.axiom.datatype.AbstractInvariantType;
-import org.apache.axiom.datatype.TypeHelper;
-
-final class XSBooleanTypeImpl extends AbstractInvariantType<Boolean> implements XSBooleanType {
- private static boolean equals(String s1, int start, String s2) {
- for (int i=0, len=s2.length(); i<len; i++) {
- if (s1.charAt(start+i) != s2.charAt(i)) {
- return false;
- }
- }
- return true;
- }
-
- public Boolean parse(String literal) throws ParseException {
- int start = TypeHelper.getStartIndex(literal);
- int end = TypeHelper.getEndIndex(literal);
- switch (end-start) {
- case 1:
- switch (literal.charAt(start)) {
- case '0': return Boolean.FALSE;
- case '1': return Boolean.TRUE;
- }
- break;
- case 4:
- if (equals(literal, start, "true")) {
- return Boolean.TRUE;
- }
- break;
- case 5:
- if (equals(literal, start, "false")) {
- return Boolean.FALSE;
- }
- }
- throw new ParseException("Unexpected boolean literal", start);
- }
-
- public String format(Boolean value) {
- return value.toString();
- }
-}
diff --git a/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDate.java b/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDate.java
index 45bef69..dce1fc9 100644
--- a/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDate.java
+++ b/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDate.java
@@ -18,6 +18,89 @@
*/
package org.apache.axiom.datatype.xsd;
-public interface XSDate extends Temporal {
- XSDateTime getDayStart();
+public final class XSDate extends Temporal {
+ private final boolean bc;
+ private final String aeon;
+ private final int year;
+ private final int month;
+ private final int day;
+ private final SimpleTimeZone timeZone;
+
+ XSDate(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 XSDateTime(bc, aeon, year, month, day, 0, 0, 0, 0, null, timeZone);
+ }
}
diff --git a/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDateImpl.java b/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDateImpl.java
deleted file mode 100644
index 4eb748a..0000000
--- a/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDateImpl.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.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);
- }
-}
diff --git a/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDateTime.java b/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDateTime.java
index dbf45db..3986a75 100644
--- a/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDateTime.java
+++ b/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDateTime.java
@@ -21,10 +21,107 @@ package org.apache.axiom.datatype.xsd;
import java.util.Date;
import java.util.TimeZone;
-public interface XSDateTime extends Temporal {
- XSDate getDate();
- XSTime getTime();
+public final class XSDateTime extends Temporal {
+ 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;
+ XSDateTime(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 XSDate(bc, aeon, year, month, day, timeZone);
+ }
+
+ public XSTime getTime() {
+ return new XSTime(hour, minute, second, nanoSecond, nanoSecondFraction, timeZone);
+ }
+
/**
* Convert this date/time to a {@link Date} object.
*
@@ -34,5 +131,8 @@ public interface XSDateTime extends Temporal {
* @throws NoTimeZoneException
* if this date/time doesn't have a time zone and no default time zone was specified
*/
- Date getDate(TimeZone defaultTimeZone);
+ public Date getDate(TimeZone defaultTimeZone) {
+ // TODO: fast path for dates in the 20th and 21st century
+ return getCalendar(defaultTimeZone).getTime();
+ }
}
diff --git a/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDateTimeImpl.java b/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDateTimeImpl.java
deleted file mode 100644
index 6d33144..0000000
--- a/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDateTimeImpl.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.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();
- }
-}
diff --git a/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDateTimeType.java b/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDateTimeType.java
index 5b3cbb4..63c044b 100644
--- a/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDateTimeType.java
+++ b/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDateTimeType.java
@@ -18,8 +18,26 @@
*/
package org.apache.axiom.datatype.xsd;
-import org.apache.axiom.datatype.InvariantType;
+public final class XSDateTimeType extends TemporalType<XSDateTime> {
+ public static final XSDateTimeType INSTANCE = new XSDateTimeType();
-public interface XSDateTimeType extends InvariantType<XSDateTime> {
- XSDateTimeType INSTANCE = new XSDateTimeTypeImpl();
+ private 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 XSDateTime(bc, aeon, year, month, day, hour, minute, second, nanoSecond,
+ nanoSecondFraction, timeZone);
+ }
}
diff --git a/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDateTimeTypeImpl.java b/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDateTimeTypeImpl.java
deleted file mode 100644
index 8d19cda..0000000
--- a/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDateTimeTypeImpl.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.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);
- }
-}
diff --git a/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDateType.java b/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDateType.java
index e982540..39412b0 100644
--- a/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDateType.java
+++ b/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDateType.java
@@ -18,8 +18,25 @@
*/
package org.apache.axiom.datatype.xsd;
-import org.apache.axiom.datatype.InvariantType;
+public final class XSDateType extends TemporalType<XSDate> {
+ public static final XSDateType INSTANCE = new XSDateType();
+
+ private XSDateType() {}
+
+ @Override
+ boolean hasDatePart() {
+ return true;
+ }
-public interface XSDateType extends InvariantType<XSDate> {
+ @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 XSDate(bc, aeon, year, month, day, timeZone);
+ }
}
diff --git a/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDateTypeImpl.java b/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDateTypeImpl.java
deleted file mode 100644
index 901a798..0000000
--- a/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSDateTypeImpl.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.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);
- }
-}
diff --git a/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSQNameType.java b/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSQNameType.java
index c8497ac..e50a918 100644
--- a/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSQNameType.java
+++ b/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSQNameType.java
@@ -18,10 +18,81 @@
*/
package org.apache.axiom.datatype.xsd;
+import java.text.ParseException;
+
+import javax.xml.XMLConstants;
import javax.xml.namespace.QName;
+import org.apache.axiom.datatype.ContextAccessor;
import org.apache.axiom.datatype.Type;
+import org.apache.axiom.datatype.TypeHelper;
+import org.apache.axiom.datatype.UnexpectedCharacterException;
+import org.apache.axiom.util.xml.NSUtils;
+
+public final class XSQNameType implements Type<QName> {
+ public static final XSQNameType INSTANCE = new XSQNameType();
+
+ private XSQNameType() {}
+
+ public <S,O> QName parse(String literal, ContextAccessor<S,O> contextAccessor, S contextObject, O options)
+ throws ParseException {
+ final int start = TypeHelper.getStartIndex(literal);
+ final int end = TypeHelper.getEndIndex(literal);
+ int colonIndex = -1;
+ for (int index = start; index<end; 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;
+ }
+ }
+ 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;
+ if (prefix.equals(XMLConstants.XML_NS_PREFIX)) {
+ namespaceURI = XMLConstants.XML_NS_URI;
+ } else if (prefix.equals(XMLConstants.XMLNS_ATTRIBUTE)) {
+ namespaceURI = XMLConstants.XMLNS_ATTRIBUTE_NS_URI;
+ } else {
+ namespaceURI = contextAccessor.lookupNamespaceURI(contextObject, options, prefix);
+ if (namespaceURI == null) {
+ throw new ParseException("Unbound namespace prefix \"" + prefix + "\"", 0);
+ }
+ }
+ return new QName(namespaceURI, localPart, prefix);
+ }
-public interface XSQNameType extends Type<QName> {
- XSQNameType INSTANCE = new XSQNameTypeImpl();
+ 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))) {
+ if (namespaceURI.length() == 0) {
+ contextAccessor.declareNamespace(contextObject, options, "", "");
+ } else {
+ if (prefix.length() == 0) {
+ prefix = contextAccessor.lookupPrefix(contextObject, options, namespaceURI);
+ if (prefix == null) {
+ prefix = NSUtils.generatePrefix(namespaceURI);
+ contextAccessor.declareNamespace(contextObject, options, prefix, namespaceURI);;
+ }
+ } else {
+ contextAccessor.declareNamespace(contextObject, options, prefix, namespaceURI);;
+ }
+ }
+ }
+ if (prefix.length() == 0) {
+ return value.getLocalPart();
+ } else {
+ return prefix + ":" + value.getLocalPart();
+ }
+ }
}
diff --git a/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSQNameTypeImpl.java b/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSQNameTypeImpl.java
deleted file mode 100644
index e896f97..0000000
--- a/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSQNameTypeImpl.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.axiom.datatype.xsd;
-
-import java.text.ParseException;
-
-import javax.xml.XMLConstants;
-import javax.xml.namespace.QName;
-
-import org.apache.axiom.datatype.ContextAccessor;
-import org.apache.axiom.datatype.TypeHelper;
-import org.apache.axiom.datatype.UnexpectedCharacterException;
-import org.apache.axiom.util.xml.NSUtils;
-
-final class XSQNameTypeImpl implements XSQNameType {
- public <S,O> QName parse(String literal, ContextAccessor<S,O> contextAccessor, S contextObject, O options)
- throws ParseException {
- final int start = TypeHelper.getStartIndex(literal);
- final int end = TypeHelper.getEndIndex(literal);
- int colonIndex = -1;
- for (int index = start; index<end; 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;
- }
- }
- 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;
- if (prefix.equals(XMLConstants.XML_NS_PREFIX)) {
- namespaceURI = XMLConstants.XML_NS_URI;
- } else if (prefix.equals(XMLConstants.XMLNS_ATTRIBUTE)) {
- namespaceURI = XMLConstants.XMLNS_ATTRIBUTE_NS_URI;
- } else {
- 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))) {
- if (namespaceURI.length() == 0) {
- contextAccessor.declareNamespace(contextObject, options, "", "");
- } else {
- if (prefix.length() == 0) {
- prefix = contextAccessor.lookupPrefix(contextObject, options, namespaceURI);
- if (prefix == null) {
- prefix = NSUtils.generatePrefix(namespaceURI);
- contextAccessor.declareNamespace(contextObject, options, prefix, namespaceURI);;
- }
- } else {
- contextAccessor.declareNamespace(contextObject, options, prefix, namespaceURI);;
- }
- }
- }
- if (prefix.length() == 0) {
- return value.getLocalPart();
- } else {
- return prefix + ":" + value.getLocalPart();
- }
- }
-}
diff --git a/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSStringType.java b/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSStringType.java
index 068656e..1ec759d 100644
--- a/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSStringType.java
+++ b/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSStringType.java
@@ -18,8 +18,20 @@
*/
package org.apache.axiom.datatype.xsd;
+import java.text.ParseException;
+
import org.apache.axiom.datatype.InvariantType;
-public interface XSStringType extends InvariantType<String> {
- XSStringType INSTANCE = new XSStringTypeImpl();
+public final class XSStringType extends InvariantType<String> {
+ public static final XSStringType INSTANCE = new XSStringType();
+
+ private XSStringType() {}
+
+ public String parse(String literal) throws ParseException {
+ return literal;
+ }
+
+ public String format(String value) {
+ return value;
+ }
}
diff --git a/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSStringTypeImpl.java b/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSStringTypeImpl.java
deleted file mode 100644
index 7c08cc6..0000000
--- a/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSStringTypeImpl.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.axiom.datatype.xsd;
-
-import java.text.ParseException;
-
-import org.apache.axiom.datatype.AbstractInvariantType;
-
-final class XSStringTypeImpl extends AbstractInvariantType<String> implements XSStringType {
- public String parse(String literal) throws ParseException {
- return literal;
- }
-
- public String format(String value) {
- return value;
- }
-}
diff --git a/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSTime.java b/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSTime.java
index dda1343..76cf708 100644
--- a/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSTime.java
+++ b/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSTime.java
@@ -18,5 +18,86 @@
*/
package org.apache.axiom.datatype.xsd;
-public interface XSTime extends Temporal {
+public final class XSTime extends Temporal {
+ private final int hour;
+ private final int minute;
+ private final int second;
+ private final int nanoSecond;
+ private final String nanoSecondFraction;
+ private final SimpleTimeZone timeZone;
+
+ XSTime(int hour, int minute, int second, int nanoSecond, String nanoSecondFraction,
+ SimpleTimeZone timeZone) {
+ this.hour = hour;
+ this.minute = minute;
+ this.second = second;
+ this.nanoSecond = nanoSecond;
+ this.nanoSecondFraction = nanoSecondFraction;
+ this.timeZone = timeZone;
+ }
+
+ @Override
+ boolean hasDatePart() {
+ return false;
+ }
+
+ @Override
+ boolean hasTimePart() {
+ return true;
+ }
+
+ @Override
+ boolean isBC() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ String getAeon() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ int getYear() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ int getMonth() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ int getDay() {
+ throw new UnsupportedOperationException();
+ }
+
+ @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;
+ }
}
diff --git a/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSTimeImpl.java b/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSTimeImpl.java
deleted file mode 100644
index 5b2e347..0000000
--- a/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSTimeImpl.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.axiom.datatype.xsd;
-
-final class XSTimeImpl extends TemporalImpl implements XSTime {
- private final int hour;
- private final int minute;
- private final int second;
- private final int nanoSecond;
- private final String nanoSecondFraction;
- private final SimpleTimeZone timeZone;
-
- XSTimeImpl(int hour, int minute, int second, int nanoSecond, String nanoSecondFraction,
- SimpleTimeZone timeZone) {
- this.hour = hour;
- this.minute = minute;
- this.second = second;
- this.nanoSecond = nanoSecond;
- this.nanoSecondFraction = nanoSecondFraction;
- this.timeZone = timeZone;
- }
-
- @Override
- boolean hasDatePart() {
- return false;
- }
-
- @Override
- boolean hasTimePart() {
- return true;
- }
-
- @Override
- boolean isBC() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- String getAeon() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- int getYear() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- int getMonth() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- int getDay() {
- throw new UnsupportedOperationException();
- }
-
- @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;
- }
-}
diff --git a/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSTimeType.java b/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSTimeType.java
index 1d9c8ac..86ad9ca 100644
--- a/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSTimeType.java
+++ b/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSTimeType.java
@@ -18,8 +18,25 @@
*/
package org.apache.axiom.datatype.xsd;
-import org.apache.axiom.datatype.InvariantType;
+public final class XSTimeType extends TemporalType<XSTime> {
+ public static final XSTimeType INSTANCE = new XSTimeType();
+
+ private XSTimeType() {}
+
+ @Override
+ boolean hasDatePart() {
+ return false;
+ }
-public interface XSTimeType extends InvariantType<XSTime> {
+ @Override
+ boolean hasTimePart() {
+ return true;
+ }
+ @Override
+ XSTime 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 XSTime(hour, minute, second, nanoSecond, nanoSecondFraction, timeZone);
+ }
}
diff --git a/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSTimeTypeImpl.java b/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSTimeTypeImpl.java
deleted file mode 100644
index 039945d..0000000
--- a/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSTimeTypeImpl.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.axiom.datatype.xsd;
-
-final class XSTimeTypeImpl extends TemporalType<XSTime> implements XSTimeType {
- @Override
- boolean hasDatePart() {
- return false;
- }
-
- @Override
- boolean hasTimePart() {
- return true;
- }
-
- @Override
- XSTime 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 XSTimeImpl(hour, minute, second, nanoSecond, nanoSecondFraction, timeZone);
- }
-}