geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r982296 - in /geronimo/specs/trunk/geronimo-jaxb_2.2_spec/src/main/java/javax/xml/bind: DatatypeConverter.java DatatypeConverterHelper.java
Date Wed, 04 Aug 2010 15:22:16 GMT
Author: gawor
Date: Wed Aug  4 15:22:16 2010
New Revision: 982296

URL: http://svn.apache.org/viewvc?rev=982296&view=rev
Log:
GERONIMO-5500: A work-around for DatatypeConverter.printDate() issue

Added:
    geronimo/specs/trunk/geronimo-jaxb_2.2_spec/src/main/java/javax/xml/bind/DatatypeConverterHelper.java
  (with props)
Modified:
    geronimo/specs/trunk/geronimo-jaxb_2.2_spec/src/main/java/javax/xml/bind/DatatypeConverter.java

Modified: geronimo/specs/trunk/geronimo-jaxb_2.2_spec/src/main/java/javax/xml/bind/DatatypeConverter.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-jaxb_2.2_spec/src/main/java/javax/xml/bind/DatatypeConverter.java?rev=982296&r1=982295&r2=982296&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-jaxb_2.2_spec/src/main/java/javax/xml/bind/DatatypeConverter.java
(original)
+++ geronimo/specs/trunk/geronimo-jaxb_2.2_spec/src/main/java/javax/xml/bind/DatatypeConverter.java
Wed Aug  4 15:22:16 2010
@@ -41,7 +41,7 @@ public final class DatatypeConverter {
                 sm.checkPermission(new JAXBPermission("setDatatypeConverter"));
             }
             
-            DatatypeConverter.converter = converter;
+            DatatypeConverter.converter = new DatatypeConverterHelper(converter);
         }
     }
 

Added: geronimo/specs/trunk/geronimo-jaxb_2.2_spec/src/main/java/javax/xml/bind/DatatypeConverterHelper.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-jaxb_2.2_spec/src/main/java/javax/xml/bind/DatatypeConverterHelper.java?rev=982296&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-jaxb_2.2_spec/src/main/java/javax/xml/bind/DatatypeConverterHelper.java
(added)
+++ geronimo/specs/trunk/geronimo-jaxb_2.2_spec/src/main/java/javax/xml/bind/DatatypeConverterHelper.java
Wed Aug  4 15:22:16 2010
@@ -0,0 +1,235 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package javax.xml.bind;
+
+import java.util.Calendar;
+import java.util.TimeZone;
+import java.math.BigInteger;
+import java.math.BigDecimal;
+
+import javax.xml.namespace.QName;
+import javax.xml.namespace.NamespaceContext;
+
+/**
+ * Wrapper for DatatypeConverterInterface that provides {@link #printDate(Calendar)} method
that
+ * outputs time zone information. All other methods are delegated to the original converter.
+ * See {@link https://jaxb.dev.java.net/issues/show_bug.cgi?id=761} for more information.
+ */
+class DatatypeConverterHelper implements DatatypeConverterInterface {
+           
+    private final DatatypeConverterInterface delegate;
+
+    DatatypeConverterHelper(DatatypeConverterInterface delegate) {
+        this.delegate = delegate;
+    }
+        
+    public String parseAnySimpleType(String lexicalXSDAnySimpleType) {
+        return delegate.parseAnySimpleType(lexicalXSDAnySimpleType);
+    }
+
+    public byte[] parseBase64Binary(String lexicalXSDBase64Binary) {
+        return delegate.parseBase64Binary(lexicalXSDBase64Binary);
+    }
+
+    public boolean parseBoolean(String lexicalXSDBoolean) {
+        return delegate.parseBoolean(lexicalXSDBoolean);
+    }
+
+    public byte parseByte(String lexicalXSDByte) {
+        return delegate.parseByte(lexicalXSDByte);
+    }
+
+    public Calendar parseDate(String lexicalXSDDate) {
+        return delegate.parseDate(lexicalXSDDate);
+    }
+
+    public Calendar parseDateTime(String lexicalXSDDateTime) {
+        return delegate.parseDateTime(lexicalXSDDateTime);
+    }
+
+    public BigDecimal parseDecimal(String lexicalXSDDecimal) {
+        return delegate.parseDecimal(lexicalXSDDecimal);
+    }
+
+    public double parseDouble(String lexicalXSDDouble) {
+        return delegate.parseDouble(lexicalXSDDouble);
+    }
+
+    public float parseFloat(String lexicalXSDFloat) {
+        return delegate.parseFloat(lexicalXSDFloat);
+    }
+
+    public byte[] parseHexBinary(String lexicalXSDHexBinary) {
+        return delegate.parseHexBinary(lexicalXSDHexBinary);
+    }
+
+    public int parseInt(String lexicalXSDInt) {
+        return delegate.parseInt(lexicalXSDInt);
+    }
+
+    public BigInteger parseInteger(String lexicalXSDInteger) {
+        return delegate.parseInteger(lexicalXSDInteger);
+    }
+
+    public long parseLong(String lexicalXSDLong) {
+        return delegate.parseLong(lexicalXSDLong);
+    }
+
+    public QName parseQName(String lexicalXSDQName, NamespaceContext nsc) {
+        return delegate.parseQName(lexicalXSDQName, nsc);
+    }
+
+    public short parseShort(String lexicalXSDShort) {
+        return delegate.parseShort(lexicalXSDShort);
+    }
+
+    public String parseString(String lexicalXSDString) {
+        return delegate.parseString(lexicalXSDString);
+    }
+
+    public Calendar parseTime(String lexicalXSDTime) {
+        return delegate.parseTime(lexicalXSDTime);
+    }
+
+    public long parseUnsignedInt(String lexicalXSDUnsignedInt) {
+        return delegate.parseUnsignedInt(lexicalXSDUnsignedInt);
+    }
+
+    public int parseUnsignedShort(String lexicalXSDUnsignedShort) {
+        return delegate.parseUnsignedShort(lexicalXSDUnsignedShort);
+    }
+
+    public String printAnySimpleType(String val) {
+        return delegate.printAnySimpleType(val);
+    }
+
+    public String printBase64Binary(byte[] val) {
+        return delegate.printBase64Binary(val);
+    }
+
+    public String printBoolean(boolean val) {
+        return delegate.printBoolean(val);
+    }
+
+    public String printByte(byte val) {
+        return delegate.printByte(val);
+    }
+
+    public String printDate(Calendar cal) {
+        StringBuilder buf = new StringBuilder();
+        
+        int year = cal.get(Calendar.YEAR);
+        if (year < 0) {
+            buf.append("-");
+            year = -year;
+        }
+        append(buf, year, 4);
+        buf.append('-');
+        append(buf, cal.get(Calendar.MONTH) + 1, 2);
+        buf.append('-');
+        append(buf, cal.get(Calendar.DAY_OF_MONTH), 2);
+        
+        TimeZone tz = cal.getTimeZone();
+        if (tz != null) {
+            int offset = cal.get(Calendar.ZONE_OFFSET);
+            if (tz.inDaylightTime(cal.getTime())) {
+                offset += cal.get(Calendar.DST_OFFSET);
+            }
+            if (offset == 0) {
+                buf.append('Z');
+            } else {
+                if (offset < 0) {
+                    buf.append('-');
+                    offset = -offset;
+                } else {
+                    buf.append('+');
+                }
+                offset /= 60 * 1000;
+                append(buf, offset / 60, 2);
+                buf.append(':');
+                append(buf, offset % 60, 2);
+            }
+        }
+        
+        return buf.toString();
+    }
+    
+    private static void append(StringBuilder buf, int value, int minLength) {
+        String str = String.valueOf(value);
+        for (int i = str.length(); i < minLength; i++) {
+            buf.append('0');
+        }
+        buf.append(str);
+    }
+
+    public String printDateTime(Calendar val) {
+        return delegate.printDateTime(val);
+    }
+
+    public String printDecimal(BigDecimal val) {
+        return delegate.printDecimal(val);
+    }
+
+    public String printDouble(double val) {
+        return delegate.printDouble(val);
+    }
+
+    public String printFloat(float val) {
+        return delegate.printFloat(val);
+    }
+
+    public String printHexBinary(byte[] val) {
+        return delegate.printHexBinary(val);
+    }
+
+    public String printInt(int val) {
+        return delegate.printInt(val);
+    }
+
+    public String printInteger(BigInteger val) {
+        return delegate.printInteger(val);
+    }
+
+    public String printLong(long val) {
+        return delegate.printLong(val);
+    }
+
+    public String printQName(QName val, NamespaceContext nsc) {
+        return delegate.printQName(val, nsc);
+    }
+
+    public String printShort(short val) {
+        return delegate.printShort(val);
+    }
+
+    public String printString(String val) {
+        return delegate.printString(val);
+    }
+
+    public String printTime(Calendar val) {
+        return delegate.printTime(val);
+    }
+
+    public String printUnsignedInt(long val) {
+        return delegate.printUnsignedInt(val);
+    }
+
+    public String printUnsignedShort(int val) {
+        return delegate.printUnsignedShort(val);
+    }
+        
+}

Propchange: geronimo/specs/trunk/geronimo-jaxb_2.2_spec/src/main/java/javax/xml/bind/DatatypeConverterHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/specs/trunk/geronimo-jaxb_2.2_spec/src/main/java/javax/xml/bind/DatatypeConverterHelper.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/specs/trunk/geronimo-jaxb_2.2_spec/src/main/java/javax/xml/bind/DatatypeConverterHelper.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message