org.hd.d.pg2k.svrCore
Class Name.CSWrapper<T extends Name>

java.lang.Object
  extended by org.hd.d.pg2k.svrCore.Name.CSWrapper<T>
All Implemented Interfaces:
java.lang.CharSequence, java.lang.Comparable<java.lang.CharSequence>, MemoryTools.Internable, TextUtils.CharSequence8Bit
Direct Known Subclasses:
Name.ExhibitShort
Enclosing class:
Name

private static class Name.CSWrapper<T extends Name>
extends java.lang.Object
implements TextUtils.CharSequence8Bit, java.lang.Comparable<java.lang.CharSequence>, MemoryTools.Internable

Effectively-immutable light-weight wrapper around the underlying text. Can be intern()ed to help eliminate some expensive duplicates.


Field Summary
(package private)  int end
          End offset (exclusive) on underlying impl; non-negative.
(package private)  int start
          Start offset (inclusive) on underlying impl; non-negative.
(package private)  T underlying
          Underlying instance; non-null.
 
Constructor Summary
Name.CSWrapper(T underlying, int start, int end)
          Create an instance.
 
Method Summary
 char charAt(int index)
           
 int compareTo(java.lang.CharSequence other)
           
 boolean equals(java.lang.Object obj)
          Equality checks for the same type and content.
 int hashCode()
          The hash code is based on a fixed-time sampling of the content for speed.
 int length()
           
 java.lang.CharSequence subSequence(int start, int end)
           
 byte[] toByteArray()
          Create private byte[] copy for caller; never null.
 java.lang.String toString()
          Convert to String containing same char sequence.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

underlying

final transient T extends Name underlying
Underlying instance; non-null. Definitely not intended to be serialised.


start

final int start
Start offset (inclusive) on underlying impl; non-negative.


end

final int end
End offset (exclusive) on underlying impl; non-negative.

Constructor Detail

Name.CSWrapper

Name.CSWrapper(T underlying,
               int start,
               int end)
Create an instance. Only called from trusted classes so arg-checking can be by assert() to save release-build CPU cycles.

Parameters:
underlying - the Name instance that this provides a view of; never null
start - inclusive start index; in range [0,end]
end - exclusive end index; in range [start,underlying.length()]
Method Detail

charAt

public char charAt(int index)
Specified by:
charAt in interface java.lang.CharSequence

length

public int length()
Specified by:
length in interface java.lang.CharSequence

subSequence

public java.lang.CharSequence subSequence(int start,
                                          int end)
Specified by:
subSequence in interface java.lang.CharSequence

equals

public boolean equals(java.lang.Object obj)
Equality checks for the same type and content.

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
The hash code is based on a fixed-time sampling of the content for speed.

Overrides:
hashCode in class java.lang.Object

compareTo

public int compareTo(java.lang.CharSequence other)
Specified by:
compareTo in interface java.lang.Comparable<java.lang.CharSequence>

toString

public java.lang.String toString()
Convert to String containing same char sequence. We don't expensively intern() the result as it may be short-lived.

Specified by:
toString in interface java.lang.CharSequence
Overrides:
toString in class java.lang.Object

toByteArray

public final byte[] toByteArray()
Create private byte[] copy for caller; never null.

Specified by:
toByteArray in interface TextUtils.CharSequence8Bit

DHD Multimedia Gallery V1.57.21

Copyright (c) 1996-2011, Damon Hart-Davis. All rights reserved.