src/share/jaxws_classes/com/sun/xml/internal/ws/message/source/SourceUtils.java

changeset 368
0989ad8c0860
parent 286
f50545b5e2f1
child 637
9c07ef4934dd
     1.1 --- a/src/share/jaxws_classes/com/sun/xml/internal/ws/message/source/SourceUtils.java	Thu Apr 04 19:05:24 2013 -0700
     1.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/message/source/SourceUtils.java	Tue Apr 09 14:51:13 2013 +0100
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -54,9 +54,9 @@
    1.11  
    1.12      int srcType;
    1.13  
    1.14 -    private final int domSource = 1;
    1.15 -    private final int streamSource = 2;
    1.16 -    private final int saxSource=4;
    1.17 +    private static final int domSource = 1;
    1.18 +    private static final int streamSource = 2;
    1.19 +    private static final int saxSource=4;
    1.20  
    1.21      public SourceUtils(Source src) {
    1.22          if(src instanceof StreamSource){
    1.23 @@ -95,8 +95,8 @@
    1.24          String namespaceUri = null;
    1.25  
    1.26          if(isDOMSource()){
    1.27 -            DOMSource domSource = (DOMSource)src;
    1.28 -            Node n = domSource.getNode();
    1.29 +            DOMSource domSrc = (DOMSource)src;
    1.30 +            Node n = domSrc.getNode();
    1.31              if(n.getNodeType()== Node.DOCUMENT_NODE) {
    1.32                  n = ((Document)n).getDocumentElement();
    1.33              }
    1.34 @@ -146,15 +146,16 @@
    1.35                              writer.writeStartElement(uri, localName);
    1.36                          }
    1.37                      } else {
    1.38 -                        assert uri != null;
    1.39 +//                        assert uri != null;
    1.40  
    1.41                          if(prefix.length() > 0){
    1.42                              /**
    1.43                               * Before we write the
    1.44                               */
    1.45                              String writerURI = null;
    1.46 -                            if (writer.getNamespaceContext() != null)
    1.47 +                            if (writer.getNamespaceContext() != null) {
    1.48                                  writerURI = writer.getNamespaceContext().getNamespaceURI(prefix);
    1.49 +                            }
    1.50                              String writerPrefix = writer.getPrefix(uri);
    1.51                              if(declarePrefix(prefix, uri, writerPrefix, writerURI)){
    1.52                                  writer.writeStartElement(prefix, localName, uri);
    1.53 @@ -172,11 +173,14 @@
    1.54                      // Write namespace declarations
    1.55                      for (int i = 0; i < n; i++) {
    1.56                          String nsPrefix = reader.getNamespacePrefix(i);
    1.57 -                        if (nsPrefix == null) nsPrefix = "";
    1.58 +                        if (nsPrefix == null) {
    1.59 +                            nsPrefix = "";
    1.60 +                        }
    1.61                          // StAX returns null for default ns
    1.62                          String writerURI = null;
    1.63 -                        if (writer.getNamespaceContext() != null)
    1.64 +                        if (writer.getNamespaceContext() != null) {
    1.65                              writerURI = writer.getNamespaceContext().getNamespaceURI(nsPrefix);
    1.66 +                        }
    1.67  
    1.68                          // Zephyr: Why is this returning null?
    1.69                          // Compare nsPrefix with prefix because of [1] (above)
    1.70 @@ -215,6 +219,9 @@
    1.71                      break;
    1.72                  case XMLStreamConstants.CHARACTERS:
    1.73                      writer.writeCharacters(reader.getText());
    1.74 +                    break;
    1.75 +                default:
    1.76 +                    break;
    1.77              }
    1.78          } while (state != XMLStreamConstants.END_DOCUMENT);
    1.79          reader.close();
    1.80 @@ -228,8 +235,9 @@
    1.81       */
    1.82      private static void setUndeclaredPrefix(String prefix, String readerURI, XMLStreamWriter writer) throws XMLStreamException {
    1.83          String writerURI = null;
    1.84 -        if (writer.getNamespaceContext() != null)
    1.85 +        if (writer.getNamespaceContext() != null) {
    1.86              writerURI = writer.getNamespaceContext().getNamespaceURI(prefix);
    1.87 +        }
    1.88  
    1.89          if (writerURI == null) {
    1.90              writer.setPrefix(prefix, readerURI != null ? readerURI : "");
    1.91 @@ -246,8 +254,9 @@
    1.92       */
    1.93      private static boolean declarePrefix(String rPrefix, String rUri, String wPrefix, String wUri){
    1.94          if (wUri == null ||((wPrefix != null) && !rPrefix.equals(wPrefix))||
    1.95 -                (rUri != null && !wUri.equals(rUri)))
    1.96 +                (rUri != null && !wUri.equals(rUri))) {
    1.97              return true;
    1.98 +        }
    1.99          return false;
   1.100      }
   1.101  }

mercurial