You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by to...@apache.org on 2005/02/17 09:54:24 UTC
cvs commit: ws-axis/java/src/org/apache/axis/utils StringUtils.java tcpmon.java tcpmon.properties
toshi 2005/02/17 00:54:24
Modified: java/src/org/apache/axis/utils StringUtils.java tcpmon.java
tcpmon.properties
Log:
Fixing AXIS-1815 - http://issues.apache.org/jira/browse/AXIS-1815.
Please test with the nightly build at:
<http://cvs.apache.org/dist/axis/nightly/axis-bin-1_2RC3.zip>
Now, you should be able to see any mulit-byte characters if you
have enough font sets on your system. Otherwise you can check the
codes as a set of hexadecimal numeric character refernces such as
'水' by just turning on the 'Numeric' check box on the GUI.
Thanks,
Toshi
Revision Changes Path
1.10 +46 -0 ws-axis/java/src/org/apache/axis/utils/StringUtils.java
Index: StringUtils.java
===================================================================
RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/utils/StringUtils.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- StringUtils.java 15 Feb 2005 10:15:43 -0000 1.9
+++ StringUtils.java 17 Feb 2005 08:54:23 -0000 1.10
@@ -312,6 +312,52 @@
}
/**
+ * write the escaped version of a given string
+ *
+ * @param str string to be encoded
+ * @return a new escaped <code>String</code>, <code>null</code> if null string input
+ */
+ public static String escapeNumericChar(String str) {
+ if (str == null) {
+ return null;
+ }
+ try {
+ StringWriter writer = new StringWriter(str.length());
+ escapeNumericChar(writer, str);
+ return writer.toString();
+ } catch (IOException ioe) {
+ // this should never ever happen while writing to a StringWriter
+ ioe.printStackTrace();
+ return null;
+ }
+ }
+
+ /**
+ * write the escaped version of a given string
+ *
+ * @param out writer to write this string to
+ * @param str string to be encoded
+ */
+ public static void escapeNumericChar(Writer out, String str)
+ throws IOException {
+ if (str == null) {
+ return;
+ }
+ int length = str.length();
+ char character;
+ for (int i = 0; i < length; i++) {
+ character = str.charAt( i );
+ if (character > 0x7F) {
+ out.write("&#x");
+ out.write(Integer.toHexString(character).toUpperCase());
+ out.write(";");
+ } else {
+ out.write(character);
+ }
+ }
+ }
+
+ /**
* <p>Unescapes numeric character referencs found in the <code>String</code>.</p>
*
* <p>For example, it will return a unicode string which means the specified numeric
1.58 +21 -6 ws-axis/java/src/org/apache/axis/utils/tcpmon.java
Index: tcpmon.java
===================================================================
RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/utils/tcpmon.java,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -r1.57 -r1.58
--- tcpmon.java 15 Mar 2004 13:08:17 -0000 1.57
+++ tcpmon.java 17 Feb 2005 08:54:23 -0000 1.58
@@ -583,6 +583,7 @@
InputStream in = null ;
OutputStream out = null ;
boolean xmlFormat ;
+ boolean numericEnc ;
volatile boolean done = false ;
TableModel tmodel = null ;
int tableIndex = 0 ;
@@ -592,7 +593,7 @@
public SocketRR(Connection c, Socket inputSocket, InputStream inputStream,
Socket outputSocket, OutputStream outputStream,
- JTextArea _textArea, boolean format,
+ JTextArea _textArea, boolean format, boolean numeric,
TableModel tModel, int index, final String type, SlowLinkSimulator slowLink) {
inSocket = inputSocket ;
in = inputStream ;
@@ -600,6 +601,7 @@
out = outputStream ;
textArea = _textArea ;
xmlFormat = format ;
+ numericEnc= numeric ;
tmodel = tModel ;
tableIndex = index ;
this.type = type;
@@ -616,6 +618,7 @@
try {
byte[] buffer = new byte[4096];
byte[] tmpbuffer = new byte[8192];
+ String message = null;
int saved = 0 ;
int len ;
int i1, i2 ;
@@ -754,8 +757,12 @@
tmpbuffer[i2++] = buffer[i1];
}
}
-
- textArea.append( new String( tmpbuffer, 0, i2 ) );
+ message = new String( tmpbuffer, 0, i2, XMLUtils.getEncoding() );
+ if (numericEnc) {
+ textArea.append( StringUtils.escapeNumericChar(message) );
+ } else {
+ textArea.append( StringUtils.unescapeNumericChar(message) );
+ }
// Shift saved bytes to the beginning
for ( i = 0 ; i < saved ; i++ ) {
@@ -763,7 +770,12 @@
}
}
else {
- textArea.append( new String( buffer, 0, len ) );
+ message = new String( buffer, 0, len, XMLUtils.getEncoding() );
+ if (numericEnc) {
+ textArea.append( StringUtils.escapeNumericChar(message) );
+ } else {
+ textArea.append( StringUtils.unescapeNumericChar(message) );
+ }
}
// this.sleep(3); // Let other threads have a chance to run
}
@@ -1123,17 +1135,18 @@
}
boolean format = listener.xmlFormatBox.isSelected();
+ boolean numeric = listener.numericBox.isSelected();
//this is the channel to the endpoint
rr1 = new SocketRR(this, inSocket, tmpIn1, outSocket,
- tmpOut2, inputText, format,
+ tmpOut2, inputText, format, numeric,
listener.tableModel, index + 1, "request:", slowLink);
//create the response slow link from the inbound slow link
SlowLinkSimulator responseLink = new SlowLinkSimulator(slowLink);
//this is the channel from the endpoint
rr2 = new SocketRR( this, outSocket, tmpIn2, inSocket,
- tmpOut1, outputText, format,
+ tmpOut1, outputText, format, numeric,
null, 0, "response:", responseLink);
while ( rr1 != null || rr2 != null ) {
@@ -1262,6 +1275,7 @@
public JButton removeButton = null ;
public JButton removeAllButton = null ;
public JCheckBox xmlFormatBox = null ;
+ public JCheckBox numericBox = null ;
public JButton saveButton = null ;
public JButton resendButton = null ;
public JButton switchButton = null ;
@@ -1513,6 +1527,7 @@
bottomButtons.setLayout( new BoxLayout(bottomButtons, BoxLayout.X_AXIS));
bottomButtons.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
bottomButtons.add( xmlFormatBox = new JCheckBox( getMessage("xmlFormat00", "XML Format") ) );
+ bottomButtons.add( numericBox = new JCheckBox( getMessage("numericEnc00", "Numeric" ) ) );
bottomButtons.add( Box.createRigidArea(new Dimension(5, 0)) );
final String save = getMessage("save00", "Save");
1.6 +1 -0 ws-axis/java/src/org/apache/axis/utils/tcpmon.properties
Index: tcpmon.properties
===================================================================
RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/utils/tcpmon.properties,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- tcpmon.properties 25 Jan 2003 19:12:54 -0000 1.5
+++ tcpmon.properties 17 Feb 2005 08:54:23 -0000 1.6
@@ -51,6 +51,7 @@
# NOTE: in xmlFormat00, do not translate "XML"
xmlFormat00=XML Format
+numericEnc00=Numeric
#NOTE: this is a SimpleDateFormat format string to declare the layout of date
#and time in the message log. It does need i18n, but not 'translation', per se.