Package net.sf.gridarta.model.io
Class AbstractGameObjectParser<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
- java.lang.Object
-
- net.sf.gridarta.model.io.AbstractGameObjectParser<G,A,R>
-
- All Implemented Interfaces:
GameObjectParser<G,A,R>
- Direct Known Subclasses:
DefaultGameObjectParser,DefaultGameObjectParser,DefaultGameObjectParser
public abstract class AbstractGameObjectParser<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>> extends java.lang.Object implements GameObjectParser<G,A,R>
Abstract base class for classes implementingGameObjectParsers. This class contains the common code for reading game objects. Subclasses can extend the parser (parseLine(String, GameObject). No support for writing is present.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractGameObjectParser(@NotNull GameObjectFactory<G,A,R> gameObjectFactory, @NotNull ArchetypeSet<G,A,R> archetypeSet)Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddModifiedFields(G gameObject, @NotNull java.util.Map<java.lang.String,java.lang.String> fields)Adds the modified fields of aGameObjectto a map.voidcollectTempList(@NotNull java.util.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.Gload(@NotNull java.io.BufferedReader reader, @NotNull java.lang.String firstLine, @Nullable java.util.Collection<G> objects)Parse a game object from a stream.Gload(@NotNull java.io.BufferedReader reader, @Nullable java.util.Collection<G> objects)Parse a game object from a stream.voidsave(@NotNull java.lang.Appendable appendable, G gameObject)Write a game object object to a stream.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.sf.gridarta.model.io.GameObjectParser
getModifiedFields
-
-
-
-
Constructor Detail
-
AbstractGameObjectParser
protected AbstractGameObjectParser(@NotNull @NotNull GameObjectFactory<G,A,R> gameObjectFactory, @NotNull @NotNull ArchetypeSet<G,A,R> archetypeSet)Creates a new instance.- Parameters:
gameObjectFactory- the game object factory for creating new game object instancesarchetypeSet- the archetype set for looking up archetypes
-
-
Method Detail
-
load
@Nullable public G load(@NotNull @NotNull java.io.BufferedReader reader, @Nullable @Nullable java.util.Collection<G> objects) throws java.io.IOException
Description copied from interface:GameObjectParserParse a game object from a stream.- Specified by:
loadin interfaceGameObjectParser<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Parameters:
reader- the stream to readobjects- if non-null, add the read game objects to this collection- Returns:
- the read game object, or
nullif the end of the stream was reached - Throws:
java.io.IOException- if the stream cannot be read or if a parsing error occurs
-
load
@Nullable public G load(@NotNull @NotNull java.io.BufferedReader reader, @NotNull @NotNull java.lang.String firstLine, @Nullable @Nullable java.util.Collection<G> objects) throws java.io.IOException
Description copied from interface:GameObjectParserParse a game object from a stream.- Specified by:
loadin interfaceGameObjectParser<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Parameters:
reader- the stream to readfirstLine- the first line to parse before reading fromreaderobjects- if non-null, add the read game objects to this collection- Returns:
- the read game object, or
nullif the end of the stream was reached - Throws:
java.io.IOException- if the stream cannot be read or if a parsing error occurs- Todo:
- Attributes not relevant during map parsing shouldn't be evaluated here, but in GameObject / ArchetypeParser instead.
-
collectTempList
public void collectTempList(@NotNull @NotNull java.util.List<G> objects)Description copied from interface:GameObjectParserBrowse first through the archetype list and attach map arches to it then browse through the face list and try to find the pictures.- Specified by:
collectTempListin interfaceGameObjectParser<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Parameters:
objects- the list of game objects to collect
-
save
public void save(@NotNull @NotNull java.lang.Appendable appendable, @NotNull G gameObject) throws java.io.IOExceptionDescription copied from interface:GameObjectParserWrite a game object object to a stream.- Specified by:
savein interfaceGameObjectParser<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Parameters:
appendable- the stream to write togameObject- the game object to write- Throws:
java.io.IOException- if the stream cannot be written
-
addModifiedFields
public void addModifiedFields(@NotNull G gameObject, @NotNull @NotNull java.util.Map<java.lang.String,java.lang.String> fields)Description copied from interface:GameObjectParserAdds the modified fields of aGameObjectto a map.- Specified by:
addModifiedFieldsin interfaceGameObjectParser<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Parameters:
gameObject- the game objectfields- the map to update
-
-