1
0
mirror of https://github.com/twiglet/cs2j.git synced 2025-01-18 13:15:17 +01:00

Adapt translations to new EncodingSupport wrapper class

- Encoding is now a wrapper class, not translated directly to coding string
This commit is contained in:
Kevin Glynn 2010-06-07 12:04:23 -05:00
parent e1729486cc
commit 0a5d22e8dd
3 changed files with 10 additions and 3 deletions

View File

@ -67,9 +67,10 @@
</Params>
<Imports>
<Import>RusticiSoftware.System.IO.StreamReader</Import>
<Import>RusticiSoftware.System.Text.EncodingSupport</Import>
<Import>java.io.*</Import>
</Imports>
<Java>new BufferedReader(StreamReader.make(new BufferedInputStream(${stream}), "UTF-8"))</Java>
<Java>new BufferedReader(StreamReader.make(new BufferedInputStream(${stream}), new EncodingSupport("UTF-8")))</Java>
</Constructor>
</Constructors>
<Methods>

View File

@ -23,6 +23,8 @@ package RusticiSoftware.System.IO;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import RusticiSoftware.System.Text.EncodingSupport;
public class StreamReader {
@ -91,13 +93,13 @@ public class StreamReader {
return retISR;
}
public static InputStreamReader make(InputStream is, String cs) throws IOException
public static InputStreamReader make(InputStream is, EncodingSupport cs) throws IOException
{
String enc = getEncoding(is);
if (enc != null)
return new InputStreamReader(is, enc);
else
return new InputStreamReader(is, cs);
return new InputStreamReader(is, cs.getString());
}
}

View File

@ -12,4 +12,8 @@ public class EncodingSupport {
public byte[] getBytes(String input) throws UnsupportedEncodingException {
return input.getBytes(coding);
}
public String getString() {
return coding;
}
}