You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by kk...@apache.org on 2011/11/10 07:23:25 UTC
svn commit: r1200180 - in
/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/buf: Ascii.java
B2CConverter.java Constants.java HexUtils.java
Author: kkolinko
Date: Thu Nov 10 06:23:25 2011
New Revision: 1200180
URL: http://svn.apache.org/viewvc?rev=1200180&view=rev
Log:
Merged revision 1187753 from tomcat/trunk:
Clean-up. No functional change.
Part 6.
Modified:
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/buf/Ascii.java
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/buf/B2CConverter.java
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/buf/Constants.java
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/buf/HexUtils.java
Modified: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/buf/Ascii.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/buf/Ascii.java?rev=1200180&r1=1200179&r2=1200180&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/buf/Ascii.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/buf/Ascii.java Thu Nov 10 06:23:25 2011
@@ -14,7 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.tomcat.util.buf;
/**
@@ -197,7 +196,7 @@ public final class Ascii {
long n = c - '0';
long m;
-
+
while (--len > 0) {
if (!isDigit(c = b[off++])) {
throw new NumberFormatException();
Modified: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/buf/B2CConverter.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/buf/B2CConverter.java?rev=1200180&r1=1200179&r2=1200180&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/buf/B2CConverter.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/buf/B2CConverter.java Thu Nov 10 06:23:25 2011
@@ -14,8 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-
package org.apache.tomcat.util.buf;
import java.io.IOException;
@@ -30,7 +28,7 @@ import java.util.Map;
import org.apache.tomcat.util.res.StringManager;
/** Efficient conversion of bytes to character .
- *
+ *
* This uses the standard JDK mechanism - a reader - but provides mechanisms
* to recycle all the objects that are used. It is compatible with JDK1.1
* and up,
@@ -41,11 +39,11 @@ import org.apache.tomcat.util.res.String
* be used in a later version or after the remaining optimizations.
*/
public class B2CConverter {
-
-
+
+
private static final org.apache.juli.logging.Log log=
org.apache.juli.logging.LogFactory.getLog( B2CConverter.class );
-
+
private static final StringManager sm =
StringManager.getManager(Constants.Package);
@@ -70,7 +68,7 @@ public class B2CConverter {
String lowerCaseEnc = enc.toLowerCase(Locale.US);
Charset charset = encodingToCharsetCache.get(lowerCaseEnc);
-
+
if (charset == null) {
// Pre-population of the cache means this must be invalid
throw new UnsupportedEncodingException(
@@ -78,14 +76,14 @@ public class B2CConverter {
}
return charset;
}
-
+
private IntermediateInputStream iis;
private ReadConvertor conv;
private String encoding;
protected B2CConverter() {
}
-
+
/** Create a converter, with bytes going to a byte buffer
*/
public B2CConverter(String encoding)
@@ -95,7 +93,7 @@ public class B2CConverter {
reset();
}
-
+
/** Reset the internal state, empty the buffers.
* The encoding remain in effect, the internal buffers remain allocated.
*/
@@ -127,19 +125,22 @@ public class B2CConverter {
int cnt=conv.read( result, 0, size );
if( cnt <= 0 ) {
// End of stream ! - we may be in a bad state
- if(log.isDebugEnabled())
+ if(log.isDebugEnabled()) {
log.debug("B2CConverter: EOF");
+ }
return;
}
- if(log.isDebugEnabled())
+ if(log.isDebugEnabled()) {
log.debug("B2CConverter: Converted: " +
new String(result, 0, cnt));
+ }
cb.append( result, 0, cnt );
limit = limit - (bbLengthBeforeRead - bb.getLength());
}
} catch( IOException ex) {
- if(log.isDebugEnabled())
+ if(log.isDebugEnabled()) {
log.debug("B2CConverter: Reseting the converter " + ex.toString());
+ }
reset();
throw ex;
}
@@ -161,16 +162,16 @@ public class B2CConverter {
/**
- *
+ *
*/
final class ReadConvertor extends InputStreamReader {
-
+
/** Create a converter.
*/
public ReadConvertor(IntermediateInputStream in, Charset charset) {
super(in, charset);
}
-
+
/** Overridden - will do nothing but reset internal state.
*/
@Override
@@ -178,7 +179,7 @@ final class ReadConvertor extends Input
// NOTHING
// Calling super.close() would reset out and cb.
}
-
+
@Override
public final int read(char cbuf[], int off, int len)
throws IOException
@@ -186,7 +187,7 @@ final class ReadConvertor extends Input
// will do the conversion and call write on the output stream
return super.read( cbuf, off, len );
}
-
+
/** Reset the buffer
*/
public final void recycle() {
@@ -204,27 +205,27 @@ final class ReadConvertor extends Input
/** Special output stream where close() is overridden, so super.close()
is never called.
-
+
This allows recycling. It can also be disabled, so callbacks will
not be called if recycling the converter and if data was not flushed.
*/
final class IntermediateInputStream extends InputStream {
ByteChunk bc = null;
-
+
public IntermediateInputStream() {
}
-
+
@Override
public final void close() throws IOException {
// shouldn't be called - we filter it out in writer
throw new IOException("close() called - shouldn't happen ");
}
-
+
@Override
public final int read(byte cbuf[], int off, int len) throws IOException {
return bc.substract(cbuf, off, len);
}
-
+
@Override
public final int read() throws IOException {
return bc.substract();
Modified: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/buf/Constants.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/buf/Constants.java?rev=1200180&r1=1200179&r2=1200180&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/buf/Constants.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/buf/Constants.java Thu Nov 10 06:23:25 2011
@@ -5,16 +5,15 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.tomcat.util.buf;
/**
Modified: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/buf/HexUtils.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/buf/HexUtils.java?rev=1200180&r1=1200179&r2=1200180&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/buf/HexUtils.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/buf/HexUtils.java Thu Nov 10 06:23:25 2011
@@ -14,7 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.tomcat.util.buf;
/**
@@ -57,9 +56,9 @@ public final class HexUtils {
/**
* Table for DEC to HEX byte translation.
*/
- private static final byte[] HEX =
- { (byte) '0', (byte) '1', (byte) '2', (byte) '3', (byte) '4', (byte) '5',
- (byte) '6', (byte) '7', (byte) '8', (byte) '9', (byte) 'a', (byte) 'b',
+ private static final byte[] HEX =
+ { (byte) '0', (byte) '1', (byte) '2', (byte) '3', (byte) '4', (byte) '5',
+ (byte) '6', (byte) '7', (byte) '8', (byte) '9', (byte) 'a', (byte) 'b',
(byte) 'c', (byte) 'd', (byte) 'e', (byte) 'f' };
@@ -72,7 +71,7 @@ public final class HexUtils {
/**
- * Provide a mechanism for ensuring this class is loaded.
+ * Provide a mechanism for ensuring this class is loaded.
*/
public static void load() {
// Nothing to do
@@ -88,14 +87,17 @@ public final class HexUtils {
public static String toHexString(byte[] bytes)
{
- if(null == bytes) return null;
+ if(null == bytes) {
+ return null;
+ }
StringBuilder sb = new StringBuilder(bytes.length << 1);
- for(int i=0; i<bytes.length; ++i)
+ for(int i=0; i<bytes.length; ++i) {
sb.append(hex[(bytes[i] & 0xf0) >> 4])
.append(hex[(bytes[i] & 0x0f)])
;
+ }
return sb.toString();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org