src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/property/Property.java

Fri, 22 Nov 2013 21:11:19 +0100

author
mkos
date
Fri, 22 Nov 2013 21:11:19 +0100
changeset 450
b0c2840e2513
parent 0
373ffda63c9a
permissions
-rw-r--r--

8010935: Better XML handling
8027378: Two closed/javax/xml/8005432 fails with jdk7u51b04
8028382: Two javax/xml/8005433 tests still fail after the fix JDK-8028147
Summary: base fix + fixes for test regressions; fix also reviewed by Maxim Soloviev, Alexander Fomin
Reviewed-by: mchung, mgrebac, mullan

     1 /*
     2  * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     8  * particular file as subject to the "Classpath" exception as provided
     9  * by Oracle in the LICENSE file that accompanied this code.
    10  *
    11  * This code is distributed in the hope that it will be useful, but WITHOUT
    12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    14  * version 2 for more details (a copy is included in the LICENSE file that
    15  * accompanied this code).
    16  *
    17  * You should have received a copy of the GNU General Public License version
    18  * 2 along with this work; if not, write to the Free Software Foundation,
    19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    20  *
    21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    22  * or visit www.oracle.com if you need additional information or have any
    23  * questions.
    24  */
    26 package com.sun.xml.internal.bind.v2.runtime.property;
    28 import java.io.IOException;
    30 import javax.xml.bind.JAXBContext;
    31 import javax.xml.bind.JAXBElement;
    32 import javax.xml.stream.XMLStreamException;
    34 import com.sun.xml.internal.bind.api.AccessorException;
    35 import com.sun.xml.internal.bind.v2.model.core.ID;
    36 import com.sun.xml.internal.bind.v2.model.core.PropertyInfo;
    37 import com.sun.xml.internal.bind.v2.model.core.PropertyKind;
    38 import com.sun.xml.internal.bind.v2.model.runtime.RuntimePropertyInfo;
    39 import com.sun.xml.internal.bind.v2.runtime.JaxBeanInfo;
    40 import com.sun.xml.internal.bind.v2.runtime.XMLSerializer;
    41 import com.sun.xml.internal.bind.v2.runtime.reflect.Accessor;
    43 import org.xml.sax.SAXException;
    45 /**
    46  * A JAXB property that constitutes a JAXB-bound bean.
    47  *
    48  * @author Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
    49  */
    50 public interface Property<BeanT> extends StructureLoaderBuilder {
    52 //    // is this method necessary? --> probably not
    53 //    RuntimePropertyInfo owner();
    55     /**
    56      * Resets the property value on the given object.
    57      *
    58      * <p>
    59      * ... for example by setting 0 or null.
    60      */
    61     void reset( BeanT o ) throws AccessorException;
    63     /**
    64      * @see JaxBeanInfo#serializeBody(Object, XMLSerializer)
    65      *
    66      * @param outerPeer
    67      *      used when this property is expected to print out an element
    68      *      and that should be associated with this outer peer. normally null.
    69      *      this is only used for {@link JaxBeanInfo} for {@link JAXBElement}s.
    70      * @throws AccessorException
    71      *      If thrown, caught by the caller and reported.
    72      */
    73     public void serializeBody(BeanT beanT, XMLSerializer target, Object outerPeer) throws SAXException, AccessorException, IOException, XMLStreamException;
    75     /**
    76      * @see JaxBeanInfo#serializeURIs(Object, XMLSerializer)
    77      */
    78     public void serializeURIs(BeanT beanT, XMLSerializer target) throws SAXException, AccessorException;
    80     /**
    81      * Returns true if
    82      * {@link #serializeURIs(Object,XMLSerializer)} performs some meaningful action.
    83      */
    84     public boolean hasSerializeURIAction();
    86 //    /**
    87 //     * Builds the unmarshaller.
    88 //     *
    89 //     * @param grammar
    90 //     *      the context object to which this property ultimately belongs to.
    91 //     *      a property will only belong to one grammar, but to reduce the memory footprint
    92 //     *      we don't keep that information stored in {@link Property}, and instead we
    93 //     *      just pass the value as a parameter when needed.
    94 //     */
    95 //    Unmarshaller.Handler createUnmarshallerHandler(JAXBContextImpl grammar, Unmarshaller.Handler tail);
    97     /**
    98      * Gets the value of the property.
    99      *
   100      * This method is only used when the corresponding {@link PropertyInfo#id()} is {@link ID#ID},
   101      * and therefore the return type is fixed to {@link String}.
   102      */
   103     String getIdValue(BeanT bean) throws AccessorException, SAXException;
   105     /**
   106      * Gets the Kind of property
   107      * @return
   108      *      always non-null.
   109      */
   110     PropertyKind getKind();
   113     // UGLY HACK to support JAX-WS
   114     // if other clients want to access those functionalities,
   115     // we should design a better model
   116     /**
   117      * If this property is mapped to the specified element,
   118      * return an accessor to it.
   119      *
   120      * @return
   121      *      null if the property is not mapped to the specified element.
   122      */
   123     Accessor getElementPropertyAccessor(String nsUri,String localName);
   125     /**
   126      * Called at the end of the {@link JAXBContext} initialization phase
   127      * to clean up any unnecessary references.
   128      */
   129     void wrapUp();
   131     /**
   132      * Provides more {@link RuntimePropertyInfo} information on the property.
   133      *
   134      * @return
   135      *      null if RETAIN_REFERENCE_TO_INFO property is not set on the {@link JAXBContext}
   136      */
   137     public RuntimePropertyInfo getInfo();
   139     public boolean isHiddenByOverride();
   141     public void setHiddenByOverride(boolean hidden);
   143     public String getFieldName();
   144 }

mercurial