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 ha...@apache.org on 2002/08/13 08:03:28 UTC

cvs commit: xml-axis/java/test/encoding TestNCName.java TestNMToken.java TestName.java PackageTests.java TestDeser2001.java

haddadc     2002/08/12 23:03:28

  Modified:    java/src/org/apache/axis Constants.java
               java/src/org/apache/axis/encoding
                        DefaultTypeMappingImpl.java
               java/src/org/apache/axis/types UnsignedByte.java
                        UnsignedInt.java UnsignedLong.java
                        UnsignedShort.java
               java/src/org/apache/axis/utils axisNLS.properties
               java/test/encoding PackageTests.java TestDeser2001.java
  Added:       java/src/org/apache/axis/types NCName.java NMToken.java
                        Name.java
               java/test/encoding TestNCName.java TestNMToken.java
                        TestName.java
  Removed:     java/src/org/apache/axis/encoding/ser
                        NormalizedStringDeserializer.java
                        NormalizedStringDeserializerFactory.java
                        NormalizedStringSerializer.java
                        NormalizedStringSerializerFactory.java
                        TokenDeserializer.java
                        TokenDeserializerFactory.java TokenSerializer.java
                        TokenSerializerFactory.java
                        UnsignedByteDeserializer.java
                        UnsignedByteDeserializerFactory.java
                        UnsignedByteSerializer.java
                        UnsignedByteSerializerFactory.java
                        UnsignedIntDeserializer.java
                        UnsignedIntDeserializerFactory.java
                        UnsignedIntSerializer.java
                        UnsignedIntSerializerFactory.java
                        UnsignedLongDeserializer.java
                        UnsignedLongDeserializerFactory.java
                        UnsignedLongSerializer.java
                        UnsignedLongSerializerFactory.java
                        UnsignedShortDeserializer.java
                        UnsignedShortDeserializerFactory.java
                        UnsignedShortSerializer.java
                        UnsignedShortSerializerFactory.java
  Log:
  Added support for xsd:NMTOKEN, xsd:Name, and xsd:NCName
  
  Removed serializers for Unsigned*, Token, and NormalizedString.
  
  TODO: update ComprehensiveTypes.wsdl and related tests.
  
  Revision  Changes    Path
  1.79      +5 -2      xml-axis/java/src/org/apache/axis/Constants.java
  
  Index: Constants.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/Constants.java,v
  retrieving revision 1.78
  retrieving revision 1.79
  diff -u -r1.78 -r1.79
  --- Constants.java	9 Aug 2002 15:18:30 -0000	1.78
  +++ Constants.java	13 Aug 2002 06:03:27 -0000	1.79
  @@ -452,13 +452,16 @@
       public static final QName XSD_UNSIGNEDINT = new QName(URI_2001_SCHEMA_XSD, "unsignedInt");
       public static final QName XSD_UNSIGNEDSHORT = new QName(URI_2001_SCHEMA_XSD, "unsignedShort");
       public static final QName XSD_UNSIGNEDBYTE = new QName(URI_2001_SCHEMA_XSD, "unsignedByte");
  -    
  +
       public static final QName XSD_YEARMONTH = new QName(URI_2001_SCHEMA_XSD, "gYearMonth");
       public static final QName XSD_MONTHDAY = new QName(URI_2001_SCHEMA_XSD, "gMonthDay");
       public static final QName XSD_YEAR = new QName(URI_2001_SCHEMA_XSD, "gYear");
       public static final QName XSD_MONTH = new QName(URI_2001_SCHEMA_XSD, "gMonth");
       public static final QName XSD_DAY = new QName(URI_2001_SCHEMA_XSD, "gDay");
  -    
  +
  +    public static final QName XSD_NAME = new QName(URI_2001_SCHEMA_XSD, "Name");
  +    public static final QName XSD_NCNAME = new QName(URI_2001_SCHEMA_XSD, "NCName");
  +    public static final QName XSD_NMTOKEN = new QName(URI_2001_SCHEMA_XSD, "NMTOKEN");
   
       public static final QName SOAP_BASE64 = new QName(URI_DEFAULT_SOAP_ENC, "base64");
       public static final QName SOAP_STRING = new QName(URI_DEFAULT_SOAP_ENC, "string");
  
  
  
  1.43      +60 -52    xml-axis/java/src/org/apache/axis/encoding/DefaultTypeMappingImpl.java
  
  Index: DefaultTypeMappingImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/DefaultTypeMappingImpl.java,v
  retrieving revision 1.42
  retrieving revision 1.43
  diff -u -r1.42 -r1.43
  --- DefaultTypeMappingImpl.java	9 Aug 2002 15:18:30 -0000	1.42
  +++ DefaultTypeMappingImpl.java	13 Aug 2002 06:03:27 -0000	1.43
  @@ -327,7 +327,7 @@
                      new SimpleDeserializerFactory(org.apache.axis.types.MonthDay.class,
                                                Constants.XSD_MONTHDAY),
                      true);
  -        
  +
           // Serialize all extensions of Map to SOAP_MAP
           // The SOAP_MAP will be deserialized into a HashMap by default.
           myRegister(Constants.SOAP_MAP,       java.util.HashMap.class,
  @@ -375,67 +375,75 @@
   
           // xsd:token
           myRegister(Constants.XSD_TOKEN, org.apache.axis.types.Token.class,
  -                new TokenSerializerFactory(org.apache.axis.types.Token.class,
  -                    Constants.XSD_TOKEN),
  -                new TokenDeserializerFactory(
  -                    org.apache.axis.types.Token.class,
  -                    Constants.XSD_TOKEN),
  -                false);
  +                   new SimplePrimitiveSerializerFactory(org.apache.axis.types.Token.class,
  +                                             Constants.XSD_TOKEN),
  +                   new SimpleDeserializerFactory(org.apache.axis.types.Token.class,
  +                                             Constants.XSD_TOKEN),
  +                   true);
   
           // a xsd:normalizedString
  -        myRegister(Constants.XSD_NORMALIZEDSTRING,
  -                org.apache.axis.types.NormalizedString.class,
  -                new NormalizedStringSerializerFactory(
  -                    org.apache.axis.types.NormalizedString.class,
  -                    Constants.XSD_NORMALIZEDSTRING),
  -                new NormalizedStringDeserializerFactory(
  -                    org.apache.axis.types.NormalizedString.class,
  -                    Constants.XSD_NORMALIZEDSTRING),
  -                false);
  +        myRegister(Constants.XSD_NORMALIZEDSTRING, org.apache.axis.types.NormalizedString.class,
  +                   new SimplePrimitiveSerializerFactory(org.apache.axis.types.NormalizedString.class,
  +                                             Constants.XSD_NORMALIZEDSTRING),
  +                   new SimpleDeserializerFactory(org.apache.axis.types.NormalizedString.class,
  +                                             Constants.XSD_NORMALIZEDSTRING),
  +                   true);
   
           // a xsd:unsignedLong
  -        myRegister(Constants.XSD_UNSIGNEDLONG,
  -                org.apache.axis.types.UnsignedLong.class,
  -                new UnsignedLongSerializerFactory(
  -                    org.apache.axis.types.UnsignedLong.class,
  -                    Constants.XSD_UNSIGNEDLONG),
  -                new UnsignedLongDeserializerFactory(
  -                    org.apache.axis.types.UnsignedLong.class,
  -                    Constants.XSD_UNSIGNEDLONG),
  -                false);
  +        myRegister(Constants.XSD_UNSIGNEDLONG, org.apache.axis.types.UnsignedLong.class,
  +             new SimplePrimitiveSerializerFactory(org.apache.axis.types.UnsignedLong.class,
  +                                                  Constants.XSD_UNSIGNEDLONG),
  +             new SimpleDeserializerFactory(org.apache.axis.types.UnsignedLong.class,
  +                                           Constants.XSD_UNSIGNEDLONG),
  +             true);
   
           // a xsd:unsignedInt
  -        myRegister(Constants.XSD_UNSIGNEDINT,
  -                org.apache.axis.types.UnsignedInt.class,
  -                new UnsignedIntSerializerFactory(
  -                    org.apache.axis.types.UnsignedInt.class,
  -                    Constants.XSD_UNSIGNEDINT),
  -                new UnsignedIntDeserializerFactory(
  -                    org.apache.axis.types.UnsignedInt.class,
  -                    Constants.XSD_UNSIGNEDINT),
  -                false);
  +        myRegister(Constants.XSD_UNSIGNEDINT, org.apache.axis.types.UnsignedInt.class,
  +             new SimplePrimitiveSerializerFactory(org.apache.axis.types.UnsignedInt.class,
  +                                                  Constants.XSD_UNSIGNEDINT),
  +             new SimpleDeserializerFactory(org.apache.axis.types.UnsignedInt.class,
  +                                           Constants.XSD_UNSIGNEDINT),
  +             true);
   
           // a xsd:unsignedShort
  -        myRegister(Constants.XSD_UNSIGNEDSHORT,
  -                org.apache.axis.types.UnsignedShort.class,
  -                new UnsignedShortSerializerFactory(
  -                    org.apache.axis.types.UnsignedShort.class,
  -                    Constants.XSD_UNSIGNEDSHORT),
  -                new UnsignedShortDeserializerFactory(
  -                    org.apache.axis.types.UnsignedShort.class,
  -                    Constants.XSD_UNSIGNEDSHORT),
  -                false);
  +        myRegister(Constants.XSD_UNSIGNEDSHORT, org.apache.axis.types.UnsignedShort.class,
  +             new SimplePrimitiveSerializerFactory(org.apache.axis.types.UnsignedShort.class,
  +                                                  Constants.XSD_UNSIGNEDSHORT),
  +             new SimpleDeserializerFactory(org.apache.axis.types.UnsignedShort.class,
  +                                           Constants.XSD_UNSIGNEDSHORT),
  +             true);
   
           // a xsd:unsignedByte
  -        myRegister(Constants.XSD_UNSIGNEDBYTE,
  -                org.apache.axis.types.UnsignedByte.class,
  -                new UnsignedByteSerializerFactory(
  -                    org.apache.axis.types.UnsignedByte.class,
  -                    Constants.XSD_UNSIGNEDBYTE),
  -                new UnsignedByteDeserializerFactory(
  -                    org.apache.axis.types.UnsignedByte.class,
  -                    Constants.XSD_UNSIGNEDBYTE),
  -                false);
  +        myRegister(Constants.XSD_UNSIGNEDBYTE, org.apache.axis.types.UnsignedByte.class,
  +                   new SimplePrimitiveSerializerFactory(org.apache.axis.types.UnsignedByte.class,
  +                                             Constants.XSD_UNSIGNEDBYTE),
  +                   new SimpleDeserializerFactory(org.apache.axis.types.UnsignedByte.class,
  +                                             Constants.XSD_UNSIGNEDBYTE),
  +                   true);
  +
  +        // a xsd:Name
  +        myRegister(Constants.XSD_NAME, org.apache.axis.types.Name.class,
  +                   new SimplePrimitiveSerializerFactory(org.apache.axis.types.Name.class,
  +                                             Constants.XSD_NAME),
  +                   new SimpleDeserializerFactory(org.apache.axis.types.Name.class,
  +                                             Constants.XSD_NAME),
  +                   true);
  +
  +        // a xsd:NCName
  +        myRegister(Constants.XSD_NCNAME, org.apache.axis.types.NCName.class,
  +                   new SimplePrimitiveSerializerFactory(org.apache.axis.types.NCName.class,
  +                                             Constants.XSD_NCNAME),
  +                   new SimpleDeserializerFactory(org.apache.axis.types.NCName.class,
  +                                             Constants.XSD_NCNAME),
  +                   true);
  +
  +        // a xsd:NmToken
  +        myRegister(Constants.XSD_NMTOKEN, org.apache.axis.types.NMToken.class,
  +                   new SimplePrimitiveSerializerFactory(org.apache.axis.types.NMToken.class,
  +                                             Constants.XSD_NMTOKEN),
  +                   new SimpleDeserializerFactory(org.apache.axis.types.NMToken.class,
  +                                             Constants.XSD_NMTOKEN),
  +                   true);
   
           // All array objects automatically get associated with the SOAP_ARRAY.
           // There is no way to do this with a hash table,
  
  
  
  1.2       +5 -1      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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- UnsignedByte.java	7 Aug 2002 21:02:09 -0000	1.1
  +++ UnsignedByte.java	13 Aug 2002 06:03:27 -0000	1.2
  @@ -76,7 +76,11 @@
        * @exception Exception will be thrown if validation fails
        */
       public UnsignedByte(long sValue) throws Exception {
  -            setValue(sValue);
  +      setValue(sValue);
  +    }
  +
  +    public UnsignedByte(String sValue) throws Exception {
  +      setValue(Long.parseLong(sValue));
       }
   
       /**
  
  
  
  1.3       +2 -2      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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- UnsignedInt.java	8 Aug 2002 16:44:15 -0000	1.2
  +++ UnsignedInt.java	13 Aug 2002 06:03:27 -0000	1.3
  @@ -78,11 +78,11 @@
        * @exception Exception will be thrown if validation fails
        */
       public UnsignedInt(long iValue) throws Exception {
  -            setValue(iValue);
  +      setValue(iValue);
       }
   
       public UnsignedInt(String stValue) throws Exception {
  -            setValue(Long.parseLong(stValue));
  +      setValue(Long.parseLong(stValue));
       }
   
   
  
  
  
  1.3       +5 -1      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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- UnsignedLong.java	8 Aug 2002 16:44:15 -0000	1.2
  +++ UnsignedLong.java	13 Aug 2002 06:03:27 -0000	1.3
  @@ -77,7 +77,11 @@
        * @exception Exception will be thrown if validation fails
        */
       public UnsignedLong(double lValue) throws Exception {
  -            setValue(lValue);
  +      setValue(lValue);
  +    }
  +
  +    public UnsignedLong(String stValue) throws Exception {
  +      setValue(Double.parseDouble(stValue));
       }
   
       /**
  
  
  
  1.2       +5 -1      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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- UnsignedShort.java	7 Aug 2002 21:02:09 -0000	1.1
  +++ UnsignedShort.java	13 Aug 2002 06:03:27 -0000	1.2
  @@ -75,7 +75,11 @@
        * @exception Exception will be thrown if validation fails
        */
       public UnsignedShort(long sValue) throws Exception {
  -            setValue(sValue);
  +      setValue(sValue);
  +    }
  +
  +    public UnsignedShort(String sValue) throws Exception {
  +      setValue(Long.parseLong(sValue));
       }
   
       /**
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/types/NCName.java
  
  Index: NCName.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.axis.types;
  
  import java.lang.Character;
  
  import org.apache.axis.utils.JavaUtils;
  
  /**
   * Custom class for supporting XSD data type NCName
   * NCName represents XML "non-colonized" Names
   * The base type of NCName is Name.
   *
   * @author Chris Haddad <ch...@cobia.net>
   * @see <a href="http://www.w3.org/TR/xmlschema-2/#NCName">XML Schema 3.3.7</a>
   * @see <A href="http://www.w3.org/TR/1999/REC-xml-names-19990114/#NT-NCName">NCName Production</a>
   */
  public class NCName extends Name {
  
      public NCName() {
          super();
      }
  
      /**
       * ctor for NCName
       * @exception Exception will be thrown if validation fails
       */
      public NCName(String stValue) throws Exception {
          try {
              setValue(stValue);
          }
          catch (Exception e) {
              // recast normalizedString exception as token exception
              throw new Exception(JavaUtils.getMessage("badNCNameType00") + "data=[" +
                      stValue + "]");
          }
      }
  
      /**
      * validate against definition of NCNameChar
      * NCNameChar ::=  Letter | Digit | '.' | '-' | '_' | CombiningChar | Extender
      **/
      public boolean isNameChar(Character cValue) {
        if ( (Character.isDigit(cValue.charValue()) == true)   ||
          (Character.isLetter(cValue.charValue()) == true) ||
          (cValue.charValue() == '.') ||
          (cValue.charValue() == '-') ||
          (cValue.charValue() == '_') )
        //TODO  CombineChar ||
        //TODO  Extender
            return true;
          else
            return false;
      }
  
      /**
       *
       * validate the value against the xsd definition
       *
       * NCName ::=  (Letter | '_') (NCNameChar)*
       * NCNameChar ::=  Letter | Digit | '.' | '-' | '_' | CombiningChar | Extender
       */
      public boolean isValid(String stValue) {
          int scan;
          Character cValue;
  
          for (scan=0; scan < stValue.length(); scan++) {
            cValue = new Character(stValue.charAt(scan));
            if (scan == 0) {
                      // Name[0] = (Letter | '_' )
              if ( (Character.isLetter(cValue.charValue()) != true) &&
                (cValue.charValue() != '_') )
                  return false;
              }
            else
              if (isNameChar(cValue) == false)
                return false;
          }
  
          return true;
      }
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/types/NMToken.java
  
  Index: NMToken.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.axis.types;
  
  import java.util.ArrayList;
  
  import org.apache.axis.utils.JavaUtils;
  
  /**
   * Custom class for supporting XSD data type NMToken
   *
   * NMTOKEN represents the NMTOKEN attribute type from
   * [XML 1.0(Second Edition)]. The value space of NMTOKEN
   * is the set of tokens that match the Nmtoken production
   * in [XML 1.0 (Second Edition)].
   * The base type of NMTOKEN is token.
   * @author Chris Haddad <ch...@cobia.net>
   * @see <a href="http://www.w3.org/TR/xmlschema-2/#nmtoken">XML Schema 3.3.4</a>
   */
  public class NMToken extends Token {
  
      public NMToken() {
          super();
      }
  
      /**
       * ctor for NMToken
       * @exception Exception will be thrown if validation fails
       */
      public NMToken(String stValue) throws Exception {
          try {
              setValue(stValue);
          }
          catch (Exception e) {
              // recast normalizedString exception as token exception
              throw new Exception(JavaUtils.getMessage("badNmtoken00") + "data=[" +
                      stValue + "]");
          }
      }
  
      /**
      * validate against definition of NameChar
      * NameChar    ::=     Letter | Digit | '.' | '-' | '_' | ':' | CombiningChar | Extender
      **/
      public boolean isNameChar(Character cValue) {
        if ( (Character.isDigit(cValue.charValue()) == true)   ||
          (Character.isLetter(cValue.charValue()) == true) ||
          (cValue.charValue() == '.') ||
          (cValue.charValue() == '-') ||
          (cValue.charValue() == '_') ||
          (cValue.charValue() == ':') )
        //TODO  CombineChar ||
        //TODO  Extender
            return true;
          else
            return false;
      }
  
      /**
       *
       * validate the value against the xsd definition
       * Nmtoken    ::=    (NameChar)+
       */
      public boolean isValid(String stValue) {
          int scan;
          Character cValue;
  
          for (scan=0; scan < stValue.length(); scan++) {
            cValue = new Character(stValue.charAt(scan));
            if (isNameChar(cValue) == false)
                return false;
          }
  
          return true;
      }
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/types/Name.java
  
  Index: Name.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.axis.types;
  
  import java.lang.Character;
  
  import org.apache.axis.utils.JavaUtils;
  
  /**
   * Custom class for supporting XSD data type Name
   * Name represents XML Names. The value space of Name is
   * the set of all strings which match the Name production
   * of [XML 1.0 (Second Edition)].
   * The base type of Name is token.
   * @author Chris Haddad <ch...@cobia.net>
   * @see <a href="http://www.w3.org/TR/xmlschema-2/#Name">XML Schema 3.3.6</a>
   */
  public class Name extends Token {
  
      public Name() {
          super();
      }
  
      /**
       * ctor for Name
       * @exception Exception will be thrown if validation fails
       */
      public Name(String stValue) throws Exception {
          try {
              setValue(stValue);
          }
          catch (Exception e) {
              // recast normalizedString exception as token exception
              throw new Exception(JavaUtils.getMessage("badNameType00") + "data=[" +
                      stValue + "]");
          }
      }
  
      /**
      * validate against XSD definition for NameChar
      * NameChar    ::=     Letter | Digit | '.' | '-' | '_' | ':' | CombiningChar | Extender
      */
      public boolean isNameChar(Character cValue) {
        if ( (Character.isDigit(cValue.charValue()) == true)   ||
          (Character.isLetter(cValue.charValue()) == true) ||
          (cValue.charValue() == '.') ||
          (cValue.charValue() == '-') ||
          (cValue.charValue() == '_') ||
          (cValue.charValue() == ':') )
        //TODO  CombineChar ||
        //TODO  Extender
            return true;
          else
            return false;
      }
  
      /**
       *
       * validate the value against the xsd definition
       *   Name    ::=    (Letter | '_' | ':') ( NameChar)*
       */
      public boolean isValid(String stValue) {
          int scan;
          Character cValue;
  
          // conform to Token validation
          if (super.isValid(stValue) == false)
            return false;
  
          for (scan=0; scan < stValue.length(); scan++) {
                cValue = new Character(stValue.charAt(scan));
                if (scan == 0) {
                  // Name[0] = (Letter | '_' | ':')
                  if ( (Character.isLetter(cValue.charValue()) != true) &&
                    (cValue.charValue() != '_') &&
                    (cValue.charValue() != ':') )
                      return false;
                }
               else
                  if (isNameChar(cValue) == false)
                      return false;
          }
  
          return true;
      }
  }
  
  
  
  1.39      +3 -0      xml-axis/java/src/org/apache/axis/utils/axisNLS.properties
  
  Index: axisNLS.properties
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/axisNLS.properties,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- axisNLS.properties	9 Aug 2002 19:40:12 -0000	1.38
  +++ axisNLS.properties	13 Aug 2002 06:03:28 -0000	1.39
  @@ -51,6 +51,9 @@
   
   badNameAttr00=No ''name'' attribute was specified in an undeployment element
   badNamespace00=Bad envelope namespace:  {0}
  +badNameType00=Invalid Name
  +badNCNameType00=Invalid NCName
  +badNmtoken00=Invalid Nmtoken
   badOffset00=Malformed offset attribute ''{0}''.
   badpackage00=Error: --NStoPKG and --package switch can't be used together
   # NOTE:  in badParmMode00, do not translate "Parameter".
  
  
  
  1.22      +3 -0      xml-axis/java/test/encoding/PackageTests.java
  
  Index: PackageTests.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/encoding/PackageTests.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- PackageTests.java	9 Aug 2002 15:18:30 -0000	1.21
  +++ PackageTests.java	13 Aug 2002 06:03:28 -0000	1.22
  @@ -48,6 +48,9 @@
           suite.addTestSuite(TestMonth.class);
           suite.addTestSuite(TestMonthDay.class);
           suite.addTestSuite(TestDay.class);
  +        suite.addTestSuite(TestName.class);
  +        suite.addTestSuite(TestNCName.class);
  +        suite.addTestSuite(TestNMToken.class);
           return suite;
       }
   }
  
  
  
  1.20      +20 -2     xml-axis/java/test/encoding/TestDeser2001.java
  
  Index: TestDeser2001.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/encoding/TestDeser2001.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- TestDeser2001.java	9 Aug 2002 15:18:30 -0000	1.19
  +++ TestDeser2001.java	13 Aug 2002 06:03:28 -0000	1.20
  @@ -15,6 +15,9 @@
   import org.apache.axis.types.Month;
   import org.apache.axis.types.Day;
   import org.apache.axis.types.MonthDay;
  +import org.apache.axis.types.Name;
  +import org.apache.axis.types.NCName;
  +import org.apache.axis.types.NMToken;
   
   import java.util.ArrayList;
   import java.util.Calendar;
  @@ -94,7 +97,7 @@
   
       /**
        * Test the xsd:Time deserialization
  -     */ 
  +     */
       public void testTimeZ() throws Exception {
           Calendar date = Calendar.getInstance();
           date.set(Calendar.HOUR_OF_DAY, 12);
  @@ -121,7 +124,7 @@
                        "</result>",
                        time);
       }
  -    
  +
       private final int msecsInMinute = 60000;
       private final int msecsInHour = 60 * msecsInMinute;
   
  @@ -190,6 +193,21 @@
       public void testUnsignedByte() throws Exception {
           deserialize("<result xsi:type=\"xsd:unsignedByte\">103</result>",
                       new UnsignedByte(103),true);
  +    }
  +
  +    public void testName() throws Exception {
  +        deserialize("<result xsi:type=\"xsd:Name\">:Braves</result>",
  +                    new Name(":Braves"),true);
  +    }
  +
  +    public void testNCName() throws Exception {
  +        deserialize("<result xsi:type=\"xsd:NCName\">_Atlanta.Braves</result>",
  +                    new NCName("_Atlanta.Braves"),true);
  +    }
  +
  +    public void testNMToken() throws Exception {
  +        deserialize("<result xsi:type=\"xsd:NMTOKEN\">_A.B.C.1-2-3</result>",
  +                    new NMToken("_A.B.C.1-2-3"),true);
       }
   
       public void testQName() throws Exception {
  
  
  
  1.1                  xml-axis/java/test/encoding/TestNCName.java
  
  Index: TestNCName.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package test.encoding;
  
  import junit.framework.TestCase;
  import org.apache.axis.types.NCName;
  
  /**
   * Test validation of types.NCName
   */
  public class TestNCName extends TestCase {
  
  
      public TestNCName(String name) {
          super(name);
      }
  
      /**
       * Run a failure test.  value should be invalid.
       */
      private void runFailTest(String value) throws Exception {
          NCName oToken = null;
          try {
              oToken = new NCName(value);
          }
          catch (Exception e) { // catch the validation exception
          }
          assertNull(
                  "NCName validation restriction failed. did not restrict bad value [" +
                     value + "] did not restrict bad value", oToken);
      }
  
      /**
       * Run a successful test.  value should be valid.
       */
      private void runPassTest(String value) throws Exception {
          NCName oToken = null;
          try {
              oToken = new NCName(value);
          }
          catch (Exception e) { // catch the validation exception
          }
          assertEquals("NCName strings not equal. orig value:" + value, oToken.toString(), value);
      }
  
      /**
       * Test a simple string.
       */
      public void testSimpleString() throws Exception {
          runPassTest("Atlanta");
      }
  
      /**
       * Test a simple string with allowed punctuation.
       */
      public void testPunctuationString() throws Exception {
          runPassTest("Atlanta_Braves.Home-Team10");
      }
  
  
      /**
       * Test a start character '_'
       */
      public void testStartUnderscore() throws Exception {
          runPassTest("_Braves");
      }
  
      /**
       * Test a simple string with allowed punctuation.
       */
      public void testMidColon() throws Exception {
          runFailTest("Atlanta:_Braves.Home-Team10");
      }
  
      /**
       * Test a start Digit
       */
      public void testStartDigit() throws Exception {
          runFailTest("1_Braves");
      }
  
  
      /**
       * Test a start character ':'
       */
      public void testStartColon() throws Exception {
          runFailTest(":_Braves.Home-Team:1");
      }
  
      /**
       * this is to differentiate from normalized string which cannot accept a \n
       */
      public void testLineFeed() throws Exception {
          runFailTest("line one\n line two");
      }
  
      /**
       * this is to differentiate from normalized string which cannot accept a \t
       */
      public void testStringWithTabs() throws Exception {
          runFailTest("this has \t a tab");
      }
  
      /**
       * this is to differentiate from normalized string which cannot accept leading spaces.
       */
      public void testStringWithLeadingSpaces() throws Exception {
          runFailTest("  a failure case");
      }
  
      /**
       * this is to differentiate from normalized string which cannot accept trailing spaces.
       */
      public void testStringWithTrailingSpaces() throws Exception {
          runFailTest("this is a  ");
      }
  
      /**
       * this is to differentiate from normalized string which cannot accept
       * leading and trailing spaces.
       */
      public void testStringWithLeadingAndTrailingSpaces() throws Exception {
          runFailTest("          centered          ");
      }
  
      /**
       * this is to differentiate from normalized string which cannot accept double spaces.
       */
      public void testDoubleSpace() throws Exception {
          runFailTest("a   B"); // note: \r fails
      }
  }
  
  
  
  1.1                  xml-axis/java/test/encoding/TestNMToken.java
  
  Index: TestNMToken.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package test.encoding;
  
  import junit.framework.TestCase;
  import org.apache.axis.types.NMToken;
  
  /**
   * Test validation of types.NMToken
   */
  public class TestNMToken extends TestCase {
  
  
      public TestNMToken(String name) {
          super(name);
      }
  
      /**
       * Run a failure test.  value should be invalid.
       */
      private void runFailTest(String value) throws Exception {
          NMToken oToken = null;
          try {
              oToken = new NMToken(value);
          }
          catch (Exception e) { // catch the validation exception
          }
          assertNull(
                  "NMToken validation restriction failed. did not restrict bad value [" +
                     value + "] did not restrict bad value", oToken);
      }
  
      /**
       * Run a successful test.  value should be valid.
       */
      private void runPassTest(String value) throws Exception {
          NMToken oToken = null;
          try {
              oToken = new NMToken(value);
          }
          catch (Exception e) { // catch the validation exception
          }
          assertEquals("NMToken strings not equal. orig value:" + value, oToken.toString(), value);
      }
  
      /**
       * Test a simple string.
       */
      public void testSimpleString() throws Exception {
          runPassTest("Atlanta1234567890");
      }
  
      /**
       * Test a simple string.
       */
      public void testPunctuationString() throws Exception {
          runPassTest("Atlanta.-_:");
      }
  
  
      /**
       * this is to differentiate from normalized string which cannot accept a \n
       */
      public void testLineFeed() throws Exception {
          runFailTest("line one\n line two");
      }
  
      /**
       * this is to differentiate from normalized string which cannot accept a \t
       */
      public void testStringWithTabs() throws Exception {
          runFailTest("this has \t a tab");
      }
  
      /**
       * this is to differentiate from normalized string which cannot accept leading spaces.
       */
      public void testStringWithLeadingSpaces() throws Exception {
          runFailTest("  a failure case");
      }
  
      /**
       * this is to differentiate from normalized string which cannot accept trailing spaces.
       */
      public void testStringWithTrailingSpaces() throws Exception {
          runFailTest("this is a  ");
      }
  
      /**
       * this is to differentiate from normalized string which cannot accept
       * leading and trailing spaces.
       */
      public void testStringWithLeadingAndTrailingSpaces() throws Exception {
          runFailTest("          centered          ");
      }
  
      /**
       * this is to differentiate from normalized string which cannot accept double spaces.
       */
      public void testDoubleSpace() throws Exception {
          runFailTest("a   B"); // note: \r fails
      }
  }
  
  
  
  1.1                  xml-axis/java/test/encoding/TestName.java
  
  Index: TestName.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package test.encoding;
  
  import junit.framework.TestCase;
  import org.apache.axis.types.Name;
  
  /**
   * Test validation of types.Name
   */
  public class TestName extends TestCase {
  
  
      public TestName(String name) {
          super(name);
      }
  
      /**
       * Run a failure test.  value should be invalid.
       */
      private void runFailTest(String value) throws Exception {
          Name oToken = null;
          try {
              oToken = new Name(value);
          }
          catch (Exception e) { // catch the validation exception
          }
          assertNull(
                  "Name validation restriction failed. did not restrict bad value [" +
                     value + "] did not restrict bad value", oToken);
      }
  
      /**
       * Run a successful test.  value should be valid.
       */
      private void runPassTest(String value) throws Exception {
          Name oToken = null;
          try {
              oToken = new Name(value);
          }
          catch (Exception e) { // catch the validation exception
          }
          assertEquals("Name strings not equal. orig value:" + value, oToken.toString(), value);
      }
  
      /**
       * Test a simple string.
       */
      public void testSimpleString() throws Exception {
          runPassTest("Atlanta");
      }
  
      /**
       * Test a simple string with allowed punctuation.
       */
      public void testPunctuationString() throws Exception {
          runPassTest("Atlanta:_Braves.Home-Team10");
      }
  
      /**
       * Test a start character ':'
       */
      public void testStartColon() throws Exception {
          runPassTest(":_Braves.Home-Team:1");
      }
  
      /**
       * Test a start character '_'
       */
      public void testStartUnderscore() throws Exception {
          runPassTest("_Braves.Home-Team:1");
      }
  
  
      /**
       * Test a start Digit
       */
      public void testStartDigit() throws Exception {
          runFailTest("1_Braves");
      }
  
  
      /**
       * this is to differentiate from normalized string which cannot accept a \n
       */
      public void testLineFeed() throws Exception {
          runFailTest("line one\n line two");
      }
  
      /**
       * this is to differentiate from normalized string which cannot accept a \t
       */
      public void testStringWithTabs() throws Exception {
          runFailTest("this has \t a tab");
      }
  
      /**
       * this is to differentiate from normalized string which cannot accept leading spaces.
       */
      public void testStringWithLeadingSpaces() throws Exception {
          runFailTest("  a failure case");
      }
  
      /**
       * this is to differentiate from normalized string which cannot accept trailing spaces.
       */
      public void testStringWithTrailingSpaces() throws Exception {
          runFailTest("this is a  ");
      }
  
      /**
       * this is to differentiate from normalized string which cannot accept
       * leading and trailing spaces.
       */
      public void testStringWithLeadingAndTrailingSpaces() throws Exception {
          runFailTest("          centered          ");
      }
  
      /**
       * this is to differentiate from normalized string which cannot accept double spaces.
       */
      public void testDoubleSpace() throws Exception {
          runFailTest("a   B"); // note: \r fails
      }
  }