You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by aj...@apache.org on 2005/11/26 14:07:29 UTC

svn commit: r349112 [4/4] - in /webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2: databinding/schema/ databinding/schema/typemap/ databinding/schema/types/ wsdl/template/csharp/

Added: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/Year.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/Year.java?rev=349112&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/Year.java (added)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/Year.java Sat Nov 26 05:07:02 2005
@@ -0,0 +1,160 @@
+/*
+ * Copyright 2002-2004 The Apache Software Foundation.
+ * 
+ * Licensed 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 org.apache.axis2.databinding.schema.types;
+
+
+import java.text.NumberFormat;
+
+/**
+ * Implementation of the XML Schema type gYear
+ *
+ * @author Tom Jordahl <to...@macromedia.com>
+ * @see <a href="http://www.w3.org/TR/xmlschema-2/#gYear">XML Schema 3.2.11</a>
+ */
+public class Year implements java.io.Serializable {
+    int year;
+    String timezone = null;
+
+    /**
+     * Constructs a Year with the given values
+     * No timezone is specified
+     */
+    public Year(int year) throws NumberFormatException {
+        setValue(year);
+    }
+
+    /**
+     * Constructs a Year with the given values, including a timezone string
+     * The timezone is validated but not used.
+     */
+    public Year(int year, String timezone) throws NumberFormatException {
+        setValue(year, timezone);
+    }
+
+    /**
+     * Construct a Year from a String in the format [-]CCYY[timezone]
+     */
+    public Year(String source) throws NumberFormatException {
+        int negative = 0;
+
+        if (source.charAt(0) == '-') {
+            negative = 1;
+        }
+        if (source.length() < (4 + negative)) {
+            throw new NumberFormatException();
+                    //Messages.getMessage("badYear00"));
+        }
+
+        // calculate how many more than 4 digits (if any) in the year
+        int pos = 4 + negative;  // skip minus sign if present
+        while (pos < source.length() && Character.isDigit(source.charAt(pos))) {
+            ++pos;
+        }
+
+        setValue(Integer.parseInt(source.substring(0,pos)),
+                 source.substring(pos));
+    }
+
+    public int getYear() {
+        return year;
+    }
+
+    public void setYear(int year) {
+        // validate year, more than 4 digits are allowed!
+        if (year == 0) {
+            throw new NumberFormatException();
+                    //Messages.getMessage("badYear00"));
+        }
+
+        this.year = year;
+    }
+
+    public String getTimezone() {
+        return timezone;
+    }
+
+    public void setTimezone(String timezone) {
+        // validate timezone
+        if (timezone != null && timezone.length() > 0) {
+            // Format [+/-]HH:MM
+            if (timezone.charAt(0)=='+' || (timezone.charAt(0)=='-')) {
+                    if (timezone.length() != 6 ||
+                        !Character.isDigit(timezone.charAt(1)) ||
+                        !Character.isDigit(timezone.charAt(2)) ||
+                        timezone.charAt(3) != ':'              ||
+                        !Character.isDigit(timezone.charAt(4)) ||
+                        !Character.isDigit(timezone.charAt(5)))
+                        throw new NumberFormatException();
+                                //Messages.getMessage("badTimezone00"));
+
+            } else if (!timezone.equals("Z")) {
+                throw new NumberFormatException();
+                       // Messages.getMessage("badTimezone00"));
+            }
+            // if we got this far, its good
+            this.timezone = timezone;
+        }
+    }
+
+    public void setValue(int year, String timezone)
+        throws NumberFormatException {
+        setYear(year);
+        setTimezone(timezone);
+    }
+
+    public void setValue(int year) throws NumberFormatException {
+        setYear(year);
+    }
+
+    public String toString() {
+        // use NumberFormat to ensure leading zeros
+        NumberFormat nf = NumberFormat.getInstance();
+        nf.setGroupingUsed(false);
+
+        // year
+        nf.setMinimumIntegerDigits(4);
+        String s = nf.format(year);
+
+        // timezone
+        if (timezone != null) {
+            s = s + timezone;
+        }
+        return s;
+    }
+
+    public boolean equals(Object obj) {
+        if (!(obj instanceof Year)) return false;
+        Year other = (Year) obj;
+        if (obj == null) return false;
+        if (this == obj) return true;
+
+        boolean equals = (this.year == other.year);
+        if (timezone != null) {
+            equals = equals && timezone.equals(other.timezone);
+        }
+        return equals;
+    }
+
+    /**
+     * Return the value of year XORed with the hashCode of timezone
+     * iff one is defined.
+     *
+     * @return an <code>int</code> value
+     */
+    public int hashCode() {
+        return null == timezone ? year : year ^ timezone.hashCode();
+    }
+}

Added: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/YearMonth.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/YearMonth.java?rev=349112&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/YearMonth.java (added)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/YearMonth.java Sat Nov 26 05:07:02 2005
@@ -0,0 +1,184 @@
+/*
+ * Copyright 2002-2004 The Apache Software Foundation.
+ * 
+ * Licensed 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 org.apache.axis2.databinding.schema.types;
+
+
+import java.text.NumberFormat;
+
+/**
+ * Implementation of the XML Schema type gYearMonth
+ *
+ * @author Tom Jordahl <to...@macromedia.com>
+ * @see <a href="http://www.w3.org/TR/xmlschema-2/#gYearMonth">XML Schema 3.2.10</a>
+ */
+public class YearMonth implements java.io.Serializable {
+    int year;
+    int month;
+    String timezone = null;
+
+    /**
+     * Constructs a YearMonth with the given values
+     * No timezone is specified
+     */
+    public YearMonth(int year, int month) throws NumberFormatException {
+        setValue(year, month);
+    }
+
+    /**
+     * Constructs a YearMonth with the given values, including a timezone string
+     * The timezone is validated but not used.
+     */
+    public YearMonth(int year, int month, String timezone) throws NumberFormatException {
+        setValue(year, month, timezone);
+    }
+
+    /**
+     * Construct a YearMonth from a String in the format [-]CCYY-MM
+     */
+    public YearMonth(String source) throws NumberFormatException {
+        int negative = 0;
+
+        if (source.charAt(0) == '-') {
+            negative = 1;
+        }
+        if (source.length() < (7 + negative)) {
+            throw new NumberFormatException();
+                   // Messages.getMessage("badYearMonth00"));
+        }
+
+        // look for first '-'
+        int pos = source.substring(negative).indexOf('-');
+        if (pos < 0) {
+            throw new NumberFormatException();
+                    //Messages.getMessage("badYearMonth00"));
+        }
+        if (negative > 0) pos++;    //adjust index for orginal string
+
+        setValue(Integer.parseInt(source.substring(0,pos)),
+                 Integer.parseInt(source.substring(pos+1,pos+3)),
+                 source.substring(pos+3));
+    }
+
+    public int getYear() {
+        return year;
+    }
+
+    public void setYear(int year) {
+        // validate year, more than 4 digits are allowed!
+        if (year == 0) {
+            throw new NumberFormatException();
+                   // Messages.getMessage("badYearMonth00"));
+        }
+
+        this.year = year;
+    }
+
+    public int getMonth() {
+        return month;
+    }
+
+    public void setMonth(int month) {
+        // validate month
+        if (month < 1 || month > 12) {
+            throw new NumberFormatException();
+                    //Messages.getMessage("badYearMonth00"));
+        }
+        this.month = month;
+    }
+
+    public String getTimezone() {
+        return timezone;
+    }
+
+    public void setTimezone(String timezone) {
+        // validate timezone
+        if (timezone != null && timezone.length() > 0) {
+            // Format [+/-]HH:MM
+            if (timezone.charAt(0)=='+' || (timezone.charAt(0)=='-')) {
+                    if (timezone.length() != 6 ||
+                        !Character.isDigit(timezone.charAt(1)) ||
+                        !Character.isDigit(timezone.charAt(2)) ||
+                        timezone.charAt(3) != ':'              ||
+                        !Character.isDigit(timezone.charAt(4)) ||
+                        !Character.isDigit(timezone.charAt(5)))
+                        throw new NumberFormatException();
+                                //Messages.getMessage("badTimezone00"));
+
+            } else if (!timezone.equals("Z")) {
+                throw new NumberFormatException();
+                        //Messages.getMessage("badTimezone00"));
+            }
+            // if we got this far, its good
+            this.timezone = timezone;
+        }
+    }
+
+    public void setValue(int year, int month, String timezone) throws NumberFormatException {
+        setYear(year);
+        setMonth(month);
+        setTimezone(timezone);
+    }
+
+    public void setValue(int year, int month) throws NumberFormatException {
+        setYear(year);
+        setMonth(month);
+    }
+
+    public String toString() {
+        // use NumberFormat to ensure leading zeros
+        NumberFormat nf = NumberFormat.getInstance();
+        nf.setGroupingUsed(false);
+
+        // year
+        nf.setMinimumIntegerDigits(4);
+        String s = nf.format(year) + "-";
+
+        // month
+        nf.setMinimumIntegerDigits(2);
+        s += nf.format(month);
+
+        // timezone
+        if (timezone != null) {
+            s = s + timezone;
+        }
+        return s;
+    }
+
+    public boolean equals(Object obj) {
+        if (!(obj instanceof YearMonth)) return false;
+        YearMonth other = (YearMonth) obj;
+        if (obj == null) return false;
+        if (this == obj) return true;
+
+        boolean equals = (this.year == other.year && this.month == other.month);
+        if (timezone != null) {
+            equals = equals && timezone.equals(other.timezone);
+        }
+        return equals;
+    }
+
+    /**
+     * Return the value of (month + year) XORed with the hashCode of
+     * timezone iff one is defined.
+     *
+     * @return an <code>int</code> value
+     */
+    public int hashCode() {
+        return null == timezone
+            ? (month + year)
+            : (month + year) ^ timezone.hashCode();
+    }
+}

Added: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/package.html
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/package.html?rev=349112&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/package.html (added)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/types/package.html Sat Nov 26 05:07:02 2005
@@ -0,0 +1,5 @@
+<html>
+<body>
+ These classes are directly salvaged from Axis 1 codebase. Original author comments has been reserved! 
+</body>
+</html>
\ No newline at end of file

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/csharp/package.html
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/csharp/package.html?rev=349112&r1=349111&r2=349112&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/csharp/package.html (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/csharp/package.html Sat Nov 26 05:07:02 2005
@@ -1,6 +1,5 @@
 <html>
 <body>
   This package is a "non class containing" one that has the xsl templates for the C# class generation
-
  </body>
 </html>