Class AbstractArchetypeParser<G extends GameObject<G,​A,​R>,​A extends MapArchObject<A>,​R extends Archetype<G,​A,​R>,​B extends AbstractArchetypeBuilder<G,​A,​R>>

    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method 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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 use
        animationObjects - the animation objects instance to use
        archetypeSet - 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.IOException
        Description copied from interface: ArchetypeParser
        Here we read an Archetype from a BufferedReader, parse the data and put the result in the ArchetypeSet in CMainControl.
        Specified by:
        parseArchetypeFromStream in interface ArchetypeParser<G extends GameObject<G,​A,​R>,​A extends MapArchObject<A>,​R extends Archetype<G,​A,​R>>
        Parameters:
        in - BufferedReader file stream of archetype data
        prototype - 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 to
        folderName - the folder name to add the archetype to
        archPath - the archetype path
        invObjects - collects all inventory objects
        errorViewCollector - the error view collector to use
        Throws:
        java.io.IOException - in case of I/O problems
        java.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.IOException
        Called for each processed line.
        Parameters:
        in - the reader reading the archetype definition
        line - the input line
        line2 - the tripped input line
        archetypeBuilder - the archetype builder for the current archetype
        errorViewCollector - the error view collector for reporting errors
        invObjects - 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 or null if archetype is the head part
        archetype - the tail part
        errorViewCollector - 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 attribute
        archetype - the archetype to add
        Returns:
        whether the archetype should be added