src/share/jaxws_classes/javax/xml/bind/annotation/DomHandler.java

Thu, 31 Aug 2017 15:18:52 +0800

author
aoqi
date
Thu, 31 Aug 2017 15:18:52 +0800
changeset 637
9c07ef4934dd
parent 397
b99d7e355d4b
parent 0
373ffda63c9a
permissions
-rw-r--r--

merge

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation. Oracle designates this
aoqi@0 8 * particular file as subject to the "Classpath" exception as provided
aoqi@0 9 * by Oracle in the LICENSE file that accompanied this code.
aoqi@0 10 *
aoqi@0 11 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 14 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 15 * accompanied this code).
aoqi@0 16 *
aoqi@0 17 * You should have received a copy of the GNU General Public License version
aoqi@0 18 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 20 *
aoqi@0 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 22 * or visit www.oracle.com if you need additional information or have any
aoqi@0 23 * questions.
aoqi@0 24 */
aoqi@0 25
aoqi@0 26 package javax.xml.bind.annotation;
aoqi@0 27
aoqi@0 28 import javax.xml.bind.ValidationEventHandler;
aoqi@0 29 import javax.xml.transform.Result;
aoqi@0 30 import javax.xml.transform.Source;
aoqi@0 31
aoqi@0 32 /**
aoqi@0 33 * Converts an element (and its descendants)
aoqi@0 34 * from/to DOM (or similar) representation.
aoqi@0 35 *
aoqi@0 36 * <p>
aoqi@0 37 * Implementations of this interface will be used in conjunction with
aoqi@0 38 * {@link XmlAnyElement} annotation to map an element of XML into a representation
aoqi@0 39 * of infoset such as W3C DOM.
aoqi@0 40 *
aoqi@0 41 * <p>
aoqi@0 42 * Implementations hide how a portion of XML is converted into/from such
aoqi@0 43 * DOM-like representation, allowing JAXB providers to work with arbitrary
aoqi@0 44 * such library.
aoqi@0 45 *
aoqi@0 46 * <P>
aoqi@0 47 * This interface is intended to be implemented by library writers
aoqi@0 48 * and consumed by JAXB providers. None of those methods are intended to
aoqi@0 49 * be called from applications.
aoqi@0 50 *
aoqi@0 51 * @author Kohsuke Kawaguchi
aoqi@0 52 * @since JAXB2.0
aoqi@0 53 */
aoqi@0 54 public interface DomHandler<ElementT,ResultT extends Result> {
aoqi@0 55 /**
aoqi@0 56 * When a JAXB provider needs to unmarshal a part of a document into an
aoqi@0 57 * infoset representation, it first calls this method to create a
aoqi@0 58 * {@link Result} object.
aoqi@0 59 *
aoqi@0 60 * <p>
aoqi@0 61 * A JAXB provider will then send a portion of the XML
aoqi@0 62 * into the given result. Such a portion always form a subtree
aoqi@0 63 * of the whole XML document rooted at an element.
aoqi@0 64 *
aoqi@0 65 * @param errorHandler
aoqi@0 66 * if any error happens between the invocation of this method
aoqi@0 67 * and the invocation of {@link #getElement(Result)}, they
aoqi@0 68 * must be reported to this handler.
aoqi@0 69 *
aoqi@0 70 * The caller must provide a non-null error handler.
aoqi@0 71 *
aoqi@0 72 * The {@link Result} object created from this method
aoqi@0 73 * may hold a reference to this error handler.
aoqi@0 74 *
aoqi@0 75 * @return
aoqi@0 76 * null if the operation fails. The error must have been reported
aoqi@0 77 * to the error handler.
aoqi@0 78 */
aoqi@0 79 ResultT createUnmarshaller( ValidationEventHandler errorHandler );
aoqi@0 80
aoqi@0 81 /**
aoqi@0 82 * Once the portion is sent to the {@link Result}. This method is called
aoqi@0 83 * by a JAXB provider to obtain the unmarshalled element representation.
aoqi@0 84 *
aoqi@0 85 * <p>
aoqi@0 86 * Multiple invocations of this method may return different objects.
aoqi@0 87 * This method can be invoked only when the whole sub-tree are fed
aoqi@0 88 * to the {@link Result} object.
aoqi@0 89 *
aoqi@0 90 * @param rt
aoqi@0 91 * The {@link Result} object created by {@link #createUnmarshaller(ValidationEventHandler)}.
aoqi@0 92 *
aoqi@0 93 * @return
aoqi@0 94 * null if the operation fails. The error must have been reported
aoqi@0 95 * to the error handler.
aoqi@0 96 */
aoqi@0 97 ElementT getElement(ResultT rt);
aoqi@0 98
aoqi@0 99 /**
aoqi@0 100 * This method is called when a JAXB provider needs to marshal an element
aoqi@0 101 * to XML.
aoqi@0 102 *
aoqi@0 103 * <p>
aoqi@0 104 * If non-null, the returned {@link Source} must contain a whole document
aoqi@0 105 * rooted at one element, which will then be weaved into a bigger document
aoqi@0 106 * that the JAXB provider is marshalling.
aoqi@0 107 *
aoqi@0 108 * @param errorHandler
aoqi@0 109 * Receives any errors happened during the process of converting
aoqi@0 110 * an element into a {@link Source}.
aoqi@0 111 *
aoqi@0 112 * The caller must provide a non-null error handler.
aoqi@0 113 *
aoqi@0 114 * @return
aoqi@0 115 * null if there was an error. The error should have been reported
aoqi@0 116 * to the handler.
aoqi@0 117 */
aoqi@0 118 Source marshal( ElementT n, ValidationEventHandler errorHandler );
aoqi@0 119 }

mercurial