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

changeset 0
373ffda63c9a
child 637
9c07ef4934dd
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/jaxws_classes/javax/xml/bind/DatatypeConverterInterface.java	Wed Apr 27 01:27:09 2016 +0800
     1.3 @@ -0,0 +1,523 @@
     1.4 +/*
     1.5 + * Copyright (c) 2003, 2013, 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 +/**
    1.32 + * <p>
    1.33 + * The DatatypeConverterInterface is for JAXB provider use only. A
    1.34 + * JAXB provider must supply a class that implements this interface.
    1.35 + * JAXB Providers are required to call the
    1.36 + * {@link DatatypeConverter#setDatatypeConverter(DatatypeConverterInterface)
    1.37 + * DatatypeConverter.setDatatypeConverter} api at
    1.38 + * some point before the first marshal or unmarshal operation (perhaps during
    1.39 + * the call to JAXBContext.newInstance).  This step is necessary to configure
    1.40 + * the converter that should be used to perform the print and parse
    1.41 + * functionality.  Calling this api repeatedly will have no effect - the
    1.42 + * DatatypeConverter instance passed into the first invocation is the one that
    1.43 + * will be used from then on.
    1.44 + * </p>
    1.45 + *
    1.46 + * <p>
    1.47 + * This interface defines the parse and print methods. There is one
    1.48 + * parse and print method for each XML schema datatype specified in the
    1.49 + * the default binding Table 5-1 in the JAXB specification.
    1.50 + * </p>
    1.51 + *
    1.52 + * <p>
    1.53 + * The parse and print methods defined here are invoked by the static parse
    1.54 + * and print methods defined in the {@link DatatypeConverter DatatypeConverter}
    1.55 + * class.
    1.56 + * </p>
    1.57 + *
    1.58 + * <p>
    1.59 + * A parse method for a XML schema datatype must be capable of converting any
    1.60 + * lexical representation of the XML schema datatype ( specified by the
    1.61 + * <a href="http://www.w3.org/TR/xmlschema-2/"> XML Schema Part2: Datatypes
    1.62 + * specification</a> into a value in the value space of the XML schema datatype.
    1.63 + * If an error is encountered during conversion, then an IllegalArgumentException
    1.64 + * or a subclass of IllegalArgumentException must be thrown by the method.
    1.65 + *
    1.66 + * </p>
    1.67 + *
    1.68 + * <p>
    1.69 + * A print method for a XML schema datatype can output any lexical
    1.70 + * representation that is valid with respect to the XML schema datatype.
    1.71 + * If an error is encountered during conversion, then an IllegalArgumentException,
    1.72 + * or a subclass of IllegalArgumentException must be thrown by the method.
    1.73 + * </p>
    1.74 + *
    1.75 + * The prefix xsd: is used to refer to XML schema datatypes
    1.76 + * <a href="http://www.w3.org/TR/xmlschema-2/"> XML Schema Part2: Datatypes
    1.77 + * specification.</a>
    1.78 + *
    1.79 + * <p>
    1.80 + * @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.81 + * @see DatatypeConverter
    1.82 + * @see ParseConversionEvent
    1.83 + * @see PrintConversionEvent
    1.84 + * @since JAXB1.0
    1.85 + */
    1.86 +
    1.87 +public interface DatatypeConverterInterface {
    1.88 +    /**
    1.89 +     * <p>
    1.90 +     * Convert the string argument into a string.
    1.91 +     * @param lexicalXSDString
    1.92 +     *     A lexical representation of the XML Schema datatype xsd:string
    1.93 +     * @return
    1.94 +     *     A string that is the same as the input string.
    1.95 +     */
    1.96 +    public String parseString( String lexicalXSDString );
    1.97 +
    1.98 +    /**
    1.99 +     * <p>
   1.100 +     * Convert the string argument into a BigInteger value.
   1.101 +     * @param lexicalXSDInteger
   1.102 +     *     A string containing a lexical representation of
   1.103 +     *     xsd:integer.
   1.104 +     * @return
   1.105 +     *     A BigInteger value represented by the string argument.
   1.106 +     * @throws NumberFormatException <code>lexicalXSDInteger</code> is not a valid string representation of a {@link java.math.BigInteger} value.
   1.107 +     */
   1.108 +    public java.math.BigInteger parseInteger( String lexicalXSDInteger );
   1.109 +
   1.110 +    /**
   1.111 +     * <p>
   1.112 +     * Convert the string argument into an int value.
   1.113 +     * @param lexicalXSDInt
   1.114 +     *     A string containing a lexical representation of
   1.115 +     *     xsd:int.
   1.116 +     * @return
   1.117 +     *     An int value represented byte the string argument.
   1.118 +     * @throws NumberFormatException <code>lexicalXSDInt</code> is not a valid string representation of an <code>int</code> value.
   1.119 +     */
   1.120 +    public int parseInt( String lexicalXSDInt );
   1.121 +
   1.122 +    /**
   1.123 +     * <p>
   1.124 +     * Converts the string argument into a long value.
   1.125 +     * @param lexicalXSDLong
   1.126 +     *     A string containing lexical representation of
   1.127 +     *     xsd:long.
   1.128 +     * @return
   1.129 +     *     A long value represented by the string argument.
   1.130 +     * @throws NumberFormatException <code>lexicalXSDLong</code> is not a valid string representation of a <code>long</code> value.
   1.131 +     */
   1.132 +    public long parseLong( String lexicalXSDLong );
   1.133 +
   1.134 +    /**
   1.135 +     * <p>
   1.136 +     * Converts the string argument into a short value.
   1.137 +     * @param lexicalXSDShort
   1.138 +     *     A string containing lexical representation of
   1.139 +     *     xsd:short.
   1.140 +     * @return
   1.141 +     *     A short value represented by the string argument.
   1.142 +     * @throws NumberFormatException <code>lexicalXSDShort</code> is not a valid string representation of a <code>short</code> value.
   1.143 +     */
   1.144 +    public short parseShort( String lexicalXSDShort );
   1.145 +
   1.146 +    /**
   1.147 +     * <p>
   1.148 +     * Converts the string argument into a BigDecimal value.
   1.149 +     * @param lexicalXSDDecimal
   1.150 +     *     A string containing lexical representation of
   1.151 +     *     xsd:decimal.
   1.152 +     * @return
   1.153 +     *     A BigDecimal value represented by the string argument.
   1.154 +     * @throws NumberFormatException <code>lexicalXSDDecimal</code> is not a valid string representation of {@link java.math.BigDecimal}.
   1.155 +     */
   1.156 +    public java.math.BigDecimal parseDecimal( String lexicalXSDDecimal );
   1.157 +
   1.158 +    /**
   1.159 +     * <p>
   1.160 +     * Converts the string argument into a float value.
   1.161 +     * @param lexicalXSDFloat
   1.162 +     *     A string containing lexical representation of
   1.163 +     *     xsd:float.
   1.164 +     * @return
   1.165 +     *     A float value represented by the string argument.
   1.166 +     * @throws NumberFormatException <code>lexicalXSDFloat</code> is not a valid string representation of a <code>float</code> value.
   1.167 +     */
   1.168 +    public float parseFloat( String lexicalXSDFloat );
   1.169 +
   1.170 +    /**
   1.171 +     * <p>
   1.172 +     * Converts the string argument into a double value.
   1.173 +     * @param lexicalXSDDouble
   1.174 +     *     A string containing lexical representation of
   1.175 +     *     xsd:double.
   1.176 +     * @return
   1.177 +     *     A double value represented by the string argument.
   1.178 +     * @throws NumberFormatException <code>lexicalXSDDouble</code> is not a valid string representation of a <code>double</code> value.
   1.179 +     */
   1.180 +    public double parseDouble( String lexicalXSDDouble );
   1.181 +
   1.182 +    /**
   1.183 +     * <p>
   1.184 +     * Converts the string argument into a boolean value.
   1.185 +     * @param lexicalXSDBoolean
   1.186 +     *     A string containing lexical representation of
   1.187 +     *     xsd:boolean.
   1.188 +     * @return
   1.189 +     *     A boolean value represented by the string argument.
   1.190 +     * @throws IllegalArgumentException if string parameter does not conform to lexical value space defined in XML Schema Part 2: Datatypes for xsd:boolean.
   1.191 +     */
   1.192 +    public boolean parseBoolean( String lexicalXSDBoolean );
   1.193 +
   1.194 +    /**
   1.195 +     * <p>
   1.196 +     * Converts the string argument into a byte value.
   1.197 +     * @param lexicalXSDByte
   1.198 +     *     A string containing lexical representation of
   1.199 +     *     xsd:byte.
   1.200 +     * @return
   1.201 +     *     A byte value represented by the string argument.
   1.202 +     * @throws NumberFormatException <code>lexicalXSDByte</code> does not contain a parseable byte.
   1.203 +     * @throws IllegalArgumentException if string parameter does not conform to lexical value space defined in XML Schema Part 2: Datatypes for xsd:byte.
   1.204 +     */
   1.205 +    public byte parseByte( String lexicalXSDByte );
   1.206 +
   1.207 +    /**
   1.208 +     * <p>
   1.209 +     * Converts the string argument into a QName value.
   1.210 +     *
   1.211 +     * <p>
   1.212 +     * String parameter <tt>lexicalXSDQname</tt> must conform to lexical value space specifed at
   1.213 +     * <a href="http://www.w3.org/TR/xmlschema-2/#QName">XML Schema Part 2:Datatypes specification:QNames</a>
   1.214 +     *
   1.215 +     * @param lexicalXSDQName
   1.216 +     *     A string containing lexical representation of xsd:QName.
   1.217 +     * @param nsc
   1.218 +     *     A namespace context for interpreting a prefix within a QName.
   1.219 +     * @return
   1.220 +     *     A QName value represented by the string argument.
   1.221 +     * @throws IllegalArgumentException  if string parameter does not conform to XML Schema Part 2 specification or
   1.222 +     *      if namespace prefix of <tt>lexicalXSDQname</tt> is not bound to a URI in NamespaceContext <tt>nsc</tt>.
   1.223 +     */
   1.224 +    public javax.xml.namespace.QName parseQName( String lexicalXSDQName,
   1.225 +                                             javax.xml.namespace.NamespaceContext nsc);
   1.226 +
   1.227 +    /**
   1.228 +     * <p>
   1.229 +     * Converts the string argument into a Calendar value.
   1.230 +     * @param lexicalXSDDateTime
   1.231 +     *     A string containing lexical representation of
   1.232 +     *     xsd:datetime.
   1.233 +     * @return
   1.234 +     *     A Calendar object represented by the string argument.
   1.235 +     * @throws IllegalArgumentException if string parameter does not conform to lexical value space defined in XML Schema Part 2: Datatypes for xsd:dateTime.
   1.236 +     */
   1.237 +    public java.util.Calendar parseDateTime( String lexicalXSDDateTime );
   1.238 +
   1.239 +    /**
   1.240 +     * <p>
   1.241 +     * Converts the string argument into an array of bytes.
   1.242 +     * @param lexicalXSDBase64Binary
   1.243 +     *     A string containing lexical representation
   1.244 +     *     of xsd:base64Binary.
   1.245 +     * @return
   1.246 +     *     An array of bytes represented by the string argument.
   1.247 +     * @throws IllegalArgumentException if string parameter does not conform to lexical value space defined in XML Schema Part 2: Datatypes for xsd:base64Binary
   1.248 +     */
   1.249 +    public byte[] parseBase64Binary( String lexicalXSDBase64Binary );
   1.250 +
   1.251 +    /**
   1.252 +     * <p>
   1.253 +     * Converts the string argument into an array of bytes.
   1.254 +     * @param lexicalXSDHexBinary
   1.255 +     *     A string containing lexical representation of
   1.256 +     *     xsd:hexBinary.
   1.257 +     * @return
   1.258 +     *     An array of bytes represented by the string argument.
   1.259 +     * @throws IllegalArgumentException if string parameter does not conform to lexical value space defined in XML Schema Part 2: Datatypes for xsd:hexBinary.
   1.260 +     */
   1.261 +    public byte[] parseHexBinary( String lexicalXSDHexBinary );
   1.262 +
   1.263 +    /**
   1.264 +     * <p>
   1.265 +     * Converts the string argument into a long value.
   1.266 +     * @param lexicalXSDUnsignedInt
   1.267 +     *     A string containing lexical representation
   1.268 +     *     of xsd:unsignedInt.
   1.269 +     * @return
   1.270 +     *     A long value represented by the string argument.
   1.271 +     * @throws NumberFormatException if string parameter can not be parsed into a <tt>long</tt> value.
   1.272 +     */
   1.273 +    public long parseUnsignedInt( String lexicalXSDUnsignedInt );
   1.274 +
   1.275 +    /**
   1.276 +     * <p>
   1.277 +     * Converts the string argument into an int value.
   1.278 +     * @param lexicalXSDUnsignedShort
   1.279 +     *     A string containing lexical
   1.280 +     *     representation of xsd:unsignedShort.
   1.281 +     * @return
   1.282 +     *     An int value represented by the string argument.
   1.283 +     * @throws NumberFormatException if string parameter can not be parsed into an <tt>int</tt> value.
   1.284 +     */
   1.285 +    public int parseUnsignedShort( String lexicalXSDUnsignedShort );
   1.286 +
   1.287 +    /**
   1.288 +     * <p>
   1.289 +     * Converts the string argument into a Calendar value.
   1.290 +     * @param lexicalXSDTime
   1.291 +     *     A string containing lexical representation of
   1.292 +     *     xsd:Time.
   1.293 +     * @return
   1.294 +     *     A Calendar value represented by the string argument.
   1.295 +     * @throws IllegalArgumentException if string parameter does not conform to lexical value space defined in XML Schema Part 2: Datatypes for xsd:Time.
   1.296 +     */
   1.297 +    public java.util.Calendar parseTime( String lexicalXSDTime );
   1.298 +
   1.299 +    /**
   1.300 +     * <p>
   1.301 +     * Converts the string argument into a Calendar value.
   1.302 +     * @param lexicalXSDDate
   1.303 +     *     A string containing lexical representation of
   1.304 +     *     xsd:Date.
   1.305 +     * @return
   1.306 +     *     A Calendar value represented by the string argument.
   1.307 +     * @throws IllegalArgumentException if string parameter does not conform to lexical value space defined in XML Schema Part 2: Datatypes for xsd:Date.
   1.308 +     */
   1.309 +    public java.util.Calendar parseDate( String lexicalXSDDate );
   1.310 +
   1.311 +    /**
   1.312 +     * <p>
   1.313 +     * Return a string containing the lexical representation of the
   1.314 +     * simple type.
   1.315 +     * @param lexicalXSDAnySimpleType
   1.316 +     *     A string containing lexical
   1.317 +     *     representation of the simple type.
   1.318 +     * @return
   1.319 +     *     A string containing the lexical representation of the
   1.320 +     *     simple type.
   1.321 +     */
   1.322 +    public String parseAnySimpleType( String lexicalXSDAnySimpleType );
   1.323 +
   1.324 +    /**
   1.325 +     * <p>
   1.326 +     * Converts the string argument into a string.
   1.327 +     * @param val
   1.328 +     *     A string value.
   1.329 +     * @return
   1.330 +     *     A string containing a lexical representation of xsd:string
   1.331 +     */
   1.332 +    public String printString( String val );
   1.333 +
   1.334 +    /**
   1.335 +     * <p>
   1.336 +     * Converts a BigInteger value into a string.
   1.337 +     * @param val
   1.338 +     *     A BigInteger value
   1.339 +     * @return
   1.340 +     *     A string containing a lexical representation of xsd:integer
   1.341 +     * @throws IllegalArgumentException <tt>val</tt> is null.
   1.342 +     */
   1.343 +    public String printInteger( java.math.BigInteger val );
   1.344 +
   1.345 +    /**
   1.346 +     * <p>
   1.347 +     * Converts an int value into a string.
   1.348 +     * @param val
   1.349 +     *     An int value
   1.350 +     * @return
   1.351 +     *     A string containing a lexical representation of xsd:int
   1.352 +     */
   1.353 +    public String printInt( int val );
   1.354 +
   1.355 +
   1.356 +    /**
   1.357 +     * <p>
   1.358 +     * Converts a long value into a string.
   1.359 +     * @param val
   1.360 +     *     A long value
   1.361 +     * @return
   1.362 +     *     A string containing a lexical representation of xsd:long
   1.363 +     */
   1.364 +    public String printLong( long val );
   1.365 +
   1.366 +    /**
   1.367 +     * <p>
   1.368 +     * Converts a short value into a string.
   1.369 +     * @param val
   1.370 +     *     A short value
   1.371 +     * @return
   1.372 +     *     A string containing a lexical representation of xsd:short
   1.373 +     */
   1.374 +    public String printShort( short val );
   1.375 +
   1.376 +    /**
   1.377 +     * <p>
   1.378 +     * Converts a BigDecimal value into a string.
   1.379 +     * @param val
   1.380 +     *     A BigDecimal value
   1.381 +     * @return
   1.382 +     *     A string containing a lexical representation of xsd:decimal
   1.383 +     * @throws IllegalArgumentException <tt>val</tt> is null.
   1.384 +     */
   1.385 +    public String printDecimal( java.math.BigDecimal val );
   1.386 +
   1.387 +    /**
   1.388 +     * <p>
   1.389 +     * Converts a float value into a string.
   1.390 +     * @param val
   1.391 +     *     A float value
   1.392 +     * @return
   1.393 +     *     A string containing a lexical representation of xsd:float
   1.394 +     */
   1.395 +    public String printFloat( float val );
   1.396 +
   1.397 +    /**
   1.398 +     * <p>
   1.399 +     * Converts a double value into a string.
   1.400 +     * @param val
   1.401 +     *     A double value
   1.402 +     * @return
   1.403 +     *     A string containing a lexical representation of xsd:double
   1.404 +     */
   1.405 +    public String printDouble( double val );
   1.406 +
   1.407 +    /**
   1.408 +     * <p>
   1.409 +     * Converts a boolean value into a string.
   1.410 +     * @param val
   1.411 +     *     A boolean value
   1.412 +     * @return
   1.413 +     *     A string containing a lexical representation of xsd:boolean
   1.414 +     */
   1.415 +    public String printBoolean( boolean val );
   1.416 +
   1.417 +    /**
   1.418 +     * <p>
   1.419 +     * Converts a byte value into a string.
   1.420 +     * @param val
   1.421 +     *     A byte value
   1.422 +     * @return
   1.423 +     *     A string containing a lexical representation of xsd:byte
   1.424 +     */
   1.425 +    public String printByte( byte val );
   1.426 +
   1.427 +    /**
   1.428 +     * <p>
   1.429 +     * Converts a QName instance into a string.
   1.430 +     * @param val
   1.431 +     *     A QName value
   1.432 +     * @param nsc
   1.433 +     *     A namespace context for interpreting a prefix within a QName.
   1.434 +     * @return
   1.435 +     *     A string containing a lexical representation of QName
   1.436 +     * @throws IllegalArgumentException if <tt>val</tt> is null or
   1.437 +     * if <tt>nsc</tt> is non-null or <tt>nsc.getPrefix(nsprefixFromVal)</tt> is null.
   1.438 +     */
   1.439 +    public String printQName( javax.xml.namespace.QName val,
   1.440 +                              javax.xml.namespace.NamespaceContext nsc );
   1.441 +
   1.442 +    /**
   1.443 +     * <p>
   1.444 +     * Converts a Calendar value into a string.
   1.445 +     * @param val
   1.446 +     *     A Calendar value
   1.447 +     * @return
   1.448 +     *     A string containing a lexical representation of xsd:dateTime
   1.449 +     * @throws IllegalArgumentException if <tt>val</tt> is null.
   1.450 +     */
   1.451 +    public String printDateTime( java.util.Calendar val );
   1.452 +
   1.453 +    /**
   1.454 +     * <p>
   1.455 +     * Converts an array of bytes into a string.
   1.456 +     * @param val
   1.457 +     *     an array of bytes
   1.458 +     * @return
   1.459 +     *     A string containing a lexical representation of xsd:base64Binary
   1.460 +     * @throws IllegalArgumentException if <tt>val</tt> is null.
   1.461 +     */
   1.462 +    public String printBase64Binary( byte[] val );
   1.463 +
   1.464 +    /**
   1.465 +     * <p>
   1.466 +     * Converts an array of bytes into a string.
   1.467 +     * @param val
   1.468 +     *     an array of bytes
   1.469 +     * @return
   1.470 +     *     A string containing a lexical representation of xsd:hexBinary
   1.471 +     * @throws IllegalArgumentException if <tt>val</tt> is null.
   1.472 +     */
   1.473 +    public String printHexBinary( byte[] val );
   1.474 +
   1.475 +    /**
   1.476 +     * <p>
   1.477 +     * Converts a long value into a string.
   1.478 +     * @param val
   1.479 +     *     A long value
   1.480 +     * @return
   1.481 +     *     A string containing a lexical representation of xsd:unsignedInt
   1.482 +     */
   1.483 +    public String printUnsignedInt( long val );
   1.484 +
   1.485 +    /**
   1.486 +     * <p>
   1.487 +     * Converts an int value into a string.
   1.488 +     * @param val
   1.489 +     *     An int value
   1.490 +     * @return
   1.491 +     *     A string containing a lexical representation of xsd:unsignedShort
   1.492 +     */
   1.493 +    public String printUnsignedShort( int val );
   1.494 +
   1.495 +    /**
   1.496 +     * <p>
   1.497 +     * Converts a Calendar value into a string.
   1.498 +     * @param val
   1.499 +     *     A Calendar value
   1.500 +     * @return
   1.501 +     *     A string containing a lexical representation of xsd:time
   1.502 +     * @throws IllegalArgumentException if <tt>val</tt> is null.
   1.503 +     */
   1.504 +    public String printTime( java.util.Calendar val );
   1.505 +
   1.506 +    /**
   1.507 +     * <p>
   1.508 +     * Converts a Calendar value into a string.
   1.509 +     * @param val
   1.510 +     *     A Calendar value
   1.511 +     * @return
   1.512 +     *     A string containing a lexical representation of xsd:date
   1.513 +     * @throws IllegalArgumentException if <tt>val</tt> is null.
   1.514 +     */
   1.515 +    public String printDate( java.util.Calendar val );
   1.516 +
   1.517 +    /**
   1.518 +     * <p>
   1.519 +     * Converts a string value into a string.
   1.520 +     * @param val
   1.521 +     *     A string value
   1.522 +     * @return
   1.523 +     *     A string containing a lexical representation of xsd:AnySimpleType
   1.524 +     */
   1.525 +    public String printAnySimpleType( String val );
   1.526 +}

mercurial