|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcz.psika.numerist.Entry
public class Entry
Entry. Basic object representing each entry, it's style and some computated characteristics. Object is observable and could conserve history status.
Nested Class Summary | |
---|---|
protected class |
Entry.EntryMemento
Class used to conserve history status of entry. |
Field Summary | |
---|---|
protected boolean |
computed
State of computation. |
static boolean |
COMPUTED
Successul computation status flag. |
protected int[] |
freqs
Computed frequencies of all numbers/digits. |
protected int |
id
Unique identifier for entry used to distinguish different entries. |
protected java.lang.String |
name
Input string truncated for making things bit faster. |
static boolean |
NOT_COMPUTED
Failed computation status flag. |
static boolean |
NOT_SELECTED
Negative selection status flag. |
static int |
NUMBERS_COUNT
Number of numbers/digits. |
protected int |
numbersUsed
Caching number of numbers with their frequency greater than zero. |
protected java.util.Set<ItemObserver> |
observers
Registered observers. |
static boolean |
SELECTED
Positive selection status flag. |
protected boolean |
selectStatus
Selection of entry, used for invoking actions later. |
protected java.lang.String |
sourceName
Original entry string used in GUI. |
protected Style |
style
Style of characteristics. |
Constructor Summary | |
---|---|
protected |
Entry(Entry original,
int newId)
Copy constructor making copy which is not connected to original entry. |
|
Entry(java.lang.Integer uniqueIdentifier,
java.lang.String entryString,
Style entryStyle)
Entry construction cause initialization of string content and entry identifier. |
Method Summary | |
---|---|
void |
addObserver(ItemObserver observer)
Attach observer to the object. |
protected boolean |
compute()
Doing computations. |
boolean |
computed()
Find out if entry was successfully computed. |
Memento |
createMemento()
Creates memento. |
void |
deleteObserver(ItemObserver observer)
Detach observer. |
boolean |
equals(java.lang.Object other)
Entries are equal when they have same identifiers. |
Entry |
fetchEntry()
DIRECT access to this instance |
int |
getFrequency(int number)
Get count of occurences of the concrete number/digit. |
int |
getId()
Getting unique identifier for this entry. |
java.lang.String |
getSourceString()
Returns input string when this entry was created. |
Style |
getStyle()
Get entry's style. |
boolean |
isCopy()
Entries could be copied. |
boolean |
isSelected()
Find out if this entry is selected. |
void |
notifyObservers(Constants.ItemEvents event)
Notify all attached observers. |
int |
numbersUsed()
Returns count of number used. |
protected void |
prepareComputation()
Initialize computed state to false to let us know
that computations are maybe processed for now and initialize
members to default initial state. |
protected boolean |
setComputationStatus(boolean computationStatus)
Set status of computation. |
void |
setMemento(Memento memento)
Set history status. |
void |
setSelection(boolean select)
Mark this entry as (un)selected. |
void |
setString(java.lang.String newString)
Change string and make computations. |
void |
setStyle(Style setStyle)
Set/modify style for entry and make all necessary computations. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final int id
protected java.lang.String name
protected java.lang.String sourceName
protected int[] freqs
protected int numbersUsed
protected Style style
public static final boolean COMPUTED
public static final boolean NOT_COMPUTED
protected boolean computed
computed()
public static final boolean SELECTED
public static final boolean NOT_SELECTED
protected boolean selectStatus
protected java.util.Set<ItemObserver> observers
public static final int NUMBERS_COUNT
Constructor Detail |
---|
public Entry(java.lang.Integer uniqueIdentifier, java.lang.String entryString, Style entryStyle)
uniqueIdentifier
- needed to observe changes quicklyentryString
- string input dataentryStyle
- styleprotected Entry(Entry original, int newId)
original
- existing entrynewId
- new identifier of entry to setequals(Object other)
Method Detail |
---|
public final int getId()
public java.lang.String getSourceString()
public void setString(java.lang.String newString)
newString
- assing new input stringpublic boolean isCopy()
true
when this entry has been created as copypublic void setSelection(boolean select)
select
- true
to select, false
to unselectpublic boolean isSelected()
true
if entry was selected, false
otherwisepublic Style getStyle()
Style
object or null
public void setStyle(Style setStyle)
setStyle
- style to setpublic int getFrequency(int number)
number
- concrete number or digit
0
is returned if frequency not successfully computedcomputed()
public int numbersUsed()
0
is returned if computation failedcomputed()
public boolean computed()
true
when entry computations successfully done,
false
if computations are not done or not completed
or when some error occured.protected void prepareComputation()
false
to let us know
that computations are maybe processed for now and initialize
members to default initial state.
protected boolean setComputationStatus(boolean computationStatus)
computationStatus
- false
on computation error
protected boolean compute()
NOT_COMPUTED
on computation error, otherwise COMPUTED
.public Entry fetchEntry()
fetchEntry
in interface Item
Entry
objectpublic boolean equals(java.lang.Object other)
equals
in class java.lang.Object
other
- the other object to compare
true
if entries are equalpublic Memento createMemento()
createMemento
in interface History
public void setMemento(Memento memento)
setMemento
in interface History
memento
- history EntryMemento
objectHistory.createMemento()
public void addObserver(ItemObserver observer)
ItemObservable
addObserver
in interface ItemObservable
observer
- an observer to attachItemObservable.addObserver(ItemObserver observer)
public void deleteObserver(ItemObserver observer)
ItemObservable
deleteObserver
in interface ItemObservable
observer
- to removeItemObservable.deleteObserver(ItemObserver observer)
public void notifyObservers(Constants.ItemEvents event)
ItemObservable
notifyObservers
in interface ItemObservable
event
- type of event to notify all registered observersItemObservable.notifyObservers(Constants.ItemEvents event)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |