summaryrefslogtreecommitdiff
path: root/BJC-Utils2/src/main/java/bjc/utils/components
diff options
context:
space:
mode:
authorbculkin2442 <bjculkin@mix.wvu.edu>2016-04-06 13:50:00 -0400
committerbculkin2442 <bjculkin@mix.wvu.edu>2016-04-06 13:50:00 -0400
commit79d3a4a47cbc1fcf17c77c6fc12ff826a3077bac (patch)
treea69e533c558326d583b3aee891fc815208c7b650 /BJC-Utils2/src/main/java/bjc/utils/components
parent4355418164c44170cfb329fcbb7e6f1358c0e314 (diff)
Minor bugfixes/changes, as well as beginnings of CLI systems
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/components')
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/components/ComponentDescriptionFileParser.java50
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/components/FileComponentRepository.java2
2 files changed, 30 insertions, 22 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
index 5ab87bb..254e380 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/components/ComponentDescriptionFileParser.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/components/ComponentDescriptionFileParser.java
@@ -19,54 +19,62 @@ public class ComponentDescriptionFileParser {
// 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
});
reader.addPragma("name", (tokenizer, state) -> {
if (!tokenizer.hasMoreTokens()) {
throw new PragmaFormatException(
"Pragma name requires one string argument");
- } else {
- state.setName(ListUtils.collapseTokens(
- tokenizer.toList((strang) -> strang)));
}
+
+ state.setName(ListUtils
+ .collapseTokens(tokenizer.toList((strang) -> strang)));
});
reader.addPragma("author", (tokenizer, state) -> {
if (!tokenizer.hasMoreTokens()) {
throw new PragmaFormatException(
"Pragma author requires one string argument");
- } else {
- state.setAuthor(ListUtils.collapseTokens(
- tokenizer.toList((strang) -> strang)));
}
+
+ state.setAuthor(ListUtils
+ .collapseTokens(tokenizer.toList((strang) -> strang)));
});
reader.addPragma("description", (tokenizer, state) -> {
if (!tokenizer.hasMoreTokens()) {
throw new PragmaFormatException(
"Pragma description requires one string argument");
- } else {
- state.setDescription(ListUtils.collapseTokens(
- tokenizer.toList((strang) -> strang)));
}
+
+ state.setDescription(ListUtils
+ .collapseTokens(tokenizer.toList((strang) -> strang)));
});
reader.addPragma("version", (tokenizer, state) -> {
if (!tokenizer.hasMoreTokens()) {
throw new PragmaFormatException(
"Pragma name requires one integer argument");
- } else {
- String token = tokenizer.nextToken();
-
- try {
- state.setVersion(Integer.parseInt(token));
- } catch (NumberFormatException nfex) {
- throw new PragmaFormatException("Argument " + token
- + " to version pragma isn't a valid integer. "
- + "This pragma requires a integer argument");
- }
+ }
+
+ String token = tokenizer.nextToken();
+
+ try {
+ state.setVersion(Integer.parseInt(token));
+ } catch (NumberFormatException nfex) {
+ PragmaFormatException pfex = new PragmaFormatException(
+ "Argument " + token
+ + " to version pragma isn't a valid integer. "
+ + "This pragma requires a integer argument");
+
+ pfex.initCause(nfex);
+
+ throw pfex;
}
});
}
@@ -78,8 +86,8 @@ public class ComponentDescriptionFileParser {
* The stream to parse from
* @return The description parsed from the stream
*/
- public static ComponentDescription
- fromStream(InputStream inputSource) {
+ public static ComponentDescription fromStream(
+ InputStream inputSource) {
ComponentDescriptionState readState = reader
.fromStream(inputSource, new ComponentDescriptionState());
diff --git a/BJC-Utils2/src/main/java/bjc/utils/components/FileComponentRepository.java b/BJC-Utils2/src/main/java/bjc/utils/components/FileComponentRepository.java
index 4b8d87b..4aea0d6 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/components/FileComponentRepository.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/components/FileComponentRepository.java
@@ -92,7 +92,7 @@ public class FileComponentRepository<E extends IDescribedComponent>
CLASS_LOGGER
.warn("Error found reading component from file "
+ componentFile.toString()
- + ". This component will not be loaded");
+ + ". This component will not be loaded", ex);
}
}