133 return DONE; 134 } 135 136 137 /** 138 * Returns previous UTF16 character and decrements the iterator's currentIndex by 139 * 1. 140 * If the resulting currentIndex is less than 0, the currentIndex is reset to 0 and a 141 * value of DONECODEPOINT is returned. 142 * @return next UTF16 character in text or DONE if the new currentIndex is off the 143 * start of the text range. 144 */ 145 public int previous(){ 146 if (currentIndex > 0) { 147 return replaceable.charAt(--currentIndex); 148 } 149 return DONE; 150 } 151 152 /** 153 * <p>Sets the currentIndex to the specified currentIndex in the text and returns that 154 * single UTF16 character at currentIndex. 155 * This assumes the text is stored as 16-bit code units.</p> 156 * @param currentIndex the currentIndex within the text. 157 * @exception IllegalArgumentException is thrown if an invalid currentIndex is 158 * supplied. i.e. currentIndex is out of bounds. 159 * @return the character at the specified currentIndex or DONE if the specified 160 * currentIndex is equal to the end of the text. 161 */ 162 public void setIndex(int currentIndex) { 163 if (currentIndex < 0 || currentIndex > replaceable.length()) { 164 throw new IllegalArgumentException(); 165 } 166 this.currentIndex = currentIndex; 167 } 168 169 //// for StringPrep 170 public int getText(char[] fillIn, int offset){ 171 int length = replaceable.length(); 172 if(offset < 0 || offset + length > fillIn.length){ 173 throw new IndexOutOfBoundsException(Integer.toString(length)); 174 } 175 replaceable.getChars(0,length,fillIn,offset); 176 return length; 177 } 178 179 // private data members ---------------------------------------------------- 180 | 133 return DONE; 134 } 135 136 137 /** 138 * Returns previous UTF16 character and decrements the iterator's currentIndex by 139 * 1. 140 * If the resulting currentIndex is less than 0, the currentIndex is reset to 0 and a 141 * value of DONECODEPOINT is returned. 142 * @return next UTF16 character in text or DONE if the new currentIndex is off the 143 * start of the text range. 144 */ 145 public int previous(){ 146 if (currentIndex > 0) { 147 return replaceable.charAt(--currentIndex); 148 } 149 return DONE; 150 } 151 152 /** 153 * Sets the currentIndex to the specified currentIndex in the text and returns that 154 * single UTF16 character at currentIndex. 155 * This assumes the text is stored as 16-bit code units. 156 * @param currentIndex the currentIndex within the text. 157 * @exception IllegalArgumentException is thrown if an invalid currentIndex is 158 * supplied. i.e. currentIndex is out of bounds. 159 */ 160 public void setIndex(int currentIndex) { 161 if (currentIndex < 0 || currentIndex > replaceable.length()) { 162 throw new IllegalArgumentException(); 163 } 164 this.currentIndex = currentIndex; 165 } 166 167 //// for StringPrep 168 public int getText(char[] fillIn, int offset){ 169 int length = replaceable.length(); 170 if(offset < 0 || offset + length > fillIn.length){ 171 throw new IndexOutOfBoundsException(Integer.toString(length)); 172 } 173 replaceable.getChars(0,length,fillIn,offset); 174 return length; 175 } 176 177 // private data members ---------------------------------------------------- 178 |