001: /*
002: * Copyright (c) 1998-2006 Caucho Technology -- all rights reserved
003: *
004: * This file is part of Resin(R) Open Source
005: *
006: * Each copy or derived work must preserve the copyright notice and this
007: * notice unmodified.
008: *
009: * Resin Open Source is free software; you can redistribute it and/or modify
010: * it under the terms of the GNU General Public License as published by
011: * the Free Software Foundation; either version 2 of the License, or
012: * (at your option) any later version.
013: *
014: * Resin Open Source is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017: * of NON-INFRINGEMENT. See the GNU General Public License for more
018: * details.
019: *
020: * You should have received a copy of the GNU General Public License
021: * along with Resin Open Source; if not, write to the
022: *
023: * Free Software Foundation, Inc.
024: * 59 Temple Place, Suite 330
025: * Boston, MA 02111-1307 USA
026: *
027: * @author Scott Ferguson
028: */
029:
030: package javax.xml.bind;
031:
032: import javax.xml.namespace.NamespaceContext;
033: import javax.xml.namespace.QName;
034: import java.math.BigDecimal;
035: import java.math.BigInteger;
036: import java.util.Calendar;
037:
038: public final class DatatypeConverter {
039: private static DatatypeConverterInterface _converter = null;
040:
041: private DatatypeConverter() {
042: }
043:
044: public static String parseAnySimpleType(
045: String lexicalXSDAnySimpleType) {
046: return _converter.parseAnySimpleType(lexicalXSDAnySimpleType);
047: }
048:
049: public static byte[] parseBase64Binary(String lexicalXSDBase64Binary) {
050: return _converter.parseBase64Binary(lexicalXSDBase64Binary);
051: }
052:
053: public static boolean parseBoolean(String lexicalXSDBoolean) {
054: return _converter.parseBoolean(lexicalXSDBoolean);
055: }
056:
057: public static byte parseByte(String lexicalXSDByte) {
058: return _converter.parseByte(lexicalXSDByte);
059: }
060:
061: public static Calendar parseDate(String lexicalXSDDate) {
062: return _converter.parseDate(lexicalXSDDate);
063: }
064:
065: public static Calendar parseDateTime(String lexicalXSDDateTime) {
066: return _converter.parseDateTime(lexicalXSDDateTime);
067: }
068:
069: public static BigDecimal parseDecimal(String lexicalXSDDecimal) {
070: return _converter.parseDecimal(lexicalXSDDecimal);
071: }
072:
073: public static double parseDouble(String lexicalXSDDouble) {
074: return _converter.parseDouble(lexicalXSDDouble);
075: }
076:
077: public static float parseFloat(String lexicalXSDFloat) {
078: return _converter.parseFloat(lexicalXSDFloat);
079: }
080:
081: public static byte[] parseHexBinary(String lexicalXSDHexBinary) {
082: return _converter.parseHexBinary(lexicalXSDHexBinary);
083: }
084:
085: public static int parseInt(String lexicalXSDInt) {
086: return _converter.parseInt(lexicalXSDInt);
087: }
088:
089: public static BigInteger parseInteger(String lexicalXSDInteger) {
090: return _converter.parseInteger(lexicalXSDInteger);
091: }
092:
093: public static long parseLong(String lexicalXSDLong) {
094: return _converter.parseLong(lexicalXSDLong);
095: }
096:
097: public static QName parseQName(String lexicalXSDQName,
098: NamespaceContext nsc) {
099: return _converter.parseQName(lexicalXSDQName, nsc);
100: }
101:
102: public static short parseShort(String lexicalXSDShort) {
103: return _converter.parseShort(lexicalXSDShort);
104: }
105:
106: public static String parseString(String lexicalXSDString) {
107: return _converter.parseString(lexicalXSDString);
108: }
109:
110: public static Calendar parseTime(String lexicalXSDTime) {
111: return _converter.parseTime(lexicalXSDTime);
112: }
113:
114: public static long parseUnsignedInt(String lexicalXSDUnsignedInt) {
115: return _converter.parseUnsignedInt(lexicalXSDUnsignedInt);
116: }
117:
118: public static int parseUnsignedShort(String lexicalXSDUnsignedShort) {
119: return _converter.parseUnsignedShort(lexicalXSDUnsignedShort);
120: }
121:
122: public static String printAnySimpleType(String val) {
123: return _converter.printAnySimpleType(val);
124: }
125:
126: public static String printBase64Binary(byte[] val) {
127: return _converter.printBase64Binary(val);
128: }
129:
130: public static String printBoolean(boolean val) {
131: return _converter.printBoolean(val);
132: }
133:
134: public static String printByte(byte val) {
135: return _converter.printByte(val);
136: }
137:
138: public static String printDate(Calendar val) {
139: return _converter.printDate(val);
140: }
141:
142: public static String printDateTime(Calendar val) {
143: return _converter.printDateTime(val);
144: }
145:
146: public static String printDecimal(BigDecimal val) {
147: return _converter.printDecimal(val);
148: }
149:
150: public static String printDouble(double val) {
151: return _converter.printDouble(val);
152: }
153:
154: public static String printFloat(float val) {
155: return _converter.printFloat(val);
156: }
157:
158: public static String printHexBinary(byte[] val) {
159: return _converter.printHexBinary(val);
160: }
161:
162: public static String printInt(int val) {
163: return _converter.printInt(val);
164: }
165:
166: public static String printInteger(BigInteger val) {
167: return _converter.printInteger(val);
168: }
169:
170: public static String printLong(long val) {
171: return _converter.printLong(val);
172: }
173:
174: public static String printQName(QName val, NamespaceContext nsc) {
175: return _converter.printQName(val, nsc);
176: }
177:
178: public static String printShort(short val) {
179: return _converter.printShort(val);
180: }
181:
182: public static String printString(String val) {
183: return _converter.printString(val);
184: }
185:
186: public static String printTime(Calendar val) {
187: return _converter.printTime(val);
188: }
189:
190: public static String printUnsignedInt(long val) {
191: return _converter.printUnsignedInt(val);
192: }
193:
194: public static String printUnsignedShort(int val) {
195: return _converter.printUnsignedShort(val);
196: }
197:
198: public static void setDatatypeConverter(
199: DatatypeConverterInterface converter)
200: throws IllegalArgumentException {
201: if (converter == null)
202: throw new IllegalArgumentException(
203: "Datatype converter cannot be null");
204:
205: // Can only be set once
206: if (_converter == null)
207: _converter = converter;
208: }
209:
210: }
|