You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by iv...@apache.org on 2009/09/29 18:26:41 UTC
svn commit: r820016 -
/wicket/trunk/wicket/src/main/java/org/apache/wicket/resource/PropertiesFactory.java
Author: ivaynberg
Date: Tue Sep 29 16:26:40 2009
New Revision: 820016
URL: http://svn.apache.org/viewvc?rev=820016&view=rev
Log:
WICKET-2451 unroll magic UTF8 handling because it broke backwards compat with existing 8859 files
Issue: WICKET-2451
Modified:
wicket/trunk/wicket/src/main/java/org/apache/wicket/resource/PropertiesFactory.java
Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/resource/PropertiesFactory.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/resource/PropertiesFactory.java?rev=820016&r1=820015&r2=820016&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/resource/PropertiesFactory.java (original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/resource/PropertiesFactory.java Tue Sep 29 16:26:40 2009
@@ -17,11 +17,7 @@
package org.apache.wicket.resource;
import java.io.BufferedInputStream;
-import java.io.ByteArrayInputStream;
import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Iterator;
@@ -317,26 +313,11 @@
*/
public class PropertiesFilePropertiesLoader extends AbstractPropertiesLoader
{
- /** Can the JDK read properties from Reader ? */
- private boolean loadFromReaderAvailable = false;
-
- /**
- * Buffer size used when reading a properties file.
- */
- private static final int BUFFER_SIZE = 2000;
-
/**
* Construct.
*/
public PropertiesFilePropertiesLoader()
{
- try {
- Properties.class.getMethod("load", new Class[] {Reader.class});
- loadFromReaderAvailable = true;
- }
- catch (NoSuchMethodException ex) {
- loadFromReaderAvailable = false;
- }
}
/**
@@ -359,53 +340,9 @@
protected java.util.Properties loadProperties(BufferedInputStream in) throws IOException
{
java.util.Properties properties = new java.util.Properties();
- // If we are on JDK 6 we load from Reader
- if (loadFromReaderAvailable) {
properties.load(in);
- // If we are on JDK <=5 then we convert to ASCII
- } else {
- properties.load(readUTFStreamToEscapedASCII(in));
- }
return properties;
}
-
- /**
- * Reads a UTF-8 stream, performing a conversion to ASCII (i.e., ISO8859-1 encoding). Characters outside the normal
- * range for ISO8859-1 are converted to unicode escapes. In effect, Tapestry is performing native2ascii on the
- * files, on the fly.
- */
- private InputStream readUTFStreamToEscapedASCII(InputStream is) throws IOException
- {
- Reader reader = new InputStreamReader(is, "UTF-8");
-
- StringBuilder builder = new StringBuilder(BUFFER_SIZE);
- char[] buffer = new char[BUFFER_SIZE];
-
- while (true)
- {
- int length = reader.read(buffer);
-
- if (length < 0) break;
-
- for (int i = 0; i < length; i++)
- {
- char ch = buffer[i];
-
- if (ch <= '\u007f')
- {
- builder.append(ch);
- continue;
- }
- builder.append(String.format("\\u%04x", (int) ch));
- }
- }
-
- reader.close();
-
- byte[] resourceContent = builder.toString().getBytes();
- return new ByteArrayInputStream(resourceContent);
- }
-
}
/**