de.hagenah.diplomacy.game
Class DiaryEntry

java.lang.Object
  extended by de.hagenah.diplomacy.game.DiaryEntry
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable

public class DiaryEntry
extends java.lang.Object
implements java.io.Serializable, java.lang.Comparable

See Also:
Serialized Form

Field Summary
static int TOSTRING_BODY
          Returns the diary entry body
static int TOSTRING_CSS
          The CSS class color-?
static int TOSTRING_HTML
          Returns a xhtml text, e.g. → instead of ->
static int TOSTRING_SHORT
          Returns a short text, e.g.
 
Constructor Summary
DiaryEntry(Person from, int number, java.lang.String text, Phase phase, int messagenumber)
          Creates a new diary message.
 
Method Summary
 int compareTo(java.lang.Object obj)
          Compares two diary entries by message number.
 boolean equals(java.lang.Object obj)
          Indicates whether obj is "equal to" this one.
 Person getFrom()
          Returns the person that created the diary entry (can be null if unknown).
 int getMessageNumber()
          Returns a unique message number for the diary entry
 int getNumber()
          Return the diary entry number (-1 if unknown)
 Phase getPhase()
          Returns she phase in which the diary entry was created
 java.lang.String getText()
          Returns the diary entry text (\n as line separator)
 int hashCode()
          Returns a hashcode for this message.
 boolean isVisible(Person person)
          Is this diary entry visible to the specified person?
 java.lang.String toString()
          Returns a short description for the diary entry
 java.lang.String toString(int flags)
          Return a text for the diary entry (e.g.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

TOSTRING_BODY

public static final int TOSTRING_BODY
Returns the diary entry body

See Also:
Constant Field Values

TOSTRING_SHORT

public static final int TOSTRING_SHORT
Returns a short text, e.g. "Entry 2 from A"

See Also:
Constant Field Values

TOSTRING_HTML

public static final int TOSTRING_HTML
Returns a xhtml text, e.g. → instead of ->

See Also:
Constant Field Values

TOSTRING_CSS

public static final int TOSTRING_CSS
The CSS class color-? (e.g. color-m) is used for the color

See Also:
Constant Field Values
Constructor Detail

DiaryEntry

public DiaryEntry(Person from,
                  int number,
                  java.lang.String text,
                  Phase phase,
                  int messagenumber)
Creates a new diary message.

Parameters:
from - The person that created the diary entry (can be null if unknown)
number - The number of the diary entry (-1 if unknown)
text - The diary entry text (\n as line separator)
phase - The phase in which the diary entry was created
messagenumber - A unique message number for the diary entry
Method Detail

getFrom

public Person getFrom()
Returns the person that created the diary entry (can be null if unknown).

Returns:
The person that created the diary entry

getNumber

public int getNumber()
Return the diary entry number (-1 if unknown)

Returns:
The number of the diary entry (-1, 0, 1, ...)

getText

public java.lang.String getText()
Returns the diary entry text (\n as line separator)

Returns:
The diary entry text

getPhase

public Phase getPhase()
Returns she phase in which the diary entry was created

Returns:
The phase

getMessageNumber

public int getMessageNumber()
Returns a unique message number for the diary entry

Returns:
The messahe number

isVisible

public boolean isVisible(Person person)
Is this diary entry visible to the specified person?

Parameters:
person - The person
Returns:
true if the diary entry is visible, false otherwise

equals

public boolean equals(java.lang.Object obj)
Indicates whether obj is "equal to" this one.

Overrides:
equals in class java.lang.Object
Parameters:
obj - The other obj
Returns:
true if obj is a DiaryEntry object and has the same message number

compareTo

public int compareTo(java.lang.Object obj)
Compares two diary entries by message number.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
obj - The other obj
Returns:
A negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

hashCode

public int hashCode()
Returns a hashcode for this message.

Overrides:
hashCode in class java.lang.Object
Returns:
The hashcode

toString

public java.lang.String toString(int flags)
Return a text for the diary entry (e.g. "Diary Entry 2 from Austria")

Parameters:
flags - TOSTRING_BODY, TOSTRING_SHORT, TOSTRING_HTML, TOSTRING_CSS
Returns:
The text

toString

public java.lang.String toString()
Returns a short description for the diary entry

Overrides:
toString in class java.lang.Object
Returns:
A short description, e.g. Entry 2 From A