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