|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.jadv.basic.SavedObject
This class implements the main Object, that is stored inside the ObjectManager
Field Summary | |
private java.util.HashMap |
_Attributes
|
private boolean |
_changed
|
private java.lang.String |
_id
|
private java.lang.String |
_name
|
private SavedObject |
_next
|
private SavedObject |
_prev
|
private boolean |
_valid
|
static ObjectManager |
ObjMan
|
private static java.security.SecureRandom |
seeder
|
Constructor Summary | |
SavedObject()
Constructor of SavedObject |
Method Summary | |
static void |
addEvent(Event evt)
Add an event to the EventQueue of the game |
boolean |
canBeSwapped()
Returns true, if the object can be swapped out! |
void |
create()
This function is only called, when the object is created! |
static java.util.HashMap |
createAttributes(org.jdom.Element el)
Create a HashMap with all attributes, that are given in the Element! |
static SavedObject |
createObject(org.jdom.Element desc)
Create a new Object out of a xml-Description! |
static SavedObject |
createObject(java.util.HashMap desc)
Create a new Object out of a xml-Description! |
static java.lang.String |
createUUID(java.lang.Object obj)
Creates a new unique ID. |
void |
destroyObject()
Destroy this object (Object will be deleted completly!) |
static SavedObject |
findObject(java.lang.String id)
Find object with the given ID |
java.lang.String |
getAttribute(java.lang.String Name)
Get the Attribute with the name |
java.util.HashMap |
getAttributes()
Returns all Attributes |
boolean |
getAutoStart()
Return, if the Object should be loaded at Serverstart |
java.lang.String |
getDeveloper(java.lang.String cname)
Returns the responsible developer of a class. |
java.lang.String |
getId()
Get the ID of the Object |
int |
getIntAttribute(java.lang.String Name)
Get an int-Value of an Attribute! |
int |
getIntAttribute(java.lang.String Name,
int def)
Get an int-Value of an Attribute! |
java.lang.String |
getName()
Get the name of the object. |
SavedObject |
getNext()
Get the next object of the internal List |
SavedObject |
getPrev()
Get the previous Object of the internal List |
private static java.security.SecureRandom |
getSeeder()
Returns the internal SecureRandom seeder! |
static java.lang.String |
hexFormat(int value,
int length)
Convert an integer value into hex-format with length chars (e.g. hexFormat(31,3) ==> 01F) |
void |
init(java.util.HashMap attribs)
Initialisation of the object! |
boolean |
isChanged()
Returns if this Object is changed or not! |
boolean |
isValid()
Returns if this Object is valid or not! |
static SavedObject |
loadObject(java.util.HashMap desc)
|
void |
markChanged()
Mark the object as changed - the object must be saved! |
void |
markNotChanged()
Mark the object as not changed - the object must not be saved! |
static void |
mergeAttributes(java.util.HashMap attribs,
java.util.HashMap oldAttribs)
mergeAttributes Merge the Attributes of two Objects into each other! |
void |
removeFromList()
This object is removed from the list of all SavedObjects. |
static SavedObject |
replaceObject(org.jdom.Element el)
Delete an object and create a new one instead ... |
static SavedObject |
replaceObject(java.util.HashMap attribs)
Delete an object and create a new one instead ... |
void |
save()
Save this Object! |
void |
saveObject()
|
java.lang.String |
setAttribute(java.lang.String Name,
java.lang.String Value)
setAttribute(name, value) Set the Attribute name := value This function returns the old value! |
void |
setId(java.lang.String id)
setId(id) Set the ID of the Object |
void |
setIntAttribute(java.lang.String name,
int val)
Set an int-value inside an Attribute. |
void |
setName(java.lang.String name)
setName(name) Set the internal name of the Object |
void |
storeAfter(SavedObject obj)
storeAfter(obj) This function is internaly used from the ObjectManager. |
void |
swapOut()
swapOut() If an Object is no longer used, call this function! |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private SavedObject _next
private SavedObject _prev
private java.lang.String _id
private boolean _changed
private java.lang.String _name
private boolean _valid
public static ObjectManager ObjMan
private static java.security.SecureRandom seeder
private java.util.HashMap _Attributes
Constructor Detail |
public SavedObject()
Object.Object()
Method Detail |
public static void addEvent(Event evt)
evt
- - the event to add.public boolean canBeSwapped()
public void create()
public static java.util.HashMap createAttributes(org.jdom.Element el)
el
- - Element with all attributes inside
public static SavedObject createObject(org.jdom.Element desc)
desc
- - Description of the Object
public static SavedObject createObject(java.util.HashMap desc)
desc
- - Description of the Object
public static java.lang.String createUUID(java.lang.Object obj)
public void destroyObject()
public static SavedObject findObject(java.lang.String id)
id
- - id of the object
public java.lang.String getAttribute(java.lang.String Name)
Name
- - Name of the attribute
public java.util.HashMap getAttributes()
public boolean getAutoStart()
public java.lang.String getDeveloper(java.lang.String cname)
cname
- - The name of the class
public java.lang.String getId()
public int getIntAttribute(java.lang.String Name, int def)
Name
- - Name of the attributedef
- - default value of the attribute
public int getIntAttribute(java.lang.String Name)
Name
- - Name of the attribute
public java.lang.String getName()
public SavedObject getNext()
public SavedObject getPrev()
private static java.security.SecureRandom getSeeder()
public static java.lang.String hexFormat(int value, int length)
value
- - value to convert to hex formatlength
- - length of target hex-String
public void init(java.util.HashMap attribs)
attribs
- - The attributes of the objectpublic boolean isValid()
public boolean isChanged()
public static SavedObject loadObject(java.util.HashMap desc)
public void markChanged()
public void markNotChanged()
public static void mergeAttributes(java.util.HashMap attribs, java.util.HashMap oldAttribs)
attribs
- - HashMap of new new ObjectoldAttribs
- - HashMap of old Objectpublic void removeFromList()
public static SavedObject replaceObject(org.jdom.Element el)
el
- - Element of Attributes of new Object
public static SavedObject replaceObject(java.util.HashMap attribs)
attribs
- - Attributes of new Object
public void save()
If you store attributes inside local variables (for speed reasons), you have to write a save() function, that stores all variables inside the HashMap again.
public void saveObject()
public java.lang.String setAttribute(java.lang.String Name, java.lang.String Value)
Name
- Value
-
public void setId(java.lang.String id)
id
- public void setIntAttribute(java.lang.String name, int val)
name
- val
- public void setName(java.lang.String name)
name
- public void storeAfter(SavedObject obj)
obj
- public void swapOut()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |