src/share/jaxws_classes/com/sun/xml/internal/ws/commons/xmlutil/Converter.java

Print this page




  64      */
  65     public static String toString(Throwable throwable) {
  66         if (throwable == null) {
  67             return "[ No exception ]";
  68         }
  69 
  70         StringWriter stringOut = new StringWriter();
  71         throwable.printStackTrace(new PrintWriter(stringOut));
  72 
  73         return stringOut.toString();
  74     }
  75 
  76     public static String toString(Packet packet) {
  77         if (packet == null) {
  78             return "[ Null packet ]";
  79         } else if (packet.getMessage() == null) {
  80                 return "[ Empty packet ]";
  81         }
  82 
  83         return toString(packet.getMessage());








  84 

  85     }
  86 
  87     public static String toString(Message message) {








  88         if (message == null) {
  89             return "[ Null message ]";
  90         }
  91         StringWriter stringOut = null;
  92         try {
  93             stringOut = new StringWriter();
  94             XMLStreamWriter writer = null;
  95             try {
  96                 writer = xmlOutputFactory.createXMLStreamWriter(stringOut);

  97                 writer = createIndenter(writer);

  98                 message.copy().writeTo(writer);
  99             } catch (Exception e) { // WSIT-1596 - Message Dumping should not affect other processing
 100                 LOGGER.log(Level.WARNING, "Unexpected exception occured while dumping message", e);
 101             } finally {
 102                 if (writer != null) {
 103                     try {
 104                         writer.close();
 105                     } catch (XMLStreamException ignored) {
 106                         LOGGER.fine("Unexpected exception occured while closing XMLStreamWriter", ignored);
 107                     }
 108                 }
 109             }
 110             return stringOut.toString();
 111         } finally {
 112             if (stringOut != null) {
 113                 try {
 114                     stringOut.close();
 115                 } catch (IOException ex) {
 116                     LOGGER.finest("An exception occured when trying to close StringWriter", ex);
 117                 }




  64      */
  65     public static String toString(Throwable throwable) {
  66         if (throwable == null) {
  67             return "[ No exception ]";
  68         }
  69 
  70         StringWriter stringOut = new StringWriter();
  71         throwable.printStackTrace(new PrintWriter(stringOut));
  72 
  73         return stringOut.toString();
  74     }
  75 
  76     public static String toString(Packet packet) {
  77         if (packet == null) {
  78             return "[ Null packet ]";
  79         } else if (packet.getMessage() == null) {
  80                 return "[ Empty packet ]";
  81         }
  82 
  83         return toString(packet.getMessage());
  84     }
  85 
  86     public static String toStringNoIndent(Packet packet) {
  87         if (packet == null) {
  88             return "[ Null packet ]";
  89         } else if (packet.getMessage() == null) {
  90                 return "[ Empty packet ]";
  91         }
  92 
  93         return toStringNoIndent(packet.getMessage());
  94     }
  95 
  96     public static String toString(Message message) {
  97         return toString(message, true);
  98     }
  99 
 100     public static String toStringNoIndent(Message message) {
 101         return toString(message, false);
 102     }
 103 
 104     private static String toString(Message message, boolean createIndenter) {
 105         if (message == null) {
 106             return "[ Null message ]";
 107         }
 108         StringWriter stringOut = null;
 109         try {
 110             stringOut = new StringWriter();
 111             XMLStreamWriter writer = null;
 112             try {
 113                 writer = xmlOutputFactory.createXMLStreamWriter(stringOut);
 114                 if (createIndenter) {
 115                     writer = createIndenter(writer);
 116                 }
 117                 message.copy().writeTo(writer);
 118             } catch (Exception e) { // WSIT-1596 - Message Dumping should not affect other processing
 119                 LOGGER.log(Level.WARNING, "Unexpected exception occured while dumping message", e);
 120             } finally {
 121                 if (writer != null) {
 122                     try {
 123                         writer.close();
 124                     } catch (XMLStreamException ignored) {
 125                         LOGGER.fine("Unexpected exception occured while closing XMLStreamWriter", ignored);
 126                     }
 127                 }
 128             }
 129             return stringOut.toString();
 130         } finally {
 131             if (stringOut != null) {
 132                 try {
 133                     stringOut.close();
 134                 } catch (IOException ex) {
 135                     LOGGER.finest("An exception occured when trying to close StringWriter", ex);
 136                 }