diff options
| author | Benjamin J. Culkin <bjculkin@mix.wvu.edu> | 2017-10-08 22:39:59 -0300 |
|---|---|---|
| committer | Benjamin J. Culkin <bjculkin@mix.wvu.edu> | 2017-10-08 22:39:59 -0300 |
| commit | c82e3b3b2de0633317ec8fc85925e91422820597 (patch) | |
| tree | 96567416ce23c5ce85601f9cedc3a94bb1c55cba /BJC-Utils2/src/main/java/bjc/utils/components/ComponentDescriptionFileParser.java | |
| parent | b3ac1c8690c3e14c879913e5dcc03a5f5e14876e (diff) | |
Start splitting into maven modules
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/components/ComponentDescriptionFileParser.java')
| -rw-r--r-- | BJC-Utils2/src/main/java/bjc/utils/components/ComponentDescriptionFileParser.java | 65 |
1 files changed, 0 insertions, 65 deletions
diff --git a/BJC-Utils2/src/main/java/bjc/utils/components/ComponentDescriptionFileParser.java b/BJC-Utils2/src/main/java/bjc/utils/components/ComponentDescriptionFileParser.java deleted file mode 100644 index f7ddaff..0000000 --- a/BJC-Utils2/src/main/java/bjc/utils/components/ComponentDescriptionFileParser.java +++ /dev/null @@ -1,65 +0,0 @@ -package bjc.utils.components; - -import static bjc.utils.ioutils.RuleBasedReaderPragmas.buildInteger; -import static bjc.utils.ioutils.RuleBasedReaderPragmas.buildStringCollapser; - -import java.io.InputStream; - -import bjc.utils.ioutils.RuleBasedConfigReader; - -/** - * Read a component description from a file - * - * @author ben - * - */ -public class ComponentDescriptionFileParser { - // The reader used to read in component descriptions - private static RuleBasedConfigReader<ComponentDescriptionState> reader; - - // Initialize the reader and its pragmas - static { - // This reader works entirely off of pragmas, so no need to - // handle - // rules - reader = new RuleBasedConfigReader<>((tokenizer, statePair) -> { - // Don't need to do anything on rule start - }, (tokenizer, state) -> { - // Don't need to do anything on rule continuation - }, (state) -> { - // Don't need to do anything on rule end - }); - - setupReaderPragmas(); - } - - /** - * Parse a component description from a stream - * - * @param inputSource - * The stream to parse from - * @return The description parsed from the stream - */ - public static ComponentDescription fromStream(final InputStream inputSource) { - if (inputSource == null) throw new NullPointerException("Input source must not be null"); - - final ComponentDescriptionState readState = reader.fromStream(inputSource, - new ComponentDescriptionState()); - - return readState.toDescription(); - } - - /* - * Create all the pragmas the reader needs to function - */ - private static void setupReaderPragmas() { - reader.addPragma("name", buildStringCollapser("name", (name, state) -> state.setName(name))); - - reader.addPragma("author", buildStringCollapser("author", (author, state) -> state.setAuthor(author))); - - reader.addPragma("description", buildStringCollapser("description", - (description, state) -> state.setDescription(description))); - - reader.addPragma("version", buildInteger("version", (version, state) -> state.setVersion(version))); - } -} |
