Text implements CharSequence { public int toInteger() throws NumberFormatException { int res = 0; byte currChar; int i=1; currChar=chars[pos]; boolean isMinus=false; if(currChar==minus_byte) isMinus=true; else if(currChar>=zero_byte && currChar<=nine_byte) res+=currChar-zero_byte; else throw new NumberFormatException("value is not numeric"); for (; i < len; i++) { currChar=chars[pos+i]; if(currChar>=zero_byte && currChar<=nine_byte) { res*=10; res+=currChar-zero_byte; } else throw new NumberFormatException("value is not numeric"); } if(isMinus) return 0-res; else return res; } Text(); protected  Text(Text another);  Text(String s);  Text(int i);  Text(byte[] data, int pos, int len); void strain(byte[] data, int pos, int len); int length(); char charAt(int index); void copy(Text destination); void duplicate(Text destination); int divide(char separator, Text[] parts); int divide(char[] separators, Text[] parts); CharSequence subSequence(int start, int end); Text subtext(int start, int end); Text subtext(int start); Collection<Text> split(char separator); Collection<Text> split(Text separator); int indexOf(Text value); int indexOf(char value); void trim(); Text nextLine(); boolean hasMoreLines(); @Override boolean equals(Object other); @Override int hashCode(); boolean startsWith(Text pattern); @Override String toString(); int toInteger(); long toLong(); int hexToInteger(); void write(ByteBuffer buffer); void copyRemainder(Text other); boolean contains(char c);  }
@Test public void testToInteger() { Text t1 = new Text("1234"); assertEquals(1234, t1.toInteger()); Text t2 = new Text("8000\r"); t2.trim(); assertEquals(8000, t2.toInteger()); }