|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectmegamek.common.Report
public class Report
This class defines a single server report. It holds information such as the report ID, who the report is about, who should see the report, and some formatting information.
Typically, the report will be created by the relevant section in the
Server, and added to the phase report vector. The actual text
of the report must also be added to the report-messages.properties
file.
Example:
Report r = new Report(3455);\n
r.subject = entity.getId();\n
r.indent();\n
r.addDesc(entity);\n
r.add(6);\n
r.choose(true);\n
vPhaseReport.addElement(r);
Then the following line would be added to report-messages.properties:
3455::<data> (<data>) does <data> damage to the <msg:3456,3457>.\n 3456::tank\n 3457::building
When the client parses the report, it will fill in the <data> tags with
the values that were given to the add methods called on the
report object.
The example above might produce a report such as this when the
getText method was called:
" Crusader (Bob) does 6 damage to the tank."
| Field Summary | |
|---|---|
static int |
HIDDEN
Report is only visible to those players who can see the subject. |
int |
messageId
Required - associates this object with its text. |
int |
newlines
The number of newlines to add at the end of this report. |
static int |
OBSCURED
Report is visible to all players, but all data marked for obscuration remains hidden. |
static java.lang.String |
OBSCURED_STRING
The string that appears in the report to obscure certain information. |
int |
player
the player this report concerns, if applicable. |
static int |
PLAYER
messages which should be sent only to the player indicated by "player" |
static int |
PUBLIC
Report is visible to all players. |
int |
subject
The entity this report concerns, if applicable. |
static int |
TESTING
Testing only - remove me later. |
int |
type
How this report is handled when double-blind play is in effect. |
| Constructor Summary | |
|---|---|
Report()
Default constructor, note that using this means the messageId field must be explicitly set. |
|
Report(int id)
Create a new report associated with the given report text. |
|
Report(int id,
int type)
Create a new report associated with the given report text and having the given type. |
|
Report(Report r)
Create a new report which is an exact copy of the given report. |
|
| Method Summary | |
|---|---|
void |
add(int data)
Add the given int to the list of data that will be substituted for the <data> tags in the report. |
void |
add(int data,
boolean obscure)
Add the given int to the list of data that will be substituted for the <data> tags in the report, and mark it as double-blind sensitive information if obscure is true. |
void |
add(java.lang.String data)
Add the given String to the list of data that will be substituted for the <data> tags in the report. |
void |
add(java.lang.String data,
boolean obscure)
Add the given String to the list of data that will be substituted for the <data> tags in the report, and mark it as double-blind sensitive information if obscure is true. |
void |
addDesc(Entity entity)
Shortcut method for adding entity name and owner data at the same time. |
static void |
addNewline(java.util.Vector<Report> v)
Adds a newline to the last report in the given Vector. |
void |
addObscuredRecipient(java.lang.String playerName)
Internal method. |
void |
choose(boolean choice)
Indicate which of two possible messages should be substituted for the <msg:n,m> tag. |
int |
dataCount()
Internal method. |
java.lang.String |
getText()
Get the report in its final form, with all the necessary substitutions made. |
void |
hideData(int index)
Internal method. |
void |
indent()
Indent the report. |
void |
indent(int n)
Indent the report n times. |
static void |
indentAll(java.util.Vector<Report> vDesc,
int amount)
|
boolean |
isObscuredRecipient(java.lang.String playerName)
Internal method. |
boolean |
isValueObscured(int index)
Internal method. |
void |
markForTesting()
DEBUG method - do not use |
java.lang.String |
toString()
Useful for debugging purposes. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public int messageId
public int newlines
public transient int type
public static final int PUBLIC
public static final int OBSCURED
obscured unless explicitly marked
public.
public static final int HIDDEN
obscured unless explicitly marked public.
public static final int TESTING
public static final int PLAYER
public transient int subject
public.
public transient int player
public static final java.lang.String OBSCURED_STRING
| Constructor Detail |
|---|
public Report()
messageId field must be explicitly set.
public Report(int id)
id - the int value of the report from report-messages.properties
public Report(int id,
int type)
id - the int value of the report from report-messages.propertiestype - the constant specifying the visibility of the report (PUBLIC,
OBSCURED, or HIDDEN)public Report(Report r)
r - the report to be copied| Method Detail |
|---|
public void add(int data)
data - the int to be substituted
public void add(int data,
boolean obscure)
obscure is true. The order in which items
are added must match the order of the tags in the report text.
data - the int to be substitutedobscure - boolean indicating whether the data is double-blind
sensitivepublic void add(java.lang.String data)
data - the String to be substituted
public void add(java.lang.String data,
boolean obscure)
obscure is true. The order in which items
are added must match the order of the tags in the report text.
data - the String to be substitutedobscure - boolean indicating whether the data is double-blind
sensitivepublic void choose(boolean choice)
<msg:n,m> tag. An argument of
true would select message n while an
argument of false would select m. In the
future, this capability may be expanded to support more than
two choices.
- Parameters:
choice - boolean indicating which message to substitute
public void addDesc(Entity entity)
entity - the entity you wish to addpublic boolean isValueObscured(int index)
Tests wheter the data value at the given index has been marked as obscured.
index - position of data value (indexes are chronological and start
at zero)
public void hideData(int index)
Remove the data value from the report. This operation is irreversible.
index - position of data value (indexes are chronological and start
at zeropublic void indent()
public void indent(int n)
n - the number of times to indent the reportpublic int dataCount()
Get the total number of data values associated with this report. Note
that this includes the true/false values added for
<msg> tags as well.
public java.lang.String getText()
public static void addNewline(java.util.Vector<Report> v)
v - a Vector of Report objectspublic void addObscuredRecipient(java.lang.String playerName)
Adds the given player name to the report's list of players who received an obscured version of this report from the server at some time in the past.
playerName - the String containing the player's namepublic boolean isObscuredRecipient(java.lang.String playerName)
Tests whether the given player name is on the report's list of players who received an obscured version of this report from the server at some time in the past.
playerName - the String containing the player's name
public java.lang.String toString()
toString in class java.lang.Objectpublic void markForTesting()
public static void indentAll(java.util.Vector<Report> vDesc,
int amount)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||