xmlbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From z...@apache.org
Subject cvs commit: xml-xmlbeans/v2/test/src/drt/drtcases MarshalTests.java
Date Sat, 13 Mar 2004 03:46:58 GMT
zieg        2004/03/12 19:46:58

  Modified:    v2/src/binding/org/apache/xmlbeans/impl/binding/bts
                        BindingType.java BindingTypeVisitor.java
                        ByNameBean.java
               v2/src/configschema/schema binding-config.xsd
               v2/src/marshal/org/apache/xmlbeans/impl/marshal
                        BuiltinRuntimeBindingType.java MarshalResult.java
                        RuntimeBindingType.java
                        RuntimeBindingTypeTable.java
                        RuntimeTypeFactory.java
                        SimpleContentBeanMarshaller.java
               v2/src/marshal/org/apache/xmlbeans/impl/marshal/util
                        ReflectionUtils.java
               v2/test/cases/marshal doc.xml example_config.xml
               v2/test/cases/marshal/com/mytest YourClass.java
               v2/test/src/drt/drtcases MarshalTests.java
  Added:       v2/src/binding/org/apache/xmlbeans/impl/binding/bts
                        JaxrpcEnumType.java
               v2/src/marshal/org/apache/xmlbeans/impl/marshal
                        JaxrpcEnumMarsahller.java
                        JaxrpcEnumRuntimeBindingType.java
                        JaxrpcEnumUnmarshaller.java
               v2/test/cases/marshal/com/mytest IntEnum.java
                        IntegerEnum.java ModeEnum.java
  Log:
  add support for jax-rpc style enumerated types
  
  Revision  Changes    Path
  1.15      +1 -0      xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/bts/BindingType.java
  
  Index: BindingType.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/bts/BindingType.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- BindingType.java	9 Mar 2004 23:50:53 -0000	1.14
  +++ BindingType.java	13 Mar 2004 03:46:57 -0000	1.15
  @@ -115,6 +115,7 @@
       registerClassAndType(SimpleContentBean.class, org.apache.xml.xmlbeans.bindingConfig.SimpleContentBean.type);
       registerClassAndType(WrappedArrayType.class, org.apache.xml.xmlbeans.bindingConfig.WrappedArray.type);
       registerClassAndType(SimpleBindingType.class, org.apache.xml.xmlbeans.bindingConfig.SimpleType.type);
  +    registerClassAndType(JaxrpcEnumType.class, org.apache.xml.xmlbeans.bindingConfig.JaxrpcEnumType.type);
       registerClassAndType(SimpleDocumentBinding.class, org.apache.xml.xmlbeans.bindingConfig.SimpleDocumentBinding.type);
     }
   
  
  
  
  1.3       +3 -0      xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/bts/BindingTypeVisitor.java
  
  Index: BindingTypeVisitor.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/bts/BindingTypeVisitor.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- BindingTypeVisitor.java	9 Mar 2004 23:50:53 -0000	1.2
  +++ BindingTypeVisitor.java	13 Mar 2004 03:46:57 -0000	1.3
  @@ -31,6 +31,9 @@
       void visit(SimpleBindingType simpleBindingType)
           throws XmlException;
   
  +    void visit(JaxrpcEnumType jaxrpcEnumType)
  +        throws XmlException;
  +
       void visit(SimpleDocumentBinding simpleDocumentBinding)
           throws XmlException;
   
  
  
  
  1.10      +1 -1      xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/bts/ByNameBean.java
  
  Index: ByNameBean.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/bts/ByNameBean.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- ByNameBean.java	6 Mar 2004 01:46:00 -0000	1.9
  +++ ByNameBean.java	13 Mar 2004 03:46:57 -0000	1.10
  @@ -89,7 +89,7 @@
      */
     public void addProperty(QNameProperty newProp) {
       if (newProp.isAttribute() ? attProps.containsKey(newProp.getQName()) : eltProps.containsKey(newProp.getQName()))
  -      throw new IllegalArgumentException();
  +      throw new IllegalArgumentException("duplicate property: " + newProp.getQName() + " in type " + this);
   
       props.add(newProp);
       if (newProp.isAttribute())
  
  
  
  1.1                  xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/bts/JaxrpcEnumType.java
  
  Index: JaxrpcEnumType.java
  ===================================================================
  /*   Copyright 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.xmlbeans.impl.binding.bts;
  
  import org.apache.xmlbeans.XmlException;
  
  /**
   * A binding of a simple user-defined type that operates by
   * delegating to another well-known (e.g., builtin) binding.
   */
  public class JaxrpcEnumType extends BindingType
  {
  
      // ========================================================================
      // Variables
  
      private BindingTypeName baseType;
      private MethodName getValueMethod;
      private MethodName fromValueMethod;
      private MethodName fromStringMethod;
      private MethodName toXMLMethod;
  
      // ========================================================================
      // Constructors
  
      public JaxrpcEnumType(BindingTypeName btName)
      {
          super(btName);
      }
  
      public JaxrpcEnumType(org.apache.xml.xmlbeans.bindingConfig.BindingType node)
      {
          this((org.apache.xml.xmlbeans.bindingConfig.JaxrpcEnumType)node);
      }
  
      public JaxrpcEnumType(org.apache.xml.xmlbeans.bindingConfig.JaxrpcEnumType node)
      {
          super(node);
  
          this.baseType = BindingTypeName.forPair(
              JavaTypeName.forString(node.getBaseJavatype()),
              XmlTypeName.forString(node.getBaseXmlcomponent()));
  
          this.getValueMethod = MethodName.create(node.getGetValueMethod());
          this.fromValueMethod = MethodName.create(node.getFromValueMethod());
          this.fromStringMethod = MethodName.create(node.getFromStringMethod());
  
          org.apache.xml.xmlbeans.bindingConfig.JavaMethodName toxml_method =
              node.getToXMLMethod();
          if (toxml_method != null) {
              this.toXMLMethod = MethodName.create(toxml_method);
          }
      }
  
  
      protected org.apache.xml.xmlbeans.bindingConfig.BindingType write(org.apache.xml.xmlbeans.bindingConfig.BindingType node)
      {
          org.apache.xml.xmlbeans.bindingConfig.JaxrpcEnumType jnode =
              (org.apache.xml.xmlbeans.bindingConfig.JaxrpcEnumType)super.write(node);
  
          if (baseType != null) {
              jnode.setBaseJavatype(baseType.getJavaName().toString());
              jnode.setBaseXmlcomponent(baseType.getXmlName().toString());
          }
  
          if (getValueMethod != null) {
              getValueMethod.write(jnode.addNewGetValueMethod());
          }
  
          if (fromValueMethod != null) {
              fromValueMethod.write(jnode.addNewFromValueMethod());
          }
  
          if (getValueMethod != null) {
              getValueMethod.write(jnode.addNewGetValueMethod());
          }
  
          if (fromStringMethod != null) {
              fromStringMethod.write(jnode.addNewFromStringMethod());
          }
  
          return jnode;
      }
  
      public void accept(BindingTypeVisitor visitor) throws XmlException
      {
          visitor.visit(this);
      }
  
  
      // ========================================================================
      // Public methods
  
      public BindingTypeName getBaseTypeName()
      {
          return baseType;
      }
  
      public void setBaseType(BindingType bType)
      {
          baseType = bType.getName();
      }
  
      public MethodName getGetValueMethod()
      {
          return getValueMethod;
      }
  
      public void setGetValueMethod(MethodName getValueMethod)
      {
          this.getValueMethod = getValueMethod;
      }
  
      public MethodName getFromValueMethod()
      {
          return fromValueMethod;
      }
  
      public void setFromValueMethod(MethodName fromValueMethod)
      {
          this.fromValueMethod = fromValueMethod;
      }
  
      public MethodName getFromStringMethod()
      {
          return fromStringMethod;
      }
  
      public void setFromStringMethod(MethodName fromStringMethod)
      {
          this.fromStringMethod = fromStringMethod;
      }
  
      public MethodName getToXMLMethod()
      {
          return toXMLMethod;
      }
  
      public void setToXMLMethod(MethodName toXMLMethod)
      {
          this.toXMLMethod = toXMLMethod;
      }
  
  }
  
  
  
  1.17      +28 -0     xml-xmlbeans/v2/src/configschema/schema/binding-config.xsd
  
  Index: binding-config.xsd
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/configschema/schema/binding-config.xsd,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- binding-config.xsd	13 Mar 2004 00:33:22 -0000	1.16
  +++ binding-config.xsd	13 Mar 2004 03:46:57 -0000	1.17
  @@ -54,6 +54,34 @@
       </xs:complexContent>
     </xs:complexType>
   
  +  <xs:complexType name="jaxrpc-enum-type">
  +    <xs:annotation>
  +      <xs:documentation>represents the binding of a enumerated type in schema to
  +        a JAX-RPC style typesafe enum class.  See JAX-RPC 1.1 Section 4.2.4
  +      </xs:documentation>
  +    </xs:annotation>
  +    <xs:complexContent>
  +      <xs:extension base="tns:binding-type">
  +        <xs:sequence>
  +          <xs:element name="base-xmlcomponent" type="tns:xml-signature"/>
  +          <xs:element name="base-javatype" type="tns:java-class-name"/>
  +          <xs:element name="getValue-method" type="tns:java-method-name"/>
  +          <xs:element name="fromValue-method" type="tns:java-method-name"/>
  +          <xs:element name="fromString-method" type="tns:java-method-name"/>
  +          <xs:element name="toXML-method" type="tns:java-method-name" minOccurs="0">
  +            <xs:annotation>
  +              <xs:documentation>not required by jax-rpc, but used if present
  +                for more efficient serialization of an enumeration value to xml.
  +                Must return a String value that will be used as the xml
  +                serialization for the given enum value (method is not static).
  +              </xs:documentation>
  +            </xs:annotation>
  +          </xs:element>
  +        </xs:sequence>
  +      </xs:extension>
  +    </xs:complexContent>
  +  </xs:complexType>
  +
     <xs:complexType name="simple-document-binding">
       <xs:complexContent>
         <xs:extension base="tns:binding-type">
  
  
  
  1.2       +1 -0      xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/BuiltinRuntimeBindingType.java
  
  Index: BuiltinRuntimeBindingType.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/BuiltinRuntimeBindingType.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BuiltinRuntimeBindingType.java	19 Feb 2004 18:43:56 -0000	1.1
  +++ BuiltinRuntimeBindingType.java	13 Mar 2004 03:46:57 -0000	1.2
  @@ -59,6 +59,7 @@
   import org.apache.xmlbeans.XmlException;
   import org.apache.xmlbeans.impl.binding.bts.BindingLoader;
   import org.apache.xmlbeans.impl.binding.bts.BuiltinBindingType;
  +import org.apache.xmlbeans.impl.binding.bts.BindingType;
   
   public class BuiltinRuntimeBindingType
       extends RuntimeBindingType
  
  
  
  1.20      +9 -0      xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/MarshalResult.java
  
  Index: MarshalResult.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/MarshalResult.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- MarshalResult.java	10 Mar 2004 06:42:19 -0000	1.19
  +++ MarshalResult.java	13 Mar 2004 03:46:57 -0000	1.20
  @@ -28,6 +28,7 @@
   import org.apache.xmlbeans.impl.binding.bts.SimpleContentBean;
   import org.apache.xmlbeans.impl.binding.bts.SimpleDocumentBinding;
   import org.apache.xmlbeans.impl.binding.bts.WrappedArrayType;
  +import org.apache.xmlbeans.impl.binding.bts.JaxrpcEnumType;
   import org.apache.xmlbeans.impl.common.XmlStreamUtils;
   import org.apache.xmlbeans.impl.common.XmlWhitespace;
   import org.apache.xmlbeans.impl.marshal.util.collections.ArrayIterator;
  @@ -684,6 +685,14 @@
           }
   
           public void visit(SimpleBindingType simpleBindingType)
  +            throws XmlException
  +        {
  +            xmlTypeVisitor = new SimpleTypeVisitor(runtimeBindingProperty,
  +                                                   parentObject,
  +                                                   marshalResult);
  +        }
  +
  +        public void visit(JaxrpcEnumType jaxrpcEnumType)
               throws XmlException
           {
               xmlTypeVisitor = new SimpleTypeVisitor(runtimeBindingProperty,
  
  
  
  1.12      +1 -1      xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/RuntimeBindingType.java
  
  Index: RuntimeBindingType.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/RuntimeBindingType.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- RuntimeBindingType.java	10 Mar 2004 07:26:15 -0000	1.11
  +++ RuntimeBindingType.java	13 Mar 2004 03:46:57 -0000	1.12
  @@ -323,7 +323,7 @@
                   "null value for " + getName() + " class=" + beanClass;
   
               assert marshaller != null :
  -                "null marshaller for prop=" + getName() + " class=" +
  +                "null marshaller for prop=" + getName() + " java-type=" +
                   beanClass + " propType=" + runtimeBindingType;
   
               return marshaller.print(value, result);
  
  
  
  1.21      +17 -0     xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/RuntimeBindingTypeTable.java
  
  Index: RuntimeBindingTypeTable.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/RuntimeBindingTypeTable.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- RuntimeBindingTypeTable.java	13 Mar 2004 00:33:22 -0000	1.20
  +++ RuntimeBindingTypeTable.java	13 Mar 2004 03:46:57 -0000	1.21
  @@ -29,6 +29,7 @@
   import org.apache.xmlbeans.impl.binding.bts.SimpleDocumentBinding;
   import org.apache.xmlbeans.impl.binding.bts.WrappedArrayType;
   import org.apache.xmlbeans.impl.binding.bts.XmlTypeName;
  +import org.apache.xmlbeans.impl.binding.bts.JaxrpcEnumType;
   import org.apache.xmlbeans.impl.common.ConcurrentReaderHashMap;
   import org.apache.xmlbeans.impl.common.XmlWhitespace;
   
  @@ -406,6 +407,11 @@
                   throw new XmlException("no asif for " + stype);
   
               m = lookupMarshaller(asif_name, loader);
  +        } else if (binding_type instanceof JaxrpcEnumType) {
  +            JaxrpcEnumType enum_type = (JaxrpcEnumType)binding_type;
  +            final JaxrpcEnumRuntimeBindingType rtt =
  +                runtimeTypeFactory.createRuntimeType(enum_type, this, loader);
  +            m = new JaxrpcEnumMarsahller(rtt);
           }
   
           if (m != null)
  @@ -469,6 +475,17 @@
               typeUnmarshaller =
                   createSimpleTypeUnmarshaller(simpleBindingType, loader,
                                                runtimeBindingTypeTable);
  +        }
  +
  +        public void visit(JaxrpcEnumType jaxrpcEnumType)
  +            throws XmlException
  +        {
  +            JaxrpcEnumRuntimeBindingType rtt =
  +                runtimeTypeFactory.createRuntimeType(jaxrpcEnumType,
  +                                                     runtimeBindingTypeTable,
  +                                                     loader);
  +
  +            typeUnmarshaller = new JaxrpcEnumUnmarshaller(rtt);
           }
   
           public void visit(SimpleDocumentBinding simpleDocumentBinding)
  
  
  
  1.13      +17 -0     xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/RuntimeTypeFactory.java
  
  Index: RuntimeTypeFactory.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/RuntimeTypeFactory.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- RuntimeTypeFactory.java	9 Mar 2004 23:50:53 -0000	1.12
  +++ RuntimeTypeFactory.java	13 Mar 2004 03:46:57 -0000	1.13
  @@ -25,6 +25,7 @@
   import org.apache.xmlbeans.impl.binding.bts.SimpleContentBean;
   import org.apache.xmlbeans.impl.binding.bts.SimpleDocumentBinding;
   import org.apache.xmlbeans.impl.binding.bts.WrappedArrayType;
  +import org.apache.xmlbeans.impl.binding.bts.JaxrpcEnumType;
   import org.apache.xmlbeans.impl.common.ConcurrentReaderHashMap;
   
   import java.util.HashMap;
  @@ -129,6 +130,16 @@
           return (SimpleContentRuntimeBindingType)rtt;
       }
   
  +    public JaxrpcEnumRuntimeBindingType createRuntimeType(JaxrpcEnumType type,
  +                                                          RuntimeBindingTypeTable type_table,
  +                                                          BindingLoader binding_loader)
  +        throws XmlException
  +    {
  +        final RuntimeBindingType rtt =
  +            createRuntimeTypeInternal(type, type_table, binding_loader);
  +        return (JaxrpcEnumRuntimeBindingType)rtt;
  +    }
  +
   
       //avoids a cast to deal with overloaded methods
       private RuntimeBindingType createRuntimeTypeInternal(BindingType type,
  @@ -179,6 +190,12 @@
               throws XmlException
           {
               runtimeBindingType = new SimpleRuntimeBindingType(simpleBindingType);
  +        }
  +
  +        public void visit(JaxrpcEnumType jaxrpcEnumType)
  +            throws XmlException
  +        {
  +            runtimeBindingType = new JaxrpcEnumRuntimeBindingType(jaxrpcEnumType);
           }
   
           public void visit(SimpleDocumentBinding simpleDocumentBinding)
  
  
  
  1.2       +6 -2      xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/SimpleContentBeanMarshaller.java
  
  Index: SimpleContentBeanMarshaller.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/SimpleContentBeanMarshaller.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SimpleContentBeanMarshaller.java	9 Mar 2004 23:50:53 -0000	1.1
  +++ SimpleContentBeanMarshaller.java	13 Mar 2004 03:46:57 -0000	1.2
  @@ -86,11 +86,15 @@
       public CharSequence print(Object value, MarshalResult result)
           throws XmlException
       {
  +        final RuntimeBindingProperty simple_content_prop =
  +            simpleContentType.getSimpleContentProperty();
  +
           final Object simple_content_val =
  -            simpleContentType.getSimpleContentProperty().getValue(value, result);
  +            simple_content_prop.getValue(value, result);
   
           final RuntimeBindingType prop_rtt =
  -            simpleContentType.getSimpleContentProperty().getRuntimeBindingType();
  +            simple_content_prop.getRuntimeBindingType();
  +
           final RuntimeBindingType actualRuntimeType =
               MarshalResult.findActualRuntimeType(simple_content_val,
                                                   prop_rtt, result);
  
  
  
  1.1                  xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/JaxrpcEnumMarsahller.java
  
  Index: JaxrpcEnumMarsahller.java
  ===================================================================
  /*
  * The Apache Software License, Version 1.1
  *
  *
  * Copyright (c) 2003 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 "Apache" 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
  *    XMLBeans", 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 and was
  * originally based on software copyright (c) 2000-2003 BEA Systems
  * Inc., <http://www.bea.com/>. For more information on the Apache Software
  * Foundation, please see <http://www.apache.org/>.
  */
  
  package org.apache.xmlbeans.impl.marshal;
  
  import org.apache.xmlbeans.XmlException;
  
  final class JaxrpcEnumMarsahller
      implements TypeMarshaller
  {
      private final JaxrpcEnumRuntimeBindingType enumType;
  
  
      public JaxrpcEnumMarsahller(JaxrpcEnumRuntimeBindingType rtt)
      {
          enumType = rtt;
      }
  
      //non simple types can throw a runtime exception
      public CharSequence print(Object value, MarshalResult result)
          throws XmlException
      {
         return enumType.print(value, result);
      }
  }
  
  
  
  1.1                  xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/JaxrpcEnumRuntimeBindingType.java
  
  Index: JaxrpcEnumRuntimeBindingType.java
  ===================================================================
  /*
  * The Apache Software License, Version 1.1
  *
  *
  * Copyright (c) 2003 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 "Apache" 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
  *    XMLBeans", 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 and was
  * originally based on software copyright (c) 2000-2003 BEA Systems
  * Inc., <http://www.bea.com/>. For more information on the Apache Software
  * Foundation, please see <http://www.apache.org/>.
  */
  
  package org.apache.xmlbeans.impl.marshal;
  
  import org.apache.xmlbeans.XmlException;
  import org.apache.xmlbeans.impl.binding.bts.BindingLoader;
  import org.apache.xmlbeans.impl.binding.bts.JaxrpcEnumType;
  import org.apache.xmlbeans.impl.binding.bts.BindingType;
  import org.apache.xmlbeans.impl.binding.bts.BindingTypeName;
  import org.apache.xmlbeans.impl.marshal.util.ReflectionUtils;
  
  import java.lang.reflect.Method;
  
  final class JaxrpcEnumRuntimeBindingType
      extends RuntimeBindingType
  {
      private final JaxrpcEnumType jaxrpcEnumType;
      private ItemInfo itemInfo;
  
      JaxrpcEnumRuntimeBindingType(JaxrpcEnumType type)
          throws XmlException
      {
          super(type);
          jaxrpcEnumType = type;
      }
  
      void initialize(RuntimeBindingTypeTable typeTable,
                      BindingLoader bindingLoader,
                      RuntimeTypeFactory rttFactory)
          throws XmlException
      {
          itemInfo = new ItemInfo(jaxrpcEnumType, getJavaType(), typeTable,
                                  bindingLoader, rttFactory);
      }
  
      CharSequence print(Object value,
                         MarshalResult result)
          throws XmlException
      {
          if (itemInfo.hasToXmlMethod()) {
              return (String)ReflectionUtils.invokeMethod(value,
                                                          itemInfo.getToXmlMethod());
          } else {
              final Object simple_content = extractValue(value);
              return itemInfo.getItemMarshaller().print(simple_content, result);
          }
      }
  
      private Object extractValue(Object value)
          throws XmlException
      {
          return ReflectionUtils.invokeMethod(value,
                                              itemInfo.getGetValueMethod());
      }
  
      TypeUnmarshaller getItemUnmarshaller()
      {
          return itemInfo.getItemUnmarshaller();
      }
  
      Object fromValue(Object itemValue) throws XmlException
      {
          return ReflectionUtils.invokeMethod(null, itemInfo.getFromValueMethod(),
                                              new Object[]{itemValue});
      }
  
  
      private static final class ItemInfo
      {
          private final TypeMarshaller itemMarshaller;
          private final TypeUnmarshaller itemUnmarshaller;
          private final Method getValueMethod;
          private final Method fromValueMethod;
          private final Method toXmlMethod;
  
          ItemInfo(JaxrpcEnumType jaxrpcEnumType,
                   Class enum_java_class,
                   RuntimeBindingTypeTable typeTable,
                   BindingLoader loader,
                   RuntimeTypeFactory rttFactory)
              throws XmlException
          {
              final BindingTypeName base_name = jaxrpcEnumType.getBaseTypeName();
              assert base_name != null;
              final BindingType item_type = loader.getBindingType(base_name);
              if (item_type == null) {
                  final String msg = "unable to load type" + item_type +
                      " for " + jaxrpcEnumType;
                  throw new XmlException(msg);
              }
  
  
              itemMarshaller = typeTable.lookupMarshaller(item_type, loader);
              if (itemMarshaller == null) {
                  String m = "unable to locate marshaller for " + item_type;
                  throw new XmlException(m);
              }
              itemUnmarshaller =
                  typeTable.getOrCreateTypeUnmarshaller(item_type, loader);
              assert itemUnmarshaller != null;
  
              fromValueMethod =
                  ReflectionUtils.getMethodOnClass(jaxrpcEnumType.getFromValueMethod(),
                                                   enum_java_class);
              if (!ReflectionUtils.isMethodStatic(fromValueMethod)) {
                  String e = "fromValue method must be static.  invalid " +
                      "method: " + fromValueMethod + " in type " + jaxrpcEnumType;
                  throw new XmlException(e);
              }
  
              getValueMethod =
                  ReflectionUtils.getMethodOnClass(jaxrpcEnumType.getGetValueMethod(),
                                                   enum_java_class);
              toXmlMethod =
                  ReflectionUtils.getMethodOnClass(jaxrpcEnumType.getToXMLMethod(),
                                                   enum_java_class);
  
              //final sanity checks
              final RuntimeBindingType itemType =
                  rttFactory.createRuntimeType(item_type, typeTable, loader);
  
              final Class[] parms = fromValueMethod.getParameterTypes();
              if (parms.length != 1) {
                  throw new XmlException("invalid fromValue method, must have" +
                                         " one parameter: " + fromValueMethod +
                                         " for type " + jaxrpcEnumType);
              }
              if (!parms[0].isAssignableFrom(itemType.getJavaType())) {
                  String m =
                      "invalid fromValue method:" + fromValueMethod +
                      " --  type mismatch between: " + parms[0] +
                      " and " + itemType.getJavaType() +
                      " for type " + jaxrpcEnumType;
                  throw new XmlException(m);
              }
          }
  
          TypeMarshaller getItemMarshaller()
          {
              return itemMarshaller;
          }
  
          TypeUnmarshaller getItemUnmarshaller()
          {
              return itemUnmarshaller;
          }
  
          Method getGetValueMethod()
          {
              return getValueMethod;
          }
  
          Method getFromValueMethod()
          {
              return fromValueMethod;
          }
  
          Method getToXmlMethod()
          {
              return toXmlMethod;
          }
  
          boolean hasToXmlMethod()
          {
              return toXmlMethod != null;
          }
  
      }
  
  }
  
  
  
  1.1                  xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/JaxrpcEnumUnmarshaller.java
  
  Index: JaxrpcEnumUnmarshaller.java
  ===================================================================
  /*
  * The Apache Software License, Version 1.1
  *
  *
  * Copyright (c) 2003 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 "Apache" 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
  *    XMLBeans", 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 and was
  * originally based on software copyright (c) 2000-2003 BEA Systems
  * Inc., <http://www.bea.com/>. For more information on the Apache Software
  * Foundation, please see <http://www.apache.org/>.
  */
  
  package org.apache.xmlbeans.impl.marshal;
  
  import org.apache.xmlbeans.XmlException;
  import org.apache.xmlbeans.impl.binding.bts.BindingLoader;
  
  final class JaxrpcEnumUnmarshaller
      implements TypeUnmarshaller
  {
      private final JaxrpcEnumRuntimeBindingType runtimeType;
  
      public JaxrpcEnumUnmarshaller(JaxrpcEnumRuntimeBindingType rtt)
      {
          runtimeType = rtt;
      }
  
      public Object unmarshal(UnmarshalResult result)
          throws XmlException
      {
  
          final TypeUnmarshaller item_um = runtimeType.getItemUnmarshaller();
          final Object itemValue = item_um.unmarshal(result);
          return runtimeType.fromValue(itemValue);
      }
  
      public Object unmarshalAttribute(UnmarshalResult result)
          throws XmlException
      {
          final TypeUnmarshaller item_um = runtimeType.getItemUnmarshaller();
          final Object itemValue = item_um.unmarshalAttribute(result);
          return runtimeType.fromValue(itemValue);
      }
  
      public void initialize(RuntimeBindingTypeTable typeTable,
                             BindingLoader bindingLoader)
      {
      }
  }
  
  
  
  1.3       +4 -0      xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/util/ReflectionUtils.java
  
  Index: ReflectionUtils.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/util/ReflectionUtils.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ReflectionUtils.java	10 Mar 2004 07:26:15 -0000	1.2
  +++ ReflectionUtils.java	13 Mar 2004 03:46:57 -0000	1.3
  @@ -120,6 +120,10 @@
           }
       }
   
  +    public static boolean isMethodStatic(Method m) {
  +        return Modifier.isStatic(m.getModifiers());
  +    }
  +
       public static boolean isClassFinal(Class javaClass)
       {
           final int modifiers = javaClass.getModifiers();
  
  
  
  1.14      +1 -0      xml-xmlbeans/v2/test/cases/marshal/doc.xml
  
  Index: doc.xml
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/test/cases/marshal/doc.xml,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- doc.xml	9 Mar 2004 23:50:54 -0000	1.13
  +++ doc.xml	13 Mar 2004 03:46:57 -0000	1.14
  @@ -31,6 +31,7 @@
           </n1:MyClassArray>
   
           <n1:simpleContentExample someAtt="1.23">testing</n1:simpleContentExample>
  +        <n1:modeEnum>Off</n1:modeEnum>
   
       </My:Myelt>
   
  
  
  
  1.25      +97 -0     xml-xmlbeans/v2/test/cases/marshal/example_config.xml
  
  Index: example_config.xml
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/test/cases/marshal/example_config.xml,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- example_config.xml	13 Mar 2004 00:33:22 -0000	1.24
  +++ example_config.xml	13 Mar 2004 03:46:57 -0000	1.25
  @@ -213,6 +213,49 @@
               </bin:qname-property>
   
   
  +            <bin:qname-property>
  +                <bin:xmlcomponent>t=ModeEnum@java:com.mytest</bin:xmlcomponent>
  +                <bin:javatype>com.mytest.ModeEnum</bin:javatype>
  +                <bin:getter>
  +                    <bin:method-name>getModeEnum</bin:method-name>
  +                </bin:getter>
  +                <bin:setter>
  +                    <bin:method-name>setModeEnum</bin:method-name>
  +                    <bin:param-type>com.mytest.ModeEnum</bin:param-type>
  +                </bin:setter>
  +                <bin:qname>java:modeEnum</bin:qname>
  +<!--                <bin:attribute>true</bin:attribute>-->
  +            </bin:qname-property>
  +
  +
  +            <bin:qname-property>
  +                <bin:xmlcomponent>t=IntEnum@java:com.mytest</bin:xmlcomponent>
  +                <bin:javatype>com.mytest.IntEnum</bin:javatype>
  +                <bin:getter>
  +                    <bin:method-name>getIntEnum</bin:method-name>
  +                </bin:getter>
  +                <bin:setter>
  +                    <bin:method-name>setIntEnum</bin:method-name>
  +                    <bin:param-type>com.mytest.IntEnum</bin:param-type>
  +                </bin:setter>
  +                <bin:qname>java:intEnum</bin:qname>
  +            </bin:qname-property>
  +
  +
  +            <bin:qname-property>
  +                <bin:xmlcomponent>t=IntegerEnum@java:com.mytest</bin:xmlcomponent>
  +                <bin:javatype>com.mytest.IntegerEnum</bin:javatype>
  +                <bin:getter>
  +                    <bin:method-name>getIntegerEnum</bin:method-name>
  +                </bin:getter>
  +                <bin:setter>
  +                    <bin:method-name>setIntegerEnum</bin:method-name>
  +                    <bin:param-type>com.mytest.IntegerEnum</bin:param-type>
  +                </bin:setter>
  +                <bin:qname>java:integerEnum</bin:qname>
  +            </bin:qname-property>
  +
  +
   
           </bin:binding-type>
   
  @@ -246,6 +289,60 @@
                   <bin:qname>someAtt</bin:qname>
                   <bin:attribute>true</bin:attribute>
               </bin:attribute-property>
  +        </bin:binding-type>
  +
  +        <bin:binding-type xsi:type="bin:jaxrpc-enum-type">
  +            <bin:xmlcomponent>t=IntEnum@java:com.mytest</bin:xmlcomponent>
  +            <bin:javatype>com.mytest.IntEnum</bin:javatype>
  +            <bin:base-xmlcomponent>t=int@http://www.w3.org/2001/XMLSchema</bin:base-xmlcomponent>
  +            <bin:base-javatype>int</bin:base-javatype>
  +            <bin:getValue-method>
  +                <bin:method-name>getValue</bin:method-name>
  +            </bin:getValue-method>
  +            <bin:fromValue-method>
  +                <bin:method-name>fromValue</bin:method-name>
  +                <bin:param-type>int</bin:param-type>
  +            </bin:fromValue-method>
  +            <bin:fromString-method>
  +                <bin:method-name>fromString</bin:method-name>
  +            </bin:fromString-method>
  +        </bin:binding-type>
  +
  +        <bin:binding-type xsi:type="bin:jaxrpc-enum-type">
  +            <bin:xmlcomponent>t=IntegerEnum@java:com.mytest</bin:xmlcomponent>
  +            <bin:javatype>com.mytest.IntegerEnum</bin:javatype>
  +            <bin:base-xmlcomponent>t=integer@http://www.w3.org/2001/XMLSchema</bin:base-xmlcomponent>
  +            <bin:base-javatype>java.math.BigInteger</bin:base-javatype>
  +            <bin:getValue-method>
  +                <bin:method-name>getValue</bin:method-name>
  +            </bin:getValue-method>
  +            <bin:fromValue-method>
  +                <bin:method-name>fromValue</bin:method-name>
  +                <bin:param-type>java.math.BigInteger</bin:param-type>
  +            </bin:fromValue-method>
  +            <bin:fromString-method>
  +                <bin:method-name>fromString</bin:method-name>
  +            </bin:fromString-method>
  +        </bin:binding-type>
  +
  +        <bin:binding-type xsi:type="bin:jaxrpc-enum-type">
  +            <bin:xmlcomponent>t=ModeEnum@java:com.mytest</bin:xmlcomponent>
  +            <bin:javatype>com.mytest.ModeEnum</bin:javatype>
  +            <bin:base-xmlcomponent>t=string@http://www.w3.org/2001/XMLSchema</bin:base-xmlcomponent>
  +            <bin:base-javatype>java.lang.String</bin:base-javatype>
  +            <bin:getValue-method>
  +                <bin:method-name>getValue</bin:method-name>
  +            </bin:getValue-method>
  +            <bin:fromValue-method>
  +                <bin:method-name>fromValue</bin:method-name>
  +                <bin:param-type>java.lang.String</bin:param-type>
  +            </bin:fromValue-method>
  +            <bin:fromString-method>
  +                <bin:method-name>fromString</bin:method-name>
  +            </bin:fromString-method>
  +            <bin:toXML-method>
  +                <bin:method-name>toXml</bin:method-name>
  +            </bin:toXML-method>
           </bin:binding-type>
   
   
  
  
  
  1.14      +43 -0     xml-xmlbeans/v2/test/cases/marshal/com/mytest/YourClass.java
  
  Index: YourClass.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/test/cases/marshal/com/mytest/YourClass.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- YourClass.java	9 Mar 2004 23:50:54 -0000	1.13
  +++ YourClass.java	13 Mar 2004 03:46:57 -0000	1.14
  @@ -50,6 +50,12 @@
   
       private SimpleContentExample simpleContentExample;
   
  +
  +    private ModeEnum modeEnum;
  +    private IntEnum intEnum;
  +    private IntegerEnum integerEnum;
  +
  +
       //hack alert
       static final Random RND = new Random();
   
  @@ -250,6 +256,36 @@
           this.simpleContentExample = simpleContentExample;
       }
   
  +    public ModeEnum getModeEnum()
  +    {
  +        return modeEnum;
  +    }
  +
  +    public void setModeEnum(ModeEnum modeEnum)
  +    {
  +        this.modeEnum = modeEnum;
  +    }
  +
  +    public IntEnum getIntEnum()
  +    {
  +        return intEnum;
  +    }
  +
  +    public void setIntEnum(IntEnum intEnum)
  +    {
  +        this.intEnum = intEnum;
  +    }
  +
  +    public IntegerEnum getIntegerEnum()
  +    {
  +        return integerEnum;
  +    }
  +
  +    public void setIntegerEnum(IntegerEnum integerEnum)
  +    {
  +        this.integerEnum = integerEnum;
  +    }
  +
       public boolean equals(Object o)
       {
           if (this == o) return true;
  @@ -278,6 +314,10 @@
               !simpleContentExample.equals(yourClass.simpleContentExample) : yourClass.simpleContentExample != null)
               return false;
   
  +        if (modeEnum != null ? !modeEnum.equals(yourClass.modeEnum) : yourClass.modeEnum != null) return false;
  +        if (intEnum != null ? !intEnum.equals(yourClass.intEnum) : yourClass.intEnum != null) return false;
  +        if (integerEnum != null ? !integerEnum.equals(yourClass.integerEnum) : yourClass.integerEnum != null) return false;
  +
   
           return true;
       }
  @@ -306,6 +346,9 @@
               ", someBool=" + someBool +
               ", qn=" + qn +
               ", qn2=" + qn2 +
  +            ", modeEnum=" + modeEnum +
  +            ", intEnum=" + intEnum +
  +            ", integerEnum=" + integerEnum +
               ", simpleContentExample=" + simpleContentExample +
   //            ", bools=" + (bools == null ? null : "size:" + bools.size() + bools) +
   //            ", strs=" + (strs == null ? null : "size:" + strs.size() + strs) +
  
  
  
  1.1                  xml-xmlbeans/v2/test/cases/marshal/com/mytest/IntEnum.java
  
  Index: IntEnum.java
  ===================================================================
  /*
  * The Apache Software License, Version 1.1
  *
  *
  * Copyright (c) 2003 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 "Apache" 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
  *    XMLBeans", 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 and was
  * originally based on software copyright (c) 2000-2003 BEA Systems
  * Inc., <http://www.bea.com/>. For more information on the Apache Software
  * Foundation, please see <http://www.apache.org/>.
  */
  
  package com.mytest;
  
  
  import org.apache.xmlbeans.impl.util.XsTypeConverter;
  
  
  public class IntEnum
      implements java.io.Serializable
  {
  
      private int __value;
  
      protected IntEnum(int value)
      {
          __value = value;
      }
  
      public static final int _value1 = 55;
      public static final com.mytest.IntEnum value1 = new com.mytest.IntEnum(_value1);
  
      public static final int _value2 = 33;
      public static final com.mytest.IntEnum value2 = new com.mytest.IntEnum(_value2);
  
      public static final int _value3 = 44;
      public static final com.mytest.IntEnum value3 = new com.mytest.IntEnum(_value3);
  
  
      // Gets the value for a enumerated value
      public int getValue()
      {
          return __value;
      }
  
  
      // Gets enumeration with a specific value
      // throws java.lang.IllegalArgumentException if
      // any invalid value is specified
      public static com.mytest.IntEnum fromValue(int value)
      {
          switch (value) {
              case _value1:
                  return value1;
              case _value2:
                  return value2;
              case _value3:
                  return value3;
              default:
                  throw new java.lang.IllegalArgumentException(invalidValueMsg("" + value));
          }
  
      }
  
      private static java.lang.String invalidValueMsg(java.lang.String value)
      {
          java.lang.String msg = "invalid enumeration value: " + value;
          return msg;
      }
  
  
      // Gets enumeration from a String
      // throws java.lang.IllegalArgumentException if
      // any invalid value is specified
      public static com.mytest.IntEnum fromString(java.lang.String value)
      {
          int __tmp = XsTypeConverter.lexInt(value);
          return fromValue(__tmp);
      }
  
  
      // Returns String representation of the enumerated value
      public java.lang.String toString()
      {
          return java.lang.String.valueOf(__value);
      }
  
      public boolean equals(java.lang.Object obj)
      {
          if (obj instanceof com.mytest.IntEnum) {
              int tmp_val = ((com.mytest.IntEnum)obj).getValue();
              return (tmp_val == __value);
  
          }
          return false;
      }
  
  
      public int hashCode()
      {
          int __hash__result__ = 17;
          __hash__result__ = 37 * __hash__result__ + __value;
  
          return __hash__result__;
      }
  
      private java.lang.Object readResolve()
          throws java.io.ObjectStreamException
      {
          return fromValue(__value);
      }
  
  
  }
  
  
  
  
  
  1.1                  xml-xmlbeans/v2/test/cases/marshal/com/mytest/IntegerEnum.java
  
  Index: IntegerEnum.java
  ===================================================================
  /*
  * The Apache Software License, Version 1.1
  *
  *
  * Copyright (c) 2003 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 "Apache" 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
  *    XMLBeans", 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 and was
  * originally based on software copyright (c) 2000-2003 BEA Systems
  * Inc., <http://www.bea.com/>. For more information on the Apache Software
  * Foundation, please see <http://www.apache.org/>.
  */
  
  package com.mytest;
  
  import org.apache.xmlbeans.impl.util.XsTypeConverter;
  
  public class IntegerEnum
      implements java.io.Serializable
  {
  
      private java.math.BigInteger __value;
  
      protected IntegerEnum(java.math.BigInteger value)
      {
          __value = value;
      }
  
      public static final java.math.BigInteger _value1 = new java.math.BigInteger("333333333333333333333333");
      public static final com.mytest.IntegerEnum value1 = new com.mytest.IntegerEnum(_value1);
  
      public static final java.math.BigInteger _value2 = new java.math.BigInteger("44444444444444444444444");
      public static final com.mytest.IntegerEnum value2 = new com.mytest.IntegerEnum(_value2);
  
      public static final java.math.BigInteger _value3 = new java.math.BigInteger("55555555555555555555");
      public static final com.mytest.IntegerEnum value3 = new com.mytest.IntegerEnum(_value3);
  
  
      private static final java.util.Map _valueMap = _buildValueMap();
  
  
      // Gets the value for a enumerated value
      public java.math.BigInteger getValue()
      {
          return __value;
      }
  
  
      // Gets enumeration with a specific value
      // throws java.lang.IllegalArgumentException if
      // any invalid value is specified
      public static com.mytest.IntegerEnum fromValue(java.math.BigInteger value)
      {
          Object obj = _valueMap.get(value);
          if (obj == null) {
              java.lang.String msg = invalidValueMsg("" + value);
              msg = msg + (" valmap=" + _valueMap);
              throw new java.lang.IllegalArgumentException(msg);
          }
          return (com.mytest.IntegerEnum)obj;
  
      }
  
      private static java.lang.String invalidValueMsg(java.lang.String value)
      {
          java.lang.String msg = "invalid enumeration value: " + value;
          return msg;
      }
  
  
      // Gets enumeration from a String
      // throws java.lang.IllegalArgumentException if
      // any invalid value is specified
      public static com.mytest.IntegerEnum fromString(java.lang.String value)
      {
          java.math.BigInteger __tmp = XsTypeConverter.lexInteger(value);
          return fromValue(__tmp);
      }
  
  
      // Returns String representation of the enumerated value
      public java.lang.String toString()
      {
          return java.lang.String.valueOf(__value);
      }
  
      public boolean equals(java.lang.Object obj)
      {
          if (obj instanceof com.mytest.IntegerEnum) {
              java.math.BigInteger tmp_val = ((com.mytest.IntegerEnum)obj).getValue();
              return tmp_val.equals(__value);
  
          }
          return false;
      }
  
  
      public int hashCode()
      {
          int __hash__result__ = 17;
          __hash__result__ = 37 * __hash__result__ + (__value == null ? 0 : __value.hashCode());
  
          return __hash__result__;
      }
  
      private java.lang.Object readResolve()
          throws java.io.ObjectStreamException
      {
          return fromValue(__value);
      }
  
  
      private static java.util.Map _buildValueMap()
      {
          java.util.Map __valmap = new java.util.HashMap();
  
          __valmap.put(_value1, value1);
          __valmap.put(_value2, value2);
          __valmap.put(_value3, value3);
  
  
          return __valmap;
      }
  
  
  }
  
  
  
  
  
  1.1                  xml-xmlbeans/v2/test/cases/marshal/com/mytest/ModeEnum.java
  
  Index: ModeEnum.java
  ===================================================================
  /*
  * The Apache Software License, Version 1.1
  *
  *
  * Copyright (c) 2003 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 "Apache" 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
  *    XMLBeans", 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 and was
  * originally based on software copyright (c) 2000-2003 BEA Systems
  * Inc., <http://www.bea.com/>. For more information on the Apache Software
  * Foundation, please see <http://www.apache.org/>.
  */
  
  /**
   * This code was automatically generated at 2:54:05 PM on Mar 10, 2004
   * by weblogic.xml.schema.binding.internal.codegen.EnumGenerator -- do not edit.
   *
   * @version WebLogic Server 9.0  Wed Mar 10 09:04:51 PST 2004 352081 - internal build by zieg on client zieg.zieg-2
   * @author Copyright (c) 2004 by BEA Systems, Inc. All Rights Reserved.
   */
  
  package com.mytest;
  
  // original type: ['http://tempuri.org/']:ModeEnum
  
  
  public class ModeEnum
      implements java.io.Serializable
  {
  
      private java.lang.String __value;
  
      protected ModeEnum(java.lang.String value)
      {
          __value = value;
      }
  
      public static final java.lang.String _Off = "Off";
      public static final com.mytest.ModeEnum Off = new com.mytest.ModeEnum(_Off);
  
      public static final java.lang.String _On = "On";
      public static final com.mytest.ModeEnum On = new com.mytest.ModeEnum(_On);
  
  
      private static final java.util.Map _valueMap = _buildValueMap();
  
  
      // Gets the value for a enumerated value
      public java.lang.String getValue()
      {
          return __value;
      }
  
  
      // Gets enumeration with a specific value
      // throws java.lang.IllegalArgumentException if
      // any invalid value is specified
      public static com.mytest.ModeEnum fromValue(java.lang.String value)
      {
          Object obj = _valueMap.get(value);
          if (obj == null) {
              java.lang.String msg = invalidValueMsg("" + value);
              msg = msg + (" valmap=" + _valueMap);
              throw new java.lang.IllegalArgumentException(msg);
          }
          return (com.mytest.ModeEnum)obj;
  
      }
  
      private static java.lang.String invalidValueMsg(java.lang.String value)
      {
          java.lang.String msg = "invalid enumeration value: " + value;
          return msg;
      }
  
  
      // Gets enumeration from a String
      // throws java.lang.IllegalArgumentException if
      // any invalid value is specified
      public static com.mytest.ModeEnum fromString(java.lang.String value)
      {
          return fromValue(value);
      }
  
  
      // Returns String representation of the enumerated value
      public java.lang.String toString()
      {
          return java.lang.String.valueOf(__value);
      }
  
      public java.lang.String toXml() {
          return toString();
      }
  
      public boolean equals(java.lang.Object obj)
      {
          if (obj instanceof com.mytest.ModeEnum) {
              java.lang.String tmp_val = ((com.mytest.ModeEnum)obj).getValue();
              return tmp_val.equals(__value);
  
          }
          return false;
      }
  
  
      public int hashCode()
      {
          int __hash__result__ = 17;
          __hash__result__ = 37 * __hash__result__ + (__value == null ? 0 : __value.hashCode());
  
          return __hash__result__;
      }
  
      private java.lang.Object readResolve()
          throws java.io.ObjectStreamException
      {
          return fromValue(__value);
      }
  
  
      private static java.util.Map _buildValueMap()
      {
          java.util.Map __valmap = new java.util.HashMap();
  
          __valmap.put(_Off, Off);
          __valmap.put(_On, On);
  
  
          return __valmap;
      }
  
  
  }
  
  
  
  
  
  1.43      +9 -1      xml-xmlbeans/v2/test/src/drt/drtcases/MarshalTests.java
  
  Index: MarshalTests.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/test/src/drt/drtcases/MarshalTests.java,v
  retrieving revision 1.42
  retrieving revision 1.43
  diff -u -r1.42 -r1.43
  --- MarshalTests.java	9 Mar 2004 23:50:54 -0000	1.42
  +++ MarshalTests.java	13 Mar 2004 03:46:58 -0000	1.43
  @@ -19,6 +19,9 @@
   import com.mytest.MySubClass;
   import com.mytest.MySubSubClass;
   import com.mytest.SimpleContentExample;
  +import com.mytest.ModeEnum;
  +import com.mytest.IntegerEnum;
  +import com.mytest.IntEnum;
   import junit.framework.Assert;
   import junit.framework.Test;
   import junit.framework.TestCase;
  @@ -343,6 +346,8 @@
           se.setSimpleContent("someSimpleContentOkay");
           myelt.setSimpleContentExample(se);
   
  +        myelt.setModeEnum(ModeEnum.On);
  +
           mc.setMyelt(myelt);
   
           myelt.setStringArray(new String[]{"one", "two", "three"});
  @@ -511,7 +516,7 @@
           //the test still has some value aside from perf
           //in that it can test large stack depths.
           final int trials = 1;
  -        final int depth = 5;
  +        final int depth = 3;
           final int boolean_array_size = 5;
   
           Random rnd = new Random();
  @@ -533,6 +538,9 @@
               myelt.setBooleanArray(bools);
               myelt.setWrappedArrayOne(new String[]{"W1" + rnd.nextInt(), null, "W2" + rnd.nextInt()});
               myelt.setWrappedArrayTwo(null);
  +            myelt.setModeEnum(ModeEnum.Off);
  +            myelt.setIntegerEnum(IntegerEnum.value2);
  +            myelt.setIntEnum(IntEnum.value3);
               final com.mytest.MyClass my_c = new com.mytest.MyClass();
               myelt.setMyClass(my_c);
               curr.setMyelt(myelt);
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xmlbeans-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-cvs-help@xml.apache.org


Mime
View raw message