Gridarta Editor
net.sf.gridarta.model.baseobject.GameObjectText Class Reference

A set of key/value attributes. More...

+ Inheritance diagram for net.sf.gridarta.model.baseobject.GameObjectText:
+ Collaboration diagram for net.sf.gridarta.model.baseobject.GameObjectText:

Public Member Functions

boolean addObjectText (@NotNull final String line, @NotNull final AbstractBaseObject<?, ?, ?, ?> baseObject)
 Appends a line to the object text. More...
 
boolean equals (@Nullable final Object obj)
 
 GameObjectText ()
 Creates a new instance. More...
 
 GameObjectText (@NotNull final GameObjectText gameObjectText)
 Creates a new instance as a copy of another instance. More...
 
Collection< String > getAttributeKeys ()
 Returns all attribute keys of this object. More...
 
String getAttributeValue (@NotNull final String attributeName)
 Returns an attribute value by attribute name. More...
 
String getObjectText ()
 Returns the object text. More...
 
int hashCode ()
 
boolean hasObjectText ()
 Returns whether an object text is set. More...
 
boolean removeAttribute (@NotNull final String attributeName, @NotNull final AbstractBaseObject<?, ?, ?, ?> baseObject)
 Removes an attribute. More...
 
boolean setAttributeValue (@NotNull final String attributeName, final boolean sameAsInArchetype, @NotNull final String value, @NotNull final AbstractBaseObject<?, ?, ?, ?> baseObject)
 Updates an attribute's value. More...
 
boolean setObjectText (@NotNull final String objectText, @NotNull final AbstractBaseObject<?, ?, ?, ?> baseObject)
 Sets the object text. More...
 

Private Member Functions

void clearAttributeCache ()
 Clears the attribute cache. More...
 
String getAttributeValueInt (@NotNull final String attributeName)
 Returns the requested attribute value from the objectText. More...
 

Private Attributes

final Map< String, String > attributeCache = new HashMap<>()
 Map which caches attributes for faster access. More...
 
final StringBuilder objectText = new StringBuilder()
 The objectText with the differences from the Archetype. More...
 

Static Private Attributes

static final long serialVersionUID = 1L
 The serial version UID. More...
 

Detailed Description

A set of key/value attributes.

Author
Christian Hujer

Definition at line 35 of file GameObjectText.java.

Constructor & Destructor Documentation

◆ GameObjectText() [1/2]

net.sf.gridarta.model.baseobject.GameObjectText.GameObjectText ( )

Creates a new instance.

Definition at line 61 of file GameObjectText.java.

Referenced by net.sf.gridarta.model.baseobject.GameObjectText.equals().

+ Here is the caller graph for this function:

◆ GameObjectText() [2/2]

net.sf.gridarta.model.baseobject.GameObjectText.GameObjectText ( @NotNull final GameObjectText  gameObjectText)

Creates a new instance as a copy of another instance.

Parameters
gameObjectTextthe other instance

Definition at line 68 of file GameObjectText.java.

Member Function Documentation

◆ addObjectText()

boolean net.sf.gridarta.model.baseobject.GameObjectText.addObjectText ( @NotNull final String  line,
@NotNull final AbstractBaseObject<?, ?, ?, ?>  baseObject 
)

Appends a line to the object text.

Parameters
linethe line to append, may contain '
' for appending multiple lines
baseObjectthe game object to notify of changes
Returns
whether the object text was changed

Definition at line 139 of file GameObjectText.java.

References net.sf.gridarta.model.baseobject.GameObjectText.clearAttributeCache().

Referenced by net.sf.gridarta.model.baseobject.AbstractBaseObject< G, A, R, G >.addObjectText().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ clearAttributeCache()

void net.sf.gridarta.model.baseobject.GameObjectText.clearAttributeCache ( )
private

Clears the attribute cache.

Definition at line 75 of file GameObjectText.java.

Referenced by net.sf.gridarta.model.baseobject.GameObjectText.addObjectText(), and net.sf.gridarta.model.baseobject.GameObjectText.setObjectText().

+ Here is the caller graph for this function:

◆ equals()

boolean net.sf.gridarta.model.baseobject.GameObjectText.equals ( @Nullable final Object  obj)

◆ getAttributeKeys()

Collection<String> net.sf.gridarta.model.baseobject.GameObjectText.getAttributeKeys ( )

Returns all attribute keys of this object.

Returns
the attribute keys

Definition at line 261 of file GameObjectText.java.

References net.sf.gridarta.utils.StringUtils.PATTERN_END_OF_LINE.

Referenced by net.sf.gridarta.model.baseobject.AbstractBaseObject< G, A, R, G >.getAttributeKeys().

+ Here is the caller graph for this function:

◆ getAttributeValue()

String net.sf.gridarta.model.baseobject.GameObjectText.getAttributeValue ( @NotNull final String  attributeName)

Returns an attribute value by attribute name.

Parameters
attributeNamethe attribute name
Returns
the attribute value or
null

Definition at line 85 of file GameObjectText.java.

References net.sf.gridarta.model.baseobject.GameObjectText.getAttributeValueInt().

Referenced by net.sf.gridarta.model.baseobject.AbstractBaseObject< G, A, R, G >.getAttributeValue().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAttributeValueInt()

String net.sf.gridarta.model.baseobject.GameObjectText.getAttributeValueInt ( @NotNull final String  attributeName)
private

Returns the requested attribute value from the objectText.

Parameters
attributeNamethe name of the attribute to search
Returns
the attribute value from the objectText or
null
if not found

Definition at line 103 of file GameObjectText.java.

References net.sf.gridarta.utils.StringUtils.PATTERN_END_OF_LINE.

Referenced by net.sf.gridarta.model.baseobject.GameObjectText.getAttributeValue().

+ Here is the caller graph for this function:

◆ getObjectText()

String net.sf.gridarta.model.baseobject.GameObjectText.getObjectText ( )

Returns the object text.

Returns
the object text

Definition at line 120 of file GameObjectText.java.

Referenced by net.sf.gridarta.model.baseobject.AbstractBaseObject< G, A, R, G >.getObjectText().

+ Here is the caller graph for this function:

◆ hashCode()

int net.sf.gridarta.model.baseobject.GameObjectText.hashCode ( )

Definition at line 187 of file GameObjectText.java.

◆ hasObjectText()

boolean net.sf.gridarta.model.baseobject.GameObjectText.hasObjectText ( )

Returns whether an object text is set.

Returns
whether an object text is set

Definition at line 128 of file GameObjectText.java.

Referenced by net.sf.gridarta.model.baseobject.AbstractBaseObject< G, A, R, G >.isDefaultGameObject().

+ Here is the caller graph for this function:

◆ removeAttribute()

boolean net.sf.gridarta.model.baseobject.GameObjectText.removeAttribute ( @NotNull final String  attributeName,
@NotNull final AbstractBaseObject<?, ?, ?, ?>  baseObject 
)

Removes an attribute.

Parameters
attributeNamethe attribute name
baseObjectthe game object to notify of changes
Returns
whether the object text has changed

Definition at line 209 of file GameObjectText.java.

References net.sf.gridarta.utils.StringUtils.PATTERN_END_OF_LINE, and net.sf.gridarta.model.baseobject.GameObjectText.setObjectText().

Referenced by net.sf.gridarta.model.baseobject.AbstractBaseObject< G, A, R, G >.removeAttribute(), and net.sf.gridarta.model.baseobject.GameObjectText.setAttributeValue().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setAttributeValue()

boolean net.sf.gridarta.model.baseobject.GameObjectText.setAttributeValue ( @NotNull final String  attributeName,
final boolean  sameAsInArchetype,
@NotNull final String  value,
@NotNull final AbstractBaseObject<?, ?, ?, ?>  baseObject 
)

Updates an attribute's value.

Parameters
attributeNamethe attribute name
sameAsInArchetypewhether the new value is the same as in the archetype
valuethe new value
baseObjectthe game object to notify of changes
Returns
whether the object text has changed

Definition at line 230 of file GameObjectText.java.

References net.sf.gridarta.utils.StringUtils.PATTERN_END_OF_LINE, net.sf.gridarta.model.baseobject.GameObjectText.removeAttribute(), and net.sf.gridarta.model.baseobject.GameObjectText.setObjectText().

Referenced by net.sf.gridarta.model.baseobject.AbstractBaseObject< G, A, R, G >.setAttributeInt(), and net.sf.gridarta.model.baseobject.AbstractBaseObject< G, A, R, G >.setAttributeString().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setObjectText()

boolean net.sf.gridarta.model.baseobject.GameObjectText.setObjectText ( @NotNull final String  objectText,
@NotNull final AbstractBaseObject<?, ?, ?, ?>  baseObject 
)

Sets the object text.

Parameters
objectTextthe object text to set
baseObjectthe game object to notify of changes
Returns
whether the object text was changed

Definition at line 162 of file GameObjectText.java.

References net.sf.gridarta.model.baseobject.GameObjectText.clearAttributeCache(), and net.sf.gridarta.utils.StringUtils.sortLines().

Referenced by net.sf.gridarta.model.baseobject.GameObjectText.removeAttribute(), net.sf.gridarta.model.baseobject.GameObjectText.setAttributeValue(), and net.sf.gridarta.model.baseobject.AbstractBaseObject< G, A, R, G >.setObjectText().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ attributeCache

final Map<String, String> net.sf.gridarta.model.baseobject.GameObjectText.attributeCache = new HashMap<>()
private

Map which caches attributes for faster access.

Key: attribute name value: attribute value

Definition at line 56 of file GameObjectText.java.

◆ objectText

final StringBuilder net.sf.gridarta.model.baseobject.GameObjectText.objectText = new StringBuilder()
private

The objectText with the differences from the Archetype.

Note
Every line in the objectText must end on '
', including the last line.

Definition at line 49 of file GameObjectText.java.

Referenced by net.sf.gridarta.model.baseobject.GameObjectText.equals().

◆ serialVersionUID

final long net.sf.gridarta.model.baseobject.GameObjectText.serialVersionUID = 1L
staticprivate

The serial version UID.

Definition at line 40 of file GameObjectText.java.


The documentation for this class was generated from the following file: