summaryrefslogtreecommitdiff
path: root/BJC-Utils2/src/main/java/bjc/utils/PropertyDB.java
diff options
context:
space:
mode:
authorBenjamin J. Culkin <bjculkin@mix.wvu.edu>2017-09-09 21:46:16 -0300
committerBenjamin J. Culkin <bjculkin@mix.wvu.edu>2017-09-09 21:47:34 -0300
commitd766896972c9e9be4a9e0021ec5f4f0665901865 (patch)
tree1f6473300ef86e0697d682360bea0d28fc144baa /BJC-Utils2/src/main/java/bjc/utils/PropertyDB.java
parent40f3a28569366c4357fbda11d2fff3b77686d84f (diff)
Update
Most of it is documentation changes. The rest is more work on BlockReaders, as well as a simple command language for configuring them.
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/PropertyDB.java')
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/PropertyDB.java20
1 files changed, 18 insertions, 2 deletions
diff --git a/BJC-Utils2/src/main/java/bjc/utils/PropertyDB.java b/BJC-Utils2/src/main/java/bjc/utils/PropertyDB.java
index 755d7e0..713e1e0 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/PropertyDB.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/PropertyDB.java
@@ -20,6 +20,9 @@ public class PropertyDB {
private static SimpleProperties formats;
+ /*
+ * Whether or not to log during the loading.
+ */
private static final boolean LOGLOAD = false;
/*
@@ -38,22 +41,32 @@ public class PropertyDB {
* being loaded will block, to prevent reads from partial states.
*/
public static void reloadProperties() {
+ /*
+ * Do the load with the write lock taken.
+ */
loadLock.write(() -> {
if (LOGLOAD) {
System.out.println("Reading regex properties:");
}
+
+ /*
+ * Load regexes.
+ */
regexes = new SimpleProperties();
regexes.loadFrom(PropertyDB.class.getResourceAsStream("/regexes.sprop"), false);
if (LOGLOAD) {
regexes.outputProperties();
System.out.println();
}
-
compiledRegexes = new HashMap<>();
if (LOGLOAD) {
System.out.println("Reading format properties:");
}
+
+ /*
+ * Load formats.
+ */
formats = new SimpleProperties();
formats.loadFrom(PropertyDB.class.getResourceAsStream("/formats.sprop"), false);
if (LOGLOAD) {
@@ -100,6 +113,9 @@ public class PropertyDB {
throw new NoSuchElementException(msg);
}
+ /*
+ * Get the regex, and cache a compiled version.
+ */
return compiledRegexes.computeIfAbsent(key, strang -> {
return Pattern.compile(regexes.get(strang));
});
@@ -141,4 +157,4 @@ public class PropertyDB {
public static String applyFormat(final String key, final Object... objects) {
return String.format(getFormat(key), objects);
}
-} \ No newline at end of file
+}