setText(String str) { this.str = str; pos = 0; }
public void setText(String text) { int idx = 0; int idx_idx = 0; int alreadyExpanded = 0; int idxToMove = 0;  this.text = text; this.index = 0;  String work_text = text.intern();  Vector v = new Vector(); Vector vi = new Vector();   while (idx < work_text.length()) { String key, key_old;  Object object = null; int p = 1;   key_old = key = null; do { if (object != null) key_old = key; key = work_text.substring (idx, idx+p); object = collator.prefix_tree.get (key); if (object != null && idx < alreadyExpanded) { RuleBasedCollator.CollationElement prefix = (RuleBasedCollator.CollationElement)object; if (prefix.expansion != null && prefix.expansion.startsWith(work_text.substring(0, idx))) { object = null; key = key_old; } } p++; } while (idx+p <= work_text.length());  if (object == null) key = key_old;  RuleBasedCollator.CollationElement prefix = (RuleBasedCollator.CollationElement) collator.prefix_tree.get (key);   if (prefix == null) {  if (alreadyExpanded > 0) { RuleBasedCollator.CollationElement e = collator.getDefaultAccentedElement (work_text.charAt (idx));  v.add (e); vi.add (new Integer(idx_idx)); idx++; alreadyExpanded--; if (alreadyExpanded == 0) {  idx_idx += idxToMove; idxToMove = 0; } else idx_idx++; } else {  RuleBasedCollator.CollationElement e = collator.getDefaultElement (work_text.charAt (idx)); Integer i_ref = new Integer(idx_idx);   v.add (RuleBasedCollator.SPECIAL_UNKNOWN_SEQ); vi.add (i_ref); v.add (e); vi.add (i_ref); idx_idx++; idx++; } continue; }   if (prefix.expansion != null) { work_text = prefix.expansion + work_text.substring (idx+prefix.key.length()); idx = 0; v.add (prefix); vi.add (new Integer(idx_idx)); if (alreadyExpanded == 0) idxToMove = prefix.key.length(); alreadyExpanded += prefix.expansion.length()-prefix.key.length(); } else {  v.add (prefix); vi.add (new Integer(idx_idx)); idx += prefix.key.length();  if (alreadyExpanded > 0) { alreadyExpanded -= prefix.key.length(); if (alreadyExpanded == 0) { idx_idx += idxToMove; idxToMove = 0; } } else idx_idx += prefix.key.length(); } }  text_decomposition = v.toArray(); text_indexes = new int[vi.size()+1]; for (int i = 0; i < vi.size(); i++) { text_indexes[i] = ((Integer)vi.elementAt(i)).intValue(); } text_indexes[vi.size()] = text.length(); }
setText(String str){  this.str = str;  pos = 0;}