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

Tue, 07 Nov 2017 18:54:04 -0800

author
asaha
date
Tue, 07 Nov 2017 18:54:04 -0800
changeset 1528
f453f4eaf8b4
parent 397
b99d7e355d4b
child 637
9c07ef4934dd
permissions
-rw-r--r--

Added tag jdk8u162-b06 for changeset 6095742f8034

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

mercurial