/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* A List of Strings each representing a word or token.
* This object itself is a CharSequence whose characters consist
* of all the tokens, separated by blanks.
*
* @author jrose
*/
protected boolean frozen;
public TokenList() {
this.separator = " ";
}
this.separator = " ";
}
}
this.separator = " ";
}
this.separator = " ";
}
}
this(tokenStr, " ", false);
}
}
}
static {
}
public void freeze() {
if (!frozen) {
}
trimToSize();
frozen = true;
}
}
public boolean isFrozen() {
return frozen;
}
void checkNotFrozen() {
if (isFrozen()) {
throw new UnsupportedOperationException("cannot modify frozen TokenList");
}
}
return separator;
}
}
/// All normal List mutators must check the frozen bit:
}
return super.add(o);
}
}
return super.addAll(c);
}
}
return super.remove(o);
}
}
public void clear() {
super.clear();
}
/** Add a collection of tokens to the list, applying toString to each. */
// Note that if this sequence is empty, no tokens are added.
// This is different from adding a null string, which is
// a single token.
boolean added = false;
added = true;
}
return added;
}
boolean added = false;
added = true;
}
return added;
}
}
boolean added = false;
if (sep < 0) {
}
if (allowNulls) {
add("");
added = true;
}
} else {
added = true;
}
}
// Input was something like "tok1 tok2 ".
add("");
added = true;
}
return added;
}
}
/** Format the token string, using quotes and escapes.
* Quotes must contain an odd number of 3 or more elements,
* which the end quote does not occur in the token.
* If the token contains all end quotes, the last pair
* is used, with all occurrences of the end quote replaced
* by the superquote. If an end quote is the empty string,
* the separator is used instead.
*/
return ""; //@@
}
protected int[] lengths;
// Layout of lengths:
// { modCount, hint, -1==beg[0], end[0]==beg[1], ..., length }
// Note that each beg[i]..end[i] span includes a leading separator,
// which is not part of the corresponding token.
return (CharSequence) get(i);
}
// Produce (and cache) an table of indexes for each token.
protected int[] getLengths() {
;
for (int i = 0; i < size; i++) {
}
}
return lengths;
}
public int length() {
int[] lengths = getLengths();
}
// Which token does the given index belong to?
protected int which(int i) {
if (i < 0) {
return -1;
}
int[] lengths = getLengths();
return wh;
}
}
if (hint == 0) {
return size(); // end of the line
}
}
}
public char charAt(int i) {
if (i < 0) {
return "".charAt(i);
}
int j = i - beg;
if (j < sepLength) {
}
}
//System.out.println("i: "+beg+".."+end);
return "";
}
if (beg < 0) {
}
}
--endWh;
}
//System.out.println("wh: "+begWh+".."+endWh);
int begFrag = 0;
}
int endFrag = 0;
}
if (false) {
}
}
// Special case: Slice the separator.
}
// Special case: Slice a single token.
}
int fillp = 0;
// Insert a leading null token to force an initial separator.
begFrag = 0;
}
// Slice it.
}
}
}
}
}
/** Returns the concatenation of all tokens,
* with intervening separator characters.
*/
for (int i = 0; i < size; i++) {
if (i > 0) {
}
}
}
/*---- TESTING CODE ----
public static void main(String[] av) {
if (av.length == 0) av = new String[]{"one", "2", "", "four"};
TokenList ts = new TokenList();
final String SEP = ", ";
ts.setSeparator(SEP);
for (int i = -1; i < av.length; i++) {
if (i >= 0) ts.addToken(av[i]);
{
TokenList tsCopy = new TokenList(ts.toString(), SEP);
if (!tsCopy.equals(ts)) {
tsCopy.setSeparator(")(");
System.out.println("!= ("+tsCopy+")");
}
}
{
TokenList tsBar = new TokenList(ts, "|");
tsBar.add(0, "[");
tsBar.add("]");
System.out.println(tsBar);
}
if (false) {
int[] ls = ts.getLengths();
System.out.println("ts: "+ts);
System.out.print("ls: {");
for (int j = 0; j < ls.length; j++) System.out.print(" "+ls[j]);
System.out.println(" }");
}
assert0(ts.size() == i+1);
assert0(i < 0 || ts.get(i) == av[i]);
String tss = ts.toString();
int tslen = tss.length();
assert0(ts.length() == tss.length());
for (int n = 0; n < tslen; n++) {
assert0(ts.charAt(n) == tss.charAt(n));
}
for (int j = 0; j < tslen; j++) {
for (int k = tslen; k >= j; k--) {
CharSequence sub = ts.subSequence(j, k);
//System.out.println("|"+sub+"|");
assert0(sub.toString().equals(tss.substring(j, k)));
}
}
}
}
static void assert0(boolean z) {
if (!z) throw new RuntimeException("assert failed");
}
// ---- TESTING CODE ----*/
}