From: <ls...@us...> - 2011-03-05 11:36:51
|
Revision: 5799 http://jnode.svn.sourceforge.net/jnode/?rev=5799&view=rev Author: lsantha Date: 2011-03-05 11:36:39 +0000 (Sat, 05 Mar 2011) Log Message: ----------- Integrating OpenJDK 6 b22. Modified Paths: -------------- classlib6/core/src/openjdk/jaxws/com/sun/tools/internal/ws/resources/model.properties classlib6/core/src/openjdk/jaxws/javax/xml/bind/ContextFinder.java classlib6/core/src/openjdk/jaxws/javax/xml/bind/DatatypeConverter.java classlib6/core/src/openjdk/jaxws/javax/xml/bind/DatatypeConverterImpl.java classlib6/core/src/openjdk/jaxws/javax/xml/bind/DatatypeConverterInterface.java classlib6/core/src/openjdk/jaxws/javax/xml/bind/Element.java classlib6/core/src/openjdk/jaxws/javax/xml/bind/JAXBContext.java classlib6/core/src/openjdk/jaxws/javax/xml/bind/JAXBException.java classlib6/core/src/openjdk/jaxws/javax/xml/bind/MarshalException.java classlib6/core/src/openjdk/jaxws/javax/xml/bind/Marshaller.java classlib6/core/src/openjdk/jaxws/javax/xml/bind/NotIdentifiableEvent.java classlib6/core/src/openjdk/jaxws/javax/xml/bind/ParseConversionEvent.java classlib6/core/src/openjdk/jaxws/javax/xml/bind/PrintConversionEvent.java classlib6/core/src/openjdk/jaxws/javax/xml/bind/PropertyException.java classlib6/core/src/openjdk/jaxws/javax/xml/bind/TypeConstraintException.java classlib6/core/src/openjdk/jaxws/javax/xml/bind/UnmarshalException.java classlib6/core/src/openjdk/jaxws/javax/xml/bind/Unmarshaller.java classlib6/core/src/openjdk/jaxws/javax/xml/bind/UnmarshallerHandler.java classlib6/core/src/openjdk/jaxws/javax/xml/bind/ValidationEvent.java classlib6/core/src/openjdk/jaxws/javax/xml/bind/ValidationEventHandler.java classlib6/core/src/openjdk/jaxws/javax/xml/bind/ValidationEventLocator.java classlib6/core/src/openjdk/jaxws/javax/xml/bind/ValidationException.java classlib6/core/src/openjdk/jaxws/javax/xml/bind/Validator.java classlib6/core/src/openjdk/jaxws/javax/xml/bind/package.html classlib6/core/src/openjdk/jaxws/javax/xml/ws/spi/FactoryFinder.java classlib6/core/src/openjdk/jaxws/javax/xml/ws/spi/package.html classlib6/core/src/openjdk/jaxws/javax/xml/ws/wsaddressing/W3CEndpointReference.java classlib6/core/src/openjdk/jaxws/javax/xml/ws/wsaddressing/package.html Added Paths: ----------- classlib6/core/src/openjdk/jaxws/com/sun/tools/internal/xjc/generator/bean/field/ContentListField.java classlib6/core/src/openjdk/jaxws/com/sun/tools/internal/xjc/generator/bean/field/DummyListField.java classlib6/core/src/openjdk/jaxws/com/sun/tools/internal/xjc/generator/bean/field/NoExtendedContentField.java classlib6/core/src/openjdk/jaxws/com/sun/tools/internal/xjc/reader/xmlschema/bindinfo/BIFactoryMethod.java classlib6/core/src/openjdk/jaxws/com/sun/tools/internal/xjc/reader/xmlschema/bindinfo/BIInlineBinaryData.java classlib6/core/src/openjdk/jaxws/com/sun/tools/internal/xjc/reader/xmlschema/ct/AbstractExtendedComplexTypeBuilder.java classlib6/core/src/openjdk/jaxws/com/sun/tools/internal/xjc/reader/xmlschema/ct/MixedExtendedComplexTypeBuilder.java Removed Paths: ------------- classlib6/core/src/openjdk/jaxws/com/sun/tools/internal/xjc/api/impl/j2s/Messages.java classlib6/core/src/openjdk/jaxws/com/sun/tools/internal/xjc/api/impl/j2s/Messages.properties classlib6/core/src/openjdk/jaxws/com/sun/xml/internal/fastinfoset/stax/events/StAXEventAllocator.java classlib6/core/src/openjdk/jaxws/com/sun/xml/internal/ws/addressing/model/InvalidMapException.java classlib6/core/src/openjdk/jaxws/com/sun/xml/internal/ws/addressing/model/MapRequiredException.java classlib6/core/src/openjdk/jaxws/com/sun/xml/internal/ws/client/ResponseImpl.java classlib6/core/src/openjdk/jaxws/com/sun/xml/internal/ws/encoding/AbstractXMLStreamWriterExImpl.java classlib6/core/src/openjdk/jaxws/com/sun/xml/internal/ws/handler/package-info.java classlib6/core/src/openjdk/jaxws/com/sun/xml/internal/ws/streaming/XMLReader.java Modified: classlib6/core/src/openjdk/jaxws/com/sun/tools/internal/ws/resources/model.properties =================================================================== --- classlib6/core/src/openjdk/jaxws/com/sun/tools/internal/ws/resources/model.properties 2011-03-05 11:28:28 UTC (rev 5798) +++ classlib6/core/src/openjdk/jaxws/com/sun/tools/internal/ws/resources/model.properties 2011-03-05 11:36:39 UTC (rev 5799) @@ -1,12 +1,12 @@ # -# Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved. +# Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. Sun designates this +# published by the Free Software Foundation. Oracle designates this # particular file as subject to the "Classpath" exception as provided -# by Sun in the LICENSE file that accompanied this code. +# by Oracle in the LICENSE file that accompanied this code. # # This code is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or @@ -18,9 +18,9 @@ # 2 along with this work; if not, write to the Free Software Foundation, # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. # -# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, -# CA 95054 USA or visit www.sun.com if you need additional information or -# have any questions. +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. # @@ -58,7 +58,6 @@ model.uniqueness=uniqueness constraint violation model.part.notUnique=parts in wsdl:message \"{0}\", reference \"{1}\", they must reference unique global elements. -model.parameter.notunique=Failed to generate Java signature: duplicate parameter names {0}. Use JAXWS binding customization to rename the wsdl:part \"{1}\" model.exception.notunique=Failed to generate Java signature: duplicate exception names {0}. Use JAXWS binding customization to rename the wsdl:part \"{1}\" model.uniqueness.javastructuretype=uniqueness constraint violation, duplicate member \"{0}\" added to JavaStructureType \"{1}\" model.parent.type.already.set=parent of type \"{0}\" already set to \"{1}\", new value = \"{2}\" @@ -78,8 +77,10 @@ model.arraywrapper.no.subtypes=LiteralArrayWrapper cannot have subtypes model.arraywrapper.no.content.member=LiteralArrayWrapper cannot have a content member model.complexType.simpleContent.reservedName=invalid attribute name: "_value" in complexType: \"{0}\", _value is JAXWS reserved name, this name is generated in the generated javabean class to hold content value in the generated javabean class for complexType/simpleContent. +model.parameter.notunique.wrapper=Failed to generate Java signature: duplicate parameter name \"{0}\". Try one of these\n\t1. Use JAXWS binding customization to rename the wsdl:part \"{1}\"\n\t2. Run wsimport with -extension switch.\n\t3. This is wrapper style operation, to resolve parameter name conflict, you can also try disabling wrapper style by using <jaxws:enableWrapperStyle>false</jaxws:enableWrapperStyle> wsdl customization. +model.parameter.notunique=Failed to generate Java signature: duplicate parameter name \"{0}\". Try one of these\n\t1. Use JAXWS binding customization to rename the wsdl:part \"{1}\"\n\t2. Run wsimport with -extension switch. -//JAXWS 2.0 +#JAXWS 2.0 model.schema.elementNotFound=Element \"{0}\" not found. model.schema.jaxbException.message="{0}" model.saxparser.exception:{0}\n{1} @@ -89,4 +90,3 @@ ConsoleErrorReporter.LineXOfY = \ \ \ line {0} of {1} - Deleted: classlib6/core/src/openjdk/jaxws/com/sun/tools/internal/xjc/api/impl/j2s/Messages.java =================================================================== --- classlib6/core/src/openjdk/jaxws/com/sun/tools/internal/xjc/api/impl/j2s/Messages.java 2011-03-05 11:28:28 UTC (rev 5798) +++ classlib6/core/src/openjdk/jaxws/com/sun/tools/internal/xjc/api/impl/j2s/Messages.java 2011-03-05 11:36:39 UTC (rev 5799) @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.sun.tools.internal.xjc.api.impl.j2s; - -import java.text.MessageFormat; -import java.util.ResourceBundle; - -/** - * @author Kohsuke Kawaguchi - */ -enum Messages { - ; - - - private static final ResourceBundle rb = ResourceBundle.getBundle(Messages.class.getName()); - - public String toString() { - return format(); - } - - public String format( Object... args ) { - return MessageFormat.format( rb.getString(name()), args ); - } -} Deleted: classlib6/core/src/openjdk/jaxws/com/sun/tools/internal/xjc/api/impl/j2s/Messages.properties =================================================================== --- classlib6/core/src/openjdk/jaxws/com/sun/tools/internal/xjc/api/impl/j2s/Messages.properties 2011-03-05 11:28:28 UTC (rev 5798) +++ classlib6/core/src/openjdk/jaxws/com/sun/tools/internal/xjc/api/impl/j2s/Messages.properties 2011-03-05 11:36:39 UTC (rev 5799) @@ -1,26 +0,0 @@ -# -# Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. Sun designates this -# particular file as subject to the "Classpath" exception as provided -# by Sun in the LICENSE file that accompanied this code. -# -# This code 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 General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, -# CA 95054 USA or visit www.sun.com if you need additional information or -# have any questions. -# - - Added: classlib6/core/src/openjdk/jaxws/com/sun/tools/internal/xjc/generator/bean/field/ContentListField.java =================================================================== --- classlib6/core/src/openjdk/jaxws/com/sun/tools/internal/xjc/generator/bean/field/ContentListField.java (rev 0) +++ classlib6/core/src/openjdk/jaxws/com/sun/tools/internal/xjc/generator/bean/field/ContentListField.java 2011-03-05 11:36:39 UTC (rev 5799) @@ -0,0 +1,176 @@ +/* + * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code 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 General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.sun.tools.internal.xjc.generator.bean.field; + +import java.util.ArrayList; +import java.util.List; + +import com.sun.codemodel.internal.JBlock; +import com.sun.codemodel.internal.JClass; +import com.sun.codemodel.internal.JExpr; +import com.sun.codemodel.internal.JExpression; +import com.sun.codemodel.internal.JMethod; +import com.sun.codemodel.internal.JType; +import com.sun.codemodel.internal.JVar; +import com.sun.tools.internal.xjc.generator.bean.ClassOutlineImpl; +import com.sun.tools.internal.xjc.generator.bean.MethodWriter; +import com.sun.tools.internal.xjc.model.CPropertyInfo; +import com.sun.tools.internal.xjc.outline.Aspect; +import com.sun.xml.internal.bind.api.impl.NameConverter; +import java.io.Serializable; + +/** + * Realizes a property as an untyped {@link List}. + * + * <pre> + * List getXXX(); + * </pre> + * + * <h2>Default value handling</h2> + * <p> + * Since unmarshaller just adds new values into the storage, + * we can't fill the storage by default values at the time of + * instanciation. (or oherwise values found in the document will + * be appended to default values, where it should overwrite them.) + * <p> + * Therefore, when the object is created, the storage will be empty. + * When the getXXX method is called, we'll check if the storage is + * modified in anyway. If it is modified, it must mean that the values + * are found in the document, so we just return it. + * + * Otherwise we will fill in default values and return it to the user. + * + * <p> + * When a list has default values, its dirty flag is set to true. + * Marshaller will check this and treat it appropriately. + * + * + * @author + * Kohsuke Kawaguchi (koh...@su...) + */ +public class ContentListField extends AbstractListField { + + /** + * A concrete class that implements the List interface. + * An instance of this class will be used to store data + * for this field. + */ + private final JClass coreList; + + /** List getFIELD() method. */ + private JMethod $get; + + /** + * @param coreList + * A concrete class that implements the List interface. + * An instance of this class will be used to store data + * for this field. + */ + protected ContentListField(ClassOutlineImpl context, CPropertyInfo prop, JClass coreList) { + // the JAXB runtime picks ArrayList if the signature is List, + // so don't do eager allocation if it's ArrayList. + // otherwise we need to do eager allocation so that the collection type specified by the user + // will be used. + super(context, prop, false); + this.coreList = coreList; + generate(); + } + + protected final JClass getCoreListType() { + return coreList; + } + + @Override + public void generateAccessors() { + final MethodWriter writer = outline.createMethodWriter(); + final Accessor acc = create(JExpr._this()); + + // [RESULT] + // List getXXX() { + // return <ref>; + // } + $get = writer.declareMethod(listT,"get"+prop.getName(true)); + writer.javadoc().append(prop.javadoc); + JBlock block = $get.body(); + fixNullRef(block); // avoid using an internal getter + block._return(acc.ref(true)); + + String pname = NameConverter.standard.toVariableName(prop.getName(true)); + writer.javadoc().append( + "Gets the value of the "+pname+" property.\n\n"+ + "<p>\n" + + "This accessor method returns a reference to the live list,\n" + + "not a snapshot. Therefore any modification you make to the\n" + + "returned list will be present inside the JAXB object.\n" + + "This is why there is not a <CODE>set</CODE> method for the " +pname+ " property.\n" + + "\n"+ + "<p>\n" + + "For example, to add a new item, do as follows:\n"+ + "<pre>\n"+ + " get"+prop.getName(true)+"().add(newItem);\n"+ + "</pre>\n"+ + "\n\n" + ); + + writer.javadoc().append( + "<p>\n" + + "Objects of the following type(s) are allowed in the list\n") + .append(listPossibleTypes(prop)); + } + + public Accessor create(JExpression targetObject) { + return new Accessor(targetObject); + } + + class Accessor extends AbstractListField.Accessor { + protected Accessor( JExpression $target ) { + super($target); + } + + public void toRawValue(JBlock block, JVar $var) { + // [RESULT] + // $<var>.addAll(bean.getLIST()); + // list.toArray( array ); + block.assign($var,JExpr._new(codeModel.ref(ArrayList.class).narrow(exposedType.boxify())).arg( + $target.invoke($get) + )); + } + + public void fromRawValue(JBlock block, String uniqueName, JExpression $var) { + // [RESULT] + // bean.getLIST().addAll($<var>); + JVar $list = block.decl(listT,uniqueName+'l',$target.invoke($get)); + block.invoke($list,"addAll").arg($var); + } + } + + @Override + protected JType getType(final Aspect aspect) { + if (Aspect.IMPLEMENTATION.equals(aspect)) { + return super.getType(aspect); + } + return codeModel.ref(Serializable.class); + } +} Added: classlib6/core/src/openjdk/jaxws/com/sun/tools/internal/xjc/generator/bean/field/DummyListField.java =================================================================== --- classlib6/core/src/openjdk/jaxws/com/sun/tools/internal/xjc/generator/bean/field/DummyListField.java (rev 0) +++ classlib6/core/src/openjdk/jaxws/com/sun/tools/internal/xjc/generator/bean/field/DummyListField.java 2011-03-05 11:36:39 UTC (rev 5799) @@ -0,0 +1,152 @@ +/* + * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code 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 General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.sun.tools.internal.xjc.generator.bean.field; + +import com.sun.codemodel.internal.JAnnotatable; +import java.util.ArrayList; +import java.util.List; + +import com.sun.codemodel.internal.JBlock; +import com.sun.codemodel.internal.JClass; +import com.sun.codemodel.internal.JExpr; +import com.sun.codemodel.internal.JExpression; +import com.sun.codemodel.internal.JMethod; +import com.sun.codemodel.internal.JVar; +import com.sun.tools.internal.xjc.generator.bean.ClassOutlineImpl; +import com.sun.tools.internal.xjc.model.CPropertyInfo; +import com.sun.tools.internal.xjc.model.CReferencePropertyInfo; +import com.sun.xml.internal.bind.annotation.OverrideAnnotationOf; + +/** + * Realizes a property as an untyped {@link List}. + * + * <pre> + * List getXXX(); + * </pre> + * + * <h2>Default value handling</h2> + * <p> + * Since unmarshaller just adds new values into the storage, + * we can't fill the storage by default values at the time of + * instanciation. (or oherwise values found in the document will + * be appended to default values, where it should overwrite them.) + * <p> + * Therefore, when the object is created, the storage will be empty. + * When the getXXX method is called, we'll check if the storage is + * modified in anyway. If it is modified, it must mean that the values + * are found in the document, so we just return it. + * + * Otherwise we will fill in default values and return it to the user. + * + * <p> + * When a list has default values, its dirty flag is set to true. + * Marshaller will check this and treat it appropriately. + * + * + * @author + * Kohsuke Kawaguchi (koh...@su...) + */ +public class DummyListField extends AbstractListField { + + /** + * A concrete class that imp lements the List interface. + * An instance of this class will be used to store data + * for this field. + */ + private final JClass coreList; + + + /** List getFIELD() method. */ + private JMethod $get; + + /** + * @param coreList + * A concrete class that implements the List interface. + * An instance of this class will be used to store data + * for this field. + */ + protected DummyListField(ClassOutlineImpl context, CPropertyInfo prop, JClass coreList) { + // the JAXB runtime picks ArrayList if the signature is List, + // so don't do eager allocation if it's ArrayList. + // otherwise we need to do eager allocation so that the collection type specified by the user + // will be used. + super(context, prop, !coreList.fullName().equals("java.util.ArrayList")); + this.coreList = coreList.narrow(exposedType.boxify()); + generate(); + } + + /** + * Annotate the field according to the recipes given as {@link CPropertyInfo}. + */ + @Override + protected void annotate( JAnnotatable field ) { + super.annotate(field); + + if (prop instanceof CReferencePropertyInfo) { + CReferencePropertyInfo pref = (CReferencePropertyInfo)prop; + if (pref.isDummy()) { + annotateDummy(field); + } + } + + } + + private void annotateDummy(JAnnotatable field) { + field.annotate(OverrideAnnotationOf.class); + } + + protected final JClass getCoreListType() { + return coreList; + } + + @Override + public void generateAccessors() { } + + public Accessor create(JExpression targetObject) { + return new Accessor(targetObject); + } + + class Accessor extends AbstractListField.Accessor { + protected Accessor( JExpression $target ) { + super($target); + } + + public void toRawValue(JBlock block, JVar $var) { + // [RESULT] + // $<var>.addAll(bean.getLIST()); + // list.toArray( array ); + block.assign($var,JExpr._new(codeModel.ref(ArrayList.class).narrow(exposedType.boxify())).arg( + $target.invoke($get) + )); + } + + public void fromRawValue(JBlock block, String uniqueName, JExpression $var) { + // [RESULT] + // bean.getLIST().addAll($<var>); + JVar $list = block.decl(listT,uniqueName+'l',$target.invoke($get)); + block.invoke($list,"addAll").arg($var); + } + } +} Added: classlib6/core/src/openjdk/jaxws/com/sun/tools/internal/xjc/generator/bean/field/NoExtendedContentField.java =================================================================== --- classlib6/core/src/openjdk/jaxws/com/sun/tools/internal/xjc/generator/bean/field/NoExtendedContentField.java (rev 0) +++ classlib6/core/src/openjdk/jaxws/com/sun/tools/internal/xjc/generator/bean/field/NoExtendedContentField.java 2011-03-05 11:36:39 UTC (rev 5799) @@ -0,0 +1,187 @@ +/* + * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code 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 General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.sun.tools.internal.xjc.generator.bean.field; + +import java.util.ArrayList; +import java.util.List; + +import com.sun.codemodel.internal.JBlock; +import com.sun.codemodel.internal.JClass; +import com.sun.codemodel.internal.JExpr; +import com.sun.codemodel.internal.JExpression; +import com.sun.codemodel.internal.JMethod; +import com.sun.codemodel.internal.JType; +import com.sun.codemodel.internal.JVar; +import com.sun.tools.internal.xjc.generator.bean.ClassOutlineImpl; +import com.sun.tools.internal.xjc.generator.bean.MethodWriter; +import com.sun.tools.internal.xjc.model.CElement; +import com.sun.tools.internal.xjc.model.CPropertyInfo; +import com.sun.tools.internal.xjc.model.CReferencePropertyInfo; +import com.sun.tools.internal.xjc.outline.Aspect; +import com.sun.xml.internal.bind.api.impl.NameConverter; +import java.io.Serializable; +import java.util.Set; + +/** + * Realizes a property as an untyped {@link List}. + * + * <pre> + * List getXXX(); + * </pre> + * + * <h2>Default value handling</h2> + * <p> + * Since unmarshaller just adds new values into the storage, + * we can't fill the storage by default values at the time of + * instanciation. (or oherwise values found in the document will + * be appended to default values, where it should overwrite them.) + * <p> + * Therefore, when the object is created, the storage will be empty. + * When the getXXX method is called, we'll check if the storage is + * modified in anyway. If it is modified, it must mean that the values + * are found in the document, so we just return it. + * + * Otherwise we will fill in default values and return it to the user. + * + * <p> + * When a list has default values, its dirty flag is set to true. + * Marshaller will check this and treat it appropriately. + * + * + * @author + * Kohsuke Kawaguchi (koh...@su...) + */ +public class NoExtendedContentField extends AbstractListField { + + /** + * A concrete class that implements the List interface. + * An instance of this class will be used to store data + * for this field. + */ + private final JClass coreList; + + /** List getFIELD() method. */ + private JMethod $get; + + /** + * @param coreList + * A concrete class that implements the List interface. + * An instance of this class will be used to store data + * for this field. + */ + protected NoExtendedContentField(ClassOutlineImpl context, CPropertyInfo prop, JClass coreList) { + // the JAXB runtime picks ArrayList if the signature is List, + // so don't do eager allocation if it's ArrayList. + // otherwise we need to do eager allocation so that the collection type specified by the user + // will be used. + super(context, prop, false); + this.coreList = coreList; + generate(); + } + + protected final JClass getCoreListType() { + return coreList; + } + + @Override + public void generateAccessors() { + final MethodWriter writer = outline.createMethodWriter(); + final Accessor acc = create(JExpr._this()); + + // [RESULT] + // List getXXX() { + // return <ref>; + // } + $get = writer.declareMethod(listT,"get"+prop.getName(true)); + writer.javadoc().append(prop.javadoc); + JBlock block = $get.body(); + fixNullRef(block); // avoid using an internal getter + block._return(acc.ref(true)); + + String pname = NameConverter.standard.toVariableName(prop.getName(true)); + writer.javadoc().append( + "Gets the value of the "+pname+" property.\n\n"+ + "<p>\n" + + "This accessor method returns a reference to the live list,\n" + + "not a snapshot. Therefore any modification you make to the\n" + + "returned list will be present inside the JAXB object.\n" + + "This is why there is not a <CODE>set</CODE> method for the " +pname+ " property.\n" + + "\n"+ + "<p>\n" + + "For example, to add a new item, do as follows:\n"+ + "<pre>\n"+ + " get"+prop.getName(true)+"().add(newItem);\n"+ + "</pre>\n"+ + "\n\n" + ); + + writer.javadoc().append( + "<p>\n" + + "Objects of the following type(s) are allowed in the list\n") + .append(listPossibleTypes(prop)); + } + + public Accessor create(JExpression targetObject) { + return new Accessor(targetObject); + } + + class Accessor extends AbstractListField.Accessor { + protected Accessor( JExpression $target ) { + super($target); + } + + public void toRawValue(JBlock block, JVar $var) { + // [RESULT] + // $<var>.addAll(bean.getLIST()); + // list.toArray( array ); + block.assign($var,JExpr._new(codeModel.ref(ArrayList.class).narrow(getType(Aspect.EXPOSED).boxify())).arg( + $target.invoke($get) + )); + } + + public void fromRawValue(JBlock block, String uniqueName, JExpression $var) { + // [RESULT] + // bean.getLIST().addAll($<var>); + JVar $list = block.decl(listT,uniqueName+'l',$target.invoke($get)); + block.invoke($list,"addAll").arg($var); + } + } + + @Override + protected JType getType(final Aspect aspect) { + if (Aspect.IMPLEMENTATION.equals(aspect)) { + return super.getType(aspect); + } + + if (prop instanceof CReferencePropertyInfo) { + Set<CElement> elements = ((CReferencePropertyInfo)prop).getElements(); + if ((elements != null) && (elements.size() > 0)) { + return codeModel.ref(Serializable.class); + } + } + + return codeModel.ref(String.class); + } +} Added: classlib6/core/src/openjdk/jaxws/com/sun/tools/internal/xjc/reader/xmlschema/bindinfo/BIFactoryMethod.java =================================================================== --- classlib6/core/src/openjdk/jaxws/com/sun/tools/internal/xjc/reader/xmlschema/bindinfo/BIFactoryMethod.java (rev 0) +++ classlib6/core/src/openjdk/jaxws/com/sun/tools/internal/xjc/reader/xmlschema/bindinfo/BIFactoryMethod.java 2011-03-05 11:36:39 UTC (rev 5799) @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code 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 General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.sun.tools.internal.xjc.reader.xmlschema.bindinfo; + +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.namespace.QName; + +import com.sun.xml.internal.xsom.XSComponent; +import com.sun.tools.internal.xjc.model.CPropertyInfo; +import com.sun.tools.internal.xjc.reader.Ring; +import com.sun.tools.internal.xjc.reader.Const; +import com.sun.tools.internal.xjc.reader.xmlschema.BGMBuilder; + +/** + * Controls the <tt>ObjectFactory</tt> method name. + * + * @author Kohsuke Kawaguchi + */ +@XmlRootElement(name="factoryMethod") +public class BIFactoryMethod extends AbstractDeclarationImpl { + @XmlAttribute + public String name; + + /** + * If the given component has {@link BIInlineBinaryData} customization, + * reflect that to the specified property. + */ + public static void handle(XSComponent source, CPropertyInfo prop) { + BIInlineBinaryData inline = Ring.get(BGMBuilder.class).getBindInfo(source).get(BIInlineBinaryData.class); + if(inline!=null) { + prop.inlineBinaryData = true; + inline.markAsAcknowledged(); + } + } + + + public final QName getName() { return NAME; } + + /** Name of the declaration. */ + public static final QName NAME = new QName(Const.JAXB_NSURI,"factoryMethod"); +} Added: classlib6/core/src/openjdk/jaxws/com/sun/tools/internal/xjc/reader/xmlschema/bindinfo/BIInlineBinaryData.java =================================================================== --- classlib6/core/src/openjdk/jaxws/com/sun/tools/internal/xjc/reader/xmlschema/bindinfo/BIInlineBinaryData.java (rev 0) +++ classlib6/core/src/openjdk/jaxws/com/sun/tools/internal/xjc/reader/xmlschema/bindinfo/BIInlineBinaryData.java 2011-03-05 11:36:39 UTC (rev 5799) @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code 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 General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.sun.tools.internal.xjc.reader.xmlschema.bindinfo; + +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlInlineBinaryData; +import javax.xml.namespace.QName; + +import com.sun.tools.internal.xjc.reader.Const; +import com.sun.tools.internal.xjc.reader.Ring; +import com.sun.tools.internal.xjc.reader.xmlschema.BGMBuilder; +import com.sun.tools.internal.xjc.model.CPropertyInfo; +import com.sun.xml.internal.xsom.XSComponent; + +/** + * Generates {@link @XmlInlineBinaryData}. + * + * @author Kohsuke Kawaguchi + */ +@XmlRootElement(name="inlineBinaryData") +public class BIInlineBinaryData extends AbstractDeclarationImpl { + + /** + * If the given component has {@link BIInlineBinaryData} customization, + * reflect that to the specified property. + */ + public static void handle(XSComponent source, CPropertyInfo prop) { + BIInlineBinaryData inline = Ring.get(BGMBuilder.class).getBindInfo(source).get(BIInlineBinaryData.class); + if(inline!=null) { + prop.inlineBinaryData = true; + inline.markAsAcknowledged(); + } + } + + + public final QName getName() { return NAME; } + + /** Name of the declaration. */ + public static final QName NAME = new QName(Const.JAXB_NSURI,"inlineBinaryData"); +} Added: classlib6/core/src/openjdk/jaxws/com/sun/tools/internal/xjc/reader/xmlschema/ct/AbstractExtendedComplexTypeBuilder.java =================================================================== --- classlib6/core/src/openjdk/jaxws/com/sun/tools/internal/xjc/reader/xmlschema/ct/AbstractExtendedComplexTypeBuilder.java (rev 0) +++ classlib6/core/src/openjdk/jaxws/com/sun/tools/internal/xjc/reader/xmlschema/ct/AbstractExtendedComplexTypeBuilder.java 2011-03-05 11:36:39 UTC (rev 5799) @@ -0,0 +1,221 @@ +/* + * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code 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 General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.sun.tools.internal.xjc.reader.xmlschema.ct; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +import com.sun.tools.internal.xjc.reader.xmlschema.WildcardNameClassBuilder; +import com.sun.xml.internal.xsom.XSAttributeUse; +import com.sun.xml.internal.xsom.XSComplexType; +import com.sun.xml.internal.xsom.XSContentType; +import com.sun.xml.internal.xsom.XSDeclaration; +import com.sun.xml.internal.xsom.XSElementDecl; +import com.sun.xml.internal.xsom.XSModelGroup; +import com.sun.xml.internal.xsom.XSModelGroupDecl; +import com.sun.xml.internal.xsom.XSParticle; +import com.sun.xml.internal.xsom.XSType; +import com.sun.xml.internal.xsom.XSWildcard; +import com.sun.xml.internal.xsom.visitor.XSTermFunction; + +import com.sun.xml.internal.rngom.nc.ChoiceNameClass; +import com.sun.xml.internal.rngom.nc.NameClass; +import com.sun.xml.internal.rngom.nc.SimpleNameClass; + +/** + * Binds a complex type derived from another complex type by extension. + * + * @author + * Kohsuke Kawaguchi (koh...@su...) + */ +abstract class AbstractExtendedComplexTypeBuilder extends CTBuilder { + + /** + * Map from {@link XSComplexType} to {@link NameClass}[2] that + * represents the names used in its child elements [0] and + * attributes [1]. + */ + protected final Map<XSComplexType, NameClass[]> characteristicNameClasses = new HashMap<XSComplexType, NameClass[]>(); + + /** + * Computes a name class that represents everything in a given content model. + */ + protected final XSTermFunction<NameClass> contentModelNameClassBuilder = new XSTermFunction<NameClass>() { + public NameClass wildcard(XSWildcard wc) { + return WildcardNameClassBuilder.build(wc); + } + + public NameClass modelGroupDecl(XSModelGroupDecl decl) { + return modelGroup(decl.getModelGroup()); + } + + public NameClass modelGroup(XSModelGroup group) { + NameClass nc = NameClass.NULL; + for( int i=0; i<group.getSize(); i++ ) + nc = new ChoiceNameClass(nc, group.getChild(i).getTerm().apply(this)); + return nc; + } + + public NameClass elementDecl(XSElementDecl decl) { + return getNameClass(decl); + } + }; + + /** + * Checks if the particles/attributes defined in the type parameter + * collides with the name classes of anc/enc. + * + * @return true if there's a collision. + */ + protected boolean checkCollision(NameClass anc, NameClass enc, XSComplexType type) { + NameClass[] chnc = characteristicNameClasses.get(type); + if (chnc == null) { + chnc = new NameClass[2]; + chnc[0] = getNameClass(type.getContentType()); + + // build attribute name classes + NameClass nc = NameClass.NULL; + Iterator itr = type.iterateAttributeUses(); + while( itr.hasNext() ) + anc = new ChoiceNameClass(anc, getNameClass(((XSAttributeUse) itr.next()).getDecl())); + XSWildcard wc = type.getAttributeWildcard(); + if(wc!=null) + nc = new ChoiceNameClass(nc, WildcardNameClassBuilder.build(wc)); + chnc[1] = nc; + + characteristicNameClasses.put(type, chnc); + } + + return chnc[0].hasOverlapWith(enc) || chnc[1].hasOverlapWith(anc); + } + + /** + * Looks for the derivation chain t_1 > t_2 > ... > t + * and find t_i such that t_i derives by restriction but + * for every j>i, t_j derives by extension. + * + * @return null + * If there's no such t_i or if t_i is any type. + */ + protected XSComplexType getLastRestrictedType(XSComplexType t) { + if (t.getBaseType() == schemas.getAnyType()) { + return null; // we don't count the restriction from anyType + } + if (t.getDerivationMethod() == XSType.RESTRICTION) { + return t; + } + + XSComplexType baseType = t.getBaseType().asComplexType(); + if (baseType != null) { + return getLastRestrictedType(baseType); + } else { + return null; + } + } + + /** + * Checks if this new extension is safe. + * + * UGLY. + * <p> + * If you have ctA extending ctB and ctB restricting ctC, our + * Java classes will look like CtAImpl extending CtBImpl + * extending CtCImpl. + * + * <p> + * Since a derived class unmarshaller uses the base class unmarshaller, + * this could potentially result in incorrect unmarshalling. + * We used to just reject such a case, but then we found that + * there are schemas that are using it. + * + * <p> + * One generalized observation that we reached is that if the extension + * is only adding new elements/attributes which has never been used + * in any of its base class (IOW, if none of the particle / attribute use / + * attribute wildcard can match the name of newly added elements/attributes) + * then it is safe to add them. + * + * <p> + * This function checks if the derivation chain to this type is + * not using restriction, and if it is, then checks if it is safe + * according to the above condition. + * + * @return false + * If this complex type needs to be rejected. + */ + protected boolean checkIfExtensionSafe(XSComplexType baseType, XSComplexType thisType) { + XSComplexType lastType = getLastRestrictedType(baseType); + + if (lastType == null) { + return true; // no restriction in derivation chain + } + NameClass anc = NameClass.NULL; + // build name class for attributes in new complex type + Iterator itr = thisType.iterateDeclaredAttributeUses(); + while (itr.hasNext()) { + anc = new ChoiceNameClass(anc, getNameClass(((XSAttributeUse) itr.next()).getDecl())); + } + // TODO: attribute wildcard + + NameClass enc = getNameClass(thisType.getExplicitContent()); + + // check against every base type ... except the root anyType + while (lastType != lastType.getBaseType()) { + if (checkCollision(anc, enc, lastType)) { + return false; + } + + if (lastType.getBaseType().isSimpleType()) // if the base type is a simple type, there won't be + // any further name collision. + { + return true; + } + + lastType = lastType.getBaseType().asComplexType(); + } + + return true; // OK + } + + /** + * Gets a {@link NameClass} that represents all the terms in the given content type. + * If t is not a particle, just return an empty name class. + */ + private NameClass getNameClass(XSContentType t) { + if(t==null) return NameClass.NULL; + XSParticle p = t.asParticle(); + if(p==null) return NameClass.NULL; + else return p.getTerm().apply(contentModelNameClassBuilder); + } + + /** + * Gets a {@link SimpleNameClass} from the name of a {@link XSDeclaration}. + */ + private NameClass getNameClass(XSDeclaration decl) { + return new SimpleNameClass(decl.getTargetNamespace(), decl.getName()); + } + +} Added: classlib6/core/src/openjdk/jaxws/com/sun/tools/internal/xjc/reader/xmlschema/ct/MixedExtendedComplexTypeBuilder.java =================================================================== --- classlib6/core/src/openjdk/jaxws/com/sun/tools/internal/xjc/reader/xmlschema/ct/MixedExtendedComplexTypeBuilder.java (rev 0) +++ classlib6/core/src/openjdk/jaxws/com/sun/tools/internal/xjc/reader/xmlschema/ct/MixedExtendedComplexTypeBuilder.java 2011-03-05 11:36:39 UTC (rev 5799) @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code 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 General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.tools.internal.xjc.reader.xmlschema.ct; + +import com.sun.tools.internal.xjc.model.CClass; +import com.sun.tools.internal.xjc.model.CPropertyInfo; +import com.sun.tools.internal.xjc.reader.RawTypeSet; +import com.sun.tools.internal.xjc.reader.xmlschema.RawTypeSetBuilder; +import com.sun.tools.internal.xjc.reader.xmlschema.bindinfo.BIGlobalBinding; +import com.sun.tools.internal.xjc.reader.xmlschema.bindinfo.BIProperty; +import com.sun.xml.internal.xsom.XSComplexType; +import com.sun.xml.internal.xsom.XSContentType; +import com.sun.xml.internal.xsom.XSType; + +/** + * @author Kohsuke Kawaguchi + */ +final class MixedExtendedComplexTypeBuilder extends AbstractExtendedComplexTypeBuilder { + + public boolean isApplicable(XSComplexType ct) { + + if (!bgmBuilder.isGenerateMixedExtensions()) return false; + + XSType bt = ct.getBaseType(); + if (bt.isComplexType() && + bt.asComplexType().isMixed() && + ct.isMixed() && + ct.getDerivationMethod()==XSType.EXTENSION && + ct.getContentType().asParticle() != null && + ct.getExplicitContent().asEmpty() == null + ) { + return true; + } + + return false; + } + + public void build(XSComplexType ct) { + XSComplexType baseType = ct.getBaseType().asComplexType(); + + // build the base class + CClass baseClass = selector.bindToType(baseType, ct, true); + assert baseClass != null; // global complex type must map to a class + + if (!checkIfExtensionSafe(baseType, ct)) { + // error. We can't handle any further extension + errorReceiver.error(ct.getLocator(), + Messages.ERR_NO_FURTHER_EXTENSION.format( + baseType.getName(), ct.getName() ) + ); + return; + } + + selector.getCurrentBean().setBaseClass(baseClass); + builder.recordBindingMode(ct, ComplexTypeBindingMode.FALLBACK_EXTENSION); + + BIProperty prop = BIProperty.getCustomization(ct); + CPropertyInfo p; + + RawTypeSet ts = RawTypeSetBuilder.build(ct.getContentType().asParticle(), false); + p = prop.createDummyExtendedMixedReferenceProperty("contentOverrideFor" + ct.getName(), ct, ts); + + selector.getCurrentBean().addProperty(p); + + // adds attributes and we are through. + green.attContainer(ct); + } + +} Deleted: classlib6/core/src/openjdk/jaxws/com/sun/xml/internal/fastinfoset/stax/events/StAXEventAllocator.java =================================================================== --- classlib6/core/src/openjdk/jaxws/com/sun/xml/internal/fastinfoset/stax/events/StAXEventAllocator.java 2011-03-05 11:28:28 UTC (rev 5798) +++ classlib6/core/src/openjdk/jaxws/com/sun/xml/internal/fastinfoset/stax/events/StAXEventAllocator.java 2011-03-05 11:36:39 UTC (rev 5799) @@ -1,238 +0,0 @@ -/* - * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - * THIS FILE WAS MODIFIED BY SUN MICROSYSTEMS, INC. - */ - - - - -package com.sun.xml.internal.fastinfoset.stax.events; - -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.events.Namespace; -import javax.xml.stream.events.XMLEvent; -import javax.xml.stream.util.XMLEventAllocator; -import javax.xml.stream.util.XMLEventConsumer; - -import com.sun.xml.internal.fastinfoset.CommonResourceBundle; - -/** - * This class provides the same functionality as StAXEventAllocatorBase, but without - * using EventFactory and creating a new object for each call. - * - * It seems to be good idea using static components. Unfortunately, EventReader's peek - * and next methods require that multiple instances being created. - * - */ -public class StAXEventAllocator implements XMLEventAllocator { - StartElementEvent startElement = new StartElementEvent(); - EndElementEvent endElement = new EndElementEvent(); - CharactersEvent characters = new CharactersEvent(); - CharactersEvent cData = new CharactersEvent("",true); - CharactersEvent space = new CharactersEvent(); - CommentEvent comment = new CommentEvent(); - EntityReferenceEvent entity = new EntityReferenceEvent(); - ProcessingInstructionEvent pi = new ProcessingInstructionEvent(); - StartDocumentEvent startDoc = new StartDocumentEvent(); - EndDocumentEvent endDoc = new EndDocumentEvent(); - DTDEvent dtd = new DTDEvent(); - - /** Creates a new instance of StAXEventAllocator */ - public StAXEventAllocator() { - } - public XMLEventAllocator newInstance() { - return new StAXEventAllocator(); - } - - /** - * This method allocates an event given the current state of the XMLStreamReader. - * If this XMLEventAllocator does not have a one-to-one mapping between reader state - * and events this method will return null. - * @param streamReader The XMLStreamReader to allocate from - * @return the event corresponding to the current reader state - */ - public XMLEvent allocate(XMLStreamReader streamReader) throws XMLStreamException { - if(streamReader == null ) - throw new XMLStreamException(CommonResourceBundle.getInstance().getString("message.nullReader")); - return getXMLEvent(streamReader); - } - - /** - * This method allocates an event or set of events given the current state of - * the XMLStreamReader and adds the event or set of events to the consumer that - * was passed in. - * @param streamReader The XMLStreamReader to allocate from - * @param consumer The XMLEventConsumer to add to. - */ - public void allocate(XMLStreamReader streamReader, XMLEventConsumer consumer) throws XMLStreamException { - consumer.add(getXMLEvent(streamReader)); - - } - // ---------------------end of methods defined by XMLEventAllocator-----------------// - - - XMLEvent getXMLEvent(XMLStreamReader reader){ - EventBase event = null; - int eventType = reader.getEventType(); - - switch(eventType){ - - case XMLEvent.START_ELEMENT: - { - startElement.reset(); - startElement.setName(new QName(reader.getNamespaceURI(), - reader.getLocalName(), reader.getPrefix())); - - addAttributes(startElement,reader); - addNamespaces(startElement, reader); - //need to fix it along with the Reader - //setNamespaceContext(startElement,reader); - event = startElement; - break; - } - case XMLEvent.END_ELEMENT: - { - endElement.reset(); - endElement.setName(new QName(reader.getNamespaceURI(), - reader.getLocalName(),reader.getPrefix())); - addNamespaces(endElement,reader); - event = endElement ; - break; - } - case XMLEvent.PROCESSING_INSTRUCTION: - { - pi.setTarget(reader.getPITarget()); - pi.setData(reader.getPIData()); - event = pi; - break; - } - case XMLEvent.CHARACTERS: - { - characters.setData(reader.getText()); - event = characters; - /** - if (reader.isWhiteSpace()) { - space.setData(reader.getText()); - space.setSpace(true); - event = space; - } - else { - characters.setData(reader.getText()); - event = characters; - } - */ - break; - } - case XMLEvent.COMMENT: - { - comment.setText(reader.getText()); - event = comment; - break; - } - case XMLEvent.START_DOCUMENT: - { - startDoc.reset(); - String encoding = reader.getEncoding(); - String version = reader.getVersion(); - if (encoding != null) - startDoc.setEncoding(encoding); - if (version != null) - startDoc.setVersion(version); - startDoc.setStandalone(reader.isStandalone()); - if(reader.getCharacterEncodingScheme() != null){ - startDoc.setDeclaredEncoding(true); - }else{ - startDoc.setDeclaredEncoding(false); - } - event = startDoc ; - break; - } - case XMLEvent.END_DOCUMENT:{ - event = endDoc; - break; - } - case XMLEvent.ENTITY_REFERENCE:{ - entity.setName(reader.getLocalName()); - entity.setDeclaration(new EntityDeclarationImpl(reader.getLocalName(),reader.getText())); - event = entity; - break; - - } - case XMLEvent.ATTRIBUTE:{ - event = null ; - break; - } - case XMLEvent.DTD:{ - dtd.setDTD(reader.getText()); - event = dtd; - break; - } - case XMLEvent.CDATA:{ - cData.setData(reader.getText()); - event = cData; - break; - } - case XMLEvent.SPACE:{ - space.setData(reader.getText()); - space.setSpace(true); - event = space; - break; - } - } - event.setLocation(reader.getLocation()); - return event ; - } - - //use event.a... [truncated message content] |