src/share/jaxws_classes/com/sun/xml/internal/ws/wsdl/parser/ParserUtil.java

Tue, 09 Apr 2013 14:51:13 +0100

author
alanb
date
Tue, 09 Apr 2013 14:51:13 +0100
changeset 368
0989ad8c0860
parent 286
f50545b5e2f1
child 637
9c07ef4934dd
permissions
-rw-r--r--

8010393: Update JAX-WS RI to 2.2.9-b12941
Reviewed-by: alanb, erikj
Contributed-by: miroslav.kos@oracle.com, martin.grebac@oracle.com

     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  */
    26 package com.sun.xml.internal.ws.wsdl.parser;
    29 import com.sun.xml.internal.ws.streaming.Attributes;
    30 import com.sun.xml.internal.ws.streaming.XMLReaderException;
    31 import com.sun.xml.internal.ws.util.xml.XmlUtil;
    32 import com.sun.istack.internal.NotNull;
    33 import com.sun.istack.internal.Nullable;
    36 import java.io.File;
    37 import java.net.MalformedURLException;
    38 import java.net.URL;
    39 import javax.xml.namespace.QName;
    40 import javax.xml.stream.XMLStreamReader;
    43 /**
    44  *
    45  * TODO: made public just for now
    46  * @author WS Development Team
    47  */
    48 public class ParserUtil {
    49     public static String getAttribute(XMLStreamReader reader, String name) {
    50         return reader.getAttributeValue(null, name);
    51     }
    53     public static String getAttribute(XMLStreamReader reader, String nsUri, String name) {
    54         return reader.getAttributeValue(nsUri, name);
    55     }
    57     public static String getAttribute(XMLStreamReader reader, QName name) {
    58         return reader.getAttributeValue(name.getNamespaceURI(), name.getLocalPart());
    59     }
    61     public static QName getQName(XMLStreamReader reader, String tag){
    62         String localName = XmlUtil.getLocalPart(tag);
    63         String pfix = XmlUtil.getPrefix(tag);
    64         String uri = reader.getNamespaceURI(fixNull(pfix));
    65         return new QName(uri, localName);
    66     }
    68     public static String getMandatoryNonEmptyAttribute(XMLStreamReader reader,
    69         String name) {
    70 //        String value = getAttribute(reader, name);
    71         String value = reader.getAttributeValue(null, name);
    73         if (value == null) {
    74             failWithLocalName("client.missing.attribute", reader, name);
    75         } else if (value.equals("")) {
    76             failWithLocalName("client.invalidAttributeValue", reader, name);
    77         }
    79         return value;
    80     }
    82     public static void failWithFullName(String key, XMLStreamReader reader) {
    83 //        throw new WebServicesClientException(key,
    84 //        new Object[]{
    85 //          Integer.toString(reader.getLineNumber()),
    86 //          reader.getName().toString()});
    87     }
    89     public static void failWithLocalName(String key, XMLStreamReader reader) {
    90         //throw new WebServicesClientException(key,
    91         //        new Object[]{
    92         //           Integer.toString(reader.getLineNumber()),
    93         //          reader.getLocalName()});
    94     }
    96     public static void failWithLocalName(String key, XMLStreamReader reader,
    97         String arg) {
    98         //throw new WebServicesClientException(key,
    99         //      new Object[]{
   100         //          Integer.toString(reader.getLineNumber()),
   101         //          reader.getLocalName(),
   102         //          arg});
   103     }
   105     private static @NotNull String fixNull(@Nullable String s) {
   106         if (s == null) return "";
   107         else return s;
   108     }
   109 }

mercurial