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/#duration">xs:duration</a> type. 24 * <p> 25 * Convertible to a {@link GDuration}. 26 * 27 * @see GDuration 28 */ 29 public interface XmlDuration extends XmlAnySimpleType 30 { 31 /** The constant {@link SchemaType} object representing this schema type. */ 32 public static final SchemaType type = XmlBeans.getBuiltinTypeSystem().typeForHandle("_BI_duration"); 33 34 /** Returns this value as a {@link GDuration} */ 35 GDuration getGDurationValue(); 36 /** Sets this value as a {@link GDuration} */ 37 void setGDurationValue(GDuration gd); 38 39 /** 40 * Returns this value as a {@link GDuration} 41 * @deprecated replaced with {@link #getGDurationValue} 42 **/ 43 GDuration gDurationValue(); 44 /** 45 * Sets this value as a {@link GDuration} 46 * @deprecated replaced with {@link #setGDurationValue} 47 **/ 48 void set(GDurationSpecification gd); 49 50 /** 51 * A class with methods for creating instances 52 * of {@link XmlDuration}. 53 */ 54 public static final class Factory 55 { 56 /** Creates an empty instance of {@link XmlDuration} */ 57 public static XmlDuration newInstance() { 58 return (XmlDuration) XmlBeans.getContextTypeLoader().newInstance( type, null ); } 59 60 /** Creates an empty instance of {@link XmlDuration} */ 61 public static XmlDuration newInstance(org.apache.xmlbeans.XmlOptions options) { 62 return (XmlDuration) XmlBeans.getContextTypeLoader().newInstance( type, options ); } 63 64 /** Creates an immutable {@link XmlDuration} value */ 65 public static XmlDuration newValue(Object obj) { 66 return (XmlDuration) type.newValue( obj ); } 67 68 /** Parses a {@link XmlDuration} fragment from a String. For example: "<code><xml-fragment>P1Y2MT2H</xml-fragment></code>". */ 69 public static XmlDuration parse(java.lang.String s) throws org.apache.xmlbeans.XmlException { 70 return (XmlDuration) XmlBeans.getContextTypeLoader().parse( s, type, null ); } 71 72 /** Parses a {@link XmlDuration} fragment from a String. For example: "<code><xml-fragment>P1Y2MT2H</xml-fragment></code>". */ 73 public static XmlDuration parse(java.lang.String s, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException { 74 return (XmlDuration) XmlBeans.getContextTypeLoader().parse( s, type, options ); } 75 76 /** Parses a {@link XmlDuration} fragment from a File. */ 77 public static XmlDuration parse(java.io.File f) throws org.apache.xmlbeans.XmlException, java.io.IOException { 78 return (XmlDuration) XmlBeans.getContextTypeLoader().parse( f, type, null ); } 79 80 /** Parses a {@link XmlDuration} fragment from a File. */ 81 public static XmlDuration parse(java.io.File f, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException { 82 return (XmlDuration) XmlBeans.getContextTypeLoader().parse( f, type, options ); } 83 84 /** Parses a {@link XmlDuration} fragment from a URL. */ 85 public static XmlDuration parse(java.net.URL u) throws org.apache.xmlbeans.XmlException, java.io.IOException { 86 return (XmlDuration) XmlBeans.getContextTypeLoader().parse( u, type, null ); } 87 88 /** Parses a {@link XmlDuration} fragment from a URL. */ 89 public static XmlDuration parse(java.net.URL u, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException { 90 return (XmlDuration) XmlBeans.getContextTypeLoader().parse( u, type, options ); } 91 92 /** Parses a {@link XmlDuration} fragment from an InputStream. */ 93 public static XmlDuration parse(java.io.InputStream is) throws org.apache.xmlbeans.XmlException, java.io.IOException { 94 return (XmlDuration) XmlBeans.getContextTypeLoader().parse( is, type, null ); } 95 96 /** Parses a {@link XmlDuration} fragment from an InputStream. */ 97 public static XmlDuration parse(java.io.InputStream is, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException { 98 return (XmlDuration) XmlBeans.getContextTypeLoader().parse( is, type, options ); } 99 100 /** Parses a {@link XmlDuration} fragment from a Reader. */ 101 public static XmlDuration parse(java.io.Reader r) throws org.apache.xmlbeans.XmlException, java.io.IOException { 102 return (XmlDuration) XmlBeans.getContextTypeLoader().parse( r, type, null ); } 103 104 /** Parses a {@link XmlDuration} fragment from a Reader. */ 105 public static XmlDuration parse(java.io.Reader r, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException { 106 return (XmlDuration) XmlBeans.getContextTypeLoader().parse( r, type, options ); } 107 108 /** Parses a {@link XmlDuration} fragment from a DOM Node. */ 109 public static XmlDuration parse(org.w3c.dom.Node node) throws org.apache.xmlbeans.XmlException { 110 return (XmlDuration) XmlBeans.getContextTypeLoader().parse( node, type, null ); } 111 112 /** Parses a {@link XmlDuration} fragment from a DOM Node. */ 113 public static XmlDuration parse(org.w3c.dom.Node node, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException { 114 return (XmlDuration) XmlBeans.getContextTypeLoader().parse( node, type, options ); } 115 116 /** Parses a {@link XmlDuration} fragment from an XMLInputStream. 117 * @deprecated XMLInputStream was deprecated by XMLStreamReader from STaX - jsr173 API. 118 */ 119 public static XmlDuration parse(org.apache.xmlbeans.xml.stream.XMLInputStream xis) throws org.apache.xmlbeans.XmlException, org.apache.xmlbeans.xml.stream.XMLStreamException { 120 return (XmlDuration) XmlBeans.getContextTypeLoader().parse( xis, type, null ); } 121 122 /** Parses a {@link XmlDuration} fragment from an XMLInputStream. 123 * @deprecated XMLInputStream was deprecated by XMLStreamReader from STaX - jsr173 API. 124 */ 125 public static XmlDuration parse(org.apache.xmlbeans.xml.stream.XMLInputStream xis, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, org.apache.xmlbeans.xml.stream.XMLStreamException { 126 return (XmlDuration) XmlBeans.getContextTypeLoader().parse( xis, type, options ); } 127 128 /** Parses a {@link XmlDuration} fragment from an XMLStreamReader. */ 129 public static XmlDuration parse(javax.xml.stream.XMLStreamReader xsr) throws org.apache.xmlbeans.XmlException { 130 return (XmlDuration) XmlBeans.getContextTypeLoader().parse( xsr, type, null ); } 131 132 /** Parses a {@link XmlDuration} fragment from an XMLStreamReader. */ 133 public static XmlDuration parse(javax.xml.stream.XMLStreamReader xsr, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException{ 134 return (XmlDuration) XmlBeans.getContextTypeLoader().parse( xsr, type, options ); } 135 136 /** Returns a validating XMLInputStream. 137 * @deprecated XMLInputStream was deprecated by XMLStreamReader from STaX - jsr173 API. 138 */ 139 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 { 140 return XmlBeans.getContextTypeLoader().newValidatingXMLInputStream( xis, type, null ); } 141 142 /** Returns a validating XMLInputStream. 143 * @deprecated XMLInputStream was deprecated by XMLStreamReader from STaX - jsr173 API. 144 */ 145 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 { 146 return XmlBeans.getContextTypeLoader().newValidatingXMLInputStream( xis, type, options ); } 147 148 private Factory() { } // No instance of this class allowed 149 } 150 } 151