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 import java.math.BigInteger; 22 23 /** 24 * Corresponds to the XML Schema 25 * <a target="_blank" href="http://www.w3.org/TR/xmlschema-2/#integer">xs:integer</a> type. 26 * One of the derived types based on <a target="_blank" href="http://www.w3.org/TR/xmlschema-2/#decimal">xs:decimal</a>. 27 * <p> 28 * This type should not be confused with <a target="_blank" href="http://www.w3.org/TR/xmlschema-2/#int">xs:int</a> 29 * or Java {@link Integer}. This type represents an arbitrary-precision integer with 30 * any number of digits, while a Java int or an xs:int is a 32-bit finite-precision integer. 31 * <p> 32 * Convertible to a Java {@link BigInteger}. 33 */ 34 public interface XmlInteger extends XmlDecimal 35 { 36 /** The constant {@link SchemaType} object representing this schema type. */ 37 public static final SchemaType type = XmlBeans.getBuiltinTypeSystem().typeForHandle("_BI_integer"); 38 39 /** Returns this value as a {@link BigInteger} */ 40 BigInteger getBigIntegerValue(); 41 /** Sets this value as a {@link BigInteger} */ 42 void setBigIntegerValue(BigInteger bi); 43 44 /** 45 * Returns this value as a {@link BigInteger} 46 * @deprecated replaced with {@link #getBigIntegerValue} 47 **/ 48 BigInteger bigIntegerValue(); 49 /** 50 * Sets this value as a {@link BigInteger} 51 * @deprecated replaced with {@link #setBigIntegerValue} 52 **/ 53 void set(BigInteger bi); 54 55 /** 56 * A class with methods for creating instances 57 * of {@link XmlInteger}. 58 */ 59 public static final class Factory 60 { 61 /** Creates an empty instance of {@link XmlInteger} */ 62 public static XmlInteger newInstance() { 63 return (XmlInteger) XmlBeans.getContextTypeLoader().newInstance( type, null ); } 64 65 /** Creates an empty instance of {@link XmlInteger} */ 66 public static XmlInteger newInstance(org.apache.xmlbeans.XmlOptions options) { 67 return (XmlInteger) XmlBeans.getContextTypeLoader().newInstance( type, options ); } 68 69 /** Creates an immutable {@link XmlInteger} value */ 70 public static XmlInteger newValue(Object obj) { 71 return (XmlInteger) type.newValue( obj ); } 72 73 /** Parses a {@link XmlInteger} fragment from a String. For example: "<code><xml-fragment>1234567890</xml-fragment></code>". */ 74 public static XmlInteger parse(java.lang.String s) throws org.apache.xmlbeans.XmlException { 75 return (XmlInteger) XmlBeans.getContextTypeLoader().parse( s, type, null ); } 76 77 /** Parses a {@link XmlInteger} fragment from a String. For example: "<code><xml-fragment>1234567890</xml-fragment></code>". */ 78 public static XmlInteger parse(java.lang.String s, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException { 79 return (XmlInteger) XmlBeans.getContextTypeLoader().parse( s, type, options ); } 80 81 /** Parses a {@link XmlInteger} fragment from a File. */ 82 public static XmlInteger parse(java.io.File f) throws org.apache.xmlbeans.XmlException, java.io.IOException { 83 return (XmlInteger) XmlBeans.getContextTypeLoader().parse( f, type, null ); } 84 85 /** Parses a {@link XmlInteger} fragment from a File. */ 86 public static XmlInteger parse(java.io.File f, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException { 87 return (XmlInteger) XmlBeans.getContextTypeLoader().parse( f, type, options ); } 88 89 /** Parses a {@link XmlInteger} fragment from a URL. */ 90 public static XmlInteger parse(java.net.URL u) throws org.apache.xmlbeans.XmlException, java.io.IOException { 91 return (XmlInteger) XmlBeans.getContextTypeLoader().parse( u, type, null ); } 92 93 /** Parses a {@link XmlInteger} fragment from a URL. */ 94 public static XmlInteger parse(java.net.URL u, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException { 95 return (XmlInteger) XmlBeans.getContextTypeLoader().parse( u, type, options ); } 96 97 /** Parses a {@link XmlInteger} fragment from an InputStream. */ 98 public static XmlInteger parse(java.io.InputStream is) throws org.apache.xmlbeans.XmlException, java.io.IOException { 99 return (XmlInteger) XmlBeans.getContextTypeLoader().parse( is, type, null ); } 100 101 /** Parses a {@link XmlInteger} fragment from an InputStream. */ 102 public static XmlInteger parse(java.io.InputStream is, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException { 103 return (XmlInteger) XmlBeans.getContextTypeLoader().parse( is, type, options ); } 104 105 /** Parses a {@link XmlInteger} fragment from a Reader. */ 106 public static XmlInteger parse(java.io.Reader r) throws org.apache.xmlbeans.XmlException, java.io.IOException { 107 return (XmlInteger) XmlBeans.getContextTypeLoader().parse( r, type, null ); } 108 109 /** Parses a {@link XmlInteger} fragment from a Reader. */ 110 public static XmlInteger parse(java.io.Reader r, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException { 111 return (XmlInteger) XmlBeans.getContextTypeLoader().parse( r, type, options ); } 112 113 /** Parses a {@link XmlInteger} fragment from a DOM Node. */ 114 public static XmlInteger parse(org.w3c.dom.Node node) throws org.apache.xmlbeans.XmlException { 115 return (XmlInteger) XmlBeans.getContextTypeLoader().parse( node, type, null ); } 116 117 /** Parses a {@link XmlInteger} fragment from a DOM Node. */ 118 public static XmlInteger parse(org.w3c.dom.Node node, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException { 119 return (XmlInteger) XmlBeans.getContextTypeLoader().parse( node, type, options ); } 120 121 /** Parses a {@link XmlInteger} fragment from an XMLInputStream. 122 * @deprecated XMLInputStream was deprecated by XMLStreamReader from STaX - jsr173 API. 123 */ 124 public static XmlInteger parse(org.apache.xmlbeans.xml.stream.XMLInputStream xis) throws org.apache.xmlbeans.XmlException, org.apache.xmlbeans.xml.stream.XMLStreamException { 125 return (XmlInteger) XmlBeans.getContextTypeLoader().parse( xis, type, null ); } 126 127 /** Parses a {@link XmlInteger} fragment from an XMLInputStream. 128 * @deprecated XMLInputStream was deprecated by XMLStreamReader from STaX - jsr173 API. 129 */ 130 public static XmlInteger parse(org.apache.xmlbeans.xml.stream.XMLInputStream xis, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, org.apache.xmlbeans.xml.stream.XMLStreamException { 131 return (XmlInteger) XmlBeans.getContextTypeLoader().parse( xis, type, options ); } 132 133 /** Parses a {@link XmlInteger} fragment from an XMLStreamReader. */ 134 public static XmlInteger parse(javax.xml.stream.XMLStreamReader xsr) throws org.apache.xmlbeans.XmlException { 135 return (XmlInteger) XmlBeans.getContextTypeLoader().parse( xsr, type, null ); } 136 137 /** Parses a {@link XmlInteger} fragment from an XMLStreamReader. */ 138 public static XmlInteger parse(javax.xml.stream.XMLStreamReader xsr, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException{ 139 return (XmlInteger) XmlBeans.getContextTypeLoader().parse( xsr, type, options ); } 140 141 /** Returns a validating XMLInputStream. 142 * @deprecated XMLInputStream was deprecated by XMLStreamReader from STaX - jsr173 API. 143 */ 144 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 { 145 return XmlBeans.getContextTypeLoader().newValidatingXMLInputStream( xis, type, null ); } 146 147 /** Returns a validating XMLInputStream. 148 * @deprecated XMLInputStream was deprecated by XMLStreamReader from STaX - jsr173 API. 149 */ 150 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 { 151 return XmlBeans.getContextTypeLoader().newValidatingXMLInputStream( xis, type, options ); } 152 153 private Factory() { } // No instance of this class allowed 154 } 155 } 156