Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #315 switched sql parser to use a UTF-8 input stream which also handles mu... #316

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/com/activeandroid/util/SqlParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
*/

import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

Expand All @@ -34,11 +36,13 @@ public class SqlParser {
public static List<String> parse(final InputStream stream) throws IOException {

final BufferedInputStream buffer = new BufferedInputStream(stream);
final BufferedReader reader = new BufferedReader(new InputStreamReader(stream, "UTF-8"));
final List<String> commands = new ArrayList<String>();

final StringBuffer sb = new StringBuffer();

try {
final Tokenizer tokenizer = new Tokenizer(buffer);
final Tokenizer tokenizer = new Tokenizer(reader);
int state = STATE_NONE;

while (tokenizer.hasNext()) {
Expand Down Expand Up @@ -100,11 +104,11 @@ public static List<String> parse(final InputStream stream) throws IOException {
return commands;
}

private static boolean isNewLine(final char c) {
private static boolean isNewLine(final int c) {
return c == '\r' || c == '\n';
}

private static boolean isWhitespace(final char c) {
private static boolean isWhitespace(final int c) {
return c == '\r' || c == '\n' || c == '\t' || c == ' ';
}
}
5 changes: 3 additions & 2 deletions src/com/activeandroid/util/Tokenizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,17 @@

import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;


public class Tokenizer {

private final InputStream mStream;
private final Reader mStream;

private boolean mIsNext;
private int mCurrent;

public Tokenizer(final InputStream in) {
public Tokenizer(final Reader in) {
this.mStream = in;
}

Expand Down