boolean (Object obj) { if (!(obj instanceof CharSequence)) return false; CharSequence other = (CharSequence)obj; if (length() != other.length()) return false; int i = 0; for (CharSegment wrapper : myWrappers) { if (wrapper.encodedString instanceof String) { if (!CharArrayUtil.regionMatches(other, i, i + wrapper.length(), (String)wrapper.encodedString)) return false; i += wrapper.length(); } else { byte[] bytes = (byte[])wrapper.encodedString; for (byte b : bytes) { char c = (char)b; if (c != other.charAt(i++)) return false; } } } return true; }