summaryrefslogtreecommitdiff
path: root/BJC-Utils2/src/main/java/bjc/utils/ioutils/SimpleProperties.java
diff options
context:
space:
mode:
authorbculkin2442 <bjculkin@mix.wvu.edu>2017-04-10 16:39:06 -0400
committerbculkin2442 <bjculkin@mix.wvu.edu>2017-04-10 16:39:06 -0400
commit1656b02144446aeedebb3d1179e07ed99c01861c (patch)
tree29c5590100b6fbef40bb7da113d9b64818348ed5 /BJC-Utils2/src/main/java/bjc/utils/ioutils/SimpleProperties.java
parent668640b08c41af55f0902bc11cab949c9dc80079 (diff)
Warning resolution
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/ioutils/SimpleProperties.java')
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/ioutils/SimpleProperties.java20
1 files changed, 12 insertions, 8 deletions
diff --git a/BJC-Utils2/src/main/java/bjc/utils/ioutils/SimpleProperties.java b/BJC-Utils2/src/main/java/bjc/utils/ioutils/SimpleProperties.java
index 531e8b8..f00f245 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/ioutils/SimpleProperties.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/ioutils/SimpleProperties.java
@@ -38,19 +38,19 @@ public class SimpleProperties implements Map<String, String> {
* Whether or not duplicate keys should be allowed.
*/
public void loadFrom(InputStream is, boolean allowDuplicates) {
- try(Scanner scn = new Scanner(is)) {
- while(scn.hasNextLine()) {
+ try (Scanner scn = new Scanner(is)) {
+ while (scn.hasNextLine()) {
String ln = scn.nextLine().trim();
/*
* Skip blank lines/comments
*/
- if(ln.equals("")) continue;
- if(ln.startsWith("#")) continue;
+ if (ln.equals("")) continue;
+ if (ln.startsWith("#")) continue;
int sepIdx = ln.indexOf(' ');
- if(sepIdx == -1) {
+ if (sepIdx == -1) {
String fmt = "Properties must be a name, a space, then the body.\n\tOffending line is '%s'";
String msg = String.format(fmt, ln);
@@ -60,7 +60,7 @@ public class SimpleProperties implements Map<String, String> {
String name = ln.substring(0, sepIdx).trim();
String body = ln.substring(sepIdx).trim();
- if(!allowDuplicates && containsKey(name)) {
+ if (!allowDuplicates && containsKey(name)) {
String msg = String.format("Duplicate key '%s'", name);
throw new IllegalStateException(msg);
@@ -77,7 +77,7 @@ public class SimpleProperties implements Map<String, String> {
public void outputProperties() {
System.out.println("Read properties:");
- for(Entry<String, String> entry : entrySet()) {
+ for (Entry<String, String> entry : entrySet()) {
System.out.printf("\t'%s'\t'%s'\n", entry.getKey(), entry.getValue());
}
@@ -94,16 +94,19 @@ public class SimpleProperties implements Map<String, String> {
return props.isEmpty();
}
+ @SuppressWarnings("unlikely-arg-type")
@Override
public boolean containsKey(Object key) {
return props.containsKey(key);
}
+ @SuppressWarnings("unlikely-arg-type")
@Override
public boolean containsValue(Object value) {
return props.containsValue(value);
}
+ @SuppressWarnings("unlikely-arg-type")
@Override
public String get(Object key) {
return props.get(key);
@@ -114,6 +117,7 @@ public class SimpleProperties implements Map<String, String> {
return props.put(key, value);
}
+ @SuppressWarnings("unlikely-arg-type")
@Override
public String remove(Object key) {
return props.remove(key);
@@ -153,4 +157,4 @@ public class SimpleProperties implements Map<String, String> {
public int hashCode() {
return props.hashCode();
}
-}
+} \ No newline at end of file