src/share/jaxws_classes/com/sun/xml/internal/ws/encoding/TagInfoset.java

Print this page


   1 /*
   2  * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.xml.internal.ws.encoding;
  27 


  28 import org.xml.sax.helpers.AttributesImpl;
  29 import org.xml.sax.ContentHandler;
  30 import org.xml.sax.SAXException;
  31 
  32 import javax.xml.stream.XMLStreamReader;
  33 import javax.xml.stream.XMLStreamWriter;
  34 import javax.xml.stream.XMLStreamException;
  35 
  36 import com.sun.xml.internal.ws.message.stream.StreamMessage;
  37 import com.sun.xml.internal.ws.encoding.StreamSOAPCodec;
  38 import com.sun.istack.internal.Nullable;
  39 import com.sun.istack.internal.NotNull;
  40 
  41 /**
  42  * Complete infoset about a start tag.
  43  *
  44  * <p>
  45  * This is used between {@link StreamMessage} and {@link StreamSOAPCodec}
  46  * to capture the infoset of the s:Envelope, s:Header, and s:Body elements.
  47  *


 204         if(qname!=null) return qname;
 205 
 206         StringBuilder sb = new StringBuilder();
 207         if(prefix!=null){
 208             sb.append(prefix);
 209             sb.append(':');
 210             sb.append(localName);
 211             qname = sb.toString();
 212         } else {
 213             qname = localName;
 214         }
 215         return qname;
 216     }
 217     private static String fixNull(String s) {
 218         if(s==null) return "";
 219         else        return s;
 220     }
 221 
 222     private static final String[] EMPTY_ARRAY = new String[0];
 223     private static final AttributesImpl EMPTY_ATTRIBUTES = new AttributesImpl();































 224 }
   1 /*
   2  * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.xml.internal.ws.encoding;
  27 
  28 import java.util.List;
  29 
  30 import org.xml.sax.helpers.AttributesImpl;
  31 import org.xml.sax.ContentHandler;
  32 import org.xml.sax.SAXException;
  33 
  34 import javax.xml.stream.XMLStreamReader;
  35 import javax.xml.stream.XMLStreamWriter;
  36 import javax.xml.stream.XMLStreamException;
  37 
  38 import com.sun.xml.internal.ws.message.stream.StreamMessage;
  39 import com.sun.xml.internal.ws.encoding.StreamSOAPCodec;
  40 import com.sun.istack.internal.Nullable;
  41 import com.sun.istack.internal.NotNull;
  42 
  43 /**
  44  * Complete infoset about a start tag.
  45  *
  46  * <p>
  47  * This is used between {@link StreamMessage} and {@link StreamSOAPCodec}
  48  * to capture the infoset of the s:Envelope, s:Header, and s:Body elements.
  49  *


 206         if(qname!=null) return qname;
 207 
 208         StringBuilder sb = new StringBuilder();
 209         if(prefix!=null){
 210             sb.append(prefix);
 211             sb.append(':');
 212             sb.append(localName);
 213             qname = sb.toString();
 214         } else {
 215             qname = localName;
 216         }
 217         return qname;
 218     }
 219     private static String fixNull(String s) {
 220         if(s==null) return "";
 221         else        return s;
 222     }
 223 
 224     private static final String[] EMPTY_ARRAY = new String[0];
 225     private static final AttributesImpl EMPTY_ATTRIBUTES = new AttributesImpl();
 226 
 227     public String getNamespaceURI(String prefix) {
 228         int size = ns.length/2;
 229         for(int i=0; i<size; i++){
 230             String p = ns[i*2  ];
 231             String n = ns[i*2+1];
 232             if (prefix.equals(p)) return n;
 233         }
 234         return null;
 235     }
 236 
 237     public String getPrefix(String namespaceURI) {
 238         int size = ns.length/2;
 239         for(int i=0; i<size; i++){
 240             String p = ns[i*2  ];
 241             String n = ns[i*2+1];
 242             if (namespaceURI.equals(n)) return p;
 243         }
 244         return null;
 245     }
 246     //Who wants this?
 247     public List<String> allPrefixes(String namespaceURI) {
 248         int size = ns.length/2;
 249         List<String> l = new java.util.ArrayList<String>();
 250         for(int i=0; i<size; i++){
 251             String p = ns[i*2  ];
 252             String n = ns[i*2+1];
 253             if (namespaceURI.equals(n)) l.add(p);
 254         }
 255         return l;
 256     }
 257 }