| /* |
| * 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. |
| */ |
| package com.sun.xml.internal.bind.v2.runtime.property; |
| |
| import java.io.IOException; |
| |
| import javax.xml.bind.JAXBContext; |
| import javax.xml.bind.JAXBElement; |
| import javax.xml.stream.XMLStreamException; |
| |
| import com.sun.xml.internal.bind.api.AccessorException; |
| import com.sun.xml.internal.bind.v2.model.core.ID; |
| import com.sun.xml.internal.bind.v2.model.core.PropertyInfo; |
| import com.sun.xml.internal.bind.v2.model.core.PropertyKind; |
| import com.sun.xml.internal.bind.v2.runtime.JaxBeanInfo; |
| import com.sun.xml.internal.bind.v2.runtime.XMLSerializer; |
| import com.sun.xml.internal.bind.v2.runtime.reflect.Accessor; |
| |
| import org.xml.sax.SAXException; |
| |
| /** |
| * A JAXB property that constitutes a JAXB-bound bean. |
| * |
| * @author Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com) |
| */ |
| public interface Property<BeanT> extends StructureLoaderBuilder { |
| |
| // // is this method necessary? --> probably not |
| // RuntimePropertyInfo owner(); |
| |
| /** |
| * Resets the property value on the given object. |
| * |
| * <p> |
| * ... for example by setting 0 or null. |
| */ |
| void reset( BeanT o ) throws AccessorException; |
| |
| /** |
| * @see JaxBeanInfo#serializeBody(Object, XMLSerializer) |
| * |
| * @param outerPeer |
| * used when this property is expected to print out an element |
| * and that should be associated with this outer peer. normally null. |
| * this is only used for {@link JaxBeanInfo} for {@link JAXBElement}s. |
| * @throws AccessorException |
| * If thrown, caught by the caller and reported. |
| */ |
| public void serializeBody(BeanT beanT, XMLSerializer target, Object outerPeer) throws SAXException, AccessorException, IOException, XMLStreamException; |
| |
| /** |
| * @see JaxBeanInfo#serializeURIs(Object, XMLSerializer) |
| */ |
| public void serializeURIs(BeanT beanT, XMLSerializer target) throws SAXException, AccessorException; |
| |
| /** |
| * Returns true if |
| * {@link #serializeURIs(Object,XMLSerializer)} performs some meaningful action. |
| */ |
| public boolean hasSerializeURIAction(); |
| |
| // /** |
| // * Builds the unmarshaller. |
| // * |
| // * @param grammar |
| // * the context object to which this property ultimately belongs to. |
| // * a property will only belong to one grammar, but to reduce the memory footprint |
| // * we don't keep that information stored in {@link Property}, and instead we |
| // * just pass the value as a parameter when needed. |
| // */ |
| // Unmarshaller.Handler createUnmarshallerHandler(JAXBContextImpl grammar, Unmarshaller.Handler tail); |
| |
| /** |
| * Gets the value of the property. |
| * |
| * This method is only used when the corresponding {@link PropertyInfo#id()} is {@link ID#ID}, |
| * and therefore the return type is fixed to {@link String}. |
| */ |
| String getIdValue(BeanT bean) throws AccessorException, SAXException; |
| |
| /** |
| * Gets the Kind of property |
| * @return |
| * always non-null. |
| */ |
| PropertyKind getKind(); |
| |
| |
| // UGLY HACK to support JAX-WS |
| // if other clients want to access those functionalities, |
| // we should design a better model |
| /** |
| * If this property is mapped to the specified element, |
| * return an accessor to it. |
| * |
| * @return |
| * null if the property is not mapped to the specified element. |
| */ |
| Accessor getElementPropertyAccessor(String nsUri,String localName); |
| |
| /** |
| * Called at the end of the {@link JAXBContext} initialization phase |
| * to clean up any unnecessary references. |
| */ |
| void wrapUp(); |
| } |