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 Fri, 21 May 2004 01:20:09 GMT
zieg        2004/05/20 18:20:09

  Modified:    v2/src/binding/org/apache/xmlbeans/impl/binding/bts
                        BindingType.java BindingTypeVisitor.java
               v2/src/marshal/org/apache/xmlbeans/impl/marshal
                        PullMarshalResult.java PushMarshalResult.java
                        RuntimeBindingTypeTable.java
                        RuntimeTypeVisitor.java SoapMarshallerImpl.java
               v2/test/cases/marshal example_config.xml
               v2/test/src/drt/drtcases MarshalTests.java
  Added:       v2/src/binding/org/apache/xmlbeans/impl/binding/bts
                        SoapArrayType.java
               v2/src/marshal/org/apache/xmlbeans/impl/marshal
                        SoapArrayRuntimeBindingType.java
                        SoapArrayTypeVisitor.java
                        SoapArrayUnmarshaller.java
  Log:
  stub out soap arrays
  
  Revision  Changes    Path
  1.17      +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.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- BindingType.java	25 Mar 2004 22:00:28 -0000	1.16
  +++ BindingType.java	21 May 2004 01:20:09 -0000	1.17
  @@ -114,6 +114,7 @@
       registerClassAndType(ByNameBean.class, org.apache.xml.xmlbeans.bindingConfig.ByNameBean.type);
       registerClassAndType(SimpleContentBean.class, org.apache.xml.xmlbeans.bindingConfig.SimpleContentBean.type);
       registerClassAndType(WrappedArrayType.class, org.apache.xml.xmlbeans.bindingConfig.WrappedArray.type);
  +    registerClassAndType(SoapArrayType.class, org.apache.xml.xmlbeans.bindingConfig.SoapArray.type);
       registerClassAndType(ListArrayType.class, org.apache.xml.xmlbeans.bindingConfig.ListArray.type);
       registerClassAndType(SimpleBindingType.class, org.apache.xml.xmlbeans.bindingConfig.SimpleType.type);
       registerClassAndType(JaxrpcEnumType.class, org.apache.xml.xmlbeans.bindingConfig.JaxrpcEnumType.type);
  
  
  
  1.5       +4 -1      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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- BindingTypeVisitor.java	25 Mar 2004 22:00:28 -0000	1.4
  +++ BindingTypeVisitor.java	21 May 2004 01:20:09 -0000	1.5
  @@ -24,7 +24,7 @@
   
       void visit(ByNameBean byNameBean)
           throws XmlException;
  -  
  +
       void visit(SimpleContentBean simpleContentBean)
           throws XmlException;
   
  @@ -38,6 +38,9 @@
           throws XmlException;
   
       void visit(WrappedArrayType wrappedArrayType)
  +        throws XmlException;
  +
  +    void visit(SoapArrayType soapArrayType)
           throws XmlException;
   
       void visit(ListArrayType wrappedArrayType)
  
  
  
  1.1                  xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/bts/SoapArrayType.java
  
  Index: SoapArrayType.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;
  
  import javax.xml.namespace.QName;
  import java.util.Arrays;
  import java.util.ArrayList;
  import java.util.List;
  
  /**
   * A binding of a simple user-defined type that operates by
   * delegating to another well-known (e.g., builtin) binding.
   */
  public class SoapArrayType extends BindingType
  {
  
      // ========================================================================
      // Variables
  
      private QName itemName;
      private BindingTypeName itemType;
      private boolean itemNillable;
      private int[] ranks;
  
      // ========================================================================
      // Constructors
  
      public SoapArrayType(BindingTypeName btName)
      {
          super(btName);
      }
  
      public SoapArrayType(org.apache.xml.xmlbeans.bindingConfig.BindingType node)
      {
          this((org.apache.xml.xmlbeans.bindingConfig.SoapArray)node);
      }
  
      public SoapArrayType(org.apache.xml.xmlbeans.bindingConfig.SoapArray node)
      {
          super(node);
          this.itemName = node.getItemName();
  
          final org.apache.xml.xmlbeans.bindingConfig.Mapping itype =
              node.getItemType();
          final JavaTypeName jName = JavaTypeName.forString(itype.getJavatype());
          final XmlTypeName xName = XmlTypeName.forString(itype.getXmlcomponent());
          this.itemType = BindingTypeName.forPair(jName, xName);
  
          itemNillable = node.getItemNillable();
  
  
          if (node.isSetRanks()) {
              final java.util.List ranks_list = node.getRanks();
              if (!ranks_list.isEmpty()) {
                  final int len = ranks_list.size();
                  int[] new_ranks = new int[len];
                  for (int i = 0; i < len; i++) {
                      final int r = ((Integer)ranks_list.get(i)).intValue();
                      if (r < 0) {
                          String msg = "illegal negative array rank: " + ranks_list;
                          throw new IllegalArgumentException(msg);
                      }
                      new_ranks[i] = r;
                  }
                  ranks = new_ranks;
              }
          }
      }
  
  
      protected org.apache.xml.xmlbeans.bindingConfig.BindingType write(org.apache.xml.xmlbeans.bindingConfig.BindingType
node)
      {
          final org.apache.xml.xmlbeans.bindingConfig.SoapArray wa =
              (org.apache.xml.xmlbeans.bindingConfig.SoapArray)super.write(node);
  
          wa.setItemName(itemName);
  
          final org.apache.xml.xmlbeans.bindingConfig.Mapping mapping =
              wa.addNewItemType();
          mapping.setJavatype(itemType.getJavaName().toString());
          mapping.setXmlcomponent(itemType.getXmlName().toString());
  
          wa.setItemNillable(itemNillable);
  
          if (ranks != null) {
              List rl = new ArrayList(ranks.length);
              for (int i = 0, alen = ranks.length; i < alen; i++) {
                  final int rank = ranks[i];
                  if (rank < 0) {
                      throw new IllegalStateException("negative rank at index " +
                                                      i + ": " + rank);
                  }
                  rl.add(new Integer(rank));
              }
              wa.setRanks(rl);
          }
  
          return wa;
      }
  
      public void accept(BindingTypeVisitor visitor) throws XmlException
      {
          visitor.visit(this);
      }
  
  
      // ========================================================================
      // Public methods
      public QName getItemName()
      {
          return itemName;
      }
  
      public void setItemName(QName itemName)
      {
          this.itemName = itemName;
      }
  
      public BindingTypeName getItemType()
      {
          return itemType;
      }
  
      public void setItemType(BindingTypeName itemType)
      {
          this.itemType = itemType;
      }
  
      public boolean isItemNillable()
      {
          return itemNillable;
      }
  
      public void setItemNillable(boolean nillable)
      {
          this.itemNillable = nillable;
      }
  
      public int[] getRanks()
      {
          return ranks;
      }
  
      public void setRanks(int[] ranks)
      {
          this.ranks = ranks;
      }
  
  }
  
  
  
  1.2       +9 -2      xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/PullMarshalResult.java
  
  Index: PullMarshalResult.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/PullMarshalResult.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PullMarshalResult.java	6 May 2004 17:47:13 -0000	1.1
  +++ PullMarshalResult.java	21 May 2004 01:20:09 -0000	1.2
  @@ -20,7 +20,6 @@
   import org.apache.xmlbeans.XmlRuntimeException;
   import org.apache.xmlbeans.impl.binding.bts.BindingLoader;
   import org.apache.xmlbeans.impl.binding.bts.BindingType;
  -import org.apache.xmlbeans.impl.binding.bts.BindingTypeName;
   import org.apache.xmlbeans.impl.binding.bts.BuiltinBindingType;
   import org.apache.xmlbeans.impl.binding.bts.ByNameBean;
   import org.apache.xmlbeans.impl.binding.bts.JaxrpcEnumType;
  @@ -28,6 +27,7 @@
   import org.apache.xmlbeans.impl.binding.bts.SimpleBindingType;
   import org.apache.xmlbeans.impl.binding.bts.SimpleContentBean;
   import org.apache.xmlbeans.impl.binding.bts.SimpleDocumentBinding;
  +import org.apache.xmlbeans.impl.binding.bts.SoapArrayType;
   import org.apache.xmlbeans.impl.binding.bts.WrappedArrayType;
   import org.apache.xmlbeans.impl.common.XmlStreamUtils;
   import org.apache.xmlbeans.impl.common.XmlWhitespace;
  @@ -175,7 +175,6 @@
       }
   
   
  -
       public void require(int i, String s, String s1)
           throws XMLStreamException
       {
  @@ -632,6 +631,14 @@
               xmlTypeVisitor = new WrappedArrayTypeVisitor(runtimeBindingProperty,
                                                            parentObject,
                                                            marshalResult);
  +        }
  +
  +        public void visit(SoapArrayType soapArrayType)
  +            throws XmlException
  +        {
  +            xmlTypeVisitor = new SoapArrayTypeVisitor(runtimeBindingProperty,
  +                                                      parentObject,
  +                                                      marshalResult);
           }
   
           public void visit(ListArrayType listArrayType)
  
  
  
  1.4       +6 -0      xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/PushMarshalResult.java
  
  Index: PushMarshalResult.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/PushMarshalResult.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- PushMarshalResult.java	20 May 2004 21:09:53 -0000	1.3
  +++ PushMarshalResult.java	21 May 2004 01:20:09 -0000	1.4
  @@ -264,6 +264,12 @@
           }
       }
   
  +    public void visit(SoapArrayRuntimeBindingType soapArrayRuntimeBindingType)
  +        throws XmlException
  +    {
  +        throw new AssertionError("UNIMP");
  +    }
  +
       public void visit(ListArrayRuntimeBindingType listArrayRuntimeBindingType)
           throws XmlException
       {
  
  
  
  1.34      +24 -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.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- RuntimeBindingTypeTable.java	10 May 2004 22:55:05 -0000	1.33
  +++ RuntimeBindingTypeTable.java	21 May 2004 01:20:09 -0000	1.34
  @@ -31,6 +31,7 @@
   import org.apache.xmlbeans.impl.binding.bts.SimpleBindingType;
   import org.apache.xmlbeans.impl.binding.bts.SimpleContentBean;
   import org.apache.xmlbeans.impl.binding.bts.SimpleDocumentBinding;
  +import org.apache.xmlbeans.impl.binding.bts.SoapArrayType;
   import org.apache.xmlbeans.impl.binding.bts.WrappedArrayType;
   import org.apache.xmlbeans.impl.binding.bts.XmlTypeName;
   import org.apache.xmlbeans.impl.common.ConcurrentReaderHashMap;
  @@ -138,6 +139,15 @@
           return (WrappedArrayRuntimeBindingType)rtt;
       }
   
  +    private SoapArrayRuntimeBindingType createRuntimeType(SoapArrayType type,
  +                                                          BindingLoader binding_loader)
  +        throws XmlException
  +    {
  +        final RuntimeBindingType rtt =
  +            createRuntimeTypeInternal(type, binding_loader);
  +        return (SoapArrayRuntimeBindingType)rtt;
  +    }
  +
       private ListArrayRuntimeBindingType createRuntimeType(ListArrayType type,
                                                             BindingLoader binding_loader)
           throws XmlException
  @@ -713,6 +723,14 @@
               typeUnmarshaller = new WrappedArrayUnmarshaller(rtt);
           }
   
  +        public void visit(SoapArrayType soapArrayType)
  +            throws XmlException
  +        {
  +            SoapArrayRuntimeBindingType rtt =
  +                typeTable.createRuntimeType(soapArrayType, loader);
  +            typeUnmarshaller = new SoapArrayUnmarshaller(rtt);
  +        }
  +
           public void visit(ListArrayType listArrayType)
               throws XmlException
           {
  @@ -780,6 +798,12 @@
               throws XmlException
           {
               runtimeBindingType = new WrappedArrayRuntimeBindingType(wrappedArrayType);
  +        }
  +
  +        public void visit(SoapArrayType soapArrayType)
  +            throws XmlException
  +        {
  +            runtimeBindingType = new SoapArrayRuntimeBindingType(soapArrayType);
           }
   
           public void visit(ListArrayType listArrayType)
  
  
  
  1.2       +3 -0      xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/RuntimeTypeVisitor.java
  
  Index: RuntimeTypeVisitor.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/RuntimeTypeVisitor.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- RuntimeTypeVisitor.java	30 Apr 2004 21:31:48 -0000	1.1
  +++ RuntimeTypeVisitor.java	21 May 2004 01:20:09 -0000	1.2
  @@ -37,6 +37,9 @@
       void visit(WrappedArrayRuntimeBindingType wrappedArrayRuntimeBindingType)
           throws XmlException;
   
  +    void visit(SoapArrayRuntimeBindingType soapArrayRuntimeBindingType)
  +        throws XmlException;
  +
       void visit(ListArrayRuntimeBindingType listArrayRuntimeBindingType)
           throws XmlException;
   }
  
  
  
  1.8       +6 -0      xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/SoapMarshallerImpl.java
  
  Index: SoapMarshallerImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/SoapMarshallerImpl.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- SoapMarshallerImpl.java	9 May 2004 23:52:16 -0000	1.7
  +++ SoapMarshallerImpl.java	21 May 2004 01:20:09 -0000	1.8
  @@ -372,6 +372,12 @@
               setCurrObject(curr_obj, curr_prop);
           }
   
  +        public void visit(SoapArrayRuntimeBindingType soapArrayRuntimeBindingType)
  +            throws XmlException
  +        {
  +            throw new AssertionError("UNIMP");
  +        }
  +
           public void visit(ListArrayRuntimeBindingType listArrayRuntimeBindingType)
               throws XmlException
           {
  
  
  
  1.1                  xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/SoapArrayRuntimeBindingType.java
  
  Index: SoapArrayRuntimeBindingType.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.marshal;
  
  import org.apache.xmlbeans.XmlException;
  import org.apache.xmlbeans.impl.binding.bts.BindingLoader;
  import org.apache.xmlbeans.impl.binding.bts.BindingType;
  import org.apache.xmlbeans.impl.binding.bts.BindingTypeName;
  import org.apache.xmlbeans.impl.binding.bts.SoapArrayType;
  import org.apache.xmlbeans.impl.marshal.util.collections.Accumulator;
  import org.apache.xmlbeans.impl.marshal.util.collections.AccumulatorFactory;
  
  import javax.xml.namespace.QName;
  import java.lang.reflect.Array;
  
  final class SoapArrayRuntimeBindingType
      extends RuntimeBindingType
  {
      private final SoapArrayType soapArrayType;
  
      private ItemProperty elementProperty;
  
      SoapArrayRuntimeBindingType(SoapArrayType binding_type)
          throws XmlException
      {
          super(binding_type);
          soapArrayType = binding_type;
      }
  
      void accept(RuntimeTypeVisitor visitor)
          throws XmlException
      {
          visitor.visit(this);
      }
  
      public void initialize(RuntimeBindingTypeTable typeTable,
                             BindingLoader bindingLoader)
          throws XmlException
      {
          final BindingTypeName item_type_name = soapArrayType.getItemType();
          assert item_type_name != null;
  
          final BindingType item_type = bindingLoader.getBindingType(item_type_name);
          if (item_type == null) {
              final String msg = "unable to lookup " + item_type_name +
                  " from type " + soapArrayType;
              throw new XmlException(msg);
          }
  
          final RuntimeBindingType item_rtt =
              typeTable.createRuntimeType(item_type, bindingLoader);
  
          elementProperty =
              new ItemProperty(this, soapArrayType.getItemName(),
                               item_rtt,
                               soapArrayType.isItemNillable());
  
  
      }
  
      boolean hasElementChildren()
      {
          return true;
      }
  
      ItemProperty getElementProperty()
      {
          assert elementProperty != null;
          return elementProperty;
      }
  
      Object createIntermediary()
      {
          return AccumulatorFactory.createAccumulator(getJavaType(),
                                                      elementProperty.getElementClass());
  
      }
  
      static Object getFinalObjectFromIntermediary(Object inter)
      {
          Accumulator acc = (Accumulator)inter;
          return acc.getFinalArray();
      }
  
      static final class ItemProperty
          extends RuntimeBindingProperty
      {
          private final QName itemName;
          private final RuntimeBindingType itemType;
          private final boolean nillable;
  
          ItemProperty(RuntimeBindingType containing_type,
                       QName item_name,
                       RuntimeBindingType item_type,
                       boolean nillable)
              throws XmlException
          {
              super(containing_type);
  
              itemName = item_name;
              itemType = item_type;
              this.nillable = nillable;
  
          }
  
          Class getElementClass()
          {
              return itemType.getJavaType();
          }
  
          RuntimeBindingType getRuntimeBindingType()
          {
              return itemType;
          }
  
          RuntimeBindingType getActualRuntimeType(Object property_value,
                                                  MarshalResult result)
              throws XmlException
          {
              return result.determineRuntimeBindingType(itemType, property_value);
          }
  
          QName getName()
          {
              return itemName;
          }
  
          public void fill(Object inter, Object prop_obj)
              throws XmlException
          {
              Accumulator acc = (Accumulator)inter;
              acc.append(prop_obj);
          }
  
          Object getValue(Object parentObject, MarshalResult result)
              throws XmlException
          {
              throw new UnsupportedOperationException("use 3 arg getValue");
          }
  
          Object getValue(Object parentObject, MarshalResult result, int item_index)
              throws XmlException
          {
              return Array.get(parentObject, item_index);
          }
  
          boolean isSet(Object parentObject, MarshalResult result)
              throws XmlException
          {
              throw new UnsupportedOperationException("use 3 arg isSet");
          }
  
          boolean isSet(Object parentObject, MarshalResult result, int item_index)
              throws XmlException
          {
              if (nillable) return true;
              if (itemType.isJavaPrimitive()) return true;
  
              //TODO: consider isSet for array elements?
  
              return getValue(parentObject, result, item_index) != null;
          }
  
          boolean isMultiple()
          {
              return true;
          }
  
          boolean isNillable()
          {
              return nillable;
          }
  
          String getLexicalDefault()
          {
              return null;
          }
  
      }
  }
  
  
  
  1.1                  xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/SoapArrayTypeVisitor.java
  
  Index: SoapArrayTypeVisitor.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.marshal;
  
  import org.apache.xmlbeans.XmlException;
  
  import java.lang.reflect.Array;
  
  //TODO: finish this class
  
  class SoapArrayTypeVisitor
      extends NamedXmlTypeVisitor
  {
      private final SoapArrayRuntimeBindingType type;
      private final int arrayLength;
  
      private int currIndex = -1;
  
      SoapArrayTypeVisitor(RuntimeBindingProperty property,
                           Object obj,
                           PullMarshalResult result)
          throws XmlException
      {
          super(obj, property, result);
  
          type = (SoapArrayRuntimeBindingType)getActualRuntimeBindingType();
          arrayLength = getArrayLength(obj);
      }
  
      private static int getArrayLength(Object obj)
      {
          if (obj == null) return 0;
  
          return Array.getLength(obj);
      }
  
      protected int getState()
      {
          assert currIndex <= arrayLength; //ensure we don't go past the end
  
          if (currIndex < 0) return START;
  
          if (currIndex >= arrayLength) return END;
  
          return CONTENT;
      }
  
      protected int advance()
          throws XmlException
      {
          assert currIndex < arrayLength; //ensure we don't go past the end
  
          do {
              currIndex++;
              if (currIndex == arrayLength) return END;
          }
          while (!currentItemHasValue());
  
  
          assert currIndex >= 0;
          assert (getState() == CONTENT);
  
          return CONTENT;
      }
  
      private boolean currentItemHasValue()
          throws XmlException
      {
          return type.getElementProperty().isSet(getParentObject(),
                                                 marshalResult,
                                                 currIndex);
      }
  
      private Object getCurrentValue()
          throws XmlException
      {
          return type.getElementProperty().getValue(getParentObject(),
                                                    marshalResult,
                                                    currIndex);
      }
  
      public XmlTypeVisitor getCurrentChild()
          throws XmlException
      {
          final Object value = getCurrentValue();
          //TODO: avoid excessive object creation
          return marshalResult.createVisitor(type.getElementProperty(), value);
      }
  
      protected CharSequence getCharData()
      {
          throw new IllegalStateException("not text: " + this);
      }
  
      protected void initAttributes()
          throws XmlException
      {
          if (getParentObject() == null) {
              marshalResult.addXsiNilAttribute();
          } else if (needsXsiType()) {
              marshalResult.addXsiTypeAttribute(getActualRuntimeBindingType());
          }
      }
  
  }
  
  
  
  1.1                  xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/SoapArrayUnmarshaller.java
  
  Index: SoapArrayUnmarshaller.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.marshal;
  
  import org.apache.xmlbeans.XmlException;
  import org.apache.xmlbeans.impl.binding.bts.BindingLoader;
  
  import javax.xml.namespace.QName;
  
  public class SoapArrayUnmarshaller
      implements TypeUnmarshaller
  {
      private final SoapArrayRuntimeBindingType type;
  
  
      public SoapArrayUnmarshaller(SoapArrayRuntimeBindingType rtt)
      {
          type = rtt;
      }
  
      public Object unmarshal(UnmarshalResult result)
          throws XmlException
      {
          final Object inter = type.createIntermediary();
          deserializeContents(inter, result);
          return type.getFinalObjectFromIntermediary(inter);
      }
  
      public void unmarshal(Object object, UnmarshalResult result)
          throws XmlException
      {
          throw new UnsupportedOperationException("not supported: this=" + this);
      }
  
      public void unmarshalIntoIntermediary(Object intermediary,
                                            UnmarshalResult result)
          throws XmlException
      {
          throw new AssertionError("UNIMP!!");
      }
  
      //TODO: cleanup this code.  We are doing extra work for assertion checking
      //also might consider consolidating the common code with the ByNameUnmarshaller
      private void deserializeContents(Object inter,
                                       UnmarshalResult context)
          throws XmlException
      {
          throw new AssertionError("UNIMP");
      }
  
  
      public Object unmarshalAttribute(UnmarshalResult result)
          throws XmlException
      {
          throw new AssertionError("not used");
      }
  
      public Object unmarshalAttribute(CharSequence lexical_value,
                                       UnmarshalResult result)
          throws XmlException
      {
          throw new AssertionError("not used");
      }
  
  
      public void unmarshalAttribute(Object object, UnmarshalResult result)
          throws XmlException
      {
          throw new AssertionError("not used");
      }
  
      public void initialize(RuntimeBindingTypeTable typeTable,
                             BindingLoader bindingLoader)
      {
      }
  }
  
  
  
  1.32      +12 -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.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- example_config.xml	10 May 2004 06:06:33 -0000	1.31
  +++ example_config.xml	21 May 2004 01:20:09 -0000	1.32
  @@ -495,6 +495,18 @@
               <bin:item-nillable>true</bin:item-nillable>
           </bin:binding-type>
   
  +        <bin:binding-type xsi:type="bin:soap-array">
  +            <bin:xmlcomponent>t=SoapStringArray@java:com.mytest</bin:xmlcomponent>
  +            <bin:javatype>java.lang.String[]</bin:javatype>
  +            <bin:item-name>item</bin:item-name>
  +            <bin:item-type>
  +                <bin:xmlcomponent>t=string@http://www.w3.org/2001/XMLSchema</bin:xmlcomponent>
  +                <bin:javatype>java.lang.String</bin:javatype>
  +            </bin:item-type>
  +            <bin:item-nillable>true</bin:item-nillable>
  +            <bin:ranks>4 5 6</bin:ranks>
  +        </bin:binding-type>
  +
   
           <bin:binding-type xsi:type="bin:wrapped-array">
               <bin:xmlcomponent>t=ArrayOfArrayOfString@java:com.mytest</bin:xmlcomponent>
  
  
  
  1.65      +30 -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.64
  retrieving revision 1.65
  diff -u -r1.64 -r1.65
  --- MarshalTests.java	20 May 2004 21:09:54 -0000	1.64
  +++ MarshalTests.java	21 May 2004 01:20:09 -0000	1.65
  @@ -618,7 +618,7 @@
           final Object obj =
               um.unmarshalType(xrdr, MYCLASS_NAME, MyClass.class.getName(), null);
   
  -        inform("GOT OBJ"  + obj, true);
  +        inform("GOT OBJ" + obj, true);
   
           xrdr.close();
       }
  @@ -747,6 +747,35 @@
           Assert.assertTrue("expected " + ArrayUtils.arrayToString(strs) +
                             " got " + ArrayUtils.arrayToString(retval),
                             ArrayUtils.arrayEquals(strs, retval));
  +    }
  +
  +
  +    public void DISABLED_testInitPerf()
  +        throws Exception
  +    {
  +        final File conf = getBindingConfigDocument();
  +
  +        final int trials = 2;
  +
  +        final BindingContextFactory context_factory = BindingContextFactory.newInstance();
  +
  +        BindingContext bindingContext = null;
  +
  +        final long before_millis = System.currentTimeMillis();
  +        for (int i = 0; i < trials; i++) {
  +
  +            bindingContext = ((BindingContextFactoryImpl)context_factory).
  +                                    createBindingContextFromConfig(conf);
  +
  +            if (bindingContext == null) {
  +                throw new Exception("bad news");
  +            }
  +        }
  +        final long after_millis = System.currentTimeMillis();
  +        final long diff = (after_millis - before_millis);
  +        boolean verbose = true;
  +        inform("INIT-milliseconds: " + diff + " trials: " + trials, verbose);
  +        inform("INIT-milliseconds PER trial: " + (diff / (double)trials), verbose);
       }
   
   
  
  
  

---------------------------------------------------------------------
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