src/share/jaxws_classes/javax/xml/bind/DatatypeConverter.java

changeset 286
f50545b5e2f1
child 397
b99d7e355d4b
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/jaxws_classes/javax/xml/bind/DatatypeConverter.java	Tue Mar 06 16:09:35 2012 -0800
     1.3 @@ -0,0 +1,695 @@
     1.4 +/*
     1.5 + * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.  Oracle designates this
    1.11 + * particular file as subject to the "Classpath" exception as provided
    1.12 + * by Oracle in the LICENSE file that accompanied this code.
    1.13 + *
    1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.17 + * version 2 for more details (a copy is included in the LICENSE file that
    1.18 + * accompanied this code).
    1.19 + *
    1.20 + * You should have received a copy of the GNU General Public License version
    1.21 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.23 + *
    1.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.25 + * or visit www.oracle.com if you need additional information or have any
    1.26 + * questions.
    1.27 + */
    1.28 +
    1.29 +package javax.xml.bind;
    1.30 +
    1.31 +import javax.xml.namespace.NamespaceContext;
    1.32 +
    1.33 +/**
    1.34 + * <p>
    1.35 + * The javaType binding declaration can be used to customize the binding of
    1.36 + * an XML schema datatype to a Java datatype. Customizations can involve
    1.37 + * writing a parse and print method for parsing and printing lexical
    1.38 + * representations of a XML schema datatype respectively. However, writing
    1.39 + * parse and print methods requires knowledge of the lexical representations (
    1.40 + * <a href="http://www.w3.org/TR/xmlschema-2/"> XML Schema Part2: Datatypes
    1.41 + * specification </a>) and hence may be difficult to write.
    1.42 + * </p>
    1.43 + * <p>
    1.44 + * This class makes it easier to write parse and print methods. It defines
    1.45 + * static parse and print methods that provide access to a JAXB provider's
    1.46 + * implementation of parse and print methods. These methods are invoked by
    1.47 + * custom parse and print methods. For example, the binding of xsd:dateTime
    1.48 + * to a long can be customized using parse and print methods as follows:
    1.49 + * <blockquote>
    1.50 + *    <pre>
    1.51 + *    // Customized parse method
    1.52 + *    public long myParseCal( String dateTimeString ) {
    1.53 + *        java.util.Calendar cal = DatatypeConverter.parseDateTime(dateTimeString);
    1.54 + *        long longval = convert_calendar_to_long(cal); //application specific
    1.55 + *        return longval;
    1.56 + *    }
    1.57 + *
    1.58 + *    // Customized print method
    1.59 + *    public String myPrintCal( Long longval ) {
    1.60 + *        java.util.Calendar cal = convert_long_to_calendar(longval) ; //application specific
    1.61 + *        String dateTimeString = DatatypeConverter.printDateTime(cal);
    1.62 + *        return dateTimeString;
    1.63 + *    }
    1.64 + *    </pre>
    1.65 + * </blockquote>
    1.66 + * <p>
    1.67 + * There is a static parse and print method corresponding to each parse and
    1.68 + * print method respectively in the {@link DatatypeConverterInterface
    1.69 + * DatatypeConverterInterface}.
    1.70 + * <p>
    1.71 + * The static methods defined in the class can also be used to specify
    1.72 + * a parse or a print method in a javaType binding declaration.
    1.73 + * </p>
    1.74 + * <p>
    1.75 + * JAXB Providers are required to call the
    1.76 + * {@link #setDatatypeConverter(DatatypeConverterInterface)
    1.77 + * setDatatypeConverter} api at some point before the first marshal or unmarshal
    1.78 + * operation (perhaps during the call to JAXBContext.newInstance).  This step is
    1.79 + * necessary to configure the converter that should be used to perform the
    1.80 + * print and parse functionality.
    1.81 + * </p>
    1.82 + *
    1.83 + * <p>
    1.84 + * A print method for a XML schema datatype can output any lexical
    1.85 + * representation that is valid with respect to the XML schema datatype.
    1.86 + * If an error is encountered during conversion, then an IllegalArgumentException,
    1.87 + * or a subclass of IllegalArgumentException must be thrown by the method.
    1.88 + * </p>
    1.89 + *
    1.90 + * @author <ul><li>Sekhar Vajjhala, Sun Microsystems, Inc.</li><li>Joe Fialli, Sun Microsystems Inc.</li><li>Kohsuke Kawaguchi, Sun Microsystems, Inc.</li><li>Ryan Shoemaker,Sun Microsystems Inc.</li></ul>
    1.91 + * @see DatatypeConverterInterface
    1.92 + * @see ParseConversionEvent
    1.93 + * @see PrintConversionEvent
    1.94 + * @since JAXB1.0
    1.95 + */
    1.96 +
    1.97 +final public class DatatypeConverter {
    1.98 +
    1.99 +    // delegate to this instance of DatatypeConverter
   1.100 +    private static DatatypeConverterInterface theConverter = null;
   1.101 +
   1.102 +    private final static JAXBPermission SET_DATATYPE_CONVERTER_PERMISSION =
   1.103 +                           new JAXBPermission("setDatatypeConverter");
   1.104 +
   1.105 +    private DatatypeConverter() {
   1.106 +        // private constructor
   1.107 +    }
   1.108 +
   1.109 +    /**
   1.110 +     * This method is for JAXB provider use only.
   1.111 +     * <p>
   1.112 +     * JAXB Providers are required to call this method at some point before
   1.113 +     * allowing any of the JAXB client marshal or unmarshal operations to
   1.114 +     * occur.  This is necessary to configure the datatype converter that
   1.115 +     * should be used to perform the print and parse conversions.
   1.116 +     *
   1.117 +     * <p>
   1.118 +     * Calling this api repeatedly will have no effect - the
   1.119 +     * DatatypeConverterInterface instance passed into the first invocation is
   1.120 +     * the one that will be used from then on.
   1.121 +     *
   1.122 +     * @param converter an instance of a class that implements the
   1.123 +     * DatatypeConverterInterface class - this parameter must not be null.
   1.124 +     * @throws IllegalArgumentException if the parameter is null
   1.125 +     * @throws SecurityException
   1.126 +     *      If the {@link SecurityManager} in charge denies the access to
   1.127 +     *      set the datatype converter.
   1.128 +     * @see JAXBPermission
   1.129 +     */
   1.130 +    public static void setDatatypeConverter( DatatypeConverterInterface converter ) {
   1.131 +        if( converter == null ) {
   1.132 +            throw new IllegalArgumentException(
   1.133 +                Messages.format( Messages.CONVERTER_MUST_NOT_BE_NULL ) );
   1.134 +        } else if( theConverter == null ) {
   1.135 +            SecurityManager sm = System.getSecurityManager();
   1.136 +            if (sm != null)
   1.137 +                sm.checkPermission(SET_DATATYPE_CONVERTER_PERMISSION);
   1.138 +            theConverter = converter;
   1.139 +        }
   1.140 +    }
   1.141 +
   1.142 +    private static synchronized void initConverter() {
   1.143 +        theConverter = new DatatypeConverterImpl();
   1.144 +    }
   1.145 +
   1.146 +    /**
   1.147 +     * <p>
   1.148 +     * Convert the lexical XSD string argument into a String value.
   1.149 +     * @param lexicalXSDString
   1.150 +     *     A string containing a lexical representation of
   1.151 +     *     xsd:string.
   1.152 +     * @return
   1.153 +     *     A String value represented by the string argument.
   1.154 +     */
   1.155 +    public static String parseString( String lexicalXSDString ) {
   1.156 +        if (theConverter == null) initConverter();
   1.157 +        return theConverter.parseString( lexicalXSDString );
   1.158 +    }
   1.159 +
   1.160 +    /**
   1.161 +     * <p>
   1.162 +     * Convert the string argument into a BigInteger value.
   1.163 +     * @param lexicalXSDInteger
   1.164 +     *     A string containing a lexical representation of
   1.165 +     *     xsd:integer.
   1.166 +     * @return
   1.167 +     *     A BigInteger value represented by the string argument.
   1.168 +     * @throws NumberFormatException <code>lexicalXSDInteger</code> is not a valid string representation of a {@link java.math.BigInteger} value.
   1.169 +     */
   1.170 +    public static java.math.BigInteger parseInteger( String lexicalXSDInteger ) {
   1.171 +        if (theConverter == null) initConverter();
   1.172 +        return theConverter.parseInteger( lexicalXSDInteger );
   1.173 +    }
   1.174 +
   1.175 +    /**
   1.176 +     * <p>
   1.177 +     * Convert the string argument into an int value.
   1.178 +     * @param lexicalXSDInt
   1.179 +     *     A string containing a lexical representation of
   1.180 +     *     xsd:int.
   1.181 +     * @return
   1.182 +     *     A int value represented by the string argument.
   1.183 +     * @throws NumberFormatException <code>lexicalXSDInt</code> is not a valid string representation of an <code>int</code> value.
   1.184 +     */
   1.185 +    public static int parseInt( String lexicalXSDInt ) {
   1.186 +        if (theConverter == null) initConverter();
   1.187 +        return theConverter.parseInt( lexicalXSDInt );
   1.188 +    }
   1.189 +
   1.190 +    /**
   1.191 +     * <p>
   1.192 +     * Converts the string argument into a long value.
   1.193 +     * @param lexicalXSDLong
   1.194 +     *     A string containing lexical representation of
   1.195 +     *     xsd:long.
   1.196 +     * @return
   1.197 +     *     A long value represented by the string argument.
   1.198 +     * @throws NumberFormatException <code>lexicalXSDLong</code> is not a valid string representation of a <code>long</code> value.
   1.199 +     */
   1.200 +    public static long parseLong( String lexicalXSDLong ) {
   1.201 +        if (theConverter == null) initConverter();
   1.202 +        return theConverter.parseLong( lexicalXSDLong );
   1.203 +    }
   1.204 +
   1.205 +    /**
   1.206 +     * <p>
   1.207 +     * Converts the string argument into a short value.
   1.208 +     * @param lexicalXSDShort
   1.209 +     *     A string containing lexical representation of
   1.210 +     *     xsd:short.
   1.211 +     * @return
   1.212 +     *     A short value represented by the string argument.
   1.213 +     * @throws NumberFormatException <code>lexicalXSDShort</code> is not a valid string representation of a <code>short</code> value.
   1.214 +     */
   1.215 +    public static short parseShort( String lexicalXSDShort ) {
   1.216 +        if (theConverter == null) initConverter();
   1.217 +        return theConverter.parseShort( lexicalXSDShort );
   1.218 +    }
   1.219 +
   1.220 +    /**
   1.221 +     * <p>
   1.222 +     * Converts the string argument into a BigDecimal value.
   1.223 +     * @param lexicalXSDDecimal
   1.224 +     *     A string containing lexical representation of
   1.225 +     *     xsd:decimal.
   1.226 +     * @return
   1.227 +     *     A BigDecimal value represented by the string argument.
   1.228 +     * @throws NumberFormatException <code>lexicalXSDDecimal</code> is not a valid string representation of {@link java.math.BigDecimal}.
   1.229 +     */
   1.230 +    public static java.math.BigDecimal parseDecimal( String lexicalXSDDecimal ) {
   1.231 +        if (theConverter == null) initConverter();
   1.232 +        return theConverter.parseDecimal( lexicalXSDDecimal );
   1.233 +    }
   1.234 +
   1.235 +    /**
   1.236 +     * <p>
   1.237 +     * Converts the string argument into a float value.
   1.238 +     * @param lexicalXSDFloat
   1.239 +     *     A string containing lexical representation of
   1.240 +     *     xsd:float.
   1.241 +     * @return
   1.242 +     *     A float value represented by the string argument.
   1.243 +     * @throws NumberFormatException <code>lexicalXSDFloat</code> is not a valid string representation of a <code>float</code> value.
   1.244 +     */
   1.245 +    public static float parseFloat( String lexicalXSDFloat ) {
   1.246 +        if (theConverter == null) initConverter();
   1.247 +        return theConverter.parseFloat( lexicalXSDFloat );
   1.248 +    }
   1.249 +
   1.250 +    /**
   1.251 +     * <p>
   1.252 +     * Converts the string argument into a double value.
   1.253 +     * @param lexicalXSDDouble
   1.254 +     *     A string containing lexical representation of
   1.255 +     *     xsd:double.
   1.256 +     * @return
   1.257 +     *     A double value represented by the string argument.
   1.258 +     * @throws NumberFormatException <code>lexicalXSDDouble</code> is not a valid string representation of a <code>double</code> value.
   1.259 +     */
   1.260 +    public static double parseDouble( String lexicalXSDDouble ) {
   1.261 +        if (theConverter == null) initConverter();
   1.262 +        return theConverter.parseDouble( lexicalXSDDouble );
   1.263 +    }
   1.264 +
   1.265 +    /**
   1.266 +     * <p>
   1.267 +     * Converts the string argument into a boolean value.
   1.268 +     * @param lexicalXSDBoolean
   1.269 +     *     A string containing lexical representation of
   1.270 +     *     xsd:boolean.
   1.271 +     * @return
   1.272 +     *     A boolean value represented by the string argument.
   1.273 +     * @throws IllegalArgumentException if string parameter does not conform to lexical value space defined in XML Schema Part 2: Datatypes for xsd:boolean.
   1.274 +     */
   1.275 +    public static boolean parseBoolean( String lexicalXSDBoolean ) {
   1.276 +        if (theConverter == null) initConverter();
   1.277 +        return theConverter.parseBoolean( lexicalXSDBoolean );
   1.278 +    }
   1.279 +
   1.280 +    /**
   1.281 +     * <p>
   1.282 +     * Converts the string argument into a byte value.
   1.283 +     * @param lexicalXSDByte
   1.284 +     *     A string containing lexical representation of
   1.285 +     *     xsd:byte.
   1.286 +     * @return
   1.287 +     *     A byte value represented by the string argument.
   1.288 +     * @throws IllegalArgumentException if string parameter does not conform to lexical value space defined in XML Schema Part 2: Datatypes for xsd:byte.
   1.289 +     */
   1.290 +    public static byte parseByte( String lexicalXSDByte ) {
   1.291 +        if (theConverter == null) initConverter();
   1.292 +        return theConverter.parseByte( lexicalXSDByte );
   1.293 +    }
   1.294 +
   1.295 +    /**
   1.296 +     * <p>
   1.297 +     * Converts the string argument into a byte value.
   1.298 +     *
   1.299 +     * <p>
   1.300 +     * String parameter <tt>lexicalXSDQname</tt> must conform to lexical value space specifed at
   1.301 +     * <a href="http://www.w3.org/TR/xmlschema-2/#QName">XML Schema Part 2:Datatypes specification:QNames</a>
   1.302 +     *
   1.303 +     * @param lexicalXSDQName
   1.304 +     *     A string containing lexical representation of xsd:QName.
   1.305 +     * @param nsc
   1.306 +     *     A namespace context for interpreting a prefix within a QName.
   1.307 +     * @return
   1.308 +     *     A QName value represented by the string argument.
   1.309 +     * @throws IllegalArgumentException  if string parameter does not conform to XML Schema Part 2 specification or
   1.310 +     *      if namespace prefix of <tt>lexicalXSDQname</tt> is not bound to a URI in NamespaceContext <tt>nsc</tt>.
   1.311 +     */
   1.312 +    public static javax.xml.namespace.QName parseQName( String lexicalXSDQName,
   1.313 +                                                    NamespaceContext nsc) {
   1.314 +        if (theConverter == null) initConverter();
   1.315 +        return theConverter.parseQName( lexicalXSDQName, nsc );
   1.316 +    }
   1.317 +
   1.318 +    /**
   1.319 +     * <p>
   1.320 +     * Converts the string argument into a Calendar value.
   1.321 +     * @param lexicalXSDDateTime
   1.322 +     *     A string containing lexical representation of
   1.323 +     *     xsd:datetime.
   1.324 +     * @return
   1.325 +     *     A Calendar object represented by the string argument.
   1.326 +     * @throws IllegalArgumentException if string parameter does not conform to lexical value space defined in XML Schema Part 2: Datatypes for xsd:dateTime.
   1.327 +     */
   1.328 +    public static java.util.Calendar parseDateTime( String lexicalXSDDateTime ) {
   1.329 +        if (theConverter == null) initConverter();
   1.330 +        return theConverter.parseDateTime( lexicalXSDDateTime );
   1.331 +    }
   1.332 +
   1.333 +    /**
   1.334 +     * <p>
   1.335 +     * Converts the string argument into an array of bytes.
   1.336 +     * @param lexicalXSDBase64Binary
   1.337 +     *     A string containing lexical representation
   1.338 +     *     of xsd:base64Binary.
   1.339 +     * @return
   1.340 +     *     An array of bytes represented by the string argument.
   1.341 +     * @throws IllegalArgumentException if string parameter does not conform to lexical value space defined in XML Schema Part 2: Datatypes for xsd:base64Binary
   1.342 +     */
   1.343 +    public static byte[] parseBase64Binary( String lexicalXSDBase64Binary ) {
   1.344 +        if (theConverter == null) initConverter();
   1.345 +        return theConverter.parseBase64Binary( lexicalXSDBase64Binary );
   1.346 +    }
   1.347 +
   1.348 +    /**
   1.349 +     * <p>
   1.350 +     * Converts the string argument into an array of bytes.
   1.351 +     * @param lexicalXSDHexBinary
   1.352 +     *     A string containing lexical representation of
   1.353 +     *     xsd:hexBinary.
   1.354 +     * @return
   1.355 +     *     An array of bytes represented by the string argument.
   1.356 +     * @throws IllegalArgumentException if string parameter does not conform to lexical value space defined in XML Schema Part 2: Datatypes for xsd:hexBinary.
   1.357 +     */
   1.358 +   public static byte[] parseHexBinary( String lexicalXSDHexBinary ) {
   1.359 +        if (theConverter == null) initConverter();
   1.360 +        return theConverter.parseHexBinary( lexicalXSDHexBinary );
   1.361 +    }
   1.362 +
   1.363 +    /**
   1.364 +     * <p>
   1.365 +     * Converts the string argument into a long value.
   1.366 +     * @param lexicalXSDUnsignedInt
   1.367 +     *     A string containing lexical representation
   1.368 +     *     of xsd:unsignedInt.
   1.369 +     * @return
   1.370 +     *     A long value represented by the string argument.
   1.371 +     * @throws NumberFormatException if string parameter can not be parsed into a <tt>long</tt> value.
   1.372 +     */
   1.373 +    public static long parseUnsignedInt( String lexicalXSDUnsignedInt ) {
   1.374 +        if (theConverter == null) initConverter();
   1.375 +        return theConverter.parseUnsignedInt( lexicalXSDUnsignedInt );
   1.376 +    }
   1.377 +
   1.378 +    /**
   1.379 +     * <p>
   1.380 +     * Converts the string argument into an int value.
   1.381 +     * @param lexicalXSDUnsignedShort
   1.382 +     *     A string containing lexical
   1.383 +     *     representation of xsd:unsignedShort.
   1.384 +     * @return
   1.385 +     *     An int value represented by the string argument.
   1.386 +     * @throws NumberFormatException if string parameter can not be parsed into an <tt>int</tt> value.
   1.387 +     */
   1.388 +    public static int   parseUnsignedShort( String lexicalXSDUnsignedShort ) {
   1.389 +        if (theConverter == null) initConverter();
   1.390 +        return theConverter.parseUnsignedShort( lexicalXSDUnsignedShort );
   1.391 +    }
   1.392 +
   1.393 +    /**
   1.394 +     * <p>
   1.395 +     * Converts the string argument into a Calendar value.
   1.396 +     * @param lexicalXSDTime
   1.397 +     *     A string containing lexical representation of
   1.398 +     *     xsd:time.
   1.399 +     * @return
   1.400 +     *     A Calendar value represented by the string argument.
   1.401 +     * @throws IllegalArgumentException if string parameter does not conform to lexical value space defined in XML Schema Part 2: Datatypes for xsd:Time.
   1.402 +     */
   1.403 +    public static java.util.Calendar parseTime( String lexicalXSDTime ) {
   1.404 +        if (theConverter == null) initConverter();
   1.405 +        return theConverter.parseTime( lexicalXSDTime );
   1.406 +    }
   1.407 +    /**
   1.408 +     * <p>
   1.409 +     * Converts the string argument into a Calendar value.
   1.410 +     * @param lexicalXSDDate
   1.411 +     *      A string containing lexical representation of
   1.412 +     *     xsd:Date.
   1.413 +     * @return
   1.414 +     *     A Calendar value represented by the string argument.
   1.415 +     * @throws IllegalArgumentException if string parameter does not conform to lexical value space defined in XML Schema Part 2: Datatypes for xsd:Date.
   1.416 +     */
   1.417 +    public static java.util.Calendar parseDate( String lexicalXSDDate ) {
   1.418 +        if (theConverter == null) initConverter();
   1.419 +        return theConverter.parseDate( lexicalXSDDate );
   1.420 +    }
   1.421 +
   1.422 +    /**
   1.423 +     * <p>
   1.424 +     * Return a string containing the lexical representation of the
   1.425 +     * simple type.
   1.426 +     * @param lexicalXSDAnySimpleType
   1.427 +     *     A string containing lexical
   1.428 +     *     representation of the simple type.
   1.429 +     * @return
   1.430 +     *     A string containing the lexical representation of the
   1.431 +     *     simple type.
   1.432 +     */
   1.433 +    public static String parseAnySimpleType( String lexicalXSDAnySimpleType ) {
   1.434 +        if (theConverter == null) initConverter();
   1.435 +        return theConverter.parseAnySimpleType( lexicalXSDAnySimpleType );
   1.436 +    }
   1.437 +    /**
   1.438 +     * <p>
   1.439 +     * Converts the string argument into a string.
   1.440 +     * @param val
   1.441 +     *     A string value.
   1.442 +     * @return
   1.443 +     *     A string containing a lexical representation of xsd:string.
   1.444 +     */
   1.445 +     // also indicate the print methods produce a lexical
   1.446 +     // representation for given Java datatypes.
   1.447 +
   1.448 +    public static String printString( String val ) {
   1.449 +        if (theConverter == null) initConverter();
   1.450 +        return theConverter.printString( val );
   1.451 +    }
   1.452 +
   1.453 +    /**
   1.454 +     * <p>
   1.455 +     * Converts a BigInteger value into a string.
   1.456 +     * @param val
   1.457 +     *     A BigInteger value
   1.458 +     * @return
   1.459 +     *     A string containing a lexical representation of xsd:integer
   1.460 +     * @throws IllegalArgumentException <tt>val</tt> is null.
   1.461 +     */
   1.462 +    public static String printInteger( java.math.BigInteger val ) {
   1.463 +        if (theConverter == null) initConverter();
   1.464 +        return theConverter.printInteger( val );
   1.465 +    }
   1.466 +
   1.467 +    /**
   1.468 +     * <p>
   1.469 +     * Converts an int value into a string.
   1.470 +     * @param val
   1.471 +     *     An int value
   1.472 +     * @return
   1.473 +     *     A string containing a lexical representation of xsd:int
   1.474 +     */
   1.475 +    public static String printInt( int val ) {
   1.476 +        if (theConverter == null) initConverter();
   1.477 +        return theConverter.printInt( val );
   1.478 +    }
   1.479 +
   1.480 +    /**
   1.481 +     * <p>
   1.482 +     * Converts A long value into a string.
   1.483 +     * @param val
   1.484 +     *     A long value
   1.485 +     * @return
   1.486 +     *     A string containing a lexical representation of xsd:long
   1.487 +     */
   1.488 +    public static String printLong( long val ) {
   1.489 +        if (theConverter == null) initConverter();
   1.490 +        return theConverter.printLong( val );
   1.491 +    }
   1.492 +
   1.493 +    /**
   1.494 +     * <p>
   1.495 +     * Converts a short value into a string.
   1.496 +     * @param val
   1.497 +     *     A short value
   1.498 +     * @return
   1.499 +     *     A string containing a lexical representation of xsd:short
   1.500 +     */
   1.501 +    public static String printShort( short val ) {
   1.502 +        if (theConverter == null) initConverter();
   1.503 +        return theConverter.printShort( val );
   1.504 +    }
   1.505 +
   1.506 +    /**
   1.507 +     * <p>
   1.508 +     * Converts a BigDecimal value into a string.
   1.509 +     * @param val
   1.510 +     *     A BigDecimal value
   1.511 +     * @return
   1.512 +     *     A string containing a lexical representation of xsd:decimal
   1.513 +     * @throws IllegalArgumentException <tt>val</tt> is null.
   1.514 +     */
   1.515 +    public static String printDecimal( java.math.BigDecimal val ) {
   1.516 +        if (theConverter == null) initConverter();
   1.517 +        return theConverter.printDecimal( val );
   1.518 +    }
   1.519 +
   1.520 +    /**
   1.521 +     * <p>
   1.522 +     * Converts a float value into a string.
   1.523 +     * @param val
   1.524 +     *     A float value
   1.525 +     * @return
   1.526 +     *     A string containing a lexical representation of xsd:float
   1.527 +     */
   1.528 +    public static String printFloat( float val ) {
   1.529 +        if (theConverter == null) initConverter();
   1.530 +        return theConverter.printFloat( val );
   1.531 +    }
   1.532 +
   1.533 +    /**
   1.534 +     * <p>
   1.535 +     * Converts a double value into a string.
   1.536 +     * @param val
   1.537 +     *     A double value
   1.538 +     * @return
   1.539 +     *     A string containing a lexical representation of xsd:double
   1.540 +     */
   1.541 +    public static String printDouble( double val ) {
   1.542 +        if (theConverter == null) initConverter();
   1.543 +        return theConverter.printDouble( val );
   1.544 +    }
   1.545 +
   1.546 +    /**
   1.547 +     * <p>
   1.548 +     * Converts a boolean value into a string.
   1.549 +     * @param val
   1.550 +     *     A boolean value
   1.551 +     * @return
   1.552 +     *     A string containing a lexical representation of xsd:boolean
   1.553 +     */
   1.554 +    public static String printBoolean( boolean val ) {
   1.555 +        if (theConverter == null) initConverter();
   1.556 +        return theConverter.printBoolean( val );
   1.557 +    }
   1.558 +
   1.559 +    /**
   1.560 +     * <p>
   1.561 +     * Converts a byte value into a string.
   1.562 +     * @param val
   1.563 +     *     A byte value
   1.564 +     * @return
   1.565 +     *     A string containing a lexical representation of xsd:byte
   1.566 +     */
   1.567 +    public static String printByte( byte val ) {
   1.568 +        if (theConverter == null) initConverter();
   1.569 +        return theConverter.printByte( val );
   1.570 +    }
   1.571 +
   1.572 +    /**
   1.573 +     * <p>
   1.574 +     * Converts a QName instance into a string.
   1.575 +     * @param val
   1.576 +     *     A QName value
   1.577 +     * @param nsc
   1.578 +     *     A namespace context for interpreting a prefix within a QName.
   1.579 +     * @return
   1.580 +     *     A string containing a lexical representation of QName
   1.581 +     * @throws IllegalArgumentException if <tt>val</tt> is null or
   1.582 +     * if <tt>nsc</tt> is non-null or <tt>nsc.getPrefix(nsprefixFromVal)</tt> is null.
   1.583 +     */
   1.584 +    public static String printQName( javax.xml.namespace.QName val,
   1.585 +                                     NamespaceContext nsc ) {
   1.586 +        if (theConverter == null) initConverter();
   1.587 +        return theConverter.printQName( val, nsc );
   1.588 +    }
   1.589 +
   1.590 +    /**
   1.591 +     * <p>
   1.592 +     * Converts a Calendar value into a string.
   1.593 +     * @param val
   1.594 +     *     A Calendar value
   1.595 +     * @return
   1.596 +     *     A string containing a lexical representation of xsd:dateTime
   1.597 +     * @throws IllegalArgumentException if <tt>val</tt> is null.
   1.598 +     */
   1.599 +    public static String printDateTime( java.util.Calendar val ) {
   1.600 +        if (theConverter == null) initConverter();
   1.601 +        return theConverter.printDateTime( val );
   1.602 +    }
   1.603 +
   1.604 +    /**
   1.605 +     * <p>
   1.606 +     * Converts an array of bytes into a string.
   1.607 +     * @param val
   1.608 +     *     An array of bytes
   1.609 +     * @return
   1.610 +     *     A string containing a lexical representation of xsd:base64Binary
   1.611 +     * @throws IllegalArgumentException if <tt>val</tt> is null.
   1.612 +     */
   1.613 +    public static String printBase64Binary( byte[] val ) {
   1.614 +        if (theConverter == null) initConverter();
   1.615 +        return theConverter.printBase64Binary( val );
   1.616 +    }
   1.617 +
   1.618 +    /**
   1.619 +     * <p>
   1.620 +     * Converts an array of bytes into a string.
   1.621 +     * @param val
   1.622 +     *     An array of bytes
   1.623 +     * @return
   1.624 +     *     A string containing a lexical representation of xsd:hexBinary
   1.625 +     * @throws IllegalArgumentException if <tt>val</tt> is null.
   1.626 +     */
   1.627 +    public static String printHexBinary( byte[] val ) {
   1.628 +        if (theConverter == null) initConverter();
   1.629 +        return theConverter.printHexBinary( val );
   1.630 +    }
   1.631 +
   1.632 +    /**
   1.633 +     * <p>
   1.634 +     * Converts a long value into a string.
   1.635 +     * @param val
   1.636 +     *     A long value
   1.637 +     * @return
   1.638 +     *     A string containing a lexical representation of xsd:unsignedInt
   1.639 +     */
   1.640 +    public static String printUnsignedInt( long val ) {
   1.641 +        if (theConverter == null) initConverter();
   1.642 +        return theConverter.printUnsignedInt( val );
   1.643 +    }
   1.644 +
   1.645 +    /**
   1.646 +     * <p>
   1.647 +     * Converts an int value into a string.
   1.648 +     * @param val
   1.649 +     *     An int value
   1.650 +     * @return
   1.651 +     *     A string containing a lexical representation of xsd:unsignedShort
   1.652 +     */
   1.653 +    public static String printUnsignedShort( int val ) {
   1.654 +        if (theConverter == null) initConverter();
   1.655 +        return theConverter.printUnsignedShort( val );
   1.656 +    }
   1.657 +
   1.658 +    /**
   1.659 +     * <p>
   1.660 +     * Converts a Calendar value into a string.
   1.661 +     * @param val
   1.662 +     *     A Calendar value
   1.663 +     * @return
   1.664 +     *     A string containing a lexical representation of xsd:time
   1.665 +     * @throws IllegalArgumentException if <tt>val</tt> is null.
   1.666 +     */
   1.667 +    public static String printTime( java.util.Calendar val ) {
   1.668 +        if (theConverter == null) initConverter();
   1.669 +        return theConverter.printTime( val );
   1.670 +    }
   1.671 +
   1.672 +    /**
   1.673 +     * <p>
   1.674 +     * Converts a Calendar value into a string.
   1.675 +     * @param val
   1.676 +     *     A Calendar value
   1.677 +     * @return
   1.678 +     *     A string containing a lexical representation of xsd:date
   1.679 +     * @throws IllegalArgumentException if <tt>val</tt> is null.
   1.680 +     */
   1.681 +    public static String printDate( java.util.Calendar val ) {
   1.682 +        if (theConverter == null) initConverter();
   1.683 +        return theConverter.printDate( val );
   1.684 +    }
   1.685 +
   1.686 +    /**
   1.687 +     * <p>
   1.688 +     * Converts a string value into a string.
   1.689 +     * @param val
   1.690 +     *     A string value
   1.691 +     * @return
   1.692 +     *     A string containing a lexical representation of xsd:AnySimpleType
   1.693 +     */
   1.694 +    public static String printAnySimpleType( String val ) {
   1.695 +        if (theConverter == null) initConverter();
   1.696 +        return theConverter.printAnySimpleType( val );
   1.697 +    }
   1.698 +}

mercurial