@GwtIncompatible private static TextBuffer wrap(final Writer writer) { return new TextBuffer() { public void append(char c) { try { writer.write(c); } catch (IOException e) { throw new WriteException(e); } } public void append(char[] chars, int off, int len) { try { writer.write(chars, off, len); } catch (IOException e) { throw new WriteException(e); } } public void append(String s) { try { writer.write(s); } catch (IOException e) { throw new WriteException(e); } } }; }
@GwtIncompatible private static TextBuffer wrap(final Writer writer) { return new TextBuffer() { public void append(char c) { try { writer.write(c); } catch (IOException e) { throw new WriteException(e); } } public void append(char[] chars, int off, int len) { try { writer.write(chars, off, len); } catch (IOException e) { throw new WriteException(e); } } public void append(String s) { try { writer.write(s); } catch (IOException e) { throw new WriteException(e); } } }; }
/** * Tokenizes a specified region by an occurrences of the pattern. * Note that a series of adjacent matches are regarded as a single separator. * The same as new RETokenizer(Pattern,Reader,int); * * @see RETokenizer * @see RETokenizer#RETokenizer(regexodus.Pattern, java.io.Reader, int) */ @GwtIncompatible public RETokenizer tokenizer(Reader in, int length) throws IOException { return new RETokenizer(this, in, length); }
/** * Tokenizes a specified region by an occurrences of the pattern. * Note that a series of adjacent matches are regarded as a single separator. * The same as new RETokenizer(Pattern,Reader,int); * * @see RETokenizer * @see RETokenizer#RETokenizer(regexodus.Pattern, java.io.Reader, int) */ @GwtIncompatible public RETokenizer tokenizer(Reader in, int length) throws IOException { return new RETokenizer(this, in, length); }
@GwtIncompatible public RETokenizer(Pattern pattern, Reader r, int len) throws IOException { this(pattern.matcher(r, len), false); }
@GwtIncompatible public RETokenizer(Pattern pattern, Reader r, int len) throws IOException { this(pattern.matcher(r, len), false); }
@GwtIncompatible public void setAll(Reader in) throws IOException { char[] mychars = data; int free; if (mychars == null || shared) { mychars = new char[free = 1024]; } else free = mychars.length; int count = 0; int c; while ((c = in.read(mychars, count, free)) >= 0) { free -= c; count += c; if (free == 0) { int newsize = count * 3; char[] newchars = new char[newsize]; System.arraycopy(mychars, 0, newchars, 0, count); mychars = newchars; free = newsize - count; } } setTarget(mychars, 0, count, false); }
@GwtIncompatible public void setAll(Reader in) throws IOException { char[] mychars = data; int free; if (mychars == null || shared) { mychars = new char[free = 1024]; } else free = mychars.length; int count = 0; int c; while ((c = in.read(mychars, count, free)) >= 0) { free -= c; count += c; if (free == 0) { int newsize = count * 3; char[] newchars = new char[newsize]; System.arraycopy(mychars, 0, newchars, 0, count); mychars = newchars; free = newsize - count; } } setTarget(mychars, 0, count, false); }
@GwtIncompatible public String replace(Reader text, int length) throws IOException { TextBuffer tb = wrap(new StringBuilder(length >= 0 ? length : 0)); replace(pattern.matcher(text, length), substitution, tb); return tb.toString(); }
@GwtIncompatible private static int replace(Matcher m, Substitution substitution, Writer out) throws IOException { try { return replace(m, substitution, wrap(out)); } catch (WriteException e) { throw e.reason; } }
@GwtIncompatible public String replace(Reader text, int length) throws IOException { TextBuffer tb = wrap(new StringBuilder(length >= 0 ? length : 0)); replace(pattern.matcher(text, length), substitution, tb); return tb.toString(); }
@GwtIncompatible private static int replace(Matcher m, Substitution substitution, Writer out) throws IOException { try { return replace(m, substitution, wrap(out)); } catch (WriteException e) { throw e.reason; } }
@GwtIncompatible public int replace(Reader text, int length, StringBuilder sb) throws IOException { return replace(text, length, wrap(sb)); }
@GwtIncompatible public void replace(MatchResult res, String groupName, Writer out) throws IOException { replace(pattern.matcher(res, groupName), substitution, out); }
@GwtIncompatible private int replace(Reader text, int length, TextBuffer dest) throws IOException { return replace(pattern.matcher(text, length), substitution, dest); }
@GwtIncompatible public void replace(MatchResult res, int group, Writer out) throws IOException { replace(pattern.matcher(res, group), substitution, out); }
@GwtIncompatible public void replace(MatchResult res, String groupName, Writer out) throws IOException { replace(pattern.matcher(res, groupName), substitution, out); }
@GwtIncompatible public void replace(CharSequence text, Writer out) throws IOException { replace(pattern.matcher(text), substitution, out); }
@GwtIncompatible public void replace(Reader in, int length, Writer out) throws IOException { replace(pattern.matcher(in, length), substitution, out); }
@GwtIncompatible public int replace(Reader text, int length, StringBuilder sb) throws IOException { return replace(text, length, wrap(sb)); }