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/#NMTOKEN">xs:NMTOKEN</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 * An NMTOKEN is XML's closest concept to an "identifier"; for example, 27 * it does not permit spaces and only limited punctuation. So NMTOKEN is 28 * commonly used to describe a single token or enumerated string value. 29 * <p> 30 * Convertible to {@link String}. 31 */ 32 public interface XmlNMTOKEN extends XmlToken 33 { 34 /** The constant {@link SchemaType} object representing this schema type. */ 35 public static final SchemaType type = XmlBeans.getBuiltinTypeSystem().typeForHandle("_BI_NMTOKEN"); 36 37 /** 38 * A class with methods for creating instances 39 * of {@link XmlNMTOKEN}. 40 */ 41 public static final class Factory 42 { 43 /** Creates an empty instance of {@link XmlNMTOKEN} */ 44 public static XmlNMTOKEN newInstance() { 45 return (XmlNMTOKEN) XmlBeans.getContextTypeLoader().newInstance( type, null ); } 46 47 /** Creates an empty instance of {@link XmlNMTOKEN} */ 48 public static XmlNMTOKEN newInstance(org.apache.xmlbeans.XmlOptions options) { 49 return (XmlNMTOKEN) XmlBeans.getContextTypeLoader().newInstance( type, options ); } 50 51 /** Creates an immutable {@link XmlNMTOKEN} value */ 52 public static XmlNMTOKEN newValue(Object obj) { 53 return (XmlNMTOKEN) type.newValue( obj ); } 54 55 /** Parses a {@link XmlNMTOKEN} fragment from a String. For example: "<code><xml-fragment>sample-1.2</xml-fragment></code>". */ 56 public static XmlNMTOKEN parse(java.lang.String s) throws org.apache.xmlbeans.XmlException { 57 return (XmlNMTOKEN) XmlBeans.getContextTypeLoader().parse( s, type, null ); } 58 59 /** Parses a {@link XmlNMTOKEN} fragment from a String. For example: "<code><xml-fragment>sample-1.2</xml-fragment></code>". */ 60 public static XmlNMTOKEN parse(java.lang.String s, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException { 61 return (XmlNMTOKEN) XmlBeans.getContextTypeLoader().parse( s, type, options ); } 62 63 /** Parses a {@link XmlNMTOKEN} fragment from a File. */ 64 public static XmlNMTOKEN parse(java.io.File f) throws org.apache.xmlbeans.XmlException, java.io.IOException { 65 return (XmlNMTOKEN) XmlBeans.getContextTypeLoader().parse( f, type, null ); } 66 67 /** Parses a {@link XmlNMTOKEN} fragment from a File. */ 68 public static XmlNMTOKEN parse(java.io.File f, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException { 69 return (XmlNMTOKEN) XmlBeans.getContextTypeLoader().parse( f, type, options ); } 70 71 /** Parses a {@link XmlNMTOKEN} fragment from a URL. */ 72 public static XmlNMTOKEN parse(java.net.URL u) throws org.apache.xmlbeans.XmlException, java.io.IOException { 73 return (XmlNMTOKEN) XmlBeans.getContextTypeLoader().parse( u, type, null ); } 74 75 /** Parses a {@link XmlNMTOKEN} fragment from a URL. */ 76 public static XmlNMTOKEN parse(java.net.URL u, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException { 77 return (XmlNMTOKEN) XmlBeans.getContextTypeLoader().parse( u, type, options ); } 78 79 /** Parses a {@link XmlNMTOKEN} fragment from an InputStream. */ 80 public static XmlNMTOKEN parse(java.io.InputStream is) throws org.apache.xmlbeans.XmlException, java.io.IOException { 81 return (XmlNMTOKEN) XmlBeans.getContextTypeLoader().parse( is, type, null ); } 82 83 /** Parses a {@link XmlNMTOKEN} fragment from an InputStream. */ 84 public static XmlNMTOKEN parse(java.io.InputStream is, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException { 85 return (XmlNMTOKEN) XmlBeans.getContextTypeLoader().parse( is, type, options ); } 86 87 /** Parses a {@link XmlNMTOKEN} fragment from a Reader. */ 88 public static XmlNMTOKEN parse(java.io.Reader r) throws org.apache.xmlbeans.XmlException, java.io.IOException { 89 return (XmlNMTOKEN) XmlBeans.getContextTypeLoader().parse( r, type, null ); } 90 91 /** Parses a {@link XmlNMTOKEN} fragment from a Reader. */ 92 public static XmlNMTOKEN parse(java.io.Reader r, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException { 93 return (XmlNMTOKEN) XmlBeans.getContextTypeLoader().parse( r, type, options ); } 94 95 /** Parses a {@link XmlNMTOKEN} fragment from a DOM Node. */ 96 public static XmlNMTOKEN parse(org.w3c.dom.Node node) throws org.apache.xmlbeans.XmlException { 97 return (XmlNMTOKEN) XmlBeans.getContextTypeLoader().parse( node, type, null ); } 98 99 /** Parses a {@link XmlNMTOKEN} fragment from a DOM Node. */ 100 public static XmlNMTOKEN parse(org.w3c.dom.Node node, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException { 101 return (XmlNMTOKEN) XmlBeans.getContextTypeLoader().parse( node, type, options ); } 102 103 /** Parses a {@link XmlNMTOKEN} fragment from an XMLInputStream. 104 * @deprecated XMLInputStream was deprecated by XMLStreamReader from STaX - jsr173 API. 105 */ 106 public static XmlNMTOKEN parse(org.apache.xmlbeans.xml.stream.XMLInputStream xis) throws org.apache.xmlbeans.XmlException, org.apache.xmlbeans.xml.stream.XMLStreamException { 107 return (XmlNMTOKEN) XmlBeans.getContextTypeLoader().parse( xis, type, null ); } 108 109 /** Parses a {@link XmlNMTOKEN} fragment from an XMLInputStream. 110 * @deprecated XMLInputStream was deprecated by XMLStreamReader from STaX - jsr173 API. 111 */ 112 public static XmlNMTOKEN parse(org.apache.xmlbeans.xml.stream.XMLInputStream xis, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, org.apache.xmlbeans.xml.stream.XMLStreamException { 113 return (XmlNMTOKEN) XmlBeans.getContextTypeLoader().parse( xis, type, options ); } 114 115 /** Parses a {@link XmlNMTOKEN} fragment from an XMLStreamReader. */ 116 public static XmlNMTOKEN parse(javax.xml.stream.XMLStreamReader xsr) throws org.apache.xmlbeans.XmlException { 117 return (XmlNMTOKEN) XmlBeans.getContextTypeLoader().parse( xsr, type, null ); } 118 119 /** Parses a {@link XmlNMTOKEN} fragment from an XMLStreamReader. */ 120 public static XmlNMTOKEN parse(javax.xml.stream.XMLStreamReader xsr, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException{ 121 return (XmlNMTOKEN) XmlBeans.getContextTypeLoader().parse( xsr, type, options ); } 122 123 /** Returns a validating XMLInputStream. 124 * @deprecated XMLInputStream was deprecated by XMLStreamReader from STaX - jsr173 API. 125 */ 126 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 { 127 return XmlBeans.getContextTypeLoader().newValidatingXMLInputStream( xis, type, null ); } 128 129 /** Returns a validating XMLInputStream. 130 * @deprecated XMLInputStream was deprecated by XMLStreamReader from STaX - jsr173 API. 131 */ 132 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 { 133 return XmlBeans.getContextTypeLoader().newValidatingXMLInputStream( xis, type, options ); } 134 135 private Factory() { } // No instance of this class allowed 136 } 137 } 138