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>
ArchetypeParser
.START_ARCH_NAME
Modifier | Constructor and Description |
---|---|
protected |
AbstractArchetypeParser(B archetypeBuilder,
@NotNull AnimationObjects animationObjects,
@NotNull ArchetypeSet<G,A,R> archetypeSet)
Creates an ArchetypeParser.
|
Modifier and Type | Method and Description |
---|---|
protected abstract boolean |
addToPanel(boolean isInternPath,
@NotNull java.lang.String editorFolder,
R archetype)
Returns whether an archetype should be added to the archetype chooser.
|
protected abstract void |
finishParseArchetype(R archetype)
Called after all parts of an archetype have been processed.
|
protected abstract void |
finishParseArchetypePart(R firstArch,
R archetype,
@NotNull ErrorViewCollector errorViewCollector)
Called after the "end" line of a part has been read.
|
protected abstract void |
initParseArchetype()
Called when a new archetype starts.
|
protected abstract boolean |
isStartLine(@NotNull java.lang.String line)
Returns whether a give input line denotes the start of a new archetype.
|
void |
parseArchetypeFromStream(@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 a
BufferedReader , parse the data
and put the result in the ArchetypeSet in CMainControl. |
protected abstract boolean |
processLine(@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.
|
protected AbstractArchetypeParser(@NotNull B archetypeBuilder, @NotNull @NotNull AnimationObjects animationObjects, @NotNull @NotNull ArchetypeSet<G,A,R> archetypeSet)
archetypeBuilder
- the archetype builder to useanimationObjects
- the animation objects instance to usearchetypeSet
- the archetype setpublic 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.IOException
ArchetypeParser
BufferedReader
, parse the data
and put the result in the ArchetypeSet in CMainControl.parseArchetypeFromStream
in interface ArchetypeParser<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
in
- BufferedReader
file 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 usejava.io.IOException
- in case of I/O problemsjava.io.EOFException
- in case an incomplete object was foundprotected abstract void initParseArchetype()
protected abstract boolean isStartLine(@NotNull @NotNull java.lang.String line)
line
- the input lineprotected 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.IOException
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 archetypejava.io.IOException
- if an I/O error occursprotected abstract void finishParseArchetypePart(@Nullable R firstArch, @NotNull R archetype, @NotNull @NotNull ErrorViewCollector errorViewCollector)
firstArch
- the head part or null
if archetype
is
the head partarchetype
- the tail parterrorViewCollector
- the error view collector for reporting errorsprotected abstract void finishParseArchetype(@NotNull R archetype)
archetype
- the archetypeprotected abstract boolean addToPanel(boolean isInternPath, @NotNull @NotNull java.lang.String editorFolder, @NotNull R archetype)
isInternPath
- whether the archetype's path contains "/intern/"editorFolder
- the editor_folder attributearchetype
- the archetype to add