src/share/jaxws_classes/com/sun/xml/internal/org/jvnet/staxex/XMLStreamReaderEx.java

Tue, 06 Mar 2012 16:09:35 -0800

author
ohair
date
Tue, 06 Mar 2012 16:09:35 -0800
changeset 286
f50545b5e2f1
child 368
0989ad8c0860
permissions
-rw-r--r--

7150322: Stop using drop source bundles in jaxws
Reviewed-by: darcy, ohrstrom

ohair@286 1 /*
ohair@286 2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
ohair@286 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ohair@286 4 *
ohair@286 5 * This code is free software; you can redistribute it and/or modify it
ohair@286 6 * under the terms of the GNU General Public License version 2 only, as
ohair@286 7 * published by the Free Software Foundation. Oracle designates this
ohair@286 8 * particular file as subject to the "Classpath" exception as provided
ohair@286 9 * by Oracle in the LICENSE file that accompanied this code.
ohair@286 10 *
ohair@286 11 * This code is distributed in the hope that it will be useful, but WITHOUT
ohair@286 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ohair@286 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
ohair@286 14 * version 2 for more details (a copy is included in the LICENSE file that
ohair@286 15 * accompanied this code).
ohair@286 16 *
ohair@286 17 * You should have received a copy of the GNU General Public License version
ohair@286 18 * 2 along with this work; if not, write to the Free Software Foundation,
ohair@286 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ohair@286 20 *
ohair@286 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ohair@286 22 * or visit www.oracle.com if you need additional information or have any
ohair@286 23 * questions.
ohair@286 24 */
ohair@286 25
ohair@286 26 package com.sun.xml.internal.org.jvnet.staxex;
ohair@286 27
ohair@286 28 import javax.xml.stream.XMLStreamReader;
ohair@286 29 import javax.xml.stream.XMLStreamException;
ohair@286 30
ohair@286 31 /**
ohair@286 32 * {@link XMLStreamReader} extended for reading binary data.
ohair@286 33 *
ohair@286 34 * <p>
ohair@286 35 * Some producer of infoset (in particular, such as FastInfoset,
ohair@286 36 * XOP deecoder), usees a native format that enables efficient
ohair@286 37 * treatment of binary data. For ordinary infoset consumer
ohair@286 38 * (that just uses {@link XMLStreamReader}, those binary data
ohair@286 39 * will just look like base64-encoded string, but this interface
ohair@286 40 * allows consumers of such infoset to access this raw binary data.
ohair@286 41 * Such infoset producer may choose to implement this additoinal
ohair@286 42 * interface, to expose this functionality.
ohair@286 43 *
ohair@286 44 * <p>
ohair@286 45 * Consumers that are capable of using this interface can query
ohair@286 46 * {@link XMLStreamReader} if it supports this by simply downcasting
ohair@286 47 * it to this interface like this:
ohair@286 48 *
ohair@286 49 * <pre>
ohair@286 50 * XMLStreamReader reader = ...;
ohair@286 51 * if( reader instanceof XMLStreamReaderEx ) {
ohair@286 52 * // this reader supports binary data exchange
ohair@286 53 * ...
ohair@286 54 * } else {
ohair@286 55 * // noop
ohair@286 56 * ...
ohair@286 57 * }
ohair@286 58 * </pre>
ohair@286 59 *
ohair@286 60 * <p>
ohair@286 61 * Also note that it is also allowed for the infoset producer
ohair@286 62 * to implement this interface in such a way that {@link #getPCDATA()}
ohair@286 63 * always delegate to {@link #getText()}, although it's not desirable.
ohair@286 64 *
ohair@286 65 * <p>
ohair@286 66 * This interface is a private contract between such producers
ohair@286 67 * and consumers to allow them to exchange binary data without
ohair@286 68 * converting it to base64.
ohair@286 69 *
ohair@286 70 * @see XMLStreamWriterEx
ohair@286 71 * @author Kohsuke Kawaguchi
ohair@286 72 * @author Paul Sandoz
ohair@286 73 */
ohair@286 74 public interface XMLStreamReaderEx extends XMLStreamReader {
ohair@286 75 ///**
ohair@286 76 // * Works like {@link XMLStreamReader#getText()}
ohair@286 77 // * but returns text as {@link DataSource}.
ohair@286 78 // *
ohair@286 79 // * <p>
ohair@286 80 // * This method can be invoked whenever {@link XMLStreamReader#getText()}
ohair@286 81 // * can be invoked. Invoking this method means the caller is assuming
ohair@286 82 // * that the text is (conceptually) base64-encoded binary data.
ohair@286 83 // *
ohair@286 84 // * <p>
ohair@286 85 // * This abstraction is necessary to treat XOP as infoset encoding.
ohair@286 86 // * That is, you can either access the XOP-attached binary through
ohair@286 87 // * {@link XMLStreamReader#getText()} (in which case you'll see the
ohair@286 88 // * base64 encoded string), or you can access it as a binary data
ohair@286 89 // * directly by using this method.
ohair@286 90 // *
ohair@286 91 // * <p>
ohair@286 92 // * Note that even if you are reading from non XOP-aware {@link XMLStreamReader},
ohair@286 93 // * this method must be still supported; if the reader is pointing
ohair@286 94 // * to a text, this method is responsible for decoding base64 and
ohair@286 95 // * producing a {@link DataHandler} with "application/octet-stream"
ohair@286 96 // * as the content type.
ohair@286 97 // *
ohair@286 98 // * @return
ohair@286 99 // * always non-null valid object.
ohair@286 100 // * Invocations of this method may return the same object as long
ohair@286 101 // * as the {@link XMLStreamReader#next()} method is not used,
ohair@286 102 // * but otherwise {@link DataSource} object returned from this method
ohair@286 103 // * is considered to be owned by the client, and therefore it shouldn't
ohair@286 104 // * be reused by the implementation of this method.
ohair@286 105 // *
ohair@286 106 // * <p>
ohair@286 107 // * The returned {@link DataSource} is read-only, and the caller
ohair@286 108 // * must not invoke {@link DataSource#getOutputStream()}.
ohair@286 109 // *
ohair@286 110 // * @throws IllegalStateException
ohair@286 111 // * if the parser is not pointing at characters infoset item.
ohair@286 112 // * @throws XMLStreamException
ohair@286 113 // * if the parser points to text but text is not base64-encoded text,
ohair@286 114 // * or if some other parsing error occurs (such as if the &lt;xop:Include>
ohair@286 115 // * points to a non-existing attachment.)
ohair@286 116 // *
ohair@286 117 // * <p>
ohair@286 118 // * It is also OK for this method to return successfully, only to fail
ohair@286 119 // * during an {@link InputStream} is read from {@link DataSource}.
ohair@286 120 // */
ohair@286 121 //DataSource getTextAsDataHandler() throws XMLStreamException;
ohair@286 122
ohair@286 123 ///**
ohair@286 124 // * Works like {@link XMLStreamReader#getText()}
ohair@286 125 // * but returns text as {@link byte[]}.
ohair@286 126 // *
ohair@286 127 // * <p>
ohair@286 128 // * The contract of this method is mostly the same as
ohair@286 129 // * {@link #getTextAsDataHandler()}, except that this
ohair@286 130 // * method returns the binary datas as an exact-size byte[].
ohair@286 131 // *
ohair@286 132 // * <p>
ohair@286 133 // * This method is also not capable of reporting the content type
ohair@286 134 // * of this binary data, even if it is available to the parser.
ohair@286 135 // *
ohair@286 136 // * @see #getTextAsDataHandler()
ohair@286 137 // */
ohair@286 138 //byte[] getTextAsByteArray() throws XMLStreamException;
ohair@286 139
ohair@286 140 /**
ohair@286 141 * Works like {@link #getText()}
ohair@286 142 * but hides the actual data representation.
ohair@286 143 *
ohair@286 144 * @return
ohair@286 145 * The {@link CharSequence} that represents the
ohair@286 146 * character infoset items at the current position.
ohair@286 147 *
ohair@286 148 * <p>
ohair@286 149 * The {@link CharSequence} is normally a {@link String},
ohair@286 150 * but can be any other {@link CharSequence} implementation.
ohair@286 151 * For binary data, however, use of {@link Base64Data} is
ohair@286 152 * recommended (so that the consumer interested in seeing it
ohair@286 153 * as binary data may take advantage of mor efficient
ohair@286 154 * data representation.)
ohair@286 155 *
ohair@286 156 * <p>
ohair@286 157 * The object returned from this method belongs to the parser,
ohair@286 158 * and its content is guaranteed to be the same only until
ohair@286 159 * the {@link #next()} method is invoked.
ohair@286 160 *
ohair@286 161 * @throws IllegalStateException
ohair@286 162 * if the parser is not pointing at characters infoset item.
ohair@286 163 *
ohair@286 164 * TODO:
ohair@286 165 * fix the dependency to JAXB internal class.
ohair@286 166 */
ohair@286 167 CharSequence getPCDATA() throws XMLStreamException;
ohair@286 168
ohair@286 169 /**
ohair@286 170 * {@inheritDoc}
ohair@286 171 */
ohair@286 172 NamespaceContextEx getNamespaceContext();
ohair@286 173
ohair@286 174 /**
ohair@286 175 * Works like {@link #getElementText()} but trims the leading
ohair@286 176 * and trailing whitespace.
ohair@286 177 *
ohair@286 178 * <p>
ohair@286 179 * The parser can often do this more efficiently than
ohair@286 180 * {@code getElementText().trim()}.
ohair@286 181 *
ohair@286 182 * @see #getElementText()
ohair@286 183 */
ohair@286 184 String getElementTextTrim() throws XMLStreamException;
ohair@286 185 }

mercurial