|
Evaluating Software Design Patterns — the "Gang of Four" patterns implemented in Java 6 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectdk.rode.thesis.meta.model.AbstractSequence<E>
dk.rode.thesis.meta.model.ArraySequence<Word>
dk.rode.thesis.flyweight.Sentence
@Participant(value="UnsharedConcreteFlyweight") public class Sentence
A sentence represents an ordered sequence of
words
making up that sentence.
A sentence is bounded
,
consistent
, but not
unique
if the same word is contained more
than once, including white space
!
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface dk.rode.thesis.meta.model.Sequence |
---|
Sequence.State |
Field Summary | |
---|---|
private int |
hashCode
The hash code of this sentence. |
private boolean |
unique
True if this sentence is unique , false
if not. |
Fields inherited from class dk.rode.thesis.meta.model.ArraySequence |
---|
elements, index |
Fields inherited from class dk.rode.thesis.meta.model.AbstractSequence |
---|
state |
Constructor Summary | |
---|---|
Sentence(Sentence sentence)
Copy constructor. |
|
Sentence(Word[] words)
Constructor, which creates this sentence to be comprised of the words in words . |
Method Summary | |
---|---|
char |
charAt(int index)
|
int |
compareTo(Sentence sentence)
|
Sentence |
copy()
Returns a copy of this sequence that will start at the same sequence index as this sequence. |
boolean |
equals(Object object)
Returns true if object is an array sequence having the
same type as this array sequence, using an equivalent
array, and is at the same sequence index, false if not. |
int |
hashCode()
Returns the hash code of this sequence. |
int |
indexOfIgnoreCase(CharSequence sequence,
int index,
Locale locale)
Finds the first index where sequence is present in this
textual representation from the index supplied, regardless of case,
or -1 if sequence cannot be found. |
Iterator<Word> |
iterator()
|
int |
length()
|
String |
lowerCaseFirst(Locale locale)
Return the first character of this textual representation lower cased. |
CharSequence |
subSequence(int start,
int end)
|
String |
toString()
Returns this sentence as a string. |
boolean |
unique()
Returns true if any given word in this
sentence is only contained once, including white
space, false otherwise. |
String |
upperCaseFirst(Locale locale)
Return the first character of this textual representation upper cased. |
Methods inherited from class dk.rode.thesis.meta.model.ArraySequence |
---|
bounded, consistent, current, next, reset, size |
Methods inherited from class dk.rode.thesis.meta.model.AbstractSequence |
---|
getStringablePolicy, state, toString |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface dk.rode.thesis.meta.model.Sequence |
---|
bounded, consistent, current, next, reset, state |
Methods inherited from interface dk.rode.thesis.strategy.Stringable |
---|
getStringablePolicy, toString |
Field Detail |
---|
private final int hashCode
private final boolean unique
unique
, false
if not.
If the same word
is contained
more than once, this sentence is not unique.
Constructor Detail |
---|
Sentence(Sentence sentence)
sentence
- The sentence to copy; cannot be null.
NullPointerException
- If sequence
is null.Sentence(Word[] words)
words
.
words
- The words; cannot be null or empty.
NullPointerException
- If words
is null.
IllegalArgumentException
- If words
is empty.Method Detail |
---|
public char charAt(int index)
charAt
in interface CharSequence
public int compareTo(Sentence sentence)
compareTo
in interface Comparable<Sentence>
public Sentence copy()
Sequence
copy
in interface Sequence<Word>
copy
in interface Copyable<Sequence<Word>>
public final boolean equals(Object object)
ArraySequence
object
is an array sequence having the
same type as this array sequence, using an equivalent
array, and is at the same sequence index, false if not.
equals
in class ArraySequence<Word>
object
- The object to test; can be null.
public final int hashCode()
ArraySequence
hashCode
in class ArraySequence<Word>
public int indexOfIgnoreCase(CharSequence sequence, int index, Locale locale)
Textual
sequence
is present in this
textual representation from the index supplied, regardless of case,
or -1 if sequence
cannot be found.
index
is allowed to be larger than the length of
this textual representation, in which case this method returns -1.
The supplied locale is used to perform the case conversion.
indexOfIgnoreCase
in interface Textual<Sentence>
sequence
- The char sequence to find; cannot be null.index
- The index to start at; cannot be negative.locale
- The locale to use; can be null, in which case
the default locale is used.
sequence
from index
,
regardless of case, or -1 if not found.public Iterator<Word> iterator()
iterator
in interface Iterable<Word>
public int length()
length
in interface CharSequence
public String lowerCaseFirst(Locale locale)
Textual
Note, that in some locales, shifting case of a given character may cause it to expand into more than one character! Hence, the return type is a string.
lowerCaseFirst
in interface Textual<Sentence>
locale
- The locale to use; can be null, in which
case the default locale is used.
public CharSequence subSequence(int start, int end)
subSequence
in interface CharSequence
public String toString()
toString
in interface CharSequence
toString
in class AbstractSequence<Word>
public boolean unique()
word
in this
sentence is only contained once, including white
space, false otherwise.
unique
in interface Sequence<Word>
unique
in class ArraySequence<Word>
Sequence.consistent()
public String upperCaseFirst(Locale locale)
Textual
Note, that in some locales, shifting case of a given character may cause it to expand into more than one character! Hence, the return type is a string.
upperCaseFirst
in interface Textual<Sentence>
locale
- The locale to use; can be null, in which
case the default locale is used.
|
Gunni Rode / rode.dk | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |