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

changeset 0
373ffda63c9a
child 637
9c07ef4934dd
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/jaxws_classes/javax/xml/bind/annotation/DomHandler.java	Wed Apr 27 01:27:09 2016 +0800
     1.3 @@ -0,0 +1,119 @@
     1.4 +/*
     1.5 + * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.  Oracle designates this
    1.11 + * particular file as subject to the "Classpath" exception as provided
    1.12 + * by Oracle in the LICENSE file that accompanied this code.
    1.13 + *
    1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.17 + * version 2 for more details (a copy is included in the LICENSE file that
    1.18 + * accompanied this code).
    1.19 + *
    1.20 + * You should have received a copy of the GNU General Public License version
    1.21 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.23 + *
    1.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.25 + * or visit www.oracle.com if you need additional information or have any
    1.26 + * questions.
    1.27 + */
    1.28 +
    1.29 +package javax.xml.bind.annotation;
    1.30 +
    1.31 +import javax.xml.bind.ValidationEventHandler;
    1.32 +import javax.xml.transform.Result;
    1.33 +import javax.xml.transform.Source;
    1.34 +
    1.35 +/**
    1.36 + * Converts an element (and its descendants)
    1.37 + * from/to DOM (or similar) representation.
    1.38 + *
    1.39 + * <p>
    1.40 + * Implementations of this interface will be used in conjunction with
    1.41 + * {@link XmlAnyElement} annotation to map an element of XML into a representation
    1.42 + * of infoset such as W3C DOM.
    1.43 + *
    1.44 + * <p>
    1.45 + * Implementations hide how a portion of XML is converted into/from such
    1.46 + * DOM-like representation, allowing JAXB providers to work with arbitrary
    1.47 + * such library.
    1.48 + *
    1.49 + * <P>
    1.50 + * This interface is intended to be implemented by library writers
    1.51 + * and consumed by JAXB providers. None of those methods are intended to
    1.52 + * be called from applications.
    1.53 + *
    1.54 + * @author Kohsuke Kawaguchi
    1.55 + * @since JAXB2.0
    1.56 + */
    1.57 +public interface DomHandler<ElementT,ResultT extends Result> {
    1.58 +    /**
    1.59 +     * When a JAXB provider needs to unmarshal a part of a document into an
    1.60 +     * infoset representation, it first calls this method to create a
    1.61 +     * {@link Result} object.
    1.62 +     *
    1.63 +     * <p>
    1.64 +     * A JAXB provider will then send a portion of the XML
    1.65 +     * into the given result. Such a portion always form a subtree
    1.66 +     * of the whole XML document rooted at an element.
    1.67 +     *
    1.68 +     * @param errorHandler
    1.69 +     *      if any error happens between the invocation of this method
    1.70 +     *      and the invocation of {@link #getElement(Result)}, they
    1.71 +     *      must be reported to this handler.
    1.72 +     *
    1.73 +     *      The caller must provide a non-null error handler.
    1.74 +     *
    1.75 +     *      The {@link Result} object created from this method
    1.76 +     *      may hold a reference to this error handler.
    1.77 +     *
    1.78 +     * @return
    1.79 +     *      null if the operation fails. The error must have been reported
    1.80 +     *      to the error handler.
    1.81 +     */
    1.82 +    ResultT createUnmarshaller( ValidationEventHandler errorHandler );
    1.83 +
    1.84 +    /**
    1.85 +     * Once the portion is sent to the {@link Result}. This method is called
    1.86 +     * by a JAXB provider to obtain the unmarshalled element representation.
    1.87 +     *
    1.88 +     * <p>
    1.89 +     * Multiple invocations of this method may return different objects.
    1.90 +     * This method can be invoked only when the whole sub-tree are fed
    1.91 +     * to the {@link Result} object.
    1.92 +     *
    1.93 +     * @param rt
    1.94 +     *      The {@link Result} object created by {@link #createUnmarshaller(ValidationEventHandler)}.
    1.95 +     *
    1.96 +     * @return
    1.97 +     *      null if the operation fails. The error must have been reported
    1.98 +     *      to the error handler.
    1.99 +     */
   1.100 +    ElementT getElement(ResultT rt);
   1.101 +
   1.102 +    /**
   1.103 +     * This method is called when a JAXB provider needs to marshal an element
   1.104 +     * to XML.
   1.105 +     *
   1.106 +     * <p>
   1.107 +     * If non-null, the returned {@link Source} must contain a whole document
   1.108 +     * rooted at one element, which will then be weaved into a bigger document
   1.109 +     * that the JAXB provider is marshalling.
   1.110 +     *
   1.111 +     * @param errorHandler
   1.112 +     *      Receives any errors happened during the process of converting
   1.113 +     *      an element into a {@link Source}.
   1.114 +     *
   1.115 +     *      The caller must provide a non-null error handler.
   1.116 +     *
   1.117 +     * @return
   1.118 +     *      null if there was an error. The error should have been reported
   1.119 +     *      to the handler.
   1.120 +     */
   1.121 +    Source marshal( ElementT n, ValidationEventHandler errorHandler );
   1.122 +}

mercurial