User: jung    
  Date: 01/01/03 02:23:55

  Modified:    src/org/zoap/xml/meta AppearanceNameAttribute.java
                        AppearanceRefAttribute.java AttributeElement.java
                        ImportType.java PrimitiveType.java
                        SimpleTypeAttribute.java TypeBaseAttribute.java
                        TypeNameAttribute.java XmlSchema.java
  Log:
  exception redesign. Improved null-pointer treatment. coherent environment and 
logging facilities.
  
  Revision  Changes    Path
  1.3       +3 -3      zoap/src/org/zoap/xml/meta/AppearanceNameAttribute.java
  
  Index: AppearanceNameAttribute.java
  ===================================================================
  RCS file: 
/products/cvs/ejboss/zoap/src/org/zoap/xml/meta/AppearanceNameAttribute.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AppearanceNameAttribute.java      2000/12/04 12:36:27     1.2
  +++ AppearanceNameAttribute.java      2001/01/03 10:23:53     1.3
  @@ -1,5 +1,5 @@
   /*
  - *   $Id: AppearanceNameAttribute.java,v 1.2 2000/12/04 12:36:27 jung Exp $
  + *   $Id: AppearanceNameAttribute.java,v 1.3 2001/01/03 10:23:53 jung Exp $
    *   Copyright 2000 (C) infor:business solutions AG, Hauerstrasse 12,
    *   D-66299 Friedrichsthal, Germany. All Rights Reserved.
    *
  @@ -74,8 +74,8 @@
   
     public Object setAttributeContent(Object target, Object value, Map references, 
Map nameSpaces) {
   
  -    if(Environment.DEBUG_XML && Environment.DEBUG_XML_META)
  -      
Environment.out.print(toString()+".setAttributeContent("+target+","+value+","+references+")\n");
  +    if(Environment.DEBUG_LEVEL>1)
  +      
Environment.CONSOLE.log(toString()+".setAttributeContent("+target+","+value+","+references+")");
   
       if(target instanceof Appearance && value instanceof String) {
   
  
  
  
  1.3       +3 -3      zoap/src/org/zoap/xml/meta/AppearanceRefAttribute.java
  
  Index: AppearanceRefAttribute.java
  ===================================================================
  RCS file: 
/products/cvs/ejboss/zoap/src/org/zoap/xml/meta/AppearanceRefAttribute.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AppearanceRefAttribute.java       2000/12/04 12:36:27     1.2
  +++ AppearanceRefAttribute.java       2001/01/03 10:23:53     1.3
  @@ -1,5 +1,5 @@
   /*
  - *   $Id: AppearanceRefAttribute.java,v 1.2 2000/12/04 12:36:27 jung Exp $
  + *   $Id: AppearanceRefAttribute.java,v 1.3 2001/01/03 10:23:53 jung Exp $
    *   Copyright 2000 (C) infor:business solutions AG, Hauerstrasse 12,
    *   D-66299 Friedrichsthal, Germany. All Rights Reserved.
    *
  @@ -75,8 +75,8 @@
   
     public Object setAttributeContent(Object target, Object value, Map references, 
Map nameSpaces) {
   
  -     if(Environment.DEBUG_XML && Environment.DEBUG_XML_META)
  -      
Environment.out.print(toString()+".setAttributeContent("+target+","+value+","+references+")");
  +     if(Environment.DEBUG_LEVEL>1)
  +      
Environment.CONSOLE.log(toString()+".setAttributeContent("+target+","+value+","+references+")");
   
       if(target instanceof Appearance && value instanceof String) {
         ((Appearance) target).setAppearanceName((String) value);
  
  
  
  1.3       +4 -4      zoap/src/org/zoap/xml/meta/AttributeElement.java
  
  Index: AttributeElement.java
  ===================================================================
  RCS file: /products/cvs/ejboss/zoap/src/org/zoap/xml/meta/AttributeElement.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AttributeElement.java     2000/12/04 12:36:28     1.2
  +++ AttributeElement.java     2001/01/03 10:23:53     1.3
  @@ -1,5 +1,5 @@
   /*
  - *   $Id: AttributeElement.java,v 1.2 2000/12/04 12:36:28 jung Exp $
  + *   $Id: AttributeElement.java,v 1.3 2001/01/03 10:23:53 jung Exp $
    *   Copyright 2000 (C) infor:business solutions AG, Hauerstrasse 12,
    *   D-66299 Friedrichsthal, Germany. All Rights Reserved.
    *
  @@ -77,9 +77,9 @@
   
       public Object addElementContent(Object target, Object value, Map references, 
Map nameSpaces) {
   
  -      if(Environment.DEBUG_XML && Environment.DEBUG_XML_META)
  -        Environment.out.print(toString()+".addElementContent("+target+","+value+","+
  -          references+","+nameSpaces+")\n");
  +      if(Environment.DEBUG_LEVEL>1)
  +        
Environment.CONSOLE.log(toString()+".addElementContent("+target+","+value+","+
  +          references+","+nameSpaces+")");
   
         if(target instanceof ComplexType && value instanceof Attribute) {
   
  
  
  
  1.3       +133 -123  zoap/src/org/zoap/xml/meta/ImportType.java
  
  Index: ImportType.java
  ===================================================================
  RCS file: /products/cvs/ejboss/zoap/src/org/zoap/xml/meta/ImportType.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ImportType.java   2000/12/04 12:36:29     1.2
  +++ ImportType.java   2001/01/03 10:23:53     1.3
  @@ -1,45 +1,22 @@
   /*
  - *   $Id: ImportType.java,v 1.2 2000/12/04 12:36:29 jung Exp $
  - *   Copyright 2000 (C) infor:business solutions AG, Hauerstrasse 12,
  - *   D-66299 Friedrichsthal, Germany. All Rights Reserved.
  - *
  - *   License Statement
  - *
  - *   Redistribution and use of this software and associated documentation 
("Software"), with or without
  - *   modification, are permitted provided that the following conditions are met:
  - *
  - *   1.      Redistributions of source code must retain copyright statements and 
notices.
  - *           Redistributions must also contain a copy of this document.
  - *
  - *   2.      Redistributions in binary form must reproduce the attached 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 infor: 
business solutions AG
  - *           (http://www.infor.de/)." Alternately, this acknowledgment may appear 
in the software itself,
  - *           if and wherever such third-party acknowledgments normally appear.
  - *
  - *   4.      The name "infor" must not be used to endorse or promote products 
derived from this
  - *           Software without prior written permission of infor: business solutions 
AG.
  - *           For written permission, please contact [EMAIL PROTECTED]
  - *
  - *   5.      Products derived from this Software may not be called "infor" nor may 
"infor" appear
  - *           in their names without prior written permission of infor: business 
solutions AG. infor
  - *           is a registered trademark of infor:business solutions AG.
  - *
  - *   Disclaimer
  - *
  - *   THIS SOFTWARE IS PROVIDED BY INFOR: BUSINESS SOLUTIONS AG AND CONTRIBUTORS "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 INFOR: BUSINESS SOLUTIONS AG 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.
  + * $Source: /products/cvs/ejboss/zoap/src/org/zoap/xml/meta/ImportType.java,v $
  + * The Zero-effort Object Access Package is a library to support XML/SOAP 
serialisation and invocation.
  + * Copyright (c) 2000 infor business solutions AG, Hauerstrasse 12,
  + * D-66299 Friedrichsthal, Germany. All Rights Reserved.
  + *
  + * This library is free software; you can redistribute it and/or
  + * modify it under the terms of the GNU Lesser General Public
  + * License as published by the Free Software Foundation; either
  + * version 2.1 of the License, or (at your option) any later version.
  + *
  + * This library is distributed in the hope that it will be useful,
  + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  + * Lesser General Public License for more details.
  + *
  + * You should have received a copy of the GNU Lesser General Public
  + * License along with this library; if not, write to the Free Software
  + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    */
   
   package org.zoap.xml.meta;
  @@ -57,113 +34,146 @@
   import java.util.Map;
   
   /**
  - *  Meta-Meta Type that describes the structure of xsd:element appearances.
  + *  Meta-Type that describes the semantics of xsd:import appearances.
  + *  @author jung
  + *  @version $Revision: 1.3 $
    */
   
   public class ImportType extends ComplexType {
  +
  +     public final static String NAMESPACE_ATTRIBUTE_NAME = "namespace";
  +     public final static String LOCATION_ATTRIBUTE_NAME = "location";
  +     public final static String TYPE_NAME = "import";
  +
  +     /** inner class that represents an import statement */
  +     public static class Import {
  +
  +             public Import() {
  +             }
  +
  +             private URN location;
  +             private URN nameSpace;
  +     }
   
  -    public static class Import {
   
  -      public Import() {
  -      }
  +     /** inner class that represents the namespace attribute of an import type */
   
  -      private URN location;
  -      private URN nameSpace;
  -    }
  +     private class ImportNamespaceAttribute extends Attribute {
   
  -    private class ImportNamespaceAttribute extends Attribute {
  +             ImportNamespaceAttribute() {
  +                     setAppearanceName(NAMESPACE_ATTRIBUTE_NAME);
  +                     setAppearanceSchema(XmlSchema.getXmlSchema());
  +                     setType(URIType.getURIType());
  +             }
   
  -      ImportNamespaceAttribute() {
  -        setAppearanceName("namespace");
  -        setAppearanceSchema(XmlSchema.getXmlSchema());
  -        setType(URIType.getURIType());
  -      }
  +             /** overloads the setAttributeContent method to the dedicated import 
mode */
   
  -      public Object setAttributeContent(Object target, Object value, Map 
references, Map nameSpaces)
  -        throws AttributeException {
  +             public Object setAttributeContent(Object target, Object value, Map 
references, Map nameSpaces)
  +                     throws AttributeException {
   
  -        if(target instanceof Import && value instanceof URN) {
  -          ((Import) target).nameSpace=(URN) value;
  +            if(target instanceof Import) {
   
  -          if(((Import) target).location!=null) {
  -            try{
  -              importSchema((Import) target,(XmlObjectReader)
  -                references.get("org.zoap.xml.XmlObjectReader"),nameSpaces);
  -            } catch(java.io.IOException e) {
  +                Import importTarget=(Import) target;
   
  -              e.printStackTrace();
  +                     importTarget.nameSpace = (URN) value;
   
  -              throw new AttributeException();
  +                     // when location has been set earlier, trigger import 
immediately
  +
  +                     if (importTarget.location != null) {
  +                             try {
  +                                     importSchema(importTarget, (XmlObjectReader)
  +                                     
references.get("org.zoap.xml.XmlObjectReader"), nameSpaces);
  +                             } catch (Throwable t) {
  +                                     throw new AttributeException(toString() + 
".setAttributeContent(" + target + "," + value + "," +
  +                                     references + "," + nameSpaces + "): 
encountered " + t.toString() + " while trying to import schema " + 
importTarget.nameSpace +
  +                                         " from location " + importTarget.location 
+ ".", t);
  +                             }
  +                     }
               }
  -          }
  -        }
  +
  +
  +                     return target;
  +             }
  +
  +     } // ImportNameSpaceAttribute
   
  -        return target;
  -      }
   
  -    }
  +     /** inner class that implements the location attribute of the import type */
   
  -    private class ImportLocationAttribute extends Attribute {
  +     private class ImportLocationAttribute extends Attribute {
   
  -      ImportLocationAttribute() {
  -        setAppearanceName("location");
  -        setAppearanceSchema(XmlSchema.getXmlSchema());
  -        setType(URIType.getURIType());
  -      }
  +             ImportLocationAttribute() {
  +                     setAppearanceName(LOCATION_ATTRIBUTE_NAME);
  +                     setAppearanceSchema(XmlSchema.getXmlSchema());
  +                     setType(URIType.getURIType());
  +             }
   
  -      public Object setAttributeContent(Object target, Object value, Map 
references, Map nameSpaces)
  -        throws AttributeException {
  +             /** overload to deliver the right mode */
   
  -        if(target instanceof Import && value instanceof URN) {
  -          ((Import) target).location=(URN) value;
  +             public Object setAttributeContent(Object target, Object value, Map 
references, Map nameSpaces)
  +             throws AttributeException {
   
  -          if(((Import) target).nameSpace!=null) {
  -            try{
  -              importSchema((Import) target,(XmlObjectReader)
  -                references.get("org.zoap.xml.XmlObjectReader"),nameSpaces);
  -            } catch(java.io.IOException e) {
  +                     if(target instanceof Import) {
  +                Import importTarget=(Import) target;
   
  -              e.printStackTrace();
  +                importTarget.location = (URN) value;
   
  -              throw new AttributeException();
  +                     // test whether namespace already exists then do the import
  +                     if (importTarget.nameSpace != null) {
  +                             try {
  +                                     importSchema(importTarget, (XmlObjectReader)
  +                                     
references.get("org.zoap.xml.XmlObjectReader"), nameSpaces);
  +                             } catch (Throwable t) {
  +                                     throw new AttributeException(toString() + 
".setAttributeContent(" + target + "," + value + "," + references + "," +
  +                                         nameSpaces + "): encountered " + 
t.toString() + " while trying to import schema " + importTarget.nameSpace +
  +                                         " from location " + importTarget.location 
+ ".", t);
  +                             }
  +                     }
               }
  -          }
  -        }
  +
  +                     return target;
  +             }
  +
  +     } // ImportLocationAttribute
  +
  +
  +     /** singleton�s private constructor */
  +
  +     private ImportType() {
  +             setTypeName(TYPE_NAME);
  +             setAssociatedClass(Import.class);
  +             addAttribute(
  +                 new ImportNamespaceAttribute());
  +             addAttribute(
  +                 new ImportLocationAttribute());
  +     }
  +
  +     /** lazy schema access to ease initialisation */
  +     public Schema getTypeSchema() {
  +             return XmlSchema.getXmlSchema();
  +     }
  +
  +     /** import a schema using the given reader context */
  +
  +     public static void importSchema(Import specification, XmlObjectReader 
superReader, Map nameSpaces)
  +     throws java.io.IOException {
  +
  +        if(Environment.DEBUG_LEVEL>1)
  +            
Environment.CONSOLE.debug(ImportType.class.toString()+".importSchema("+specification+","+superReader+","+nameSpaces+")");
   
  -        return target;
  -      }
  +             XmlObjectReader subReader = 
superReader.resolveURN(specification.location);
  +             if (subReader != null) {
  +                     subReader.setBinding(superReader.getBinding());
  +                     subReader.readObject();
  +             }
  +     }
   
  -    }
  +     /** singleton */
  +     private static ImportType importType = new ImportType();
   
  -    private ImportType() {
  -        setTypeName("import");
  -        setAssociatedClass(Import.class);
  -        addAttribute(new ImportNamespaceAttribute());
  -        addAttribute(new ImportLocationAttribute());
  -    }
  -
  -    public Schema getTypeSchema() {
  -        return XmlSchema.getXmlSchema();
  -    }
  -
  -    public static void importSchema(Import specification, XmlObjectReader 
superReader, Map nameSpaces)
  -      throws java.io.IOException {
  -
  -      if(Environment.DEBUG_XML && Environment.DEBUG_XML_META)
  -        
Environment.out.print(ImportType.class.toString()+".importSchema("+specification+","+
  -          superReader+","+nameSpaces+")\n");
  -
  -      XmlObjectReader subReader=superReader.resolveURN(specification.location);
  -      if(subReader!=null) {
  -        subReader.setBinding(superReader.getBinding());
  -        subReader.readObject();
  -      }
  -    }
  -
  -    private static ImportType importType=new ImportType();
  -
  -    public static ImportType getImportType() {
  -            return importType;
  -    }
  +     /** singleton access */
  +     public static ImportType getImportType() {
  +             return importType;
  +     }
   
  -}
  +} // ImportType
  
  
  
  1.3       +79 -158   zoap/src/org/zoap/xml/meta/PrimitiveType.java
  
  Index: PrimitiveType.java
  ===================================================================
  RCS file: /products/cvs/ejboss/zoap/src/org/zoap/xml/meta/PrimitiveType.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- PrimitiveType.java        2000/12/04 12:36:29     1.2
  +++ PrimitiveType.java        2001/01/03 10:23:53     1.3
  @@ -1,45 +1,22 @@
  -/*
  - *   $Id: PrimitiveType.java,v 1.2 2000/12/04 12:36:29 jung Exp $
  - *   Copyright 2000 (C) infor:business solutions AG, Hauerstrasse 12,
  - *   D-66299 Friedrichsthal, Germany. All Rights Reserved.
  - *
  - *   License Statement
  - *
  - *   Redistribution and use of this software and associated documentation 
("Software"), with or without
  - *   modification, are permitted provided that the following conditions are met:
  - *
  - *   1.      Redistributions of source code must retain copyright statements and 
notices.
  - *           Redistributions must also contain a copy of this document.
  - *
  - *   2.      Redistributions in binary form must reproduce the attached 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 infor: 
business solutions AG
  - *           (http://www.infor.de/)." Alternately, this acknowledgment may appear 
in the software itself,
  - *           if and wherever such third-party acknowledgments normally appear.
  - *
  - *   4.      The name "infor" must not be used to endorse or promote products 
derived from this
  - *           Software without prior written permission of infor: business solutions 
AG.
  - *           For written permission, please contact [EMAIL PROTECTED]
  - *
  - *   5.      Products derived from this Software may not be called "infor" nor may 
"infor" appear
  - *           in their names without prior written permission of infor: business 
solutions AG. infor
  - *           is a registered trademark of infor:business solutions AG.
  - *
  - *   Disclaimer
  - *
  - *   THIS SOFTWARE IS PROVIDED BY INFOR: BUSINESS SOLUTIONS AG AND CONTRIBUTORS "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 INFOR: BUSINESS SOLUTIONS AG 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.
  +/*   
  + * $Source: /products/cvs/ejboss/zoap/src/org/zoap/xml/meta/PrimitiveType.java,v $
  + * The Zero-effort Object Access Package is a library to support XML/SOAP 
serialisation and invocation.
  + * Copyright (c) 2000 infor business solutions AG, Hauerstrasse 12,
  + * D-66299 Friedrichsthal, Germany. All Rights Reserved.
  + *
  + * This library is free software; you can redistribute it and/or
  + * modify it under the terms of the GNU Lesser General Public
  + * License as published by the Free Software Foundation; either
  + * version 2.1 of the License, or (at your option) any later version.
  + *
  + * This library is distributed in the hope that it will be useful,
  + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  + * Lesser General Public License for more details.
  + *
  + * You should have received a copy of the GNU Lesser General Public
  + * License along with this library; if not, write to the Free Software
  + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    */
   
   package org.zoap.xml.meta;
  @@ -59,135 +36,70 @@
   
   /**
    * XML type around most primitive Java classes that accept a single string in
  - * their constructor, such as Integer, String, Boolean, etc.
  - * <br>
  - * @author $Author: jung $
  - * @version $Revision: 1.2 $
  + * their constructor, such as Integer, String, Boolean, etc. <br>
  + * @author jung
  + * @version $Revision: 1.3 $
    */
   
   public abstract class PrimitiveType extends SimpleType {
  -
   
  -   public PrimitiveType() {
  -   }
  +     /**
  +      * all primitives are part of XmlSchema
  +      * @link association
  +      * @label typeSchema
  +      */
   
  -    /**
  -     * @link association
  -     * @label typeSchema
  -     */
       /*#XmlSchema typeSchema;*/
   
  -   public Schema getTypeSchema() {
  -    return XmlSchema.getXmlSchema();
  -   }
  -
  -    /**
  -     * create some primitive value. Defaults to
  -     * noop, since most of the builtin Java types need a non-mutable
  -     * input body string to operate correctly
  -     */
  -
  -    public Object newInstance(Map attributes, Map references, Map nameSpaces)
  -        throws TypeException {
  -
  -      if(Environment.DEBUG_XML && Environment.DEBUG_XML_META)
  -        
Environment.out.print(toString()+".newInstance("+attributes+","+references+","+nameSpaces+")\n");
  -
  -      return null;
  -    }
  -
  -    /**
  -     * reading the content of a primitive happens via simply
  -     * calling the toString method.
  -     */
  -
  -    public String getContent(Object object) throws TypeException {
  -
  -        if(Environment.DEBUG_XML && Environment.DEBUG_XML_META)
  -          Environment.out.print(toString()+".getContent("+object+")");
  -
  -      if(object!=null)
  -        return object.toString();
  -      else
  -        return null;
  -    }
  -
  -    /**
  -     * we have deferred the creation of values to the setContent method
  -     * to set the immutable content correctly. We assume primitives to
  -     * accept a single string as the only argument to their constructor
  -     */
  -
  -    public Object setContent(Object target,String body,String verboseElements,Map 
references,Map nameSpaces)
  -        throws TypeException {
  -
  -        if(Environment.DEBUG_XML && Environment.DEBUG_XML_META)
  -          
Environment.out.print(toString()+".setContent("+target+","+body+","+verboseElements+","+references+","+nameSpaces+")\n");
  -
  -      try{
  -
  -        return getAssociatedClass().getConstructor(new Class[] {String.class}).
  -            newInstance(new Object[] {body});
  -
  -      } catch(NoSuchMethodException e) {
  -        throw new TypeException();
  -      } catch(InvocationTargetException e) {
  -        throw new TypeException();
  -      } catch(IllegalAccessException e) {
  -        throw new TypeException();
  -      } catch(InstantiationException e) {
  -        throw new TypeException();
  -      }
  -    }
  -
  -     public boolean isStateless() {
  -      return true;
  -     }
  -}
  -
  -/*
  - *   $Log: PrimitiveType.java,v $
  - *   Revision 1.2  2000/12/04 12:36:29  jung
  - *   adopted to latest jboss container,
  - *   
  - *   added decimal and date
  - *   
  - *   removed some problems due to forward-referencing in meta-data
  - *   
  - *   added serialisation policy
  - *   
  - *   Revision 1.1.1.1  2000/08/10 21:07:52  jung
  - *   Initial import.
  - *   
  - *   
  - *   Revision 1.1.2.1  2000/08/04 17:20:20  jung
  - *   close to beta stadium. Meta-Data import now works.
  - *   
  - *   Revision 1.1.2.2  2000/07/20 14:35:27  jung
  - *   some refactoring inside infor:xml
  - *
  - *   Revision 1.1.2.1  2000/07/17 12:46:19  jung
  - *   refactored package and meta-model
  - *
  - *   Revision 1.1.2.1  2000/07/13 12:46:25  jung
  - *   package renaming, most of the zoap stuff now under org.zoap
  - *   util and http stay infor.ce, containerInvoker etc move to org.jboss
  - *
  - *   changed the makefile, adopted most of the licenses
  - *
  - *   Revision 1.2.2.1  2000/07/11 08:08:35  jung
  - *   added functionality to store retrieve a part of a types elements
  - *   within "ignored" strings. Useful for writing generic handlers that
  - *   just process a part of the XML and transfer the rest.
  - *
  - *   Revision 1.2  2000/07/06 16:55:06  jung
  - *   moved the default binding caches in order to make apartments
  - *   with different versions of the same class possible.
  - *
  - *   Revision 1.1.1.1  2000/07/06 14:11:29  jung
  - *   Import of a pre beta version of ZOAP source with a new directory structure,
  - *   ant-based make, apache-kind of license, etc.
  - *
  - *   jars are coming later because of cvs-history reasons.
  - *
  - */
  +     public Schema getTypeSchema() {
  +             return XmlSchema.getXmlSchema();
  +     }
  +
  +     /**
  +      * create some primitive value. Defaults to noop, since most of the builtin 
Java types need a non-mutable
  +      * input body string to operate correctly
  +      */
  +
  +     public Object newInstance(Map attributes, Map references, Map nameSpaces)
  +     throws TypeException {
  +             return null;
  +     }
  +
  +     /** reading the content of a primitive happens via simply calling the toString 
method. */
  +
  +     public String getContent(Object object) throws TypeException {
  +           if(object!=null)
  +             return object.toString();
  +           else
  +             return null;
  +     }
  +
  +     /**
  +      * we have deferred the creation of values to the setContent method
  +      * to set the immutable content correctly. We assume primitives to
  +      * accept a single string as the only argument to their constructor
  +      */
  +
  +     public Object setContent(Object target, String body, String verboseElements, 
Map references, Map nameSpaces)
  +     throws TypeException {
  +
  +             try {
  +
  +                     return getAssociatedClass().getConstructor(
  +                         new Class[] { String.class }).
  +                         newInstance(
  +                         new Object[] { body });
  +
  +             } catch (Throwable t) {
  +                     throw new TypeException(toString() + ".setContent(" + target + 
"," + body + "," + verboseElements + "," + references + "," +
  +                         nameSpaces + "): encountered " +
  +                         t.toString() + " while trying to instantiate with 
string/body-based constructor", t);
  +             }
  +     }
  +
  +     /** important to defer references before body-based instantiation is done */
  +     public boolean isStateless() {
  +             return true;
  +     }
  +
  +} // PrimitiveType
  
  
  
  1.3       +101 -111  zoap/src/org/zoap/xml/meta/SimpleTypeAttribute.java
  
  Index: SimpleTypeAttribute.java
  ===================================================================
  RCS file: /products/cvs/ejboss/zoap/src/org/zoap/xml/meta/SimpleTypeAttribute.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SimpleTypeAttribute.java  2000/12/04 12:36:30     1.2
  +++ SimpleTypeAttribute.java  2001/01/03 10:23:53     1.3
  @@ -1,45 +1,22 @@
  -/*
  - *   $Id: SimpleTypeAttribute.java,v 1.2 2000/12/04 12:36:30 jung Exp $
  - *   Copyright 2000 (C) infor:business solutions AG, Hauerstrasse 12,
  - *   D-66299 Friedrichsthal, Germany. All Rights Reserved.
  - *
  - *   License Statement
  - *
  - *   Redistribution and use of this software and associated documentation 
("Software"), with or without
  - *   modification, are permitted provided that the following conditions are met:
  - *
  - *   1.      Redistributions of source code must retain copyright statements and 
notices.
  - *           Redistributions must also contain a copy of this document.
  - *
  - *   2.      Redistributions in binary form must reproduce the attached 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 infor: 
business solutions AG
  - *           (http://www.infor.de/)." Alternately, this acknowledgment may appear 
in the software itself,
  - *           if and wherever such third-party acknowledgments normally appear.
  - *
  - *   4.      The name "infor" must not be used to endorse or promote products 
derived from this
  - *           Software without prior written permission of infor: business solutions 
AG.
  - *           For written permission, please contact [EMAIL PROTECTED]
  - *
  - *   5.      Products derived from this Software may not be called "infor" nor may 
"infor" appear
  - *           in their names without prior written permission of infor: business 
solutions AG. infor
  - *           is a registered trademark of infor:business solutions AG.
  - *
  - *   Disclaimer
  - *
  - *   THIS SOFTWARE IS PROVIDED BY INFOR: BUSINESS SOLUTIONS AG AND CONTRIBUTORS "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 INFOR: BUSINESS SOLUTIONS AG 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.
  +/*   
  + * $Source: 
/products/cvs/ejboss/zoap/src/org/zoap/xml/meta/SimpleTypeAttribute.java,v $
  + * The Zero-effort Object Access Package is a library to support XML/SOAP 
serialisation and invocation.
  + * Copyright (c) 2000 infor business solutions AG, Hauerstrasse 12,
  + * D-66299 Friedrichsthal, Germany. All Rights Reserved.
  + *
  + * This library is free software; you can redistribute it and/or
  + * modify it under the terms of the GNU Lesser General Public
  + * License as published by the Free Software Foundation; either
  + * version 2.1 of the License, or (at your option) any later version.
  + *
  + * This library is distributed in the hope that it will be useful,
  + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  + * Lesser General Public License for more details.
  + *
  + * You should have received a copy of the GNU Lesser General Public
  + * License along with this library; if not, write to the Free Software
  + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    */
   
   package org.zoap.xml.meta;
  @@ -62,78 +39,91 @@
   import java.util.Map;
   
   /**
  - *  The meta-ttribute xsd:type that will
  - *  set a simple type into a given appearance
  + *  The meta-ttribute xsd:type that will set a simple type into a given appearance
  + *  @author jung
  + *  @version $Revision: 1.3 $
    */
  +
   public class SimpleTypeAttribute extends Attribute {
  -    /**
  -     * Its a qname attribute
  -     * @link association
  -     * @label type
  -     */
  +
  +     /** how spelled */
  +     public static final String ATTRIBUTE_NAME = "type";
  +
  +     /**
  +      * Its a qname attribute
  +      * @link association
  +      * @label type
  +      */
   
       /*#QNameType lnkQNameType;*/
   
  -    private SimpleTypeAttribute() {
  -        setAppearanceName("type");
  -        setType(QNameType.getQNameType());
  -        setAppearanceSchema(XmlSchema.getXmlSchema());
  -    }
  -
  -    /**
  -     * The setAttributeContent method is able to lazily initiate types
  -     * not yet mentioned in the binding for enabling forward and cyclic referencing.
  -     */
  -    public Object setAttributeContent(Object target, Object value, Map references, 
Map nameSpaces) throws AttributeException {
  -        // target appearance must be initialised in each case
  -        if (target instanceof Appearance) {
  -            // first we try to interpret the qname as prefix:type
  -            Schema schema = 
(Schema)nameSpaces.get(Environment.getNameSpacePrefix((String)value));
  -            Type type = null;
  -            // here it is?
  -            if (schema != null) {
  -                // yes, then the second part of the qname must be a type
  -                type = schema.getType(Environment.getProperName((String)value));
  -                // its already initialised?
  -                if (type == null) {
  -                    type = new SimpleType();
  -                    // register it in the right schema
  -                    type.setTypeSchema(schema);
  -                    // set the type name accordingly
  -                    type.setTypeName(Environment.getProperName((String)value));
  -                    // and add it prophilactically to the schema
  -                    schema.addType(type);
  -                }
  -            } else {
  -                // no, then we think that the name should be a local type
  -                type = (Type)references.get(value);
  -                // its here
  -                if (type == null) {
  -                    // no, sucking forward reference, we assume its a complex
  -                    // type, but this must not be always true
  -                    type = new SimpleType();
  -                    // schema is hopefully set later
  -                    // set the name to the given qname
  -                    type.setTypeName((String)value);
  -                    // register locally
  -                    references.put(value, type);
  -                }
  -            }
  -            try {
  -                // next assign it to the element
  -                ((Appearance)target).setType(type);
  -            } catch (IllegalTypeException e) {
  -                throw new AttributeException();
  -            }
  -        }
  -        return target;
  -    }
  -
  -    /** its a singleton */
  -    private static SimpleTypeAttribute typeAttribute = new SimpleTypeAttribute();
  -
  -    /** public accessor */
  -    public static SimpleTypeAttribute getSimpleTypeAttribute() {
  -        return typeAttribute;
  -    }
  +     private SimpleTypeAttribute() {
  +             setAppearanceName(ATTRIBUTE_NAME);
  +             setType(QNameType.getQNameType());
  +             setAppearanceSchema(XmlSchema.getXmlSchema());
  +     }
  +
  +     /**
  +      * The setAttributeContent method is able to lazily initiate types
  +      * not yet mentioned in the binding for enabling forward and cyclic 
referencing.
  +      */
  +
  +     public Object setAttributeContent(Object target, Object value, Map references, 
Map nameSpaces) throws AttributeException {
  +
  +             // target appearance must be initialised in each case
  +             if (target instanceof Appearance) {
  +                     // first we try to interpret the qname as prefix:type
  +                     Schema schema = 
(Schema)nameSpaces.get(Environment.getNameSpacePrefix((String)value));
  +                     Type type = null;
  +                     // here it is?
  +                     if (schema != null) {
  +                             // yes, then the second part of the qname must be a 
type
  +                             type = 
schema.getType(Environment.getProperName((String)value));
  +                             // its already initialised?
  +                             if (type == null) {
  +                                     type = new SimpleType();
  +                                     // register it in the right schema
  +                                     type.setTypeSchema(schema);
  +                                     // set the type name accordingly
  +                                     
type.setTypeName(Environment.getProperName((String)value));
  +                                     // and add it prophilactically to the schema
  +                                     schema.addType(type);
  +                             }
  +                     } else {
  +                             // no, then we think that the name should be a local 
type
  +                             type = (Type)references.get(value);
  +                             // its here
  +                             if (type == null) {
  +                                     // no, sucking forward reference, we assume 
its a complex
  +                                     // type, but this must not be always true
  +                                     type = new SimpleType();
  +                                     // schema is hopefully set later
  +                                     // set the name to the given qname
  +                                     type.setTypeName((String)value);
  +                                     // register locally
  +                                     references.put(value, type);
  +                             }
  +                     }
  +                     try {
  +                             // next assign it to the element
  +                             ((Appearance)target).setType(type);
  +                     } catch (IllegalTypeException e) {
  +                             throw new AttributeException(toString() + 
".setAttributeContent(" + target + "," + value + "," +
  +                             references + "," + nameSpaces + "): encountered " + e 
+ " while trying to set simple type.", e);
  +                     }
  +             } else if (target != null) {
  +                     throw new AttributeException(toString() + 
".setAttributeContent(" + target + "," + value + "," +
  +                     references + "," + nameSpaces + "): could not set type in 
target.");
  +             }
  +
  +             return target;
  +     }
  +
  +     /** its a singleton */
  +     private static SimpleTypeAttribute typeAttribute = new SimpleTypeAttribute();
  +
  +     /** public accessor */
  +     public static SimpleTypeAttribute getSimpleTypeAttribute() {
  +             return typeAttribute;
  +     }
   }
  
  
  
  1.3       +3 -3      zoap/src/org/zoap/xml/meta/TypeBaseAttribute.java
  
  Index: TypeBaseAttribute.java
  ===================================================================
  RCS file: /products/cvs/ejboss/zoap/src/org/zoap/xml/meta/TypeBaseAttribute.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TypeBaseAttribute.java    2000/12/04 12:36:30     1.2
  +++ TypeBaseAttribute.java    2001/01/03 10:23:53     1.3
  @@ -1,5 +1,5 @@
   /*
  - *   $Id: TypeBaseAttribute.java,v 1.2 2000/12/04 12:36:30 jung Exp $
  + *   $Id: TypeBaseAttribute.java,v 1.3 2001/01/03 10:23:53 jung Exp $
    *   Copyright 2000 (C) infor:business solutions AG, Hauerstrasse 12,
    *   D-66299 Friedrichsthal, Germany. All Rights Reserved.
    *
  @@ -77,8 +77,8 @@
     public Object setAttributeContent(Object target, Object value, Map references, 
Map nameSpaces)
       throws AttributeException {
   
  -    if(Environment.DEBUG_XML && Environment.DEBUG_XML_META)
  -      
Environment.out.print(toString()+".setAttributeContent("+target+","+value+","+references+","+nameSpaces+")");
  +    if(Environment.DEBUG_LEVEL>1)
  +      
Environment.CONSOLE.log(toString()+".setAttributeContent("+target+","+value+","+references+","+nameSpaces+")");
   
         if(target instanceof ComplexType && value instanceof String) {
           Schema schema=(Schema)
  
  
  
  1.3       +4 -4      zoap/src/org/zoap/xml/meta/TypeNameAttribute.java
  
  Index: TypeNameAttribute.java
  ===================================================================
  RCS file: /products/cvs/ejboss/zoap/src/org/zoap/xml/meta/TypeNameAttribute.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TypeNameAttribute.java    2000/12/04 12:36:30     1.2
  +++ TypeNameAttribute.java    2001/01/03 10:23:53     1.3
  @@ -1,5 +1,5 @@
   /*
  - *   $Id: TypeNameAttribute.java,v 1.2 2000/12/04 12:36:30 jung Exp $
  + *   $Id: TypeNameAttribute.java,v 1.3 2001/01/03 10:23:53 jung Exp $
    *   Copyright 2000 (C) infor:business solutions AG, Hauerstrasse 12,
    *   D-66299 Friedrichsthal, Germany. All Rights Reserved.
    *
  @@ -68,9 +68,9 @@
       }
   
       public Object setAttributeContent(Object target, Object value, Map references, 
Map nameSpaces) {
  -        if (Environment.DEBUG_XML && Environment.DEBUG_XML_META)
  -            Environment.out.print(toString() + ".setAttributeContent(" + target + 
"," + value + "," + references +
  -                "," + nameSpaces + ")\n");
  +        if (Environment.DEBUG_LEVEL>1)
  +            Environment.CONSOLE.log(toString() + ".setAttributeContent(" + target + 
"," + value + "," + references +
  +                "," + nameSpaces + ")");
           if (target instanceof Type && value instanceof String) {
               ((Type)target).setTypeName((String)value);
               references.put(value, target);
  
  
  
  1.3       +12 -3     zoap/src/org/zoap/xml/meta/XmlSchema.java
  
  Index: XmlSchema.java
  ===================================================================
  RCS file: /products/cvs/ejboss/zoap/src/org/zoap/xml/meta/XmlSchema.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- XmlSchema.java    2000/12/04 12:36:30     1.2
  +++ XmlSchema.java    2001/01/03 10:23:54     1.3
  @@ -1,5 +1,5 @@
   /*
  - *   $Id: XmlSchema.java,v 1.2 2000/12/04 12:36:30 jung Exp $
  + *   $Id: XmlSchema.java,v 1.3 2001/01/03 10:23:54 jung Exp $
    *   Copyright 2000 (C) infor:business solutions AG, Hauerstrasse 12,
    *   D-66299 Friedrichsthal, Germany. All Rights Reserved.
    *
  @@ -62,8 +62,8 @@
   
        private XmlSchema() {
   
  -             if (Environment.DEBUG_XML && Environment.DEBUG_XML_META)
  -                     Environment.out.print(toString() + "()\n");
  +             if (Environment.DEBUG_LEVEL>1)
  +                     Environment.CONSOLE.log(toString() + "()");
   
                setUrn(new URN(new String[] { "http://www.w3.org/1999/XMLSchema" }
                ));
  @@ -104,6 +104,9 @@
   
   /*
    *   $Log: XmlSchema.java,v $
  + *   Revision 1.3  2001/01/03 10:23:54  jung
  + *   exception redesign. Improved null-pointer treatment. coherent environment and 
logging facilities.
  + *   
    *   Revision 1.2  2000/12/04 12:36:30  jung
    *   adopted to latest jboss container,
    *   
  
  
  

Reply via email to