@Test public void subSequence() throws Exception { assertEquals(new Precoded("123"), new Precoded("abc123xyz").subSequence(3, 6)); assertEquals("123", new Precoded("abc123xyz").subSequence(3, 6).toString()); }
@Override public UriEncoded subSequence(int startIndex, int endIndex) { if (startIndex == 0 && endIndex == length()) { return this; } if (endIndex < startIndex) { throw new ArrayIndexOutOfBoundsException(String.format("Start index %d < end index %d.", startIndex, endIndex)); } if (startIndex < 0) { throw new ArrayIndexOutOfBoundsException(String.format("Start index %d is negative.", startIndex)); } if (mStart + endIndex > mEnd) { throw new ArrayIndexOutOfBoundsException(String.format("End index %d exceeds length %d", endIndex, length())); } return new Precoded(mEncoded, startIndex + mStart, endIndex + mStart); }
Precoded implements UriEncoded { @Override public UriEncoded subSequence(int startIndex, int endIndex) { if (startIndex == 0 && endIndex == length()) { return this; } if (endIndex < startIndex) { throw new ArrayIndexOutOfBoundsException(String.format("Start index %d < end index %d.", startIndex, endIndex)); } if (startIndex < 0) { throw new ArrayIndexOutOfBoundsException(String.format("Start index %d is negative.", startIndex)); } if (mStart + endIndex > mEnd) { throw new ArrayIndexOutOfBoundsException(String.format("End index %d exceeds length %d", endIndex, length())); } return new Precoded(mEncoded, startIndex + mStart, endIndex + mStart); } }
Precoded implements UriEncoded { @Override public UriEncoded subSequence(int startIndex, int endIndex) { if (startIndex == 0 && endIndex == length()) { return this; } if (endIndex < startIndex) { throw new ArrayIndexOutOfBoundsException(String.format("Start index %d < end index %d.", startIndex, endIndex)); } if (startIndex < 0) { throw new ArrayIndexOutOfBoundsException(String.format("Start index %d is negative.", startIndex)); } if (mStart + endIndex > mEnd) { throw new ArrayIndexOutOfBoundsException(String.format("End index %d exceeds length %d", endIndex, length())); } return new Precoded(mEncoded, startIndex + mStart, endIndex + mStart); } Precoded(CharSequence encoded); private  Precoded(CharSequence encoded, int start, int end); }
Precoded implements UriEncoded { @Override public UriEncoded subSequence(int startIndex, int endIndex) { if (startIndex == 0 && endIndex == length()) { return this; } if (endIndex < startIndex) { throw new ArrayIndexOutOfBoundsException(String.format("Start index %d < end index %d.", startIndex, endIndex)); } if (startIndex < 0) { throw new ArrayIndexOutOfBoundsException(String.format("Start index %d is negative.", startIndex)); } if (mStart + endIndex > mEnd) { throw new ArrayIndexOutOfBoundsException(String.format("End index %d exceeds length %d", endIndex, length())); } return new Precoded(mEncoded, startIndex + mStart, endIndex + mStart); } Precoded(CharSequence encoded); private  Precoded(CharSequence encoded, int start, int end); @Override UriEncoded normalized(); @Override CharSequence decoded(String charset); @Override CharSequence decoded(); @Override int length(); @Override char charAt(int i); @Override UriEncoded subSequence(int startIndex, int endIndex); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); }
Precoded implements UriEncoded { @Override public UriEncoded subSequence(int startIndex, int endIndex) { if (startIndex == 0 && endIndex == length()) { return this; } if (endIndex < startIndex) { throw new ArrayIndexOutOfBoundsException(String.format("Start index %d < end index %d.", startIndex, endIndex)); } if (startIndex < 0) { throw new ArrayIndexOutOfBoundsException(String.format("Start index %d is negative.", startIndex)); } if (mStart + endIndex > mEnd) { throw new ArrayIndexOutOfBoundsException(String.format("End index %d exceeds length %d", endIndex, length())); } return new Precoded(mEncoded, startIndex + mStart, endIndex + mStart); } Precoded(CharSequence encoded); private  Precoded(CharSequence encoded, int start, int end); @Override UriEncoded normalized(); @Override CharSequence decoded(String charset); @Override CharSequence decoded(); @Override int length(); @Override char charAt(int i); @Override UriEncoded subSequence(int startIndex, int endIndex); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString();  }