Skip to content

Commit b8ae1fa

Browse files
committed
more cleanup
1 parent 6262275 commit b8ae1fa

File tree

2 files changed

+8
-23
lines changed

2 files changed

+8
-23
lines changed

src/main/java/com/gargoylesoftware/css/parser/InputSource.java

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,7 @@
1616

1717
import java.io.Closeable;
1818
import java.io.IOException;
19-
import java.io.InputStream;
20-
import java.io.InputStreamReader;
2119
import java.io.Reader;
22-
import java.io.UnsupportedEncodingException;
23-
import java.nio.charset.Charset;
2420

2521
/**
2622
* The input supported by the parser.
@@ -33,21 +29,6 @@ public class InputSource implements Closeable {
3329
private String media_;
3430
private String title_;
3531

36-
/**
37-
* Create a new input source backed by byteStream.
38-
* @param byteStream the byte stream
39-
* @param encoding the encoding
40-
* @throws UnsupportedEncodingException if the encoding is not supported
41-
*/
42-
public InputSource(final InputStream byteStream, final String encoding) throws UnsupportedEncodingException {
43-
if (encoding == null || encoding.length() < 1) {
44-
reader_ = new InputStreamReader(byteStream, Charset.defaultCharset());
45-
}
46-
else {
47-
reader_ = new InputStreamReader(byteStream, encoding);
48-
}
49-
}
50-
5132
/**
5233
* Create a new input source backed by a reader.
5334
* @param reader the reader

src/test/java/com/gargoylesoftware/css/parser/CSS3ParserTest.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
import java.io.IOException;
1919
import java.io.InputStream;
2020
import java.io.InputStreamReader;
21+
import java.io.Reader;
2122
import java.io.StringReader;
23+
import java.nio.charset.Charset;
2224
import java.util.Set;
2325
import java.util.TreeSet;
2426

@@ -3407,7 +3409,8 @@ private void realWorld(final String resourceName, final int rules, final int pro
34073409
public void unicodeInputByteStream() throws Exception {
34083410
final String css = "h1:before { content: \"\u04c5 - \u0666\" }";
34093411

3410-
final InputSource source = new InputSource(new ByteArrayInputStream(css.getBytes("UTF-8")), "UTF-8");
3412+
final Reader reader = new InputStreamReader(new ByteArrayInputStream(css.getBytes("UTF-8")), "UTF-8");
3413+
final InputSource source = new InputSource(reader);
34113414
final CSSStyleSheetImpl sheet = parse(source, 0, 0, 0);
34123415

34133416
Assert.assertEquals(css, sheet.toString());
@@ -3422,8 +3425,8 @@ public void unicodeInputByteStream() throws Exception {
34223425
public void unicodeInputByteStreamDefaultEncoding() throws Exception {
34233426
final String css = "h1:before { content: \"\u00fe - \u00e4\" }";
34243427

3425-
final InputSource source = new InputSource(new ByteArrayInputStream(css.getBytes()), null);
3426-
3428+
final Reader reader = new InputStreamReader(new ByteArrayInputStream(css.getBytes()), Charset.defaultCharset());
3429+
final InputSource source = new InputSource(reader);
34273430
final CSSStyleSheetImpl sheet = parse(source, 0, 0, 0);
34283431

34293432
Assert.assertEquals(css, sheet.toString());
@@ -3436,7 +3439,8 @@ public void unicodeInputByteStreamDefaultEncoding() throws Exception {
34363439
public void clip() throws Exception {
34373440
final String css = "h1 { clip: rect(0px 0px 1px 1px); }";
34383441

3439-
final InputSource source = new InputSource(new ByteArrayInputStream(css.getBytes()), null);
3442+
final Reader reader = new InputStreamReader(new ByteArrayInputStream(css.getBytes()), Charset.defaultCharset());
3443+
final InputSource source = new InputSource(reader);
34403444
final CSSStyleSheetImpl sheet = parse(source, 0, 0, 0);
34413445

34423446
Assert.assertEquals("h1 { clip: rect(0px, 0px, 1px, 1px) }", sheet.toString());

0 commit comments

Comments
 (0)