/* * Copyright (c) 1997, 2013, Oracle and/or its affiliates. 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. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package com.sun.xml.internal.ws.encoding; import java.util.List; import org.xml.sax.helpers.AttributesImpl; import org.xml.sax.ContentHandler; import org.xml.sax.SAXException; import javax.xml.stream.XMLStreamReader; import javax.xml.stream.XMLStreamWriter; import javax.xml.stream.XMLStreamException; import com.sun.xml.internal.ws.message.stream.StreamMessage; import com.sun.xml.internal.ws.encoding.StreamSOAPCodec; import com.sun.istack.internal.Nullable; import com.sun.istack.internal.NotNull; /** * Complete infoset about a start tag. * *
* This is used between {@link StreamMessage} and {@link StreamSOAPCodec} * to capture the infoset of the s:Envelope, s:Header, and s:Body elements. * * *
* Since StAX and SAX uses different null vs empty string convention, one has
* to choose which format we store things. It can go either way, but I'm assuming
* that we'll be using StAX more in JAX-WS, so things are kept in the StAX style
* in this class.
*
* @author Kohsuke Kawaguchi
*/
public final class TagInfoset {
/**
* Namespace declarations on this tag. Read-only.
*
* This is an array of the even length of the form { prefix0, uri0, prefix1, uri1, ... }.
*
* URIs/prefixes can be null (StAX-style)
*/
public final @NotNull String[] ns;
/**
* Attributes on this tag. Read-only.
*/
public final @NotNull AttributesImpl atts;
/**
* Prefix of the start tag in stax-style.
*/
public final @Nullable String prefix;
/**
* Namespace URI of the start tag in stax-style.
*/
public final @Nullable String nsUri;
/**
* Local name of the start tag.
*/
public final @NotNull String localName;
/**
* Lazily computed QName (i.e., "foo:bar")
*/
private @Nullable String qname;
public TagInfoset(String nsUri, String localName, String prefix, AttributesImpl atts, String... ns) {
this.nsUri = nsUri;
this.prefix = prefix;
this.localName = localName;
this.atts = atts;
this.ns = ns;
}
/**
* Fills a {@link TagInfoset} object by the current element
* that the reader points to.
*/
public TagInfoset(XMLStreamReader reader) {
prefix = reader.getPrefix();
nsUri = reader.getNamespaceURI();
localName = reader.getLocalName();
int nsc = reader.getNamespaceCount();
if(nsc>0) {
ns = new String[nsc*2];
for(int i=0; i