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

Thu, 31 Aug 2017 15:18:52 +0800

author
aoqi
date
Thu, 31 Aug 2017 15:18:52 +0800
changeset 637
9c07ef4934dd
parent 397
b99d7e355d4b
parent 0
373ffda63c9a
permissions
-rw-r--r--

merge

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation. Oracle designates this
aoqi@0 8 * particular file as subject to the "Classpath" exception as provided
aoqi@0 9 * by Oracle in the LICENSE file that accompanied this code.
aoqi@0 10 *
aoqi@0 11 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 14 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 15 * accompanied this code).
aoqi@0 16 *
aoqi@0 17 * You should have received a copy of the GNU General Public License version
aoqi@0 18 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 20 *
aoqi@0 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 22 * or visit www.oracle.com if you need additional information or have any
aoqi@0 23 * questions.
aoqi@0 24 */
aoqi@0 25
aoqi@0 26 package javax.xml.bind;
aoqi@0 27
aoqi@0 28 import javax.xml.namespace.NamespaceContext;
aoqi@0 29
aoqi@0 30 /**
aoqi@0 31 * <p>
aoqi@0 32 * The javaType binding declaration can be used to customize the binding of
aoqi@0 33 * an XML schema datatype to a Java datatype. Customizations can involve
aoqi@0 34 * writing a parse and print method for parsing and printing lexical
aoqi@0 35 * representations of a XML schema datatype respectively. However, writing
aoqi@0 36 * parse and print methods requires knowledge of the lexical representations (
aoqi@0 37 * <a href="http://www.w3.org/TR/xmlschema-2/"> XML Schema Part2: Datatypes
aoqi@0 38 * specification </a>) and hence may be difficult to write.
aoqi@0 39 * </p>
aoqi@0 40 * <p>
aoqi@0 41 * This class makes it easier to write parse and print methods. It defines
aoqi@0 42 * static parse and print methods that provide access to a JAXB provider's
aoqi@0 43 * implementation of parse and print methods. These methods are invoked by
aoqi@0 44 * custom parse and print methods. For example, the binding of xsd:dateTime
aoqi@0 45 * to a long can be customized using parse and print methods as follows:
aoqi@0 46 * <blockquote>
aoqi@0 47 * <pre>
aoqi@0 48 * // Customized parse method
aoqi@0 49 * public long myParseCal( String dateTimeString ) {
aoqi@0 50 * java.util.Calendar cal = DatatypeConverter.parseDateTime(dateTimeString);
aoqi@0 51 * long longval = convert_calendar_to_long(cal); //application specific
aoqi@0 52 * return longval;
aoqi@0 53 * }
aoqi@0 54 *
aoqi@0 55 * // Customized print method
aoqi@0 56 * public String myPrintCal( Long longval ) {
aoqi@0 57 * java.util.Calendar cal = convert_long_to_calendar(longval) ; //application specific
aoqi@0 58 * String dateTimeString = DatatypeConverter.printDateTime(cal);
aoqi@0 59 * return dateTimeString;
aoqi@0 60 * }
aoqi@0 61 * </pre>
aoqi@0 62 * </blockquote>
aoqi@0 63 * <p>
aoqi@0 64 * There is a static parse and print method corresponding to each parse and
aoqi@0 65 * print method respectively in the {@link DatatypeConverterInterface
aoqi@0 66 * DatatypeConverterInterface}.
aoqi@0 67 * <p>
aoqi@0 68 * The static methods defined in the class can also be used to specify
aoqi@0 69 * a parse or a print method in a javaType binding declaration.
aoqi@0 70 * </p>
aoqi@0 71 * <p>
aoqi@0 72 * JAXB Providers are required to call the
aoqi@0 73 * {@link #setDatatypeConverter(DatatypeConverterInterface)
aoqi@0 74 * setDatatypeConverter} api at some point before the first marshal or unmarshal
aoqi@0 75 * operation (perhaps during the call to JAXBContext.newInstance). This step is
aoqi@0 76 * necessary to configure the converter that should be used to perform the
aoqi@0 77 * print and parse functionality.
aoqi@0 78 * </p>
aoqi@0 79 *
aoqi@0 80 * <p>
aoqi@0 81 * A print method for a XML schema datatype can output any lexical
aoqi@0 82 * representation that is valid with respect to the XML schema datatype.
aoqi@0 83 * If an error is encountered during conversion, then an IllegalArgumentException,
aoqi@0 84 * or a subclass of IllegalArgumentException must be thrown by the method.
aoqi@0 85 * </p>
aoqi@0 86 *
aoqi@0 87 * @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>
aoqi@0 88 * @see DatatypeConverterInterface
aoqi@0 89 * @see ParseConversionEvent
aoqi@0 90 * @see PrintConversionEvent
aoqi@0 91 * @since JAXB1.0
aoqi@0 92 */
aoqi@0 93
aoqi@0 94 final public class DatatypeConverter {
aoqi@0 95
aoqi@0 96 // delegate to this instance of DatatypeConverter
aoqi@0 97 private static volatile DatatypeConverterInterface theConverter = null;
aoqi@0 98
aoqi@0 99 private final static JAXBPermission SET_DATATYPE_CONVERTER_PERMISSION =
aoqi@0 100 new JAXBPermission("setDatatypeConverter");
aoqi@0 101
aoqi@0 102 private DatatypeConverter() {
aoqi@0 103 // private constructor
aoqi@0 104 }
aoqi@0 105
aoqi@0 106 /**
aoqi@0 107 * This method is for JAXB provider use only.
aoqi@0 108 * <p>
aoqi@0 109 * JAXB Providers are required to call this method at some point before
aoqi@0 110 * allowing any of the JAXB client marshal or unmarshal operations to
aoqi@0 111 * occur. This is necessary to configure the datatype converter that
aoqi@0 112 * should be used to perform the print and parse conversions.
aoqi@0 113 *
aoqi@0 114 * <p>
aoqi@0 115 * Calling this api repeatedly will have no effect - the
aoqi@0 116 * DatatypeConverterInterface instance passed into the first invocation is
aoqi@0 117 * the one that will be used from then on.
aoqi@0 118 *
aoqi@0 119 * @param converter an instance of a class that implements the
aoqi@0 120 * DatatypeConverterInterface class - this parameter must not be null.
aoqi@0 121 * @throws IllegalArgumentException if the parameter is null
aoqi@0 122 * @throws SecurityException
aoqi@0 123 * If the {@link SecurityManager} in charge denies the access to
aoqi@0 124 * set the datatype converter.
aoqi@0 125 * @see JAXBPermission
aoqi@0 126 */
aoqi@0 127 public static void setDatatypeConverter( DatatypeConverterInterface converter ) {
aoqi@0 128 if( converter == null ) {
aoqi@0 129 throw new IllegalArgumentException(
aoqi@0 130 Messages.format( Messages.CONVERTER_MUST_NOT_BE_NULL ) );
aoqi@0 131 } else if( theConverter == null ) {
aoqi@0 132 SecurityManager sm = System.getSecurityManager();
aoqi@0 133 if (sm != null)
aoqi@0 134 sm.checkPermission(SET_DATATYPE_CONVERTER_PERMISSION);
aoqi@0 135 theConverter = converter;
aoqi@0 136 }
aoqi@0 137 }
aoqi@0 138
aoqi@0 139 private static synchronized void initConverter() {
aoqi@0 140 theConverter = new DatatypeConverterImpl();
aoqi@0 141 }
aoqi@0 142
aoqi@0 143 /**
aoqi@0 144 * <p>
aoqi@0 145 * Convert the lexical XSD string argument into a String value.
aoqi@0 146 * @param lexicalXSDString
aoqi@0 147 * A string containing a lexical representation of
aoqi@0 148 * xsd:string.
aoqi@0 149 * @return
aoqi@0 150 * A String value represented by the string argument.
aoqi@0 151 */
aoqi@0 152 public static String parseString( String lexicalXSDString ) {
aoqi@0 153 if (theConverter == null) initConverter();
aoqi@0 154 return theConverter.parseString( lexicalXSDString );
aoqi@0 155 }
aoqi@0 156
aoqi@0 157 /**
aoqi@0 158 * <p>
aoqi@0 159 * Convert the string argument into a BigInteger value.
aoqi@0 160 * @param lexicalXSDInteger
aoqi@0 161 * A string containing a lexical representation of
aoqi@0 162 * xsd:integer.
aoqi@0 163 * @return
aoqi@0 164 * A BigInteger value represented by the string argument.
aoqi@0 165 * @throws NumberFormatException <code>lexicalXSDInteger</code> is not a valid string representation of a {@link java.math.BigInteger} value.
aoqi@0 166 */
aoqi@0 167 public static java.math.BigInteger parseInteger( String lexicalXSDInteger ) {
aoqi@0 168 if (theConverter == null) initConverter();
aoqi@0 169 return theConverter.parseInteger( lexicalXSDInteger );
aoqi@0 170 }
aoqi@0 171
aoqi@0 172 /**
aoqi@0 173 * <p>
aoqi@0 174 * Convert the string argument into an int value.
aoqi@0 175 * @param lexicalXSDInt
aoqi@0 176 * A string containing a lexical representation of
aoqi@0 177 * xsd:int.
aoqi@0 178 * @return
aoqi@0 179 * A int value represented by the string argument.
aoqi@0 180 * @throws NumberFormatException <code>lexicalXSDInt</code> is not a valid string representation of an <code>int</code> value.
aoqi@0 181 */
aoqi@0 182 public static int parseInt( String lexicalXSDInt ) {
aoqi@0 183 if (theConverter == null) initConverter();
aoqi@0 184 return theConverter.parseInt( lexicalXSDInt );
aoqi@0 185 }
aoqi@0 186
aoqi@0 187 /**
aoqi@0 188 * <p>
aoqi@0 189 * Converts the string argument into a long value.
aoqi@0 190 * @param lexicalXSDLong
aoqi@0 191 * A string containing lexical representation of
aoqi@0 192 * xsd:long.
aoqi@0 193 * @return
aoqi@0 194 * A long value represented by the string argument.
aoqi@0 195 * @throws NumberFormatException <code>lexicalXSDLong</code> is not a valid string representation of a <code>long</code> value.
aoqi@0 196 */
aoqi@0 197 public static long parseLong( String lexicalXSDLong ) {
aoqi@0 198 if (theConverter == null) initConverter();
aoqi@0 199 return theConverter.parseLong( lexicalXSDLong );
aoqi@0 200 }
aoqi@0 201
aoqi@0 202 /**
aoqi@0 203 * <p>
aoqi@0 204 * Converts the string argument into a short value.
aoqi@0 205 * @param lexicalXSDShort
aoqi@0 206 * A string containing lexical representation of
aoqi@0 207 * xsd:short.
aoqi@0 208 * @return
aoqi@0 209 * A short value represented by the string argument.
aoqi@0 210 * @throws NumberFormatException <code>lexicalXSDShort</code> is not a valid string representation of a <code>short</code> value.
aoqi@0 211 */
aoqi@0 212 public static short parseShort( String lexicalXSDShort ) {
aoqi@0 213 if (theConverter == null) initConverter();
aoqi@0 214 return theConverter.parseShort( lexicalXSDShort );
aoqi@0 215 }
aoqi@0 216
aoqi@0 217 /**
aoqi@0 218 * <p>
aoqi@0 219 * Converts the string argument into a BigDecimal value.
aoqi@0 220 * @param lexicalXSDDecimal
aoqi@0 221 * A string containing lexical representation of
aoqi@0 222 * xsd:decimal.
aoqi@0 223 * @return
aoqi@0 224 * A BigDecimal value represented by the string argument.
aoqi@0 225 * @throws NumberFormatException <code>lexicalXSDDecimal</code> is not a valid string representation of {@link java.math.BigDecimal}.
aoqi@0 226 */
aoqi@0 227 public static java.math.BigDecimal parseDecimal( String lexicalXSDDecimal ) {
aoqi@0 228 if (theConverter == null) initConverter();
aoqi@0 229 return theConverter.parseDecimal( lexicalXSDDecimal );
aoqi@0 230 }
aoqi@0 231
aoqi@0 232 /**
aoqi@0 233 * <p>
aoqi@0 234 * Converts the string argument into a float value.
aoqi@0 235 * @param lexicalXSDFloat
aoqi@0 236 * A string containing lexical representation of
aoqi@0 237 * xsd:float.
aoqi@0 238 * @return
aoqi@0 239 * A float value represented by the string argument.
aoqi@0 240 * @throws NumberFormatException <code>lexicalXSDFloat</code> is not a valid string representation of a <code>float</code> value.
aoqi@0 241 */
aoqi@0 242 public static float parseFloat( String lexicalXSDFloat ) {
aoqi@0 243 if (theConverter == null) initConverter();
aoqi@0 244 return theConverter.parseFloat( lexicalXSDFloat );
aoqi@0 245 }
aoqi@0 246
aoqi@0 247 /**
aoqi@0 248 * <p>
aoqi@0 249 * Converts the string argument into a double value.
aoqi@0 250 * @param lexicalXSDDouble
aoqi@0 251 * A string containing lexical representation of
aoqi@0 252 * xsd:double.
aoqi@0 253 * @return
aoqi@0 254 * A double value represented by the string argument.
aoqi@0 255 * @throws NumberFormatException <code>lexicalXSDDouble</code> is not a valid string representation of a <code>double</code> value.
aoqi@0 256 */
aoqi@0 257 public static double parseDouble( String lexicalXSDDouble ) {
aoqi@0 258 if (theConverter == null) initConverter();
aoqi@0 259 return theConverter.parseDouble( lexicalXSDDouble );
aoqi@0 260 }
aoqi@0 261
aoqi@0 262 /**
aoqi@0 263 * <p>
aoqi@0 264 * Converts the string argument into a boolean value.
aoqi@0 265 * @param lexicalXSDBoolean
aoqi@0 266 * A string containing lexical representation of
aoqi@0 267 * xsd:boolean.
aoqi@0 268 * @return
aoqi@0 269 * A boolean value represented by the string argument.
aoqi@0 270 * @throws IllegalArgumentException if string parameter does not conform to lexical value space defined in XML Schema Part 2: Datatypes for xsd:boolean.
aoqi@0 271 */
aoqi@0 272 public static boolean parseBoolean( String lexicalXSDBoolean ) {
aoqi@0 273 if (theConverter == null) initConverter();
aoqi@0 274 return theConverter.parseBoolean( lexicalXSDBoolean );
aoqi@0 275 }
aoqi@0 276
aoqi@0 277 /**
aoqi@0 278 * <p>
aoqi@0 279 * Converts the string argument into a byte value.
aoqi@0 280 * @param lexicalXSDByte
aoqi@0 281 * A string containing lexical representation of
aoqi@0 282 * xsd:byte.
aoqi@0 283 * @return
aoqi@0 284 * A byte value represented by the string argument.
aoqi@0 285 * @throws IllegalArgumentException if string parameter does not conform to lexical value space defined in XML Schema Part 2: Datatypes for xsd:byte.
aoqi@0 286 */
aoqi@0 287 public static byte parseByte( String lexicalXSDByte ) {
aoqi@0 288 if (theConverter == null) initConverter();
aoqi@0 289 return theConverter.parseByte( lexicalXSDByte );
aoqi@0 290 }
aoqi@0 291
aoqi@0 292 /**
aoqi@0 293 * <p>
aoqi@0 294 * Converts the string argument into a byte value.
aoqi@0 295 *
aoqi@0 296 * <p>
aoqi@0 297 * String parameter <tt>lexicalXSDQname</tt> must conform to lexical value space specifed at
aoqi@0 298 * <a href="http://www.w3.org/TR/xmlschema-2/#QName">XML Schema Part 2:Datatypes specification:QNames</a>
aoqi@0 299 *
aoqi@0 300 * @param lexicalXSDQName
aoqi@0 301 * A string containing lexical representation of xsd:QName.
aoqi@0 302 * @param nsc
aoqi@0 303 * A namespace context for interpreting a prefix within a QName.
aoqi@0 304 * @return
aoqi@0 305 * A QName value represented by the string argument.
aoqi@0 306 * @throws IllegalArgumentException if string parameter does not conform to XML Schema Part 2 specification or
aoqi@0 307 * if namespace prefix of <tt>lexicalXSDQname</tt> is not bound to a URI in NamespaceContext <tt>nsc</tt>.
aoqi@0 308 */
aoqi@0 309 public static javax.xml.namespace.QName parseQName( String lexicalXSDQName,
aoqi@0 310 NamespaceContext nsc) {
aoqi@0 311 if (theConverter == null) initConverter();
aoqi@0 312 return theConverter.parseQName( lexicalXSDQName, nsc );
aoqi@0 313 }
aoqi@0 314
aoqi@0 315 /**
aoqi@0 316 * <p>
aoqi@0 317 * Converts the string argument into a Calendar value.
aoqi@0 318 * @param lexicalXSDDateTime
aoqi@0 319 * A string containing lexical representation of
aoqi@0 320 * xsd:datetime.
aoqi@0 321 * @return
aoqi@0 322 * A Calendar object represented by the string argument.
aoqi@0 323 * @throws IllegalArgumentException if string parameter does not conform to lexical value space defined in XML Schema Part 2: Datatypes for xsd:dateTime.
aoqi@0 324 */
aoqi@0 325 public static java.util.Calendar parseDateTime( String lexicalXSDDateTime ) {
aoqi@0 326 if (theConverter == null) initConverter();
aoqi@0 327 return theConverter.parseDateTime( lexicalXSDDateTime );
aoqi@0 328 }
aoqi@0 329
aoqi@0 330 /**
aoqi@0 331 * <p>
aoqi@0 332 * Converts the string argument into an array of bytes.
aoqi@0 333 * @param lexicalXSDBase64Binary
aoqi@0 334 * A string containing lexical representation
aoqi@0 335 * of xsd:base64Binary.
aoqi@0 336 * @return
aoqi@0 337 * An array of bytes represented by the string argument.
aoqi@0 338 * @throws IllegalArgumentException if string parameter does not conform to lexical value space defined in XML Schema Part 2: Datatypes for xsd:base64Binary
aoqi@0 339 */
aoqi@0 340 public static byte[] parseBase64Binary( String lexicalXSDBase64Binary ) {
aoqi@0 341 if (theConverter == null) initConverter();
aoqi@0 342 return theConverter.parseBase64Binary( lexicalXSDBase64Binary );
aoqi@0 343 }
aoqi@0 344
aoqi@0 345 /**
aoqi@0 346 * <p>
aoqi@0 347 * Converts the string argument into an array of bytes.
aoqi@0 348 * @param lexicalXSDHexBinary
aoqi@0 349 * A string containing lexical representation of
aoqi@0 350 * xsd:hexBinary.
aoqi@0 351 * @return
aoqi@0 352 * An array of bytes represented by the string argument.
aoqi@0 353 * @throws IllegalArgumentException if string parameter does not conform to lexical value space defined in XML Schema Part 2: Datatypes for xsd:hexBinary.
aoqi@0 354 */
aoqi@0 355 public static byte[] parseHexBinary( String lexicalXSDHexBinary ) {
aoqi@0 356 if (theConverter == null) initConverter();
aoqi@0 357 return theConverter.parseHexBinary( lexicalXSDHexBinary );
aoqi@0 358 }
aoqi@0 359
aoqi@0 360 /**
aoqi@0 361 * <p>
aoqi@0 362 * Converts the string argument into a long value.
aoqi@0 363 * @param lexicalXSDUnsignedInt
aoqi@0 364 * A string containing lexical representation
aoqi@0 365 * of xsd:unsignedInt.
aoqi@0 366 * @return
aoqi@0 367 * A long value represented by the string argument.
aoqi@0 368 * @throws NumberFormatException if string parameter can not be parsed into a <tt>long</tt> value.
aoqi@0 369 */
aoqi@0 370 public static long parseUnsignedInt( String lexicalXSDUnsignedInt ) {
aoqi@0 371 if (theConverter == null) initConverter();
aoqi@0 372 return theConverter.parseUnsignedInt( lexicalXSDUnsignedInt );
aoqi@0 373 }
aoqi@0 374
aoqi@0 375 /**
aoqi@0 376 * <p>
aoqi@0 377 * Converts the string argument into an int value.
aoqi@0 378 * @param lexicalXSDUnsignedShort
aoqi@0 379 * A string containing lexical
aoqi@0 380 * representation of xsd:unsignedShort.
aoqi@0 381 * @return
aoqi@0 382 * An int value represented by the string argument.
aoqi@0 383 * @throws NumberFormatException if string parameter can not be parsed into an <tt>int</tt> value.
aoqi@0 384 */
aoqi@0 385 public static int parseUnsignedShort( String lexicalXSDUnsignedShort ) {
aoqi@0 386 if (theConverter == null) initConverter();
aoqi@0 387 return theConverter.parseUnsignedShort( lexicalXSDUnsignedShort );
aoqi@0 388 }
aoqi@0 389
aoqi@0 390 /**
aoqi@0 391 * <p>
aoqi@0 392 * Converts the string argument into a Calendar value.
aoqi@0 393 * @param lexicalXSDTime
aoqi@0 394 * A string containing lexical representation of
aoqi@0 395 * xsd:time.
aoqi@0 396 * @return
aoqi@0 397 * A Calendar value represented by the string argument.
aoqi@0 398 * @throws IllegalArgumentException if string parameter does not conform to lexical value space defined in XML Schema Part 2: Datatypes for xsd:Time.
aoqi@0 399 */
aoqi@0 400 public static java.util.Calendar parseTime( String lexicalXSDTime ) {
aoqi@0 401 if (theConverter == null) initConverter();
aoqi@0 402 return theConverter.parseTime( lexicalXSDTime );
aoqi@0 403 }
aoqi@0 404 /**
aoqi@0 405 * <p>
aoqi@0 406 * Converts the string argument into a Calendar value.
aoqi@0 407 * @param lexicalXSDDate
aoqi@0 408 * A string containing lexical representation of
aoqi@0 409 * xsd:Date.
aoqi@0 410 * @return
aoqi@0 411 * A Calendar value represented by the string argument.
aoqi@0 412 * @throws IllegalArgumentException if string parameter does not conform to lexical value space defined in XML Schema Part 2: Datatypes for xsd:Date.
aoqi@0 413 */
aoqi@0 414 public static java.util.Calendar parseDate( String lexicalXSDDate ) {
aoqi@0 415 if (theConverter == null) initConverter();
aoqi@0 416 return theConverter.parseDate( lexicalXSDDate );
aoqi@0 417 }
aoqi@0 418
aoqi@0 419 /**
aoqi@0 420 * <p>
aoqi@0 421 * Return a string containing the lexical representation of the
aoqi@0 422 * simple type.
aoqi@0 423 * @param lexicalXSDAnySimpleType
aoqi@0 424 * A string containing lexical
aoqi@0 425 * representation of the simple type.
aoqi@0 426 * @return
aoqi@0 427 * A string containing the lexical representation of the
aoqi@0 428 * simple type.
aoqi@0 429 */
aoqi@0 430 public static String parseAnySimpleType( String lexicalXSDAnySimpleType ) {
aoqi@0 431 if (theConverter == null) initConverter();
aoqi@0 432 return theConverter.parseAnySimpleType( lexicalXSDAnySimpleType );
aoqi@0 433 }
aoqi@0 434 /**
aoqi@0 435 * <p>
aoqi@0 436 * Converts the string argument into a string.
aoqi@0 437 * @param val
aoqi@0 438 * A string value.
aoqi@0 439 * @return
aoqi@0 440 * A string containing a lexical representation of xsd:string.
aoqi@0 441 */
aoqi@0 442 // also indicate the print methods produce a lexical
aoqi@0 443 // representation for given Java datatypes.
aoqi@0 444
aoqi@0 445 public static String printString( String val ) {
aoqi@0 446 if (theConverter == null) initConverter();
aoqi@0 447 return theConverter.printString( val );
aoqi@0 448 }
aoqi@0 449
aoqi@0 450 /**
aoqi@0 451 * <p>
aoqi@0 452 * Converts a BigInteger value into a string.
aoqi@0 453 * @param val
aoqi@0 454 * A BigInteger value
aoqi@0 455 * @return
aoqi@0 456 * A string containing a lexical representation of xsd:integer
aoqi@0 457 * @throws IllegalArgumentException <tt>val</tt> is null.
aoqi@0 458 */
aoqi@0 459 public static String printInteger( java.math.BigInteger val ) {
aoqi@0 460 if (theConverter == null) initConverter();
aoqi@0 461 return theConverter.printInteger( val );
aoqi@0 462 }
aoqi@0 463
aoqi@0 464 /**
aoqi@0 465 * <p>
aoqi@0 466 * Converts an int value into a string.
aoqi@0 467 * @param val
aoqi@0 468 * An int value
aoqi@0 469 * @return
aoqi@0 470 * A string containing a lexical representation of xsd:int
aoqi@0 471 */
aoqi@0 472 public static String printInt( int val ) {
aoqi@0 473 if (theConverter == null) initConverter();
aoqi@0 474 return theConverter.printInt( val );
aoqi@0 475 }
aoqi@0 476
aoqi@0 477 /**
aoqi@0 478 * <p>
aoqi@0 479 * Converts A long value into a string.
aoqi@0 480 * @param val
aoqi@0 481 * A long value
aoqi@0 482 * @return
aoqi@0 483 * A string containing a lexical representation of xsd:long
aoqi@0 484 */
aoqi@0 485 public static String printLong( long val ) {
aoqi@0 486 if (theConverter == null) initConverter();
aoqi@0 487 return theConverter.printLong( val );
aoqi@0 488 }
aoqi@0 489
aoqi@0 490 /**
aoqi@0 491 * <p>
aoqi@0 492 * Converts a short value into a string.
aoqi@0 493 * @param val
aoqi@0 494 * A short value
aoqi@0 495 * @return
aoqi@0 496 * A string containing a lexical representation of xsd:short
aoqi@0 497 */
aoqi@0 498 public static String printShort( short val ) {
aoqi@0 499 if (theConverter == null) initConverter();
aoqi@0 500 return theConverter.printShort( val );
aoqi@0 501 }
aoqi@0 502
aoqi@0 503 /**
aoqi@0 504 * <p>
aoqi@0 505 * Converts a BigDecimal value into a string.
aoqi@0 506 * @param val
aoqi@0 507 * A BigDecimal value
aoqi@0 508 * @return
aoqi@0 509 * A string containing a lexical representation of xsd:decimal
aoqi@0 510 * @throws IllegalArgumentException <tt>val</tt> is null.
aoqi@0 511 */
aoqi@0 512 public static String printDecimal( java.math.BigDecimal val ) {
aoqi@0 513 if (theConverter == null) initConverter();
aoqi@0 514 return theConverter.printDecimal( val );
aoqi@0 515 }
aoqi@0 516
aoqi@0 517 /**
aoqi@0 518 * <p>
aoqi@0 519 * Converts a float value into a string.
aoqi@0 520 * @param val
aoqi@0 521 * A float value
aoqi@0 522 * @return
aoqi@0 523 * A string containing a lexical representation of xsd:float
aoqi@0 524 */
aoqi@0 525 public static String printFloat( float val ) {
aoqi@0 526 if (theConverter == null) initConverter();
aoqi@0 527 return theConverter.printFloat( val );
aoqi@0 528 }
aoqi@0 529
aoqi@0 530 /**
aoqi@0 531 * <p>
aoqi@0 532 * Converts a double value into a string.
aoqi@0 533 * @param val
aoqi@0 534 * A double value
aoqi@0 535 * @return
aoqi@0 536 * A string containing a lexical representation of xsd:double
aoqi@0 537 */
aoqi@0 538 public static String printDouble( double val ) {
aoqi@0 539 if (theConverter == null) initConverter();
aoqi@0 540 return theConverter.printDouble( val );
aoqi@0 541 }
aoqi@0 542
aoqi@0 543 /**
aoqi@0 544 * <p>
aoqi@0 545 * Converts a boolean value into a string.
aoqi@0 546 * @param val
aoqi@0 547 * A boolean value
aoqi@0 548 * @return
aoqi@0 549 * A string containing a lexical representation of xsd:boolean
aoqi@0 550 */
aoqi@0 551 public static String printBoolean( boolean val ) {
aoqi@0 552 if (theConverter == null) initConverter();
aoqi@0 553 return theConverter.printBoolean( val );
aoqi@0 554 }
aoqi@0 555
aoqi@0 556 /**
aoqi@0 557 * <p>
aoqi@0 558 * Converts a byte value into a string.
aoqi@0 559 * @param val
aoqi@0 560 * A byte value
aoqi@0 561 * @return
aoqi@0 562 * A string containing a lexical representation of xsd:byte
aoqi@0 563 */
aoqi@0 564 public static String printByte( byte val ) {
aoqi@0 565 if (theConverter == null) initConverter();
aoqi@0 566 return theConverter.printByte( val );
aoqi@0 567 }
aoqi@0 568
aoqi@0 569 /**
aoqi@0 570 * <p>
aoqi@0 571 * Converts a QName instance into a string.
aoqi@0 572 * @param val
aoqi@0 573 * A QName value
aoqi@0 574 * @param nsc
aoqi@0 575 * A namespace context for interpreting a prefix within a QName.
aoqi@0 576 * @return
aoqi@0 577 * A string containing a lexical representation of QName
aoqi@0 578 * @throws IllegalArgumentException if <tt>val</tt> is null or
aoqi@0 579 * if <tt>nsc</tt> is non-null or <tt>nsc.getPrefix(nsprefixFromVal)</tt> is null.
aoqi@0 580 */
aoqi@0 581 public static String printQName( javax.xml.namespace.QName val,
aoqi@0 582 NamespaceContext nsc ) {
aoqi@0 583 if (theConverter == null) initConverter();
aoqi@0 584 return theConverter.printQName( val, nsc );
aoqi@0 585 }
aoqi@0 586
aoqi@0 587 /**
aoqi@0 588 * <p>
aoqi@0 589 * Converts a Calendar value into a string.
aoqi@0 590 * @param val
aoqi@0 591 * A Calendar value
aoqi@0 592 * @return
aoqi@0 593 * A string containing a lexical representation of xsd:dateTime
aoqi@0 594 * @throws IllegalArgumentException if <tt>val</tt> is null.
aoqi@0 595 */
aoqi@0 596 public static String printDateTime( java.util.Calendar val ) {
aoqi@0 597 if (theConverter == null) initConverter();
aoqi@0 598 return theConverter.printDateTime( val );
aoqi@0 599 }
aoqi@0 600
aoqi@0 601 /**
aoqi@0 602 * <p>
aoqi@0 603 * Converts an array of bytes into a string.
aoqi@0 604 * @param val
aoqi@0 605 * An array of bytes
aoqi@0 606 * @return
aoqi@0 607 * A string containing a lexical representation of xsd:base64Binary
aoqi@0 608 * @throws IllegalArgumentException if <tt>val</tt> is null.
aoqi@0 609 */
aoqi@0 610 public static String printBase64Binary( byte[] val ) {
aoqi@0 611 if (theConverter == null) initConverter();
aoqi@0 612 return theConverter.printBase64Binary( val );
aoqi@0 613 }
aoqi@0 614
aoqi@0 615 /**
aoqi@0 616 * <p>
aoqi@0 617 * Converts an array of bytes into a string.
aoqi@0 618 * @param val
aoqi@0 619 * An array of bytes
aoqi@0 620 * @return
aoqi@0 621 * A string containing a lexical representation of xsd:hexBinary
aoqi@0 622 * @throws IllegalArgumentException if <tt>val</tt> is null.
aoqi@0 623 */
aoqi@0 624 public static String printHexBinary( byte[] val ) {
aoqi@0 625 if (theConverter == null) initConverter();
aoqi@0 626 return theConverter.printHexBinary( val );
aoqi@0 627 }
aoqi@0 628
aoqi@0 629 /**
aoqi@0 630 * <p>
aoqi@0 631 * Converts a long value into a string.
aoqi@0 632 * @param val
aoqi@0 633 * A long value
aoqi@0 634 * @return
aoqi@0 635 * A string containing a lexical representation of xsd:unsignedInt
aoqi@0 636 */
aoqi@0 637 public static String printUnsignedInt( long val ) {
aoqi@0 638 if (theConverter == null) initConverter();
aoqi@0 639 return theConverter.printUnsignedInt( val );
aoqi@0 640 }
aoqi@0 641
aoqi@0 642 /**
aoqi@0 643 * <p>
aoqi@0 644 * Converts an int value into a string.
aoqi@0 645 * @param val
aoqi@0 646 * An int value
aoqi@0 647 * @return
aoqi@0 648 * A string containing a lexical representation of xsd:unsignedShort
aoqi@0 649 */
aoqi@0 650 public static String printUnsignedShort( int val ) {
aoqi@0 651 if (theConverter == null) initConverter();
aoqi@0 652 return theConverter.printUnsignedShort( val );
aoqi@0 653 }
aoqi@0 654
aoqi@0 655 /**
aoqi@0 656 * <p>
aoqi@0 657 * Converts a Calendar value into a string.
aoqi@0 658 * @param val
aoqi@0 659 * A Calendar value
aoqi@0 660 * @return
aoqi@0 661 * A string containing a lexical representation of xsd:time
aoqi@0 662 * @throws IllegalArgumentException if <tt>val</tt> is null.
aoqi@0 663 */
aoqi@0 664 public static String printTime( java.util.Calendar val ) {
aoqi@0 665 if (theConverter == null) initConverter();
aoqi@0 666 return theConverter.printTime( val );
aoqi@0 667 }
aoqi@0 668
aoqi@0 669 /**
aoqi@0 670 * <p>
aoqi@0 671 * Converts a Calendar value into a string.
aoqi@0 672 * @param val
aoqi@0 673 * A Calendar value
aoqi@0 674 * @return
aoqi@0 675 * A string containing a lexical representation of xsd:date
aoqi@0 676 * @throws IllegalArgumentException if <tt>val</tt> is null.
aoqi@0 677 */
aoqi@0 678 public static String printDate( java.util.Calendar val ) {
aoqi@0 679 if (theConverter == null) initConverter();
aoqi@0 680 return theConverter.printDate( val );
aoqi@0 681 }
aoqi@0 682
aoqi@0 683 /**
aoqi@0 684 * <p>
aoqi@0 685 * Converts a string value into a string.
aoqi@0 686 * @param val
aoqi@0 687 * A string value
aoqi@0 688 * @return
aoqi@0 689 * A string containing a lexical representation of xsd:AnySimpleType
aoqi@0 690 */
aoqi@0 691 public static String printAnySimpleType( String val ) {
aoqi@0 692 if (theConverter == null) initConverter();
aoqi@0 693 return theConverter.printAnySimpleType( val );
aoqi@0 694 }
aoqi@0 695 }

mercurial