Gridarta Editor
net.sf.gridarta.model.io.AbstractGameObjectParser< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R > Class Template Referenceabstract

Abstract base class for classes implementing GameObjectParsers. More...

+ Inheritance diagram for net.sf.gridarta.model.io.AbstractGameObjectParser< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >:
+ Collaboration diagram for net.sf.gridarta.model.io.AbstractGameObjectParser< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >:

Public Member Functions

void addModifiedFields (@NotNull final G gameObject, @NotNull final Map< String, String > fields)
 
void collectTempList (@NotNull final List< G > objects)
 
load (@NotNull final BufferedReader reader, @Nullable final Collection< G > objects) throws IOException
 
load (@NotNull final BufferedReader reader, @NotNull final String firstLine, @Nullable final Collection< G > objects) throws IOException
 
void save (@NotNull final Appendable appendable, @NotNull final G gameObject) throws IOException
 
- Public Member Functions inherited from net.sf.gridarta.model.io.GameObjectParser< G, A, R >
void addModifiedFields ( @NotNull G gameObject, @NotNull Map< String, String > fields)
 Adds the modified fields of a GameObject to a map. More...
 
void collectTempList ( @NotNull List< G > objects)
 Browse first through the archetype list and attach map arches to it then browse through the face list and try to find the pictures. More...
 
Map< String, String > getModifiedFields ( @NotNull G gameObject)
 Returns the modified fields of a GameObject. More...
 
load ( @NotNull BufferedReader reader, @Nullable Collection< G > objects) throws IOException
 Parse a game object from a stream. More...
 
load ( @NotNull BufferedReader reader, @NotNull String firstLine, @Nullable Collection< G > objects) throws IOException
 Parse a game object from a stream. More...
 
void save ( @NotNull Appendable appendable, @NotNull G gameObject) throws IOException
 Write a game object object to a stream. More...
 

Protected Member Functions

 AbstractGameObjectParser (@NotNull final GameObjectFactory< G, A, R > gameObjectFactory, @NotNull final ArchetypeSet< G, A, R > archetypeSet)
 Create a new instance. More...
 
boolean parseLine (@NotNull final String line, @NotNull final G gameObject)
 Parse one line. More...
 

Private Member Functions

void expandMulti (@NotNull final G gameObject, @NotNull final Collection< G > objects)
 If the given gameObject is a multi-part head, we generate the appropriate tail (from the archetype stack) and attach it. More...
 

Static Private Member Functions

static String readArchName (@NotNull final BufferedReader reader, @NotNull final String firstLine) throws IOException
 Read an archetype name. More...
 

Private Attributes

final ArchetypeSet< G, A, R > archetypeSet
 The ArchetypeSet for looking up archetypes. More...
 
final GameObjectFactory< G, A, R > gameObjectFactory
 The game object factory for creating new game object instances. More...
 

Static Private Attributes

static final Category LOG = Logger.getLogger(AbstractGameObjectParser.class)
 The Logger for printing log messages. More...
 

Detailed Description

Abstract base class for classes implementing GameObjectParsers.

This class contains the common code for reading game objects. Subclasses can extend the parser (GameObject). No support for writing is present.

Author
Andreas Kirschbaum

Definition at line 49 of file AbstractGameObjectParser.java.

Constructor & Destructor Documentation

◆ AbstractGameObjectParser()

net.sf.gridarta.model.io.AbstractGameObjectParser< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.AbstractGameObjectParser ( @NotNull final GameObjectFactory< G, A, R >  gameObjectFactory,
@NotNull final ArchetypeSet< G, A, R >  archetypeSet 
)
protected

Create a new instance.

Parameters
gameObjectFactorythe game object factory for creating new game object instances
archetypeSetthe archetype set for looking up archetypes

Definition at line 74 of file AbstractGameObjectParser.java.

Member Function Documentation

◆ addModifiedFields()

void net.sf.gridarta.model.io.AbstractGameObjectParser< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.addModifiedFields ( @NotNull final G  gameObject,
@NotNull final Map< String, String >  fields 
)

◆ collectTempList()

void net.sf.gridarta.model.io.AbstractGameObjectParser< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.collectTempList ( @NotNull final List< G >  objects)

Definition at line 182 of file AbstractGameObjectParser.java.

◆ expandMulti()

void net.sf.gridarta.model.io.AbstractGameObjectParser< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.expandMulti ( @NotNull final G  gameObject,
@NotNull final Collection< G >  objects 
)
private

If the given gameObject is a multi-part head, we generate the appropriate tail (from the archetype stack) and attach it.

The new gameObjects get added to the temp list, not a map. This method should only be called after map-loading. The ArchetypeSet should be fully initialized at this point.

Parameters
gameObjectmulti-part head that needs tail attached
objectslist with objects that should get the tails attached
Todo:
think whether expanding multi-parts here is a good idea, maybe MapModel is a better place.

Definition at line 264 of file AbstractGameObjectParser.java.

Referenced by net.sf.gridarta.model.io.AbstractGameObjectParser< TestGameObject, TestMapArchObject, TestArchetype >.collectTempList().

+ Here is the caller graph for this function:

◆ load() [1/2]

G net.sf.gridarta.model.io.AbstractGameObjectParser< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.load ( @NotNull final BufferedReader  reader,
@Nullable final Collection< G >  objects 
) throws IOException

◆ load() [2/2]

G net.sf.gridarta.model.io.AbstractGameObjectParser< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.load ( @NotNull final BufferedReader  reader,
@NotNull final String  firstLine,
@Nullable final Collection< G >  objects 
) throws IOException
Todo:
Attributes not relevant during map parsing shouldn't be evaluated here, but in GameObject / ArchetypeParser instead.

Definition at line 96 of file AbstractGameObjectParser.java.

◆ parseLine()

boolean net.sf.gridarta.model.io.AbstractGameObjectParser< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.parseLine ( @NotNull final String  line,
@NotNull final G  gameObject 
)
protected

Parse one line.

This function performs actions needed for this editor.

Parameters
linethe line to process
gameObjectthe current game object
Returns
whether the line has been consumed; if
false
is returned, the default parsing is performed UnusedDeclaration

Definition at line 155 of file AbstractGameObjectParser.java.

Referenced by net.sf.gridarta.model.io.AbstractGameObjectParser< TestGameObject, TestMapArchObject, TestArchetype >.load().

+ Here is the caller graph for this function:

◆ readArchName()

static String net.sf.gridarta.model.io.AbstractGameObjectParser< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.readArchName ( @NotNull final BufferedReader  reader,
@NotNull final String  firstLine 
) throws IOException
staticprivate

Read an archetype name.

Parameters
readerthe reader to read from
firstLinethe first line to parse before reading from
reader
Returns
the archetype name, or
null
if the end of the file was reached
Exceptions
IOExceptionif an error occurs

Definition at line 169 of file AbstractGameObjectParser.java.

Referenced by net.sf.gridarta.model.io.AbstractGameObjectParser< TestGameObject, TestMapArchObject, TestArchetype >.load().

+ Here is the caller graph for this function:

◆ save()

void net.sf.gridarta.model.io.AbstractGameObjectParser< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.save ( @NotNull final Appendable  appendable,
@NotNull final G  gameObject 
) throws IOException

Member Data Documentation

◆ archetypeSet

final ArchetypeSet<G, A, R> net.sf.gridarta.model.io.AbstractGameObjectParser< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.archetypeSet
private

◆ gameObjectFactory

final GameObjectFactory<G, A, R> net.sf.gridarta.model.io.AbstractGameObjectParser< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.gameObjectFactory
private

The game object factory for creating new game object instances.

Definition at line 60 of file AbstractGameObjectParser.java.

Referenced by net.sf.gridarta.model.io.AbstractGameObjectParser< TestGameObject, TestMapArchObject, TestArchetype >.AbstractGameObjectParser().

◆ LOG

final Category net.sf.gridarta.model.io.AbstractGameObjectParser< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.LOG = Logger.getLogger(AbstractGameObjectParser.class)
staticprivate

The Logger for printing log messages.

Definition at line 54 of file AbstractGameObjectParser.java.


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