You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by rf...@apache.org on 2006/09/26 09:32:55 UTC
svn commit: r449937 - in
/incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding:
./ extension/
Author: rfeng
Date: Tue Sep 26 00:32:53 2006
New Revision: 449937
URL: http://svn.apache.org/viewvc?view=rev&rev=449937
Log:
Clean up some checkstyle complaints
Modified:
incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/DataBindingRegistry.java
incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/DataPipe.java
incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/Mediator.java
incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/PullTransformer.java
incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/PushTransformer.java
incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/TransformationContext.java
incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/Transformer.java
incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/TransformerRegistry.java
incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/DOMHelper.java
incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/SimpleTypeMapperExtension.java
incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/XSDDataTypeConverter.java
Modified: incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/DataBindingRegistry.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/DataBindingRegistry.java?view=diff&rev=449937&r1=449936&r2=449937
==============================================================================
--- incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/DataBindingRegistry.java (original)
+++ incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/DataBindingRegistry.java Tue Sep 26 00:32:53 2006
@@ -25,29 +25,40 @@
public interface DataBindingRegistry {
/**
* Register a data binding
+ *
* @param dataBinding
*/
- public void register(DataBinding dataBinding);
+ void register(DataBinding dataBinding);
/**
* Look up a data binding by id
- * @param id
- * @return
+ *
+ * @param id The name of the databinding
+ * @return The databinding
*/
- public DataBinding getDataBinding(String id);
+ DataBinding getDataBinding(String id);
/**
* Unregister a data binding
+ *
* @param id
- * @return
+ * @return The unregistered databinding
*/
- public DataBinding unregister(String id);
-
+ DataBinding unregister(String id);
+
/**
* Introspect the java class to figure out what DataType supports it
+ *
* @param javaType The java class or interface
- * @return
+ * @return A DataType representing the java type or null if no databinding recognizes the java type
+ */
+ DataType introspectType(Class<?> javaType);
+
+ /**
+ * Introspect the value to figure out the corresponding DataType
+ *
+ * @param value The object value
+ * @return A DataType representing the value or null if no databinding recognizes the value
*/
- public DataType introspectType(Class<?> javaType);
- public DataType introspectType(Object value);
+ DataType introspectType(Object value);
}
Modified: incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/DataPipe.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/DataPipe.java?view=diff&rev=449937&r1=449936&r2=449937
==============================================================================
--- incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/DataPipe.java (original)
+++ incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/DataPipe.java Tue Sep 26 00:32:53 2006
@@ -31,12 +31,12 @@
* receive data pushed by the source
* @return The sink to consume data
*/
- public S getSink();
+ S getSink();
/**
* Returns the data populated by the sink
* @return
*/
- public R getResult();
+ R getResult();
}
Modified: incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/Mediator.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/Mediator.java?view=diff&rev=449937&r1=449936&r2=449937
==============================================================================
--- incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/Mediator.java (original)
+++ incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/Mediator.java Tue Sep 26 00:32:53 2006
@@ -46,6 +46,11 @@
* @param sourceDataType Data type for the source data
* @param targetDataType Data type for the target data
*/
- void mediate(Object source, Object target, DataType sourceDataType, DataType targetDataType, Map<Class<?>, Object> context);
+ void mediate(
+ Object source,
+ Object target,
+ DataType sourceDataType,
+ DataType targetDataType,
+ Map<Class<?>, Object> context);
}
Modified: incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/PullTransformer.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/PullTransformer.java?view=diff&rev=449937&r1=449936&r2=449937
==============================================================================
--- incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/PullTransformer.java (original)
+++ incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/PullTransformer.java Tue Sep 26 00:32:53 2006
@@ -21,20 +21,16 @@
/**
* PullTransformer transforms data from one binding format to the other one which can be directly consumed
*
- * @param <S>
- * The source data type
- * @param <R>
- * the target data type
+ * @param <S> The source data type
+ * @param <R> the target data type
*/
public interface PullTransformer<S, R> extends Transformer {
/**
* Transform source data into the result type.
*
- * @param source
- * The source data
- * @param context
- * The context for the transformation
+ * @param source The source data
+ * @param context The context for the transformation
* @return The transformed result
*/
- public R transform(S source, TransformationContext context);
+ R transform(S source, TransformationContext context);
}
Modified: incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/PushTransformer.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/PushTransformer.java?view=diff&rev=449937&r1=449936&r2=449937
==============================================================================
--- incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/PushTransformer.java (original)
+++ incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/PushTransformer.java Tue Sep 26 00:32:53 2006
@@ -18,17 +18,17 @@
*/
package org.apache.tuscany.spi.databinding;
-
/**
* A transformer that pushes data from its source into the sink
+ *
* @param <S>
* @param <R>
*/
public interface PushTransformer<S, R> extends Transformer {
/**
- * @param source
- * @param sink
+ * @param source The source data
+ * @param sink The sink to receive the data
* @param context
*/
- public void transform(S source, R sink, TransformationContext context);
+ void transform(S source, R sink, TransformationContext context);
}
Modified: incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/TransformationContext.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/TransformationContext.java?view=diff&rev=449937&r1=449936&r2=449937
==============================================================================
--- incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/TransformationContext.java (original)
+++ incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/TransformationContext.java Tue Sep 26 00:32:53 2006
@@ -28,30 +28,45 @@
*/
public interface TransformationContext {
/**
+ * Get the source data type
+ *
* @return
*/
- public DataType getSourceDataType();
+ DataType getSourceDataType();
/**
+ * Get the target data type
+ *
* @return
*/
- public DataType getTargetDataType();
+ DataType getTargetDataType();
/**
+ * Set the source data type
+ *
* @param sourceDataType
*/
- public void setSourceDataType(DataType sourceDataType);
+ void setSourceDataType(DataType sourceDataType);
/**
+ * Set the target data type
+ *
* @param targetDataType
*/
- public void setTargetDataType(DataType targetDataType);
+ void setTargetDataType(DataType targetDataType);
/**
+ * Get the classloader
+ *
* @return
*/
- public ClassLoader getClassLoader();
-
- public Map<Class<?>, Object> getMetadata();
+ ClassLoader getClassLoader();
+
+ /**
+ * Get a map of metadata
+ *
+ * @return
+ */
+ Map<Class<?>, Object> getMetadata();
}
Modified: incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/Transformer.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/Transformer.java?view=diff&rev=449937&r1=449936&r2=449937
==============================================================================
--- incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/Transformer.java (original)
+++ incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/Transformer.java Tue Sep 26 00:32:53 2006
@@ -18,35 +18,32 @@
*/
package org.apache.tuscany.spi.databinding;
-
/**
- * A transformer provides the data transformation from source type to target type. The cost
- * of the transformation is modeled as weight.
+ * A transformer provides the data transformation from source type to target type. The cost of the transformation is
+ * modeled as weight.
*/
public interface Transformer {
- // FIXME: [rfeng] I'm not very sure if Class is a good id to represent the data type. Another option
- // is to use URI strings
/**
- * Get the source type that this transformer transforms data from. The type is used as the key when the
- * transformer is registered with TransformerRegistry.
- *
+ * Get the source type that this transformer transforms data from. The type is used as the key when the transformer
+ * is registered with TransformerRegistry.
+ *
* @return A key indentifying the source type
*/
- public String getSourceDataBinding();
+ String getSourceDataBinding();
/**
- * Get the target type that this transformer transforms data into. The type is used as the key when the
- * transformer is registered with TransformerRegistry.
+ * Get the target type that this transformer transforms data into. The type is used as the key when the transformer
+ * is registered with TransformerRegistry.
*
* @return A key indentifying the target type
*/
- public String getTargetDataBinding();
+ String getTargetDataBinding();
/**
- * Get the cost of the transformation. The weight can be used to choose the most efficient path if
- * there are more than one available from the source to the target.
+ * Get the cost of the transformation. The weight can be used to choose the most efficient path if there are more
+ * than one available from the source to the target.
*
* @return An integer representing the cost of the transformation
*/
- public int getWeight();
+ int getWeight();
}
Modified: incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/TransformerRegistry.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/TransformerRegistry.java?view=diff&rev=449937&r1=449936&r2=449937
==============================================================================
--- incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/TransformerRegistry.java (original)
+++ incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/TransformerRegistry.java Tue Sep 26 00:32:53 2006
@@ -32,13 +32,13 @@
* @param weight
* @param transformer
*/
- public void registerTransformer(String sourceDataBinding, String targetDataBinding, int weight, Transformer transformer);
+ void registerTransformer(String sourceDataBinding, String targetDataBinding, int weight, Transformer transformer);
/**
* Register a transformer
* @param transformer
*/
- public void registerTransformer(Transformer transformer);
+ void registerTransformer(Transformer transformer);
/**
* Unregister a transformer
@@ -46,7 +46,7 @@
* @param targetDataBinding
* @return
*/
- public boolean unregisterTransformer(String sourceDataBinding, String targetDataBinding);
+ boolean unregisterTransformer(String sourceDataBinding, String targetDataBinding);
/**
* Get the direct Transformer which can transform data from source type to result type
@@ -55,7 +55,7 @@
* @param targetDataBinding
* @return
*/
- public Transformer getTransformer(String sourceDataBinding, String targetDataBinding);
+ Transformer getTransformer(String sourceDataBinding, String targetDataBinding);
/**
* Get the a chain of Transformers which can transform data from source type to result type
@@ -63,5 +63,5 @@
* @param targetDataBinding
* @return
*/
- public List<Transformer> getTransformerChain(String sourceDataBinding, String targetDataBinding);
+ List<Transformer> getTransformerChain(String sourceDataBinding, String targetDataBinding);
}
Modified: incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/DOMHelper.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/DOMHelper.java?view=diff&rev=449937&r1=449936&r2=449937
==============================================================================
--- incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/DOMHelper.java (original)
+++ incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/DOMHelper.java Tue Sep 26 00:32:53 2006
@@ -29,7 +29,7 @@
/**
* Helper for DOM
*/
-public class DOMHelper {
+public final class DOMHelper {
private final static DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
static {
factory.setNamespaceAware(true);
Modified: incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/SimpleTypeMapperExtension.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/SimpleTypeMapperExtension.java?view=diff&rev=449937&r1=449936&r2=449937
==============================================================================
--- incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/SimpleTypeMapperExtension.java (original)
+++ incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/SimpleTypeMapperExtension.java Tue Sep 26 00:32:53 2006
@@ -35,77 +35,118 @@
import org.apache.tuscany.spi.idl.TypeInfo;
public class SimpleTypeMapperExtension extends XSDDataTypeConverter implements SimpleTypeMapper {
- private DatatypeFactory factory;
+ public static final Map<Class, String> JAVA2XML = new HashMap<Class, String>();
+
+ private static final String[] typeNames =
+ { "string", "boolean", "double", "float", "int", "integer", "long", "short", "byte", "decimal",
+ "base64Binary", "hexBinary", "anySimpleType", "anyType", "any", "QName", "dateTime", "date",
+ "time", "normalizedString", "token", "unsignedLong", "unsignedInt", "unsignedShort",
+ "unsignedByte", "positiveInteger", "negativeInteger", "nonNegativeInteger", "nonPositiveInteger",
+ "gYearMonth", "gMonthDay", "gYear", "gMonth", "gDay", "duration", "Name", "NCName", "NMTOKEN",
+ "NMTOKENS", "NOTATION", "ENTITY", "ENTITIES", "IDREF", "IDREFS", "anyURI", "language", "ID" };
public static final String URI_2001_SCHEMA_XSD = "http://www.w3.org/2001/XMLSchema";
- public static final QName XSD_STRING = new QName(URI_2001_SCHEMA_XSD, "string");
+
+ public static final Map<String, Class> XML2JAVA = new HashMap<String, Class>();
+
+ public static final QName XSD_ANY = new QName(URI_2001_SCHEMA_XSD, "any");
+
+ public static final QName XSD_ANYSIMPLETYPE = new QName(URI_2001_SCHEMA_XSD, "anySimpleType");
+
+ public static final QName XSD_ANYTYPE = new QName(URI_2001_SCHEMA_XSD, "anyType");
+
+ public static final QName XSD_ANYURI = new QName(URI_2001_SCHEMA_XSD, "anyURI");
+
+ public static final QName XSD_BASE64 = new QName(URI_2001_SCHEMA_XSD, "base64Binary");
+
public static final QName XSD_BOOLEAN = new QName(URI_2001_SCHEMA_XSD, "boolean");
+
+ public static final QName XSD_BYTE = new QName(URI_2001_SCHEMA_XSD, "byte");
+
+ public static final QName XSD_DATE = new QName(URI_2001_SCHEMA_XSD, "date");
+
+ public static final QName XSD_DATETIME = new QName(URI_2001_SCHEMA_XSD, "dateTime");
+
+ public static final QName XSD_DAY = new QName(URI_2001_SCHEMA_XSD, "gDay");
+
+ public static final QName XSD_DECIMAL = new QName(URI_2001_SCHEMA_XSD, "decimal");
+
public static final QName XSD_DOUBLE = new QName(URI_2001_SCHEMA_XSD, "double");
+
+ public static final QName XSD_DURATION = new QName(URI_2001_SCHEMA_XSD, "duration");
+
+ public static final QName XSD_ENTITIES = new QName(URI_2001_SCHEMA_XSD, "ENTITIES");
+
+ public static final QName XSD_ENTITY = new QName(URI_2001_SCHEMA_XSD, "ENTITY");
+
public static final QName XSD_FLOAT = new QName(URI_2001_SCHEMA_XSD, "float");
+
+ public static final QName XSD_HEXBIN = new QName(URI_2001_SCHEMA_XSD, "hexBinary");
+
+ public static final QName XSD_IDREF = new QName(URI_2001_SCHEMA_XSD, "IDREF");
+
+ public static final QName XSD_IDREFS = new QName(URI_2001_SCHEMA_XSD, "IDREFS");
+
public static final QName XSD_INT = new QName(URI_2001_SCHEMA_XSD, "int");
+
public static final QName XSD_INTEGER = new QName(URI_2001_SCHEMA_XSD, "integer");
- public static final QName XSD_LONG = new QName(URI_2001_SCHEMA_XSD, "long");
- public static final QName XSD_SHORT = new QName(URI_2001_SCHEMA_XSD, "short");
- public static final QName XSD_BYTE = new QName(URI_2001_SCHEMA_XSD, "byte");
- public static final QName XSD_DECIMAL = new QName(URI_2001_SCHEMA_XSD, "decimal");
- public static final QName XSD_BASE64 = new QName(URI_2001_SCHEMA_XSD, "base64Binary");
- public static final QName XSD_HEXBIN = new QName(URI_2001_SCHEMA_XSD, "hexBinary");
- public static final QName XSD_ANYSIMPLETYPE = new QName(URI_2001_SCHEMA_XSD, "anySimpleType");
- public static final QName XSD_ANYTYPE = new QName(URI_2001_SCHEMA_XSD, "anyType");
- public static final QName XSD_ANY = new QName(URI_2001_SCHEMA_XSD, "any");
- public static final QName XSD_QNAME = new QName(URI_2001_SCHEMA_XSD, "QName");
- public static final QName XSD_DATETIME = new QName(URI_2001_SCHEMA_XSD, "dateTime");
- public static final QName XSD_DATE = new QName(URI_2001_SCHEMA_XSD, "date");
- public static final QName XSD_TIME = new QName(URI_2001_SCHEMA_XSD, "time");
- public static final QName XSD_NORMALIZEDSTRING = new QName(URI_2001_SCHEMA_XSD, "normalizedString");
- public static final QName XSD_TOKEN = new QName(URI_2001_SCHEMA_XSD, "token");
+ public static final QName XSD_LONG = new QName(URI_2001_SCHEMA_XSD, "long");
- public static final QName XSD_UNSIGNEDLONG = new QName(URI_2001_SCHEMA_XSD, "unsignedLong");
- public static final QName XSD_UNSIGNEDINT = new QName(URI_2001_SCHEMA_XSD, "unsignedInt");
- public static final QName XSD_UNSIGNEDSHORT = new QName(URI_2001_SCHEMA_XSD, "unsignedShort");
- public static final QName XSD_UNSIGNEDBYTE = new QName(URI_2001_SCHEMA_XSD, "unsignedByte");
- public static final QName XSD_POSITIVEINTEGER = new QName(URI_2001_SCHEMA_XSD, "positiveInteger");
- public static final QName XSD_NEGATIVEINTEGER = new QName(URI_2001_SCHEMA_XSD, "negativeInteger");
- public static final QName XSD_NONNEGATIVEINTEGER = new QName(URI_2001_SCHEMA_XSD, "nonNegativeInteger");
- public static final QName XSD_NONPOSITIVEINTEGER = new QName(URI_2001_SCHEMA_XSD, "nonPositiveInteger");
+ public static final QName XSD_MONTH = new QName(URI_2001_SCHEMA_XSD, "gMonth");
- public static final QName XSD_YEARMONTH = new QName(URI_2001_SCHEMA_XSD, "gYearMonth");
public static final QName XSD_MONTHDAY = new QName(URI_2001_SCHEMA_XSD, "gMonthDay");
- public static final QName XSD_YEAR = new QName(URI_2001_SCHEMA_XSD, "gYear");
- public static final QName XSD_MONTH = new QName(URI_2001_SCHEMA_XSD, "gMonth");
- public static final QName XSD_DAY = new QName(URI_2001_SCHEMA_XSD, "gDay");
- public static final QName XSD_DURATION = new QName(URI_2001_SCHEMA_XSD, "duration");
public static final QName XSD_NAME = new QName(URI_2001_SCHEMA_XSD, "Name");
+
public static final QName XSD_NCNAME = new QName(URI_2001_SCHEMA_XSD, "NCName");
+
+ public static final QName XSD_NEGATIVEINTEGER = new QName(URI_2001_SCHEMA_XSD, "negativeInteger");
+
public static final QName XSD_NMTOKEN = new QName(URI_2001_SCHEMA_XSD, "NMTOKEN");
+
public static final QName XSD_NMTOKENS = new QName(URI_2001_SCHEMA_XSD, "NMTOKENS");
+
+ public static final QName XSD_NONNEGATIVEINTEGER = new QName(URI_2001_SCHEMA_XSD, "nonNegativeInteger");
+
+ public static final QName XSD_NONPOSITIVEINTEGER = new QName(URI_2001_SCHEMA_XSD, "nonPositiveInteger");
+
+ public static final QName XSD_NORMALIZEDSTRING = new QName(URI_2001_SCHEMA_XSD, "normalizedString");
+
public static final QName XSD_NOTATION = new QName(URI_2001_SCHEMA_XSD, "NOTATION");
- public static final QName XSD_ENTITY = new QName(URI_2001_SCHEMA_XSD, "ENTITY");
- public static final QName XSD_ENTITIES = new QName(URI_2001_SCHEMA_XSD, "ENTITIES");
- public static final QName XSD_IDREF = new QName(URI_2001_SCHEMA_XSD, "IDREF");
- public static final QName XSD_IDREFS = new QName(URI_2001_SCHEMA_XSD, "IDREFS");
- public static final QName XSD_ANYURI = new QName(URI_2001_SCHEMA_XSD, "anyURI");
-
- private static final String[] typeNames =
- { "string", "boolean", "double", "float", "int", "integer", "long", "short", "byte", "decimal",
- "base64Binary", "hexBinary", "anySimpleType", "anyType", "any", "QName", "dateTime", "date",
- "time", "normalizedString", "token", "unsignedLong", "unsignedInt", "unsignedShort",
- "unsignedByte", "positiveInteger", "negativeInteger", "nonNegativeInteger", "nonPositiveInteger",
- "gYearMonth", "gMonthDay", "gYear", "gMonth", "gDay", "duration", "Name", "NCName", "NMTOKEN",
- "NMTOKENS", "NOTATION", "ENTITY", "ENTITIES", "IDREF", "IDREFS", "anyURI", "language", "ID" };
+
+ public static final QName XSD_POSITIVEINTEGER = new QName(URI_2001_SCHEMA_XSD, "positiveInteger");
+
+ public static final QName XSD_QNAME = new QName(URI_2001_SCHEMA_XSD, "QName");
+
+ public static final QName XSD_SHORT = new QName(URI_2001_SCHEMA_XSD, "short");
public static final Map<String, TypeInfo> XSD_SIMPLE_TYPES = new HashMap<String, TypeInfo>();
+ public static final QName XSD_STRING = new QName(URI_2001_SCHEMA_XSD, "string");
+
+ public static final QName XSD_TIME = new QName(URI_2001_SCHEMA_XSD, "time");
+
+ public static final QName XSD_TOKEN = new QName(URI_2001_SCHEMA_XSD, "token");
+
+ public static final QName XSD_UNSIGNEDBYTE = new QName(URI_2001_SCHEMA_XSD, "unsignedByte");
+
+ public static final QName XSD_UNSIGNEDINT = new QName(URI_2001_SCHEMA_XSD, "unsignedInt");
+
+ public static final QName XSD_UNSIGNEDLONG = new QName(URI_2001_SCHEMA_XSD, "unsignedLong");
+
+ public static final QName XSD_UNSIGNEDSHORT = new QName(URI_2001_SCHEMA_XSD, "unsignedShort");
+
+ public static final QName XSD_YEAR = new QName(URI_2001_SCHEMA_XSD, "gYear");
+
+ public static final QName XSD_YEARMONTH = new QName(URI_2001_SCHEMA_XSD, "gYearMonth");
+
static {
for (String type : typeNames) {
TypeInfo simpleType = new TypeInfo(new QName(URI_2001_SCHEMA_XSD, type), true, null);
XSD_SIMPLE_TYPES.put(type, simpleType);
}
}
-
- public static final Map<Class, String> JAVA2XML = new HashMap<Class, String>();
static {
JAVA2XML.put(boolean.class, "boolean");
JAVA2XML.put(byte.class, "byte");
@@ -120,7 +161,7 @@
JAVA2XML.put(Integer.class, "int");
JAVA2XML.put(Long.class, "long");
JAVA2XML.put(Float.class, "float");
- JAVA2XML.put(Double.class, "double");
+ JAVA2XML.put(Double.class, "double");
JAVA2XML.put(java.lang.String.class, "string");
JAVA2XML.put(java.math.BigInteger.class, "integer");
JAVA2XML.put(java.math.BigDecimal.class, "decimal");
@@ -137,8 +178,7 @@
JAVA2XML.put(javax.xml.transform.Source.class, "base64Binary");
JAVA2XML.put(java.util.UUID.class, "string");
}
-
- public static final Map<String, Class> XML2JAVA = new HashMap<String, Class>();
+
static {
XML2JAVA.put("string", java.lang.String.class);
XML2JAVA.put("integer", java.math.BigInteger.class);
@@ -170,6 +210,8 @@
XML2JAVA.put("NOTATION", javax.xml.namespace.QName.class);
}
+ private DatatypeFactory factory;
+
public SimpleTypeMapperExtension() {
super();
try {
@@ -178,7 +220,7 @@
throw new IllegalArgumentException(e);
}
}
-
+
public Class getJavaType(TypeInfo xmlType) {
TypeInfo baseType = xmlType;
while (baseType.getBaseType() != null) {
@@ -291,6 +333,18 @@
}
}
+ @SuppressWarnings("deprecation")
+ private XMLGregorianCalendar toXMLGregorianCalendar(Date date) {
+ GregorianCalendar c =
+ new GregorianCalendar(date.getYear(), date.getMonth(), date.getDate(), date.getHours(), date
+ .getMinutes(), date.getSeconds());
+ return factory.newXMLGregorianCalendar(c);
+ }
+
+ private XMLGregorianCalendar toXMLGregorianCalendar(GregorianCalendar calendar) {
+ return factory.newXMLGregorianCalendar(calendar);
+ }
+
public String toXMLLiteral(TypeInfo simpleType, Object obj, TransformationContext context) {
if (obj instanceof Float || obj instanceof Double) {
if (obj instanceof Float) {
@@ -318,18 +372,6 @@
return printQName((QName) obj, namespaceContext);
}
return obj.toString();
- }
-
- private XMLGregorianCalendar toXMLGregorianCalendar(GregorianCalendar calendar) {
- return factory.newXMLGregorianCalendar(calendar);
- }
-
- @SuppressWarnings("deprecation")
- private XMLGregorianCalendar toXMLGregorianCalendar(Date date) {
- GregorianCalendar c =
- new GregorianCalendar(date.getYear(), date.getMonth(), date.getDate(), date.getHours(), date
- .getMinutes(), date.getSeconds());
- return factory.newXMLGregorianCalendar(c);
}
}
Modified: incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/XSDDataTypeConverter.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/XSDDataTypeConverter.java?view=diff&rev=449937&r1=449936&r2=449937
==============================================================================
--- incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/XSDDataTypeConverter.java (original)
+++ incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/XSDDataTypeConverter.java Tue Sep 26 00:32:53 2006
@@ -41,254 +41,269 @@
* Utility class for XSD data type conversions
*/
public class XSDDataTypeConverter {
- public String parseString(String value) {
- return value;
- }
-
- public BigInteger parseInteger(String value) {
- return new BigInteger(value);
- }
-
- public int parseInt(String value) {
- return Integer.parseInt(value);
- }
-
- public long parseLong(String value) {
- return Long.parseLong(value);
- }
-
- public short parseShort(String value) {
- return Short.parseShort(value);
- }
+ public static class Base64Binary {
+ private static final char[] S_BASE64CHAR =
+ { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
+ 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
+ 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5',
+ '6', '7', '8', '9', '+', '/' };
- public BigDecimal parseDecimal(String value) {
- return new BigDecimal(value);
- }
+ private static final char S_BASE64PAD = '=';
- public float parseFloat(String value) {
- if (value.equals("INF")) {
- return Float.POSITIVE_INFINITY;
- } else if (value.equals("-INF")) {
- return Float.NEGATIVE_INFINITY;
- } else if (value.equals("NaN")) {
- return Float.NaN;
- } else {
- return Float.parseFloat(value);
- }
- }
+ private static final byte[] S_DECODETABLE = new byte[128];
- public double parseDouble(String value) {
- if (value.equals("INF")) {
- return Double.POSITIVE_INFINITY;
- } else if (value.equals("-INF")) {
- return Double.NEGATIVE_INFINITY;
- } else if (value.equals("NaN")) {
- return Double.NaN;
- } else {
- return Double.parseDouble(value);
+ static {
+ for (int i = 0; i < S_DECODETABLE.length; i++)
+ S_DECODETABLE[i] = Byte.MAX_VALUE; // 127
+ for (int i = 0; i < S_BASE64CHAR.length; i++)
+ // 0 to 63
+ S_DECODETABLE[S_BASE64CHAR[i]] = (byte) i;
}
- }
-
- public boolean parseBoolean(String value) {
- return Boolean.valueOf(value).booleanValue();
- }
-
- public byte parseByte(String value) {
- return Byte.parseByte(value);
- }
- public QName parseQName(String value, NamespaceContext context) {
- int offset = value.indexOf(':');
- String uri;
- String localName;
- switch (offset) {
- case -1:
- localName = value;
- uri = context.getNamespaceURI("");
- if (uri == null) {
- // Should not happen, indicates an error in the NamespaceContext implementation
- throw new IllegalArgumentException("The default prefix is not bound.");
- }
- break;
- case 0:
- throw new IllegalArgumentException("Default prefix must be indicated by not using a colon: " + value);
- default:
- String prefix = value.substring(0, offset);
- localName = value.substring(offset + 1);
- uri = context.getNamespaceURI(prefix);
- if (uri == null) {
- throw new IllegalArgumentException("The prefix " + prefix + " is not bound.");
+ /**
+ *
+ */
+ public static byte[] decode(char[] data, int off, int len) {
+ char[] ibuf = new char[4];
+ int ibufcount = 0;
+ byte[] obuf = new byte[len / 4 * 3 + 3];
+ int obufcount = 0;
+ for (int i = off; i < off + len; i++) {
+ char ch = data[i];
+ if (ch == S_BASE64PAD || ch < S_DECODETABLE.length && S_DECODETABLE[ch] != Byte.MAX_VALUE) {
+ ibuf[ibufcount++] = ch;
+ if (ibufcount == ibuf.length) {
+ ibufcount = 0;
+ obufcount += decode0(ibuf, obuf, obufcount);
+ }
+ }
}
+ if (obufcount == obuf.length) {
+ return obuf;
+ }
+ byte[] ret = new byte[obufcount];
+ System.arraycopy(obuf, 0, ret, 0, obufcount);
+ return ret;
}
- return new QName(uri, localName);
- }
- public Calendar parseDateTime(String value) {
- XSDDateTimeFormat format = new XSDDateTimeFormat();
- ParsePosition pos = new ParsePosition(0);
- Calendar cal = (Calendar) format.parseObject(value, pos);
- if (cal == null) {
- throw new IllegalArgumentException("Failed to parse dateTime " + value + " at:"
- + value.substring(pos.getErrorIndex()));
+ /**
+ *
+ */
+ public static void decode(char[] data, int off, int len, OutputStream ostream) throws IOException {
+ char[] ibuf = new char[4];
+ int ibufcount = 0;
+ byte[] obuf = new byte[3];
+ for (int i = off; i < off + len; i++) {
+ char ch = data[i];
+ if (ch == S_BASE64PAD || ch < S_DECODETABLE.length && S_DECODETABLE[ch] != Byte.MAX_VALUE) {
+ ibuf[ibufcount++] = ch;
+ if (ibufcount == ibuf.length) {
+ ibufcount = 0;
+ int obufcount = decode0(ibuf, obuf, 0);
+ ostream.write(obuf, 0, obufcount);
+ }
+ }
+ }
}
- return cal;
- }
-
- public byte[] parseBase64Binary(String value) {
- return Base64Binary.decode(value);
- }
-
- public byte[] parseHexBinary(String value) {
- return HexBinary.decode(value);
- }
- private static final long MAX_UNSIGNED_INT = (((long) Integer.MAX_VALUE) * 2) + 1;
-
- public long parseUnsignedInt(String value) {
- long l = Long.parseLong(value);
- if (l < 0) {
- throw new IllegalArgumentException("Failed to parse UnsignedInt " + value + ": result is negative");
- }
- if (l > MAX_UNSIGNED_INT) {
- throw new IllegalArgumentException("Failed to parse UnsignedInt " + value
- + ": result exceeds maximum value " + MAX_UNSIGNED_INT);
+ /**
+ *
+ */
+ public static byte[] decode(String data) {
+ char[] ibuf = new char[4];
+ int ibufcount = 0;
+ byte[] obuf = new byte[data.length() / 4 * 3 + 3];
+ int obufcount = 0;
+ for (int i = 0; i < data.length(); i++) {
+ char ch = data.charAt(i);
+ if (ch == S_BASE64PAD || ch < S_DECODETABLE.length && S_DECODETABLE[ch] != Byte.MAX_VALUE) {
+ ibuf[ibufcount++] = ch;
+ if (ibufcount == ibuf.length) {
+ ibufcount = 0;
+ obufcount += decode0(ibuf, obuf, obufcount);
+ }
+ }
+ }
+ if (obufcount == obuf.length) {
+ return obuf;
+ }
+ byte[] ret = new byte[obufcount];
+ System.arraycopy(obuf, 0, ret, 0, obufcount);
+ return ret;
}
- return l;
- }
-
- private static final int MAX_UNSIGNED_SHORT = Short.MAX_VALUE * 2 + 1;
- public int parseUnsignedShort(String value) {
- int i = Integer.parseInt(value);
- if (i < 0) {
- throw new IllegalArgumentException("Failed to parse UnsignedShort " + value + ": result is negative");
- }
- if (i > MAX_UNSIGNED_SHORT) {
- throw new IllegalArgumentException("Failed to parse UnsignedShort " + value
- + ": result exceeds maximum value " + MAX_UNSIGNED_SHORT);
+ /**
+ *
+ */
+ public static void decode(String data, OutputStream ostream) throws IOException {
+ char[] ibuf = new char[4];
+ int ibufcount = 0;
+ byte[] obuf = new byte[3];
+ for (int i = 0; i < data.length(); i++) {
+ char ch = data.charAt(i);
+ if (ch == S_BASE64PAD || ch < S_DECODETABLE.length && S_DECODETABLE[ch] != Byte.MAX_VALUE) {
+ ibuf[ibufcount++] = ch;
+ if (ibufcount == ibuf.length) {
+ ibufcount = 0;
+ int obufcount = decode0(ibuf, obuf, 0);
+ ostream.write(obuf, 0, obufcount);
+ }
+ }
+ }
}
- return i;
- }
- public Calendar parseTime(String value) {
- XSDTimeFormat format = new XSDTimeFormat();
- ParsePosition pos = new ParsePosition(0);
- Calendar cal = (Calendar) format.parseObject(value, pos);
- if (cal == null) {
- throw new IllegalArgumentException("Failed to parse time " + value + " at:"
- + value.substring(pos.getErrorIndex()));
+ private static int decode0(char[] ibuf, byte[] obuf, int index) {
+ int wp = index;
+ int outlen = 3;
+ if (ibuf[3] == S_BASE64PAD) {
+ outlen = 2;
+ }
+ if (ibuf[2] == S_BASE64PAD) {
+ outlen = 1;
+ }
+ int b0 = S_DECODETABLE[ibuf[0]];
+ int b1 = S_DECODETABLE[ibuf[1]];
+ int b2 = S_DECODETABLE[ibuf[2]];
+ int b3 = S_DECODETABLE[ibuf[3]];
+ switch (outlen) {
+ case 1:
+ obuf[wp] = (byte) (b0 << 2 & 0xfc | b1 >> 4 & 0x3);
+ return 1;
+ case 2:
+ obuf[wp++] = (byte) (b0 << 2 & 0xfc | b1 >> 4 & 0x3);
+ obuf[wp] = (byte) (b1 << 4 & 0xf0 | b2 >> 2 & 0xf);
+ return 2;
+ case 3:
+ obuf[wp++] = (byte) (b0 << 2 & 0xfc | b1 >> 4 & 0x3);
+ obuf[wp++] = (byte) (b1 << 4 & 0xf0 | b2 >> 2 & 0xf);
+ obuf[wp] = (byte) (b2 << 6 & 0xc0 | b3 & 0x3f);
+ return 3;
+ default:
+ throw new IllegalArgumentException("The character sequence is not base64 encoded.");
+ }
}
- return cal;
- }
- public Calendar parseDate(String value) {
- XSDDateFormat format = new XSDDateFormat();
- ParsePosition pos = new ParsePosition(0);
- Calendar cal = (Calendar) format.parseObject(value, pos);
- if (cal == null) {
- throw new IllegalArgumentException("Failed to parse date " + value + " at:"
- + value.substring(pos.getErrorIndex()));
+ /**
+ * Returns base64 representation of specified byte array.
+ */
+ public static String encode(byte[] data) {
+ return encode(data, 0, data.length);
}
- return cal;
- }
- public String parseAnySimpleType(String value) {
- return value;
- }
-
- public Duration parseDuration(String pDuration) {
- try {
- return DatatypeFactory.newInstance().newDuration(pDuration);
- } catch (DatatypeConfigurationException e) {
- throw new IllegalArgumentException(e);
+ /**
+ * Returns base64 representation of specified byte array.
+ */
+ public static String encode(byte[] data, int off, int len) {
+ if (len <= 0) {
+ return "";
+ }
+ char[] out = new char[len / 3 * 4 + 4];
+ int rindex = off;
+ int windex = 0;
+ int rest = len - off;
+ while (rest >= 3) {
+ int i = ((data[rindex] & 0xff) << 16) + ((data[rindex + 1] & 0xff) << 8) + (data[rindex + 2] & 0xff);
+ out[windex++] = S_BASE64CHAR[i >> 18];
+ out[windex++] = S_BASE64CHAR[(i >> 12) & 0x3f];
+ out[windex++] = S_BASE64CHAR[(i >> 6) & 0x3f];
+ out[windex++] = S_BASE64CHAR[i & 0x3f];
+ rindex += 3;
+ rest -= 3;
+ }
+ if (rest == 1) {
+ int i = data[rindex] & 0xff;
+ out[windex++] = S_BASE64CHAR[i >> 2];
+ out[windex++] = S_BASE64CHAR[(i << 4) & 0x3f];
+ out[windex++] = S_BASE64PAD;
+ out[windex++] = S_BASE64PAD;
+ } else if (rest == 2) {
+ int i = ((data[rindex] & 0xff) << 8) + (data[rindex + 1] & 0xff);
+ out[windex++] = S_BASE64CHAR[i >> 10];
+ out[windex++] = S_BASE64CHAR[(i >> 4) & 0x3f];
+ out[windex++] = S_BASE64CHAR[(i << 2) & 0x3f];
+ out[windex++] = S_BASE64PAD;
+ }
+ return new String(out, 0, windex);
}
- }
-
- public String printString(String value) {
- return value;
- }
-
- public String printInteger(BigInteger value) {
- return value.toString();
- }
-
- public String printInt(int value) {
- return Integer.toString(value);
- }
-
- public String printLong(long value) {
- return Long.toString(value);
- }
-
- public String printShort(short value) {
- return Short.toString(value);
- }
-
- public String printDecimal(BigDecimal value) {
- return value.toString();
- }
-
- public String printFloat(float value) {
- return Float.toString(value);
- }
-
- public String printDouble(double value) {
- return Double.toString(value);
- }
-
- public String printBoolean(boolean value) {
- return (value ? Boolean.TRUE : Boolean.FALSE).toString();
- }
-
- public String printByte(byte value) {
- return Byte.toString(value);
- }
- public String printQName(QName value, NamespaceContext context) {
- String prefix = context.getPrefix(value.getNamespaceURI());
- if (prefix == null) {
- throw new IllegalArgumentException("The namespace URI " + value.getNamespaceURI() + " is not bound.");
- } else if (XMLConstants.DEFAULT_NS_PREFIX.equals(prefix)) {
- return value.getLocalPart();
- } else {
- return prefix + ":" + value.getLocalPart();
+ /**
+ * Outputs base64 representation of the specified byte array to a byte stream.
+ */
+ public static void encode(byte[] data, int off, int len, OutputStream ostream) throws IOException {
+ if (len <= 0) {
+ return;
+ }
+ byte[] out = new byte[4];
+ int rindex = off;
+ int rest = len - off;
+ while (rest >= 3) {
+ int i = ((data[rindex] & 0xff) << 16) + ((data[rindex + 1] & 0xff) << 8) + (data[rindex + 2] & 0xff);
+ out[0] = (byte) S_BASE64CHAR[i >> 18];
+ out[1] = (byte) S_BASE64CHAR[(i >> 12) & 0x3f];
+ out[2] = (byte) S_BASE64CHAR[(i >> 6) & 0x3f];
+ out[3] = (byte) S_BASE64CHAR[i & 0x3f];
+ ostream.write(out, 0, 4);
+ rindex += 3;
+ rest -= 3;
+ }
+ if (rest == 1) {
+ int i = data[rindex] & 0xff;
+ out[0] = (byte) S_BASE64CHAR[i >> 2];
+ out[1] = (byte) S_BASE64CHAR[(i << 4) & 0x3f];
+ out[2] = (byte) S_BASE64PAD;
+ out[3] = (byte) S_BASE64PAD;
+ ostream.write(out, 0, 4);
+ } else if (rest == 2) {
+ int i = ((data[rindex] & 0xff) << 8) + (data[rindex + 1] & 0xff);
+ out[0] = (byte) S_BASE64CHAR[i >> 10];
+ out[1] = (byte) S_BASE64CHAR[(i >> 4) & 0x3f];
+ out[2] = (byte) S_BASE64CHAR[(i << 2) & 0x3f];
+ out[3] = (byte) S_BASE64PAD;
+ ostream.write(out, 0, 4);
+ }
}
- }
-
- public String printDateTime(Calendar value) {
- return new XSDDateTimeFormat().format(value);
- }
- public String printBase64Binary(byte[] value) {
- return Base64Binary.encode(value);
- }
-
- public String printHexBinary(byte[] value) {
- return HexBinary.encode(value);
- }
-
- public String printUnsignedInt(long value) {
- return Long.toString(value);
- }
-
- public String printUnsignedShort(int value) {
- return Integer.toString(value);
- }
-
- public String printTime(Calendar value) {
- return new XSDTimeFormat().format(value);
- }
-
- public String printDate(Calendar value) {
- return new XSDDateFormat().format(value);
- }
-
- public String printAnySimpleType(String value) {
- return value;
- }
-
- public String printDuration(Duration pDuration) {
- return pDuration.toString();
+ /**
+ * Outputs base64 representation of the specified byte array to a character stream.
+ */
+ public static void encode(byte[] data, int off, int len, Writer writer) throws IOException {
+ if (len <= 0) {
+ return;
+ }
+ char[] out = new char[4];
+ int rindex = off;
+ int rest = len - off;
+ int output = 0;
+ while (rest >= 3) {
+ int i = ((data[rindex] & 0xff) << 16) + ((data[rindex + 1] & 0xff) << 8) + (data[rindex + 2] & 0xff);
+ out[0] = S_BASE64CHAR[i >> 18];
+ out[1] = S_BASE64CHAR[(i >> 12) & 0x3f];
+ out[2] = S_BASE64CHAR[(i >> 6) & 0x3f];
+ out[3] = S_BASE64CHAR[i & 0x3f];
+ writer.write(out, 0, 4);
+ rindex += 3;
+ rest -= 3;
+ output += 4;
+ if (output % 76 == 0) {
+ writer.write("\n");
+ }
+ }
+ if (rest == 1) {
+ int i = data[rindex] & 0xff;
+ out[0] = S_BASE64CHAR[i >> 2];
+ out[1] = S_BASE64CHAR[(i << 4) & 0x3f];
+ out[2] = S_BASE64PAD;
+ out[3] = S_BASE64PAD;
+ writer.write(out, 0, 4);
+ } else if (rest == 2) {
+ int i = ((data[rindex] & 0xff) << 8) + (data[rindex + 1] & 0xff);
+ out[0] = S_BASE64CHAR[i >> 10];
+ out[1] = S_BASE64CHAR[(i >> 4) & 0x3f];
+ out[2] = S_BASE64CHAR[(i << 2) & 0x3f];
+ out[3] = S_BASE64PAD;
+ writer.write(out, 0, 4);
+ }
+ }
}
/**
@@ -298,15 +313,6 @@
*/
public static class HexBinary {
/**
- * Creates a clone of the given byte array.
- */
- public static byte[] getClone(byte[] pHexBinary) {
- byte[] result = new byte[pHexBinary.length];
- System.arraycopy(pHexBinary, 0, result, 0, pHexBinary.length);
- return result;
- }
-
- /**
* Converts the string <code>pValue</code> into an array of hex bytes.
*/
public static byte[] decode(String pValue) {
@@ -364,6 +370,26 @@
}
return result.toString();
}
+
+ /**
+ * Creates a clone of the given byte array.
+ */
+ public static byte[] getClone(byte[] pHexBinary) {
+ byte[] result = new byte[pHexBinary.length];
+ System.arraycopy(pHexBinary, 0, result, 0, pHexBinary.length);
+ return result;
+ }
+ }
+
+ public class XSDDateFormat extends XSDDateTimeFormat {
+ private static final long serialVersionUID = -1629412916827246627L;
+
+ /**
+ * Creates a new instance.
+ */
+ public XSDDateFormat() {
+ super(true, false);
+ }
}
/**
@@ -380,11 +406,6 @@
final boolean parseTime;
- XSDDateTimeFormat(boolean pParseDate, boolean pParseTime) {
- parseDate = pParseDate;
- parseTime = pParseTime;
- }
-
/**
* Creates a new instance.
*/
@@ -392,26 +413,97 @@
this(true, true);
}
- private int parseInt(String pString, int offset, StringBuffer pDigits) {
- int length = pString.length();
- int pOffset = offset;
- pDigits.setLength(0);
- while (pOffset < length) {
- char c = pString.charAt(pOffset);
- if (Character.isDigit(c)) {
- pDigits.append(c);
- ++pOffset;
- } else {
- break;
- }
+ XSDDateTimeFormat(boolean pParseDate, boolean pParseTime) {
+ parseDate = pParseDate;
+ parseTime = pParseTime;
+ }
+
+ private void append(StringBuffer pBuffer, int pNum, int pMinLen) {
+ String s = Integer.toString(pNum);
+ for (int i = s.length(); i < pMinLen; i++) {
+ pBuffer.append('0');
}
- return pOffset;
+ pBuffer.append(s);
}
- public Object parseObject(String pString, ParsePosition pParsePosition) {
- assert pString != null : "The String argument must not be null.";
- assert pParsePosition != null : "The ParsePosition argument must not be null.";
- int offset = pParsePosition.getIndex();
+ public StringBuffer format(Object pCalendar, StringBuffer pBuffer, FieldPosition pPos) {
+ assert pCalendar != null : "The Calendar argument must not be null.";
+ assert pBuffer != null : "The StringBuffer argument must not be null.";
+ assert pPos != null : "The FieldPosition argument must not be null.";
+
+ Calendar cal = (Calendar) pCalendar;
+ if (parseDate) {
+ int year = cal.get(Calendar.YEAR);
+ if (year < 0) {
+ pBuffer.append('-');
+ year = -year;
+ }
+ append(pBuffer, year, 4);
+ pBuffer.append('-');
+ append(pBuffer, cal.get(Calendar.MONTH) + 1, 2);
+ pBuffer.append('-');
+ append(pBuffer, cal.get(Calendar.DAY_OF_MONTH), 2);
+ if (parseTime) {
+ pBuffer.append('T');
+ }
+ }
+ if (parseTime) {
+ append(pBuffer, cal.get(Calendar.HOUR_OF_DAY), 2);
+ pBuffer.append(':');
+ append(pBuffer, cal.get(Calendar.MINUTE), 2);
+ pBuffer.append(':');
+ append(pBuffer, cal.get(Calendar.SECOND), 2);
+ int millis = cal.get(Calendar.MILLISECOND);
+ if (millis > 0) {
+ pBuffer.append('.');
+ append(pBuffer, millis, 3);
+ }
+ }
+ TimeZone tz = cal.getTimeZone();
+ // JDK 1.4: int offset = tz.getOffset(cal.getTimeInMillis());
+ int offset = cal.get(Calendar.ZONE_OFFSET);
+ if (tz.inDaylightTime(cal.getTime())) {
+ offset += cal.get(Calendar.DST_OFFSET);
+ }
+ if (offset == 0) {
+ pBuffer.append('Z');
+ } else {
+ if (offset < 0) {
+ pBuffer.append('-');
+ offset = -offset;
+ } else {
+ pBuffer.append('+');
+ }
+ int minutes = offset / (60 * 1000);
+ int hours = minutes / 60;
+ minutes -= hours * 60;
+ append(pBuffer, hours, 2);
+ pBuffer.append(':');
+ append(pBuffer, minutes, 2);
+ }
+ return pBuffer;
+ }
+
+ private int parseInt(String pString, int offset, StringBuffer pDigits) {
+ int length = pString.length();
+ int pOffset = offset;
+ pDigits.setLength(0);
+ while (pOffset < length) {
+ char c = pString.charAt(pOffset);
+ if (Character.isDigit(c)) {
+ pDigits.append(c);
+ ++pOffset;
+ } else {
+ break;
+ }
+ }
+ return pOffset;
+ }
+
+ public Object parseObject(String pString, ParsePosition pParsePosition) {
+ assert pString != null : "The String argument must not be null.";
+ assert pParsePosition != null : "The ParsePosition argument must not be null.";
+ int offset = pParsePosition.getIndex();
int length = pString.length();
boolean isMinus = false;
@@ -561,83 +653,6 @@
pParsePosition.setIndex(offset);
return cal;
}
-
- private void append(StringBuffer pBuffer, int pNum, int pMinLen) {
- String s = Integer.toString(pNum);
- for (int i = s.length(); i < pMinLen; i++) {
- pBuffer.append('0');
- }
- pBuffer.append(s);
- }
-
- public StringBuffer format(Object pCalendar, StringBuffer pBuffer, FieldPosition pPos) {
- assert pCalendar != null : "The Calendar argument must not be null.";
- assert pBuffer != null : "The StringBuffer argument must not be null.";
- assert pPos != null : "The FieldPosition argument must not be null.";
-
- Calendar cal = (Calendar) pCalendar;
- if (parseDate) {
- int year = cal.get(Calendar.YEAR);
- if (year < 0) {
- pBuffer.append('-');
- year = -year;
- }
- append(pBuffer, year, 4);
- pBuffer.append('-');
- append(pBuffer, cal.get(Calendar.MONTH) + 1, 2);
- pBuffer.append('-');
- append(pBuffer, cal.get(Calendar.DAY_OF_MONTH), 2);
- if (parseTime) {
- pBuffer.append('T');
- }
- }
- if (parseTime) {
- append(pBuffer, cal.get(Calendar.HOUR_OF_DAY), 2);
- pBuffer.append(':');
- append(pBuffer, cal.get(Calendar.MINUTE), 2);
- pBuffer.append(':');
- append(pBuffer, cal.get(Calendar.SECOND), 2);
- int millis = cal.get(Calendar.MILLISECOND);
- if (millis > 0) {
- pBuffer.append('.');
- append(pBuffer, millis, 3);
- }
- }
- TimeZone tz = cal.getTimeZone();
- // JDK 1.4: int offset = tz.getOffset(cal.getTimeInMillis());
- int offset = cal.get(Calendar.ZONE_OFFSET);
- if (tz.inDaylightTime(cal.getTime())) {
- offset += cal.get(Calendar.DST_OFFSET);
- }
- if (offset == 0) {
- pBuffer.append('Z');
- } else {
- if (offset < 0) {
- pBuffer.append('-');
- offset = -offset;
- } else {
- pBuffer.append('+');
- }
- int minutes = offset / (60 * 1000);
- int hours = minutes / 60;
- minutes -= hours * 60;
- append(pBuffer, hours, 2);
- pBuffer.append(':');
- append(pBuffer, minutes, 2);
- }
- return pBuffer;
- }
- }
-
- public class XSDDateFormat extends XSDDateTimeFormat {
- private static final long serialVersionUID = -1629412916827246627L;
-
- /**
- * Creates a new instance.
- */
- public XSDDateFormat() {
- super(true, false);
- }
}
public static class XSDTimeFormat extends XSDDateTimeFormat {
@@ -651,260 +666,253 @@
}
}
- public static class Base64Binary {
- private static final char[] S_BASE64CHAR =
- { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
- 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
- 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5',
- '6', '7', '8', '9', '+', '/' };
+ private static final long MAX_UNSIGNED_INT = (((long) Integer.MAX_VALUE) * 2) + 1;
- private static final char S_BASE64PAD = '=';
+ private static final int MAX_UNSIGNED_SHORT = Short.MAX_VALUE * 2 + 1;
- private static final byte[] S_DECODETABLE = new byte[128];
+ public String parseAnySimpleType(String value) {
+ return value;
+ }
- static {
- for (int i = 0; i < S_DECODETABLE.length; i++)
- S_DECODETABLE[i] = Byte.MAX_VALUE; // 127
- for (int i = 0; i < S_BASE64CHAR.length; i++)
- // 0 to 63
- S_DECODETABLE[S_BASE64CHAR[i]] = (byte) i;
- }
+ public byte[] parseBase64Binary(String value) {
+ return Base64Binary.decode(value);
+ }
- private static int decode0(char[] ibuf, byte[] obuf, int index) {
- int wp = index;
- int outlen = 3;
- if (ibuf[3] == S_BASE64PAD)
- outlen = 2;
- if (ibuf[2] == S_BASE64PAD)
- outlen = 1;
- int b0 = S_DECODETABLE[ibuf[0]];
- int b1 = S_DECODETABLE[ibuf[1]];
- int b2 = S_DECODETABLE[ibuf[2]];
- int b3 = S_DECODETABLE[ibuf[3]];
- switch (outlen) {
- case 1:
- obuf[wp] = (byte) (b0 << 2 & 0xfc | b1 >> 4 & 0x3);
- return 1;
- case 2:
- obuf[wp++] = (byte) (b0 << 2 & 0xfc | b1 >> 4 & 0x3);
- obuf[wp] = (byte) (b1 << 4 & 0xf0 | b2 >> 2 & 0xf);
- return 2;
- case 3:
- obuf[wp++] = (byte) (b0 << 2 & 0xfc | b1 >> 4 & 0x3);
- obuf[wp++] = (byte) (b1 << 4 & 0xf0 | b2 >> 2 & 0xf);
- obuf[wp] = (byte) (b2 << 6 & 0xc0 | b3 & 0x3f);
- return 3;
- default:
- throw new IllegalArgumentException("The character sequence is not base64 encoded.");
- }
+ public boolean parseBoolean(String value) {
+ return Boolean.valueOf(value).booleanValue();
+ }
+
+ public byte parseByte(String value) {
+ return Byte.parseByte(value);
+ }
+
+ public Calendar parseDate(String value) {
+ XSDDateFormat format = new XSDDateFormat();
+ ParsePosition pos = new ParsePosition(0);
+ Calendar cal = (Calendar) format.parseObject(value, pos);
+ if (cal == null) {
+ throw new IllegalArgumentException("Failed to parse date " + value + " at:"
+ + value.substring(pos.getErrorIndex()));
}
+ return cal;
+ }
- /**
- *
- */
- public static byte[] decode(char[] data, int off, int len) {
- char[] ibuf = new char[4];
- int ibufcount = 0;
- byte[] obuf = new byte[len / 4 * 3 + 3];
- int obufcount = 0;
- for (int i = off; i < off + len; i++) {
- char ch = data[i];
- if (ch == S_BASE64PAD || ch < S_DECODETABLE.length && S_DECODETABLE[ch] != Byte.MAX_VALUE) {
- ibuf[ibufcount++] = ch;
- if (ibufcount == ibuf.length) {
- ibufcount = 0;
- obufcount += decode0(ibuf, obuf, obufcount);
- }
- }
- }
- if (obufcount == obuf.length)
- return obuf;
- byte[] ret = new byte[obufcount];
- System.arraycopy(obuf, 0, ret, 0, obufcount);
- return ret;
+ public Calendar parseDateTime(String value) {
+ XSDDateTimeFormat format = new XSDDateTimeFormat();
+ ParsePosition pos = new ParsePosition(0);
+ Calendar cal = (Calendar) format.parseObject(value, pos);
+ if (cal == null) {
+ throw new IllegalArgumentException("Failed to parse dateTime " + value + " at:"
+ + value.substring(pos.getErrorIndex()));
}
+ return cal;
+ }
- /**
- *
- */
- public static byte[] decode(String data) {
- char[] ibuf = new char[4];
- int ibufcount = 0;
- byte[] obuf = new byte[data.length() / 4 * 3 + 3];
- int obufcount = 0;
- for (int i = 0; i < data.length(); i++) {
- char ch = data.charAt(i);
- if (ch == S_BASE64PAD || ch < S_DECODETABLE.length && S_DECODETABLE[ch] != Byte.MAX_VALUE) {
- ibuf[ibufcount++] = ch;
- if (ibufcount == ibuf.length) {
- ibufcount = 0;
- obufcount += decode0(ibuf, obuf, obufcount);
- }
- }
- }
- if (obufcount == obuf.length)
- return obuf;
- byte[] ret = new byte[obufcount];
- System.arraycopy(obuf, 0, ret, 0, obufcount);
- return ret;
- }
+ public BigDecimal parseDecimal(String value) {
+ return new BigDecimal(value);
+ }
- /**
- *
- */
- public static void decode(char[] data, int off, int len, OutputStream ostream) throws IOException {
- char[] ibuf = new char[4];
- int ibufcount = 0;
- byte[] obuf = new byte[3];
- for (int i = off; i < off + len; i++) {
- char ch = data[i];
- if (ch == S_BASE64PAD || ch < S_DECODETABLE.length && S_DECODETABLE[ch] != Byte.MAX_VALUE) {
- ibuf[ibufcount++] = ch;
- if (ibufcount == ibuf.length) {
- ibufcount = 0;
- int obufcount = decode0(ibuf, obuf, 0);
- ostream.write(obuf, 0, obufcount);
- }
- }
- }
+ public double parseDouble(String value) {
+ if (value.equals("INF")) {
+ return Double.POSITIVE_INFINITY;
+ } else if (value.equals("-INF")) {
+ return Double.NEGATIVE_INFINITY;
+ } else if (value.equals("NaN")) {
+ return Double.NaN;
+ } else {
+ return Double.parseDouble(value);
}
+ }
- /**
- *
- */
- public static void decode(String data, OutputStream ostream) throws IOException {
- char[] ibuf = new char[4];
- int ibufcount = 0;
- byte[] obuf = new byte[3];
- for (int i = 0; i < data.length(); i++) {
- char ch = data.charAt(i);
- if (ch == S_BASE64PAD || ch < S_DECODETABLE.length && S_DECODETABLE[ch] != Byte.MAX_VALUE) {
- ibuf[ibufcount++] = ch;
- if (ibufcount == ibuf.length) {
- ibufcount = 0;
- int obufcount = decode0(ibuf, obuf, 0);
- ostream.write(obuf, 0, obufcount);
- }
- }
- }
+ public Duration parseDuration(String pDuration) {
+ try {
+ return DatatypeFactory.newInstance().newDuration(pDuration);
+ } catch (DatatypeConfigurationException e) {
+ throw new IllegalArgumentException(e);
}
+ }
- /**
- * Returns base64 representation of specified byte array.
- */
- public static String encode(byte[] data) {
- return encode(data, 0, data.length);
+ public float parseFloat(String value) {
+ if (value.equals("INF")) {
+ return Float.POSITIVE_INFINITY;
+ } else if (value.equals("-INF")) {
+ return Float.NEGATIVE_INFINITY;
+ } else if (value.equals("NaN")) {
+ return Float.NaN;
+ } else {
+ return Float.parseFloat(value);
}
+ }
- /**
- * Returns base64 representation of specified byte array.
- */
- public static String encode(byte[] data, int off, int len) {
- if (len <= 0)
- return "";
- char[] out = new char[len / 3 * 4 + 4];
- int rindex = off;
- int windex = 0;
- int rest = len - off;
- while (rest >= 3) {
- int i = ((data[rindex] & 0xff) << 16) + ((data[rindex + 1] & 0xff) << 8) + (data[rindex + 2] & 0xff);
- out[windex++] = S_BASE64CHAR[i >> 18];
- out[windex++] = S_BASE64CHAR[(i >> 12) & 0x3f];
- out[windex++] = S_BASE64CHAR[(i >> 6) & 0x3f];
- out[windex++] = S_BASE64CHAR[i & 0x3f];
- rindex += 3;
- rest -= 3;
+ public byte[] parseHexBinary(String value) {
+ return HexBinary.decode(value);
+ }
+
+ public int parseInt(String value) {
+ return Integer.parseInt(value);
+ }
+
+ public BigInteger parseInteger(String value) {
+ return new BigInteger(value);
+ }
+
+ public long parseLong(String value) {
+ return Long.parseLong(value);
+ }
+
+ public QName parseQName(String value, NamespaceContext context) {
+ int offset = value.indexOf(':');
+ String uri;
+ String localName;
+ switch (offset) {
+ case -1:
+ localName = value;
+ uri = context.getNamespaceURI("");
+ if (uri == null) {
+ // Should not happen, indicates an error in the NamespaceContext implementation
+ throw new IllegalArgumentException("The default prefix is not bound.");
}
- if (rest == 1) {
- int i = data[rindex] & 0xff;
- out[windex++] = S_BASE64CHAR[i >> 2];
- out[windex++] = S_BASE64CHAR[(i << 4) & 0x3f];
- out[windex++] = S_BASE64PAD;
- out[windex++] = S_BASE64PAD;
- } else if (rest == 2) {
- int i = ((data[rindex] & 0xff) << 8) + (data[rindex + 1] & 0xff);
- out[windex++] = S_BASE64CHAR[i >> 10];
- out[windex++] = S_BASE64CHAR[(i >> 4) & 0x3f];
- out[windex++] = S_BASE64CHAR[(i << 2) & 0x3f];
- out[windex++] = S_BASE64PAD;
+ break;
+ case 0:
+ throw new IllegalArgumentException("Default prefix must be indicated by not using a colon: " + value);
+ default:
+ String prefix = value.substring(0, offset);
+ localName = value.substring(offset + 1);
+ uri = context.getNamespaceURI(prefix);
+ if (uri == null) {
+ throw new IllegalArgumentException("The prefix " + prefix + " is not bound.");
}
- return new String(out, 0, windex);
}
+ return new QName(uri, localName);
+ }
- /**
- * Outputs base64 representation of the specified byte array to a byte stream.
- */
- public static void encode(byte[] data, int off, int len, OutputStream ostream) throws IOException {
- if (len <= 0)
- return;
- byte[] out = new byte[4];
- int rindex = off;
- int rest = len - off;
- while (rest >= 3) {
- int i = ((data[rindex] & 0xff) << 16) + ((data[rindex + 1] & 0xff) << 8) + (data[rindex + 2] & 0xff);
- out[0] = (byte) S_BASE64CHAR[i >> 18];
- out[1] = (byte) S_BASE64CHAR[(i >> 12) & 0x3f];
- out[2] = (byte) S_BASE64CHAR[(i >> 6) & 0x3f];
- out[3] = (byte) S_BASE64CHAR[i & 0x3f];
- ostream.write(out, 0, 4);
- rindex += 3;
- rest -= 3;
- }
- if (rest == 1) {
- int i = data[rindex] & 0xff;
- out[0] = (byte) S_BASE64CHAR[i >> 2];
- out[1] = (byte) S_BASE64CHAR[(i << 4) & 0x3f];
- out[2] = (byte) S_BASE64PAD;
- out[3] = (byte) S_BASE64PAD;
- ostream.write(out, 0, 4);
- } else if (rest == 2) {
- int i = ((data[rindex] & 0xff) << 8) + (data[rindex + 1] & 0xff);
- out[0] = (byte) S_BASE64CHAR[i >> 10];
- out[1] = (byte) S_BASE64CHAR[(i >> 4) & 0x3f];
- out[2] = (byte) S_BASE64CHAR[(i << 2) & 0x3f];
- out[3] = (byte) S_BASE64PAD;
- ostream.write(out, 0, 4);
- }
+ public short parseShort(String value) {
+ return Short.parseShort(value);
+ }
+
+ public String parseString(String value) {
+ return value;
+ }
+
+ public Calendar parseTime(String value) {
+ XSDTimeFormat format = new XSDTimeFormat();
+ ParsePosition pos = new ParsePosition(0);
+ Calendar cal = (Calendar) format.parseObject(value, pos);
+ if (cal == null) {
+ throw new IllegalArgumentException("Failed to parse time " + value + " at:"
+ + value.substring(pos.getErrorIndex()));
}
+ return cal;
+ }
- /**
- * Outputs base64 representation of the specified byte array to a character stream.
- */
- public static void encode(byte[] data, int off, int len, Writer writer) throws IOException {
- if (len <= 0)
- return;
- char[] out = new char[4];
- int rindex = off;
- int rest = len - off;
- int output = 0;
- while (rest >= 3) {
- int i = ((data[rindex] & 0xff) << 16) + ((data[rindex + 1] & 0xff) << 8) + (data[rindex + 2] & 0xff);
- out[0] = S_BASE64CHAR[i >> 18];
- out[1] = S_BASE64CHAR[(i >> 12) & 0x3f];
- out[2] = S_BASE64CHAR[(i >> 6) & 0x3f];
- out[3] = S_BASE64CHAR[i & 0x3f];
- writer.write(out, 0, 4);
- rindex += 3;
- rest -= 3;
- output += 4;
- if (output % 76 == 0)
- writer.write("\n");
- }
- if (rest == 1) {
- int i = data[rindex] & 0xff;
- out[0] = S_BASE64CHAR[i >> 2];
- out[1] = S_BASE64CHAR[(i << 4) & 0x3f];
- out[2] = S_BASE64PAD;
- out[3] = S_BASE64PAD;
- writer.write(out, 0, 4);
- } else if (rest == 2) {
- int i = ((data[rindex] & 0xff) << 8) + (data[rindex + 1] & 0xff);
- out[0] = S_BASE64CHAR[i >> 10];
- out[1] = S_BASE64CHAR[(i >> 4) & 0x3f];
- out[2] = S_BASE64CHAR[(i << 2) & 0x3f];
- out[3] = S_BASE64PAD;
- writer.write(out, 0, 4);
- }
+ public long parseUnsignedInt(String value) {
+ long l = Long.parseLong(value);
+ if (l < 0) {
+ throw new IllegalArgumentException("Failed to parse UnsignedInt " + value + ": result is negative");
+ }
+ if (l > MAX_UNSIGNED_INT) {
+ throw new IllegalArgumentException("Failed to parse UnsignedInt " + value
+ + ": result exceeds maximum value " + MAX_UNSIGNED_INT);
+ }
+ return l;
+ }
+
+ public int parseUnsignedShort(String value) {
+ int i = Integer.parseInt(value);
+ if (i < 0) {
+ throw new IllegalArgumentException("Failed to parse UnsignedShort " + value + ": result is negative");
}
+ if (i > MAX_UNSIGNED_SHORT) {
+ throw new IllegalArgumentException("Failed to parse UnsignedShort " + value
+ + ": result exceeds maximum value " + MAX_UNSIGNED_SHORT);
+ }
+ return i;
+ }
+
+ public String printAnySimpleType(String value) {
+ return value;
+ }
+
+ public String printBase64Binary(byte[] value) {
+ return Base64Binary.encode(value);
+ }
+
+ public String printBoolean(boolean value) {
+ return (value ? Boolean.TRUE : Boolean.FALSE).toString();
+ }
+
+ public String printByte(byte value) {
+ return Byte.toString(value);
+ }
+
+ public String printDate(Calendar value) {
+ return new XSDDateFormat().format(value);
+ }
+
+ public String printDateTime(Calendar value) {
+ return new XSDDateTimeFormat().format(value);
+ }
+
+ public String printDecimal(BigDecimal value) {
+ return value.toString();
+ }
+
+ public String printDouble(double value) {
+ return Double.toString(value);
+ }
+
+ public String printDuration(Duration pDuration) {
+ return pDuration.toString();
+ }
+
+ public String printFloat(float value) {
+ return Float.toString(value);
+ }
+
+ public String printHexBinary(byte[] value) {
+ return HexBinary.encode(value);
+ }
+
+ public String printInt(int value) {
+ return Integer.toString(value);
+ }
+
+ public String printInteger(BigInteger value) {
+ return value.toString();
+ }
+
+ public String printLong(long value) {
+ return Long.toString(value);
+ }
+
+ public String printQName(QName value, NamespaceContext context) {
+ String prefix = context.getPrefix(value.getNamespaceURI());
+ if (prefix == null) {
+ throw new IllegalArgumentException("The namespace URI " + value.getNamespaceURI() + " is not bound.");
+ } else if (XMLConstants.DEFAULT_NS_PREFIX.equals(prefix)) {
+ return value.getLocalPart();
+ } else {
+ return prefix + ":" + value.getLocalPart();
+ }
+ }
+
+ public String printShort(short value) {
+ return Short.toString(value);
+ }
+
+ public String printString(String value) {
+ return value;
+ }
+
+ public String printTime(Calendar value) {
+ return new XSDTimeFormat().format(value);
+ }
+
+ public String printUnsignedInt(long value) {
+ return Long.toString(value);
+ }
+
+ public String printUnsignedShort(int value) {
+ return Integer.toString(value);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org