Home » xmlbeans-2.5.0-src » org.apache » xmlbeans » [javadoc | source]

    1   /*   Copyright 2004 The Apache Software Foundation
    2    *
    3    *   Licensed under the Apache License, Version 2.0 (the "License");
    4    *   you may not use this file except in compliance with the License.
    5    *   You may obtain a copy of the License at
    6    *
    7    *       http://www.apache.org/licenses/LICENSE-2.0
    8    *
    9    *   Unless required by applicable law or agreed to in writing, software
   10    *   distributed under the License is distributed on an "AS IS" BASIS,
   11    *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   12    *   See the License for the specific language governing permissions and
   13    *  limitations under the License.
   14    */
   15   
   16   package org.apache.xmlbeans;
   17   
   18   import javax.xml.stream.XMLStreamReader;
   19   
   20   
   21   /**
   22    * Corresponds to the XML Schema
   23    * <a target="_blank" href="http://www.w3.org/TR/xmlschema-2/#token">xs:token</a> type.
   24    * One of the derived types based on <a target="_blank" href="http://www.w3.org/TR/xmlschema-2/#string">xs:string</a>.
   25    * <p>
   26    * A token is XML's best representation for a "whitespace insensitive string."
   27    * All carriage returns, linefeeds, and tabs are converted to ordinary space
   28    * characters (as with <a target="_blank" href="http://www.w3.org/TR/xmlschema-2/#normalizedString">xs:normalizedString</a>),
   29    * and furthermore, all contiguous runs of space are collapsed to single spaces,
   30    * and leading and trailing spaces are trimmed.
   31    * <p>
   32    * If you want <code>"&nbsp;&nbsp;high&nbsp;&nbsp;priority&nbsp;&nbsp;"</code>
   33    * to be equivalent to <code>"high priority"</code>, you should consider
   34    * using xs:token or a subtype of xs:token.
   35    * <p>
   36    * When the {@link #stringValue} is obtained from an XmlToken, the normalized,
   37    * trimmed, whitespace collapsed value is returned.
   38    * <p>
   39    * Convertible to {@link String}.
   40    */ 
   41   public interface XmlToken extends XmlNormalizedString
   42   {
   43       /** The constant {@link SchemaType} object representing this schema type. */
   44       public static final SchemaType type = XmlBeans.getBuiltinTypeSystem().typeForHandle("_BI_token");
   45       
   46       /**
   47        * A class with methods for creating instances
   48        * of {@link XmlToken}.
   49        */
   50       public static final class Factory
   51       {
   52           /** Creates an empty instance of {@link XmlToken} */
   53           public static XmlToken newInstance() {
   54             return (XmlToken) XmlBeans.getContextTypeLoader().newInstance( type, null ); }
   55           
   56           /** Creates an empty instance of {@link XmlToken} */
   57           public static XmlToken newInstance(org.apache.xmlbeans.XmlOptions options) {
   58             return (XmlToken) XmlBeans.getContextTypeLoader().newInstance( type, options ); }
   59           
   60           /** Creates an immutable {@link XmlToken} value */
   61           public static XmlToken newValue(Object obj) {
   62             return (XmlToken) type.newValue( obj ); }
   63           
   64           /** Parses a {@link XmlToken} fragment from a String. For example: "<code>&lt;xml-fragment&gt;string to collapse&lt;/xml-fragment&gt;</code>". */
   65           public static XmlToken parse(java.lang.String s) throws org.apache.xmlbeans.XmlException {
   66             return (XmlToken) XmlBeans.getContextTypeLoader().parse( s, type, null ); }
   67           
   68           /** Parses a {@link XmlToken} fragment from a String. For example: "<code>&lt;xml-fragment&gt;string to collapse&lt;/xml-fragment&gt;</code>". */
   69           public static XmlToken parse(java.lang.String s, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
   70             return (XmlToken) XmlBeans.getContextTypeLoader().parse( s, type, options ); }
   71           
   72           /** Parses a {@link XmlToken} fragment from a File. */
   73           public static XmlToken parse(java.io.File f) throws org.apache.xmlbeans.XmlException, java.io.IOException {
   74             return (XmlToken) XmlBeans.getContextTypeLoader().parse( f, type, null ); }
   75           
   76           /** Parses a {@link XmlToken} fragment from a File. */
   77           public static XmlToken parse(java.io.File f, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
   78             return (XmlToken) XmlBeans.getContextTypeLoader().parse( f, type, options ); }
   79           
   80           /** Parses a {@link XmlToken} fragment from a URL. */
   81           public static XmlToken parse(java.net.URL u) throws org.apache.xmlbeans.XmlException, java.io.IOException {
   82             return (XmlToken) XmlBeans.getContextTypeLoader().parse( u, type, null ); }
   83   
   84           /** Parses a {@link XmlToken} fragment from a URL. */
   85           public static XmlToken parse(java.net.URL u, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
   86             return (XmlToken) XmlBeans.getContextTypeLoader().parse( u, type, options ); }
   87   
   88           /** Parses a {@link XmlToken} fragment from an InputStream. */
   89           public static XmlToken parse(java.io.InputStream is) throws org.apache.xmlbeans.XmlException, java.io.IOException {
   90             return (XmlToken) XmlBeans.getContextTypeLoader().parse( is, type, null ); }
   91           
   92           /** Parses a {@link XmlToken} fragment from an InputStream. */
   93           public static XmlToken parse(java.io.InputStream is, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
   94             return (XmlToken) XmlBeans.getContextTypeLoader().parse( is, type, options ); }
   95           
   96           /** Parses a {@link XmlToken} fragment from a Reader. */
   97           public static XmlToken parse(java.io.Reader r) throws org.apache.xmlbeans.XmlException, java.io.IOException {
   98             return (XmlToken) XmlBeans.getContextTypeLoader().parse( r, type, null ); }
   99           
  100           /** Parses a {@link XmlToken} fragment from a Reader. */
  101           public static XmlToken parse(java.io.Reader r, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
  102             return (XmlToken) XmlBeans.getContextTypeLoader().parse( r, type, options ); }
  103           
  104           /** Parses a {@link XmlToken} fragment from a DOM Node. */
  105           public static XmlToken parse(org.w3c.dom.Node node) throws org.apache.xmlbeans.XmlException {
  106             return (XmlToken) XmlBeans.getContextTypeLoader().parse( node, type, null ); }
  107           
  108           /** Parses a {@link XmlToken} fragment from a DOM Node. */
  109           public static XmlToken parse(org.w3c.dom.Node node, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
  110             return (XmlToken) XmlBeans.getContextTypeLoader().parse( node, type, options ); }
  111           
  112           /** Parses a {@link XmlToken} fragment from an XMLInputStream.
  113            * @deprecated XMLInputStream was deprecated by XMLStreamReader from STaX - jsr173 API.
  114            */
  115           public static XmlToken parse(org.apache.xmlbeans.xml.stream.XMLInputStream xis) throws org.apache.xmlbeans.XmlException, org.apache.xmlbeans.xml.stream.XMLStreamException {
  116             return (XmlToken) XmlBeans.getContextTypeLoader().parse( xis, type, null ); }
  117           
  118           /** Parses a {@link XmlToken} fragment from an XMLInputStream.
  119            * @deprecated XMLInputStream was deprecated by XMLStreamReader from STaX - jsr173 API.
  120            */
  121           public static XmlToken parse(org.apache.xmlbeans.xml.stream.XMLInputStream xis, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, org.apache.xmlbeans.xml.stream.XMLStreamException {
  122             return (XmlToken) XmlBeans.getContextTypeLoader().parse( xis, type, options ); }
  123           
  124           /** Parses a {@link XmlToken} fragment from an XMLStreamReader. */
  125           public static XmlToken parse(javax.xml.stream.XMLStreamReader xsr) throws org.apache.xmlbeans.XmlException {
  126             return (XmlToken) XmlBeans.getContextTypeLoader().parse( xsr, type, null ); }
  127           
  128           /** Parses a {@link XmlToken} fragment from an XMLStreamReader. */
  129           public static XmlToken parse(javax.xml.stream.XMLStreamReader xsr, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException{
  130             return (XmlToken) XmlBeans.getContextTypeLoader().parse( xsr, type, options ); }
  131           
  132           /** Returns a validating XMLInputStream.
  133            * @deprecated XMLInputStream was deprecated by XMLStreamReader from STaX - jsr173 API.
  134            */
  135           public static org.apache.xmlbeans.xml.stream.XMLInputStream newValidatingXMLInputStream(org.apache.xmlbeans.xml.stream.XMLInputStream xis) throws org.apache.xmlbeans.XmlException, org.apache.xmlbeans.xml.stream.XMLStreamException {
  136             return XmlBeans.getContextTypeLoader().newValidatingXMLInputStream( xis, type, null ); }
  137           
  138           /** Returns a validating XMLInputStream.
  139            * @deprecated XMLInputStream was deprecated by XMLStreamReader from STaX - jsr173 API.
  140            */
  141           public static org.apache.xmlbeans.xml.stream.XMLInputStream newValidatingXMLInputStream(org.apache.xmlbeans.xml.stream.XMLInputStream xis, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, org.apache.xmlbeans.xml.stream.XMLStreamException {
  142             return XmlBeans.getContextTypeLoader().newValidatingXMLInputStream( xis, type, options ); }
  143           
  144           private Factory() { } // No instance of this class allowed
  145       }
  146   }
  147   

Home » xmlbeans-2.5.0-src » org.apache » xmlbeans » [javadoc | source]