You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by sc...@apache.org on 2002/09/24 17:23:12 UTC

cvs commit: xml-axis/java/src/org/apache/axis/types Day.java Month.java MonthDay.java NCName.java NMToken.java Name.java NormalizedString.java Token.java UnsignedByte.java UnsignedInt.java UnsignedLong.java UnsignedShort.java Year.java YearMonth.java

scheu       2002/09/24 08:23:12

  Modified:    java/src/org/apache/axis/types Day.java Month.java
                        MonthDay.java NCName.java NMToken.java Name.java
                        NormalizedString.java Token.java UnsignedByte.java
                        UnsignedInt.java UnsignedLong.java
                        UnsignedShort.java Year.java YearMonth.java
  Log:
  The specialized types are changed to consistently throw
  IllegalArgumentException or NumberFormatException (i.e. RuntimeExceptions)
  when erroneous values are used to construct or set the object.
  
  This makes the types consistent with the wrapper types (like Integer)
  which thrown an IllegalArgumentException when an attempt is made to construct
  with an illegal value.
  
  *Note: These java classes could use some improved javadocs!
  
  This work was requested by an IBM user, Damian Hagge.
  
  Revision  Changes    Path
  1.5       +5 -3      xml-axis/java/src/org/apache/axis/types/Day.java
  
  Index: Day.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/types/Day.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Day.java	18 Sep 2002 16:10:40 -0000	1.4
  +++ Day.java	24 Sep 2002 15:23:11 -0000	1.5
  @@ -76,7 +76,7 @@
        * Constructs a Day with the given values
        * No timezone is specified
        */ 
  -    public Day(int day) throws Exception {
  +    public Day(int day) throws NumberFormatException {
           setValue(day);
       }
   
  @@ -84,7 +84,8 @@
        * Constructs a Day with the given values, including a timezone string
        * The timezone is validated but not used.
        */ 
  -    public Day(int day, String timezone) throws Exception {
  +    public Day(int day, String timezone) 
  +        throws NumberFormatException {
           setValue(day, timezone);
       }
       
  @@ -151,7 +152,8 @@
           }
       }
   
  -    public void setValue(int day, String timezone) throws NumberFormatException {
  +    public void setValue(int day, String timezone) 
  +        throws NumberFormatException {
           setDay(day);
           setTimezone(timezone);
       }
  
  
  
  1.5       +3 -2      xml-axis/java/src/org/apache/axis/types/Month.java
  
  Index: Month.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/types/Month.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Month.java	18 Sep 2002 16:10:40 -0000	1.4
  +++ Month.java	24 Sep 2002 15:23:11 -0000	1.5
  @@ -76,7 +76,7 @@
        * Constructs a Month with the given values
        * No timezone is specified
        */ 
  -    public Month(int month) throws Exception {
  +    public Month(int month) throws NumberFormatException {
           setValue(month);
       }
   
  @@ -84,7 +84,8 @@
        * Constructs a Month with the given values, including a timezone string
        * The timezone is validated but not used.
        */ 
  -    public Month(int month, String timezone) throws Exception {
  +    public Month(int month, String timezone) 
  +        throws NumberFormatException {
           setValue(month, timezone);
       }
       
  
  
  
  1.5       +6 -3      xml-axis/java/src/org/apache/axis/types/MonthDay.java
  
  Index: MonthDay.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/types/MonthDay.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- MonthDay.java	18 Sep 2002 16:10:40 -0000	1.4
  +++ MonthDay.java	24 Sep 2002 15:23:11 -0000	1.5
  @@ -77,7 +77,8 @@
        * Constructs a MonthDay with the given values
        * No timezone is specified
        */ 
  -    public MonthDay(int month, int day) throws Exception {
  +    public MonthDay(int month, int day) 
  +        throws NumberFormatException {
           setValue(month, day);
       }
   
  @@ -85,7 +86,8 @@
        * Constructs a MonthDay with the given values, including a timezone string
        * The timezone is validated but not used.
        */ 
  -    public MonthDay(int month, int day, String timezone) throws Exception {
  +    public MonthDay(int month, int day, String timezone) 
  +        throws NumberFormatException {
           setValue(month, day, timezone);
       }
       
  @@ -174,7 +176,8 @@
           }
       }
   
  -    public void setValue(int month, int day, String timezone) throws NumberFormatException {
  +    public void setValue(int month, int day, String timezone)
  +        throws NumberFormatException {
           setMonth(month);
           setDay(day);
           setTimezone(timezone);
  
  
  
  1.6       +5 -4      xml-axis/java/src/org/apache/axis/types/NCName.java
  
  Index: NCName.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/types/NCName.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- NCName.java	18 Sep 2002 16:10:40 -0000	1.5
  +++ NCName.java	24 Sep 2002 15:23:11 -0000	1.6
  @@ -76,15 +76,16 @@
   
       /**
        * ctor for NCName
  -     * @exception Exception will be thrown if validation fails
  +     * @exception IllegalArgumentException will be thrown if validation fails
        */
  -    public NCName(String stValue) throws Exception {
  +    public NCName(String stValue) throws IllegalArgumentException {
           try {
               setValue(stValue);
           }
  -        catch (Exception e) {
  +        catch (IllegalArgumentException e) {
               // recast normalizedString exception as token exception
  -            throw new Exception(Messages.getMessage("badNCNameType00") + "data=[" +
  +            throw new IllegalArgumentException(
  +                    Messages.getMessage("badNCNameType00") + "data=[" +
                       stValue + "]");
           }
       }
  
  
  
  1.6       +6 -5      xml-axis/java/src/org/apache/axis/types/NMToken.java
  
  Index: NMToken.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/types/NMToken.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- NMToken.java	18 Sep 2002 16:10:40 -0000	1.5
  +++ NMToken.java	24 Sep 2002 15:23:11 -0000	1.6
  @@ -79,16 +79,17 @@
   
       /**
        * ctor for NMToken
  -     * @exception Exception will be thrown if validation fails
  +     * @exception IllegalArgumentException will be thrown if validation fails
        */
  -    public NMToken(String stValue) throws Exception {
  +    public NMToken(String stValue) throws IllegalArgumentException {
           try {
               setValue(stValue);
           }
  -        catch (Exception e) {
  +        catch (IllegalArgumentException e) {
               // recast normalizedString exception as token exception
  -            throw new Exception(Messages.getMessage("badNmtoken00") + "data=[" +
  -                    stValue + "]");
  +            throw new IllegalArgumentException(
  +                Messages.getMessage("badNmtoken00") + "data=[" +
  +                stValue + "]");
           }
       }
   
  
  
  
  1.6       +6 -5      xml-axis/java/src/org/apache/axis/types/Name.java
  
  Index: Name.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/types/Name.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Name.java	18 Sep 2002 16:10:40 -0000	1.5
  +++ Name.java	24 Sep 2002 15:23:11 -0000	1.6
  @@ -76,16 +76,17 @@
   
       /**
        * ctor for Name
  -     * @exception Exception will be thrown if validation fails
  +     * @exception IllegalArgumentException will be thrown if validation fails
        */
  -    public Name(String stValue) throws Exception {
  +    public Name(String stValue) throws IllegalArgumentException {
           try {
               setValue(stValue);
           }
  -        catch (Exception e) {
  +        catch (IllegalArgumentException e) {
               // recast normalizedString exception as token exception
  -            throw new Exception(Messages.getMessage("badNameType00") + "data=[" +
  -                    stValue + "]");
  +            throw new IllegalArgumentException(
  +                 Messages.getMessage("badNameType00") + "data=[" +
  +                 stValue + "]");
           }
       }
   
  
  
  
  1.5       +9 -8      xml-axis/java/src/org/apache/axis/types/NormalizedString.java
  
  Index: NormalizedString.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/types/NormalizedString.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- NormalizedString.java	18 Sep 2002 16:10:40 -0000	1.4
  +++ NormalizedString.java	24 Sep 2002 15:23:11 -0000	1.5
  @@ -76,22 +76,24 @@
       /**
        *
        * ctor for NormalizedString
  -     * NOTE: null will be returned if validation fails
  +     * @param stValue is the String value
  +     * @throws IllegalArgumentException if invalid format
        */
  -    public NormalizedString(String stValue) throws Exception {
  +    public NormalizedString(String stValue) throws IllegalArgumentException {
           setValue(stValue);
       }
   
       /**
        *
        * validates the data and sets the value for the object.
  -     *
  -     * @param normalizedString value
  +     * @param normalizedString String value
  +     * @throws IllegalArgumentException if invalid format
        */
  -    public void setValue(String stValue) throws Exception {
  +    public void setValue(String stValue) throws IllegalArgumentException {
           if (isValid(stValue) == false)
  -            throw new Exception(Messages.getMessage("badNormalizedString00") +
  -                    " data=[" + stValue + "]");
  +            throw new IllegalArgumentException(
  +               Messages.getMessage("badNormalizedString00") +
  +               " data=[" + stValue + "]");
           m_value = stValue;
       }
   
  @@ -100,7 +102,6 @@
       }
   
       public int hashCode(){
  -        //TODO: How do we hash this?
           return m_value.hashCode();
       }
   
  
  
  
  1.5       +5 -4      xml-axis/java/src/org/apache/axis/types/Token.java
  
  Index: Token.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/types/Token.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Token.java	18 Sep 2002 16:10:40 -0000	1.4
  +++ Token.java	24 Sep 2002 15:23:11 -0000	1.5
  @@ -75,15 +75,16 @@
   
       /**
        * ctor for Token
  -     * @exception Exception will be thrown if validation fails
  +     * @exception IllegalArgumentException will be thrown if validation fails
        */
  -    public Token(String stValue) throws Exception {
  +    public Token(String stValue) throws IllegalArgumentException {
           try {
               setValue(stValue);
           }
  -        catch (Exception e) {
  +        catch (IllegalArgumentException e) {
               // recast normalizedString exception as token exception
  -            throw new Exception(Messages.getMessage("badToken00") + "data=[" +
  +            throw new IllegalArgumentException(
  +                    Messages.getMessage("badToken00") + "data=[" +
                       stValue + "]");
           }
       }
  
  
  
  1.6       +5 -4      xml-axis/java/src/org/apache/axis/types/UnsignedByte.java
  
  Index: UnsignedByte.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/types/UnsignedByte.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- UnsignedByte.java	18 Sep 2002 16:10:40 -0000	1.5
  +++ UnsignedByte.java	24 Sep 2002 15:23:11 -0000	1.6
  @@ -75,11 +75,11 @@
        * ctor for UnsignedByte
        * @exception Exception will be thrown if validation fails
        */
  -    public UnsignedByte(long sValue) throws Exception {
  +    public UnsignedByte(long sValue) throws NumberFormatException {
         setValue(sValue);
       }
   
  -    public UnsignedByte(String sValue) throws Exception {
  +    public UnsignedByte(String sValue) throws NumberFormatException {
         setValue(Long.parseLong(sValue));
       }
   
  @@ -89,9 +89,10 @@
        *
        * @param sValue the number to set
        */
  -    public void setValue(long sValue) throws Exception {
  +    public void setValue(long sValue) throws NumberFormatException {
           if (isValid(sValue) == false)
  -            throw new Exception(Messages.getMessage("badUnsignedByte00") +
  +            throw new NumberFormatException(
  +                    Messages.getMessage("badUnsignedByte00") +
                       String.valueOf(sValue) + "]");
           lValue = new Long(sValue);
       }
  
  
  
  1.7       +6 -5      xml-axis/java/src/org/apache/axis/types/UnsignedInt.java
  
  Index: UnsignedInt.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/types/UnsignedInt.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- UnsignedInt.java	18 Sep 2002 16:10:40 -0000	1.6
  +++ UnsignedInt.java	24 Sep 2002 15:23:11 -0000	1.7
  @@ -74,13 +74,13 @@
   
       /**
        * ctor for UnsignedInt
  -     * @exception Exception will be thrown if validation fails
  +     * @exception NumberFormatException will be thrown if validation fails
        */
  -    public UnsignedInt(long iValue) throws Exception {
  +    public UnsignedInt(long iValue) throws NumberFormatException {
         setValue(iValue);
       }
   
  -    public UnsignedInt(String stValue) throws Exception {
  +    public UnsignedInt(String stValue) throws NumberFormatException {
         setValue(Long.parseLong(stValue));
       }
   
  @@ -91,9 +91,10 @@
        *
        * @param int value
        */
  -    public void setValue(long iValue) throws Exception {
  +    public void setValue(long iValue) throws NumberFormatException {
         if (isValid(iValue) == false)
  -            throw new Exception(Messages.getMessage("badUnsignedInt00") +
  +            throw new NumberFormatException(
  +                    Messages.getMessage("badUnsignedInt00") +
                       String.valueOf(iValue) + "]");
         lValue = new Long(iValue);
       }
  
  
  
  1.7       +6 -5      xml-axis/java/src/org/apache/axis/types/UnsignedLong.java
  
  Index: UnsignedLong.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/types/UnsignedLong.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- UnsignedLong.java	18 Sep 2002 16:10:40 -0000	1.6
  +++ UnsignedLong.java	24 Sep 2002 15:23:11 -0000	1.7
  @@ -75,13 +75,13 @@
   
       /**
        * ctor for UnsignedLong
  -     * @exception Exception will be thrown if validation fails
  +     * @exception NumberFormatException will be thrown if validation fails
        */
  -    public UnsignedLong(double lValue) throws Exception {
  +    public UnsignedLong(double lValue) throws NumberFormatException {
         setValue(lValue);
       }
   
  -    public UnsignedLong(String stValue) throws Exception {
  +    public UnsignedLong(String stValue) throws NumberFormatException {
         setValue(Double.parseDouble(stValue));
       }
   
  @@ -91,9 +91,10 @@
        *
        * @param long value
        */
  -    public void setValue(double lValue) throws Exception {
  +    public void setValue(double lValue) throws NumberFormatException {
           if (isValid(lValue) == false)
  -            throw new Exception(Messages.getMessage("badUnsignedLong00") +
  +            throw new NumberFormatException(
  +                    Messages.getMessage("badUnsignedLong00") +
                       String.valueOf(lValue) + "]");
           this.lValue = new Double(lValue);
       }
  
  
  
  1.6       +6 -5      xml-axis/java/src/org/apache/axis/types/UnsignedShort.java
  
  Index: UnsignedShort.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/types/UnsignedShort.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- UnsignedShort.java	18 Sep 2002 16:10:40 -0000	1.5
  +++ UnsignedShort.java	24 Sep 2002 15:23:11 -0000	1.6
  @@ -73,13 +73,13 @@
   
       /**
        * ctor for UnsignedShort
  -     * @exception Exception will be thrown if validation fails
  +     * @exception NumberFormatException will be thrown if validation fails
        */
  -    public UnsignedShort(long sValue) throws Exception {
  +    public UnsignedShort(long sValue) throws NumberFormatException {
         setValue(sValue);
       }
   
  -    public UnsignedShort(String sValue) throws Exception {
  +    public UnsignedShort(String sValue) throws NumberFormatException {
         setValue(Long.parseLong(sValue));
       }
   
  @@ -89,9 +89,10 @@
        *
        * @param short value
        */
  -    public void setValue(long sValue) throws Exception {
  +    public void setValue(long sValue) throws NumberFormatException {
           if (isValid(sValue) == false)
  -            throw new Exception(Messages.getMessage("badUnsignedShort00") +
  +            throw new NumberFormatException(
  +                Messages.getMessage("badUnsignedShort00") +
                       String.valueOf(sValue) + "]");
           lValue = new Long(sValue);
       }
  
  
  
  1.5       +4 -3      xml-axis/java/src/org/apache/axis/types/Year.java
  
  Index: Year.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/types/Year.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Year.java	18 Sep 2002 16:10:40 -0000	1.4
  +++ Year.java	24 Sep 2002 15:23:11 -0000	1.5
  @@ -76,7 +76,7 @@
        * Constructs a Year with the given values
        * No timezone is specified
        */ 
  -    public Year(int year) throws Exception {
  +    public Year(int year) throws NumberFormatException {
           setValue(year);
       }
   
  @@ -84,7 +84,7 @@
        * 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 Exception {
  +    public Year(int year, String timezone) throws NumberFormatException {
           setValue(year, timezone);
       }
       
  @@ -153,7 +153,8 @@
           }
       }
   
  -    public void setValue(int year, String timezone) throws NumberFormatException {
  +    public void setValue(int year, String timezone) 
  +        throws NumberFormatException {
           setYear(year);
           setTimezone(timezone);
       }
  
  
  
  1.5       +2 -2      xml-axis/java/src/org/apache/axis/types/YearMonth.java
  
  Index: YearMonth.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/types/YearMonth.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- YearMonth.java	18 Sep 2002 16:10:40 -0000	1.4
  +++ YearMonth.java	24 Sep 2002 15:23:11 -0000	1.5
  @@ -77,7 +77,7 @@
        * Constructs a YearMonth with the given values
        * No timezone is specified
        */ 
  -    public YearMonth(int year, int month) throws Exception {
  +    public YearMonth(int year, int month) throws NumberFormatException {
           setValue(year, month);
       }
   
  @@ -85,7 +85,7 @@
        * 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 Exception {
  +    public YearMonth(int year, int month, String timezone) throws NumberFormatException {
           setValue(year, month, timezone);
       }