2 * Copyright 2003-2004 The Apache Software Foundation
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 * 2004 - modified for PHPeclipse plugins
18 package net.sourceforge.phpeclipse.wiki.editor;
20 import java.io.Reader;
21 import java.io.IOException;
24 * class to tokenize the input as lines seperated
25 * by \r (mac style), \r\n (dos/windows style) or \n (unix style)
28 public class LineTokenizer {
29 private String lineEnd = "";
30 private int pushed = -2;
31 private boolean includeDelims = false;
34 * attribute includedelims - whether to include
35 * the line ending with the line, or to return
38 * @param includeDelims if true include /r and /n in the line
41 public void setIncludeDelims(boolean includeDelims) {
42 this.includeDelims = includeDelims;
46 * get the next line from the input
48 * @param in the input reader
49 * @return the line excluding /r or /n, unless includedelims is set
50 * @exception IOException if an error occurs reading
52 public boolean getToken(StringBuffer line, Reader in) throws IOException {
65 // StringBuffer line = new StringBuffer();
72 } else if (ch == '\n') {
76 line.append((char) ch);
90 if (ch == -1 && state == 1) {
101 * @return the line ending character(s) for the current line
103 public String getPostToken() {