Package net.sf.gridarta.model.io
Class AbstractArchetypeParser<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>,B extends AbstractArchetypeBuilder<G,A,R>>
- java.lang.Object
-
- net.sf.gridarta.model.io.AbstractArchetypeParser<G,A,R,B>
-
- All Implemented Interfaces:
ArchetypeParser<G,A,R>
- Direct Known Subclasses:
ArchetypeParser,ArchetypeParser,ArchetypeParser
public abstract class AbstractArchetypeParser<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>,B extends AbstractArchetypeBuilder<G,A,R>> extends java.lang.Object implements ArchetypeParser<G,A,R>
Abstract base implementation ofArchetypeParser.
-
-
Field Summary
-
Fields inherited from interface net.sf.gridarta.model.io.ArchetypeParser
START_ARCH_NAME
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractArchetypeParser(B archetypeBuilder, @NotNull AnimationObjects animationObjects, @NotNull ArchetypeSet<G,A,R> archetypeSet)Creates an ArchetypeParser.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract booleanaddToPanel(boolean isInternPath, @NotNull java.lang.String editorFolder, R archetype)Returns whether an archetype should be added to the archetype chooser.protected abstract voidfinishParseArchetype(R archetype)Called after all parts of an archetype have been processed.protected abstract voidfinishParseArchetypePart(R firstArch, R archetype, @NotNull ErrorViewCollector errorViewCollector)Called after the "end" line of a part has been read.protected abstract voidinitParseArchetype()Called when a new archetype starts.protected abstract booleanisStartLine(@NotNull java.lang.String line)Returns whether a give input line denotes the start of a new archetype.voidparseArchetypeFromStream(@NotNull java.io.BufferedReader in, R prototype, @Nullable java.lang.String line, @Nullable java.lang.String archName, @NotNull java.lang.String panelName, @NotNull java.lang.String folderName, @NotNull java.lang.String archPath, @NotNull java.util.List<G> invObjects, @NotNull ErrorViewCollector errorViewCollector)Here we read an Archetype from aBufferedReader, parse the data and put the result in the ArchetypeSet in CMainControl.protected abstract booleanprocessLine(@NotNull java.io.BufferedReader in, @NotNull java.lang.String line, @NotNull java.lang.String line2, B archetypeBuilder, @NotNull ErrorViewCollector errorViewCollector, @NotNull java.util.List<G> invObjects)Called for each processed line.
-
-
-
Constructor Detail
-
AbstractArchetypeParser
protected AbstractArchetypeParser(@NotNull B archetypeBuilder, @NotNull @NotNull AnimationObjects animationObjects, @NotNull @NotNull ArchetypeSet<G,A,R> archetypeSet)Creates an ArchetypeParser.- Parameters:
archetypeBuilder- the archetype builder to useanimationObjects- the animation objects instance to usearchetypeSet- the archetype set
-
-
Method Detail
-
parseArchetypeFromStream
public void parseArchetypeFromStream(@NotNull @NotNull java.io.BufferedReader in, @Nullable R prototype, @Nullable @Nullable java.lang.String line, @Nullable @Nullable java.lang.String archName, @NotNull @NotNull java.lang.String panelName, @NotNull @NotNull java.lang.String folderName, @NotNull @NotNull java.lang.String archPath, @NotNull @NotNull java.util.List<G> invObjects, @NotNull @NotNull ErrorViewCollector errorViewCollector) throws java.io.IOExceptionDescription copied from interface:ArchetypeParserHere we read an Archetype from aBufferedReader, parse the data and put the result in the ArchetypeSet in CMainControl.- Specified by:
parseArchetypeFromStreamin interfaceArchetypeParser<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Parameters:
in-BufferedReaderfile stream of archetype dataprototype- Prototype Archetype (only for artifacts)line- first line, pre-parsed (only for artifacts)archName- archetype-object name (only for artifacts)panelName- the panel name to add the archetype tofolderName- the folder name to add the archetype toarchPath- the archetype pathinvObjects- collects all inventory objectserrorViewCollector- the error view collector to use- Throws:
java.io.IOException- in case of I/O problemsjava.io.EOFException- in case an incomplete object was found
-
initParseArchetype
protected abstract void initParseArchetype()
Called when a new archetype starts.
-
isStartLine
protected abstract boolean isStartLine(@NotNull @NotNull java.lang.String line)Returns whether a give input line denotes the start of a new archetype.- Parameters:
line- the input line- Returns:
- whether the line is a start line
-
processLine
protected abstract boolean processLine(@NotNull @NotNull java.io.BufferedReader in, @NotNull @NotNull java.lang.String line, @NotNull @NotNull java.lang.String line2, @NotNull B archetypeBuilder, @NotNull @NotNull ErrorViewCollector errorViewCollector, @NotNull @NotNull java.util.List<G> invObjects) throws java.io.IOExceptionCalled for each processed line.- Parameters:
in- the reader reading the archetype definitionline- the input lineline2- the tripped input linearchetypeBuilder- the archetype builder for the current archetypeerrorViewCollector- the error view collector for reporting errorsinvObjects- the inventory objects of the current archetype- Returns:
- whether the line has been consumed
- Throws:
java.io.IOException- if an I/O error occurs
-
finishParseArchetypePart
protected abstract void finishParseArchetypePart(@Nullable R firstArch, @NotNull R archetype, @NotNull @NotNull ErrorViewCollector errorViewCollector)Called after the "end" line of a part has been read.- Parameters:
firstArch- the head part ornullifarchetypeis the head partarchetype- the tail parterrorViewCollector- the error view collector for reporting errors
-
finishParseArchetype
protected abstract void finishParseArchetype(@NotNull R archetype)Called after all parts of an archetype have been processed.- Parameters:
archetype- the archetype
-
addToPanel
protected abstract boolean addToPanel(boolean isInternPath, @NotNull @NotNull java.lang.String editorFolder, @NotNull R archetype)Returns whether an archetype should be added to the archetype chooser.- Parameters:
isInternPath- whether the archetype's path contains "/intern/"editorFolder- the editor_folder attributearchetype- the archetype to add- Returns:
- whether the archetype should be added
-
-