summaryrefslogtreecommitdiff
path: root/BJC-Utils2/src/main/java/bjc/utils/PropertyDB.java
diff options
context:
space:
mode:
authorstudent <student@192.168.1.186>2017-04-07 11:34:00 -0400
committerstudent <student@192.168.1.186>2017-04-07 11:34:00 -0400
commit7692fa077a84972231948354d3f0de99f27a9ad7 (patch)
treea7539aff7732339f7655c35f2c2c07723618127b /BJC-Utils2/src/main/java/bjc/utils/PropertyDB.java
parent63d88eb8db1f7a6d5924ec2a8b7f462373d5ac9a (diff)
Fix property bugs
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/PropertyDB.java')
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/PropertyDB.java30
1 files changed, 18 insertions, 12 deletions
diff --git a/BJC-Utils2/src/main/java/bjc/utils/PropertyDB.java b/BJC-Utils2/src/main/java/bjc/utils/PropertyDB.java
index 20be2fc..3f2c078 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/PropertyDB.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/PropertyDB.java
@@ -15,8 +15,8 @@ import java.util.regex.Pattern;
*
*/
public class PropertyDB {
- private static SimpleProperties regexes;
- private static Map<String, Pattern> compiledRegexes;
+ private static SimpleProperties regexes;
+ private static Map<String, Pattern> compiledRegexes;
private static SimpleProperties formats;
@@ -37,13 +37,20 @@ public class PropertyDB {
*/
public static void reloadProperties() {
loadLock.write(() -> {
+ System.out.println("Reading regex properties:");
regexes = new SimpleProperties();
regexes.loadFrom(PropertyDB.class.getResourceAsStream("/regexes.sprop"), false);
+ System.out.println();
compiledRegexes = new HashMap<>();
+ System.out.println("Reading format properties:");
formats = new SimpleProperties();
formats.loadFrom(PropertyDB.class.getResourceAsStream("/formats.sprop"), false);
+ System.out.println();
+
+ if (regexes.equals(formats))
+ System.out.println("WAT");
});
}
@@ -51,13 +58,13 @@ public class PropertyDB {
* Retrieve a persisted regular expression.
*
* @param key
- * The name of the regular expression.
+ * The name of the regular expression.
*
* @return The regular expression with that name.
*/
public static String getRegex(String key) {
return loadLock.read(() -> {
- if(!regexes.containsKey(key)) {
+ if (!regexes.containsKey(key)) {
String msg = String.format("No regular expression named '%s' found", key);
throw new NoSuchElementException(msg);
@@ -72,13 +79,13 @@ public class PropertyDB {
* expression.
*
* @param key
- * The name of the regular expression.
+ * The name of the regular expression.
*
* @return The regular expression with that name.
*/
public static Pattern getCompiledRegex(String key) {
return loadLock.read(() -> {
- if(!regexes.containsKey(key)) {
+ if (!regexes.containsKey(key)) {
String msg = String.format("No regular expression named '%s' found", key);
throw new NoSuchElementException(msg);
@@ -94,13 +101,13 @@ public class PropertyDB {
* Retrieve a persisted format string.
*
* @param key
- * The name of the format string.
+ * The name of the format string.
*
* @return The format string with that name.
*/
public static String getFormat(String key) {
return loadLock.read(() -> {
- if(!formats.containsKey(key)) {
+ if (!formats.containsKey(key)) {
String msg = String.format("No format string named '%s' found", key);
throw new NoSuchElementException(msg);
@@ -111,14 +118,13 @@ public class PropertyDB {
}
/**
- * Retrieve a persisted format string, and apply it to a set of
- * arguments.
+ * Retrieve a persisted format string, and apply it to a set of arguments.
*
* @param key
- * The name of the format string.
+ * The name of the format string.
*
* @param objects
- * The parameters to the format string.
+ * The parameters to the format string.
*
* @return The format string with that name.
*/