|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.sf.freecol.common.model.FreeColGameObject
public abstract class FreeColGameObject
The superclass of all game objects in FreeCol.
| Field Summary | |
|---|---|
static java.lang.String |
COPYRIGHT
|
static java.lang.String |
LICENSE
|
static java.lang.String |
REVISION
|
| Constructor Summary | |
|---|---|
protected |
FreeColGameObject()
|
|
FreeColGameObject(Game game)
Creates a new FreeColGameObject with an automatically assigned
ID and registers this object at the specified Game. |
|
FreeColGameObject(Game game,
org.w3c.dom.Element e)
Initiates a new FreeColGameObject from an Element. |
|
FreeColGameObject(Game game,
java.lang.String id)
Initiates a new FreeColGameObject
with the given ID. |
|
FreeColGameObject(Game game,
javax.xml.stream.XMLStreamReader in)
Initiates a new FreeColGameObject from an Element. |
| Method Summary | |
|---|---|
protected void |
addModelMessage(FreeColGameObject source,
java.lang.String messageID,
java.lang.String[][] data,
int type)
Creates a ModelMessage and uses
getGame().addModelMessage(modelMessage)
to register it. |
protected void |
addModelMessage(FreeColGameObject source,
java.lang.String messageID,
java.lang.String[][] data,
int type,
java.lang.Object display)
Creates a ModelMessage and uses
getGame().addModelMessage(modelMessage)
to register it. |
void |
dispose()
Removes all references to this object. |
boolean |
equals(FreeColGameObject o)
Checks if the given FreeColGameObject equals this object. |
boolean |
equals(java.lang.Object o)
Checks if the given FreeColGameObject equals this object. |
Game |
getGame()
Gets the game object this FreeColGameObject belongs to. |
GameOptions |
getGameOptions()
Gets the GameOptions that is associated with the
Game owning this FreeColGameObject. |
java.lang.String |
getID()
Gets the unique ID of this object. |
java.lang.Integer |
getIntegerID()
Gets the ID's integer part of this object. |
static java.lang.String |
getXMLElementTagName()
Gets the tag name of the root element representing this object. |
int |
hashCode()
|
boolean |
hasID(java.lang.String id)
Checks if this object has the specified ID. |
boolean |
isDisposed()
Checks if this object has been disposed. |
boolean |
isUninitialized()
Checks if this FreeColGameObject
is uninitialized. |
protected boolean[][] |
readFromArrayElement(java.lang.String tagName,
javax.xml.stream.XMLStreamReader in,
boolean[][] arrayType)
Reads an XML-representation of an array. |
protected static int[] |
readFromArrayElement(java.lang.String tagName,
javax.xml.stream.XMLStreamReader in,
int[] arrayType)
Reads an XML-representation of an array. |
protected int[][] |
readFromArrayElement(java.lang.String tagName,
javax.xml.stream.XMLStreamReader in,
int[][] arrayType)
Reads an XML-representation of an array. |
protected java.lang.String[] |
readFromArrayElement(java.lang.String tagName,
javax.xml.stream.XMLStreamReader in,
java.lang.String[] arrayType)
Reads an XML-representation of an array. |
void |
readFromXML(javax.xml.stream.XMLStreamReader in)
Initialize this object from an XML-representation of this object. |
void |
readFromXMLElement(org.w3c.dom.Element element)
Initialize this object from an XML-representation of this object. |
protected abstract void |
readFromXMLImpl(javax.xml.stream.XMLStreamReader in)
Initialize this object from an XML-representation of this object. |
void |
setFakeID(java.lang.String newID)
Sets the ID of this object for temporary use with toXMLElement. |
void |
setGame(Game game)
Sets the game object this FreeColGameObject belongs to. |
void |
setID(java.lang.String newID)
Sets the unique ID of this object. |
protected void |
toArrayElement(java.lang.String tagName,
boolean[][] array,
javax.xml.stream.XMLStreamWriter out)
Creates an XML-representation of an array. |
protected void |
toArrayElement(java.lang.String tagName,
int[][] array,
javax.xml.stream.XMLStreamWriter out)
Creates an XML-representation of an array. |
protected static void |
toArrayElement(java.lang.String tagName,
int[] array,
javax.xml.stream.XMLStreamWriter out)
Creates an XML-representation of an array. |
protected void |
toArrayElement(java.lang.String tagName,
java.lang.String[] array,
javax.xml.stream.XMLStreamWriter out)
Creates an XML-representation of an array. |
void |
toSavedXML(javax.xml.stream.XMLStreamWriter out)
This method writes an XML-representation of this object to the given stream for the purpose of storing this object as a part of a saved game. |
java.lang.String |
toString()
Returns a string representation of the object. |
void |
toXML(javax.xml.stream.XMLStreamWriter out)
This method writes an XML-representation of this object to the given stream. |
void |
toXML(javax.xml.stream.XMLStreamWriter out,
Player player)
This method writes an XML-representation of this object to the given stream. |
void |
toXML(javax.xml.stream.XMLStreamWriter out,
Player player,
boolean showAll,
boolean toSavedGame)
This method writes an XML-representation of this object to the given stream. |
org.w3c.dom.Element |
toXMLElement(Player player,
org.w3c.dom.Document document)
This method writes an XML-representation of this object to the given stream. |
org.w3c.dom.Element |
toXMLElement(Player player,
org.w3c.dom.Document document,
boolean showAll,
boolean toSavedGame)
This method writes an XML-representation of this object to the given stream. |
protected abstract void |
toXMLImpl(javax.xml.stream.XMLStreamWriter out,
Player player,
boolean showAll,
boolean toSavedGame)
This method writes an XML-representation of this object to the given stream. |
void |
updateID()
Updates the id. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String COPYRIGHT
public static final java.lang.String LICENSE
public static final java.lang.String REVISION
| Constructor Detail |
|---|
protected FreeColGameObject()
public FreeColGameObject(Game game)
FreeColGameObject with an automatically assigned
ID and registers this object at the specified Game.
game - The Game in which this object belong.
public FreeColGameObject(Game game,
javax.xml.stream.XMLStreamReader in)
throws javax.xml.stream.XMLStreamException
FreeColGameObject from an Element.
game - The Game in which this object belong.in - The input stream containing the XML.
javax.xml.stream.XMLStreamException - if a problem was encountered
during parsing.
public FreeColGameObject(Game game,
org.w3c.dom.Element e)
FreeColGameObject from an Element.
game - The Game in which this object belong.e - An XML-element that will be used to initialize
this object.
public FreeColGameObject(Game game,
java.lang.String id)
FreeColGameObject
with the given ID. The object should later be
initialized by calling either
readFromXML(XMLStreamReader) or
readFromXMLElement(Element).
game - The Game in which this object belong.id - The unique identifier for this object.| Method Detail |
|---|
public Game getGame()
FreeColGameObject belongs to.
game.public GameOptions getGameOptions()
GameOptions that is associated with the
Game owning this FreeColGameObject.
GameOptions-object as returned
by getGame().getGameOptions().public void setGame(Game game)
FreeColGameObject belongs to.
game - The game.public void dispose()
public boolean isDisposed()
true if this object has been disposed.dispose()public boolean isUninitialized()
FreeColGameObject
is uninitialized. That is: it has been referenced
by another object, but has not yet been updated with
readFromXML(javax.xml.stream.XMLStreamReader).
true if this object is not initialized.public void updateID()
public void toXML(javax.xml.stream.XMLStreamWriter out,
Player player)
throws javax.xml.stream.XMLStreamException
Player will be added to that representation.
out - The target stream.player - The Player this XML-representation is
made for.
javax.xml.stream.XMLStreamException - if there are any problems writing
to the stream.toXML(XMLStreamWriter, Player, boolean, boolean)
public void toXML(javax.xml.stream.XMLStreamWriter out)
throws javax.xml.stream.XMLStreamException
out - The target stream.
javax.xml.stream.XMLStreamException - if there are any problems writing
to the stream.toXML(XMLStreamWriter, Player, boolean, boolean)
public void toSavedXML(javax.xml.stream.XMLStreamWriter out)
throws javax.xml.stream.XMLStreamException
out - The target stream.
javax.xml.stream.XMLStreamException - if there are any problems writing
to the stream.toXML(XMLStreamWriter, Player, boolean, boolean)
public org.w3c.dom.Element toXMLElement(Player player,
org.w3c.dom.Document document)
Player will
be added to that representation if showAll is
set to false.
player - The Player this XML-representation
should be made for, or null if
showAll == true.document - The Document.
public org.w3c.dom.Element toXMLElement(Player player,
org.w3c.dom.Document document,
boolean showAll,
boolean toSavedGame)
Player will
be added to that representation if showAll is
set to false.
player - The Player this XML-representation
should be made for, or null if
showAll == true.document - The Document.showAll - Only attributes visible to player
will be added to the representation if showAll
is set to false.toSavedGame - If true then information that
is only needed when saving a game is added.
public void readFromXMLElement(org.w3c.dom.Element element)
element - An XML-element that will be used to initialize
this object.
protected abstract void toXMLImpl(javax.xml.stream.XMLStreamWriter out,
Player player,
boolean showAll,
boolean toSavedGame)
throws javax.xml.stream.XMLStreamException
Player will
be added to that representation if showAll is
set to false.
out - The target stream.player - The Player this XML-representation
should be made for, or null if
showAll == true.showAll - Only attributes visible to player
will be added to the representation if showAll
is set to false.toSavedGame - If true then information that
is only needed when saving a game is added.
javax.xml.stream.XMLStreamException - if there are any problems writing
to the stream.
protected abstract void readFromXMLImpl(javax.xml.stream.XMLStreamReader in)
throws javax.xml.stream.XMLStreamException
in - The input stream containing the XML.
javax.xml.stream.XMLStreamException - if a problem was encountered
during parsing.
public final void toXML(javax.xml.stream.XMLStreamWriter out,
Player player,
boolean showAll,
boolean toSavedGame)
throws javax.xml.stream.XMLStreamException
Player will
be added to that representation if showAll is
set to false.
out - The target stream.player - The Player this XML-representation
should be made for, or null if
showAll == true.showAll - Only attributes visible to player
will be added to the representation if showAll
is set to false.toSavedGame - If true then information that
is only needed when saving a game is added.
javax.xml.stream.XMLStreamException - if there are any problems writing
to the stream.
public final void readFromXML(javax.xml.stream.XMLStreamReader in)
throws javax.xml.stream.XMLStreamException
in - The input stream containing the XML.
javax.xml.stream.XMLStreamException - if a problem was encountered
during parsing.public static java.lang.String getXMLElementTagName()
public java.lang.String getID()
public java.lang.Integer getIntegerID()
public void setID(java.lang.String newID)
Game
with the new ID.
newID - the unique ID of this object,public void setFakeID(java.lang.String newID)
toXMLElement. This method does not
register the object.
newID - the unique ID of this object,
protected void addModelMessage(FreeColGameObject source,
java.lang.String messageID,
java.lang.String[][] data,
int type)
ModelMessage and uses
getGame().addModelMessage(modelMessage)
to register it.
addModelMessage(this, "messageID", new String[][] {{"%test1%", "ok1"}, {"%test2%", "ok2"})
with the entry "messageID=This is %test1% and %test2%" in Messages,
would give the following message: "This is ok1 and ok2".
source - The source of the message. This is what the message should be
associated with. In addition, the owner of the source is the
player getting the message.messageID - The ID of the message to display. See: Messages.data - Contains the data to be displayed in the message or null.type - The type of message.Canvas,
Game.addModelMessage(ModelMessage),
ModelMessage
protected void addModelMessage(FreeColGameObject source,
java.lang.String messageID,
java.lang.String[][] data,
int type,
java.lang.Object display)
ModelMessage and uses
getGame().addModelMessage(modelMessage)
to register it.
addModelMessage(this, "messageID", new String[][] {{"%test1%", "ok1"}, {"%test2%", "ok2"})
with the entry "messageID=This is %test1% and %test2%" in Messages,
would give the following message: "This is ok1 and ok2".
source - The source of the message. This is what the message should be
associated with. In addition, the owner of the source is the
player getting the message.messageID - The ID of the message to display. See: Messages.data - Contains the data to be displayed in the message or null.type - The type of message.display - The Object to display.Canvas,
Game.addModelMessage(ModelMessage),
ModelMessagepublic boolean hasID(java.lang.String id)
id - The ID to check against.
public boolean equals(FreeColGameObject o)
FreeColGameObject equals this object.
o - The FreeColGameObject to compare against this object.
FreeColGameObject are equal and false otherwise.public boolean equals(java.lang.Object o)
FreeColGameObject equals this object.
equals in class java.lang.Objecto - The FreeColGameObject to compare against this object.
FreeColGameObject are equal and false otherwise.public int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.ObjectString
protected void toArrayElement(java.lang.String tagName,
int[][] array,
javax.xml.stream.XMLStreamWriter out)
throws javax.xml.stream.XMLStreamException
tagName - The tagname for the Element
representing the array.array - The array to represent.out - The target stream.
javax.xml.stream.XMLStreamException - if there are any problems writing
to the stream.
protected int[][] readFromArrayElement(java.lang.String tagName,
javax.xml.stream.XMLStreamReader in,
int[][] arrayType)
throws javax.xml.stream.XMLStreamException
tagName - The tagname for the Element
representing the array.in - The input stream with the XML.arrayType - The type of array to be read.
javax.xml.stream.XMLStreamException - if a problem was encountered
during parsing.
protected static void toArrayElement(java.lang.String tagName,
int[] array,
javax.xml.stream.XMLStreamWriter out)
throws javax.xml.stream.XMLStreamException
tagName - The tagname for the Element
representing the array.array - The array to represent.out - The target stream.
javax.xml.stream.XMLStreamException - if there are any problems writing
to the stream.
protected static int[] readFromArrayElement(java.lang.String tagName,
javax.xml.stream.XMLStreamReader in,
int[] arrayType)
throws javax.xml.stream.XMLStreamException
tagName - The tagname for the Element
representing the array.in - The input stream with the XML.arrayType - The type of array to be read.
javax.xml.stream.XMLStreamException - if a problem was encountered
during parsing.
protected void toArrayElement(java.lang.String tagName,
boolean[][] array,
javax.xml.stream.XMLStreamWriter out)
throws javax.xml.stream.XMLStreamException
tagName - The tagname for the Element
representing the array.array - The array to represent.out - The target stream.
javax.xml.stream.XMLStreamException - if there are any problems writing
to the stream.
protected boolean[][] readFromArrayElement(java.lang.String tagName,
javax.xml.stream.XMLStreamReader in,
boolean[][] arrayType)
throws javax.xml.stream.XMLStreamException
tagName - The tagname for the Element
representing the array.in - The input stream with the XML.arrayType - The type of array to be read.
javax.xml.stream.XMLStreamException - if a problem was encountered
during parsing.
protected void toArrayElement(java.lang.String tagName,
java.lang.String[] array,
javax.xml.stream.XMLStreamWriter out)
throws javax.xml.stream.XMLStreamException
tagName - The tagname for the Element
representing the array.array - The array to represent.out - The target stream.
javax.xml.stream.XMLStreamException - if there are any problems writing
to the stream.
protected java.lang.String[] readFromArrayElement(java.lang.String tagName,
javax.xml.stream.XMLStreamReader in,
java.lang.String[] arrayType)
throws javax.xml.stream.XMLStreamException
tagName - The tagname for the Element
representing the array.in - The input stream with the XML.arrayType - The type of array to be read.
javax.xml.stream.XMLStreamException - if a problem was encountered
during parsing.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||