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.util.Calendar; 22 23 24 /** 25 * Corresponds to the XML Schema 26 * <a target="_blank" href="http://www.w3.org/TR/xmlschema-2/#time">xs:time</a> type. 27 * A gDay specifies only a day-of-month. 28 * <p> 29 * Convertible to {@link Calendar} or {@link GDate}. 30 * 31 * @see XmlCalendar 32 * @see GDate 33 */ 34 public interface XmlTime extends XmlAnySimpleType 35 { 36 /** The constant {@link SchemaType} object representing this schema type. */ 37 public static final SchemaType type = XmlBeans.getBuiltinTypeSystem().typeForHandle("_BI_time"); 38 39 /** Returns this value as a {@link Calendar} */ 40 Calendar getCalendarValue(); 41 /** Sets this value as a {@link Calendar} */ 42 void setCalendarValue(Calendar c); 43 /** Returns this value as a {@link GDate} */ 44 GDate getGDateValue(); 45 /** Sets this value as a {@link GDateSpecification} */ 46 void setGDateValue(GDate gd); 47 48 /** 49 * Returns this value as a {@link Calendar} 50 * @deprecated replaced with {@link #getCalendarValue} 51 **/ 52 Calendar calendarValue(); 53 /** 54 * Sets this value as a {@link Calendar} 55 * @deprecated replaced with {@link #setCalendarValue} 56 **/ 57 void set(Calendar c); 58 /** 59 * Returns this value as a {@link GDate} 60 * @deprecated replaced with {@link #getGDateValue} 61 **/ 62 GDate gDateValue(); 63 /** 64 * Sets this value as a {@link GDateSpecification} 65 * @deprecated replaced with {@link #setGDateValue} 66 **/ 67 void set(GDateSpecification gd); 68 69 70 /** 71 * A class with methods for creating instances 72 * of {@link XmlTime}. 73 */ 74 public static final class Factory 75 { 76 /** Creates an empty instance of {@link XmlTime} */ 77 public static XmlTime newInstance() { 78 return (XmlTime) XmlBeans.getContextTypeLoader().newInstance( type, null ); } 79 80 /** Creates an empty instance of {@link XmlTime} */ 81 public static XmlTime newInstance(org.apache.xmlbeans.XmlOptions options) { 82 return (XmlTime) XmlBeans.getContextTypeLoader().newInstance( type, options ); } 83 84 /** Creates an immutable {@link XmlTime} value */ 85 public static XmlTime newValue(Object obj) { 86 return (XmlTime) type.newValue( obj ); } 87 88 /** Parses a {@link XmlTime} fragment from a String. For example: "<code><xml-fragment>12:00:00</xml-fragment></code>". */ 89 public static XmlTime parse(java.lang.String s) throws org.apache.xmlbeans.XmlException { 90 return (XmlTime) XmlBeans.getContextTypeLoader().parse( s, type, null ); } 91 92 /** Parses a {@link XmlTime} fragment from a String. For example: "<code><xml-fragment>12:00:00</xml-fragment></code>". */ 93 public static XmlTime parse(java.lang.String s, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException { 94 return (XmlTime) XmlBeans.getContextTypeLoader().parse( s, type, options ); } 95 96 /** Parses a {@link XmlTime} fragment from a File. */ 97 public static XmlTime parse(java.io.File f) throws org.apache.xmlbeans.XmlException, java.io.IOException { 98 return (XmlTime) XmlBeans.getContextTypeLoader().parse( f, type, null ); } 99 100 /** Parses a {@link XmlTime} fragment from a File. */ 101 public static XmlTime parse(java.io.File f, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException { 102 return (XmlTime) XmlBeans.getContextTypeLoader().parse( f, type, options ); } 103 104 /** Parses a {@link XmlTime} fragment from a URL. */ 105 public static XmlTime parse(java.net.URL u) throws org.apache.xmlbeans.XmlException, java.io.IOException { 106 return (XmlTime) XmlBeans.getContextTypeLoader().parse( u, type, null ); } 107 108 /** Parses a {@link XmlTime} fragment from a URL. */ 109 public static XmlTime parse(java.net.URL u, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException { 110 return (XmlTime) XmlBeans.getContextTypeLoader().parse( u, type, options ); } 111 112 /** Parses a {@link XmlTime} fragment from an InputStream. */ 113 public static XmlTime parse(java.io.InputStream is) throws org.apache.xmlbeans.XmlException, java.io.IOException { 114 return (XmlTime) XmlBeans.getContextTypeLoader().parse( is, type, null ); } 115 116 /** Parses a {@link XmlTime} fragment from an InputStream. */ 117 public static XmlTime parse(java.io.InputStream is, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException { 118 return (XmlTime) XmlBeans.getContextTypeLoader().parse( is, type, options ); } 119 120 /** Parses a {@link XmlTime} fragment from a Reader. */ 121 public static XmlTime parse(java.io.Reader r) throws org.apache.xmlbeans.XmlException, java.io.IOException { 122 return (XmlTime) XmlBeans.getContextTypeLoader().parse( r, type, null ); } 123 124 /** Parses a {@link XmlTime} fragment from a Reader. */ 125 public static XmlTime parse(java.io.Reader r, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException { 126 return (XmlTime) XmlBeans.getContextTypeLoader().parse( r, type, options ); } 127 128 /** Parses a {@link XmlTime} fragment from a DOM Node. */ 129 public static XmlTime parse(org.w3c.dom.Node node) throws org.apache.xmlbeans.XmlException { 130 return (XmlTime) XmlBeans.getContextTypeLoader().parse( node, type, null ); } 131 132 /** Parses a {@link XmlTime} fragment from a DOM Node. */ 133 public static XmlTime parse(org.w3c.dom.Node node, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException { 134 return (XmlTime) XmlBeans.getContextTypeLoader().parse( node, type, options ); } 135 136 /** Parses a {@link XmlTime} fragment from an XMLInputStream. 137 * @deprecated XMLInputStream was deprecated by XMLStreamReader from STaX - jsr173 API. 138 */ 139 public static XmlTime parse(org.apache.xmlbeans.xml.stream.XMLInputStream xis) throws org.apache.xmlbeans.XmlException, org.apache.xmlbeans.xml.stream.XMLStreamException { 140 return (XmlTime) XmlBeans.getContextTypeLoader().parse( xis, type, null ); } 141 142 /** Parses a {@link XmlTime} fragment from an XMLInputStream. 143 * @deprecated XMLInputStream was deprecated by XMLStreamReader from STaX - jsr173 API. 144 */ 145 public static XmlTime parse(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 (XmlTime) XmlBeans.getContextTypeLoader().parse( xis, type, options ); } 147 148 /** Parses a {@link XmlTime} fragment from an XMLStreamReader. */ 149 public static XmlTime parse(javax.xml.stream.XMLStreamReader xsr) throws org.apache.xmlbeans.XmlException { 150 return (XmlTime) XmlBeans.getContextTypeLoader().parse( xsr, type, null ); } 151 152 /** Parses a {@link XmlTime} fragment from an XMLStreamReader. */ 153 public static XmlTime parse(javax.xml.stream.XMLStreamReader xsr, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException{ 154 return (XmlTime) XmlBeans.getContextTypeLoader().parse( xsr, type, options ); } 155 156 /** Returns a validating XMLInputStream. 157 * @deprecated XMLInputStream was deprecated by XMLStreamReader from STaX - jsr173 API. 158 */ 159 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 { 160 return XmlBeans.getContextTypeLoader().newValidatingXMLInputStream( xis, type, null ); } 161 162 /** Returns a validating XMLInputStream. 163 * @deprecated XMLInputStream was deprecated by XMLStreamReader from STaX - jsr173 API. 164 */ 165 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 { 166 return XmlBeans.getContextTypeLoader().newValidatingXMLInputStream( xis, type, options ); } 167 168 private Factory() { } // No instance of this class allowed 169 } 170 } 171