Skip to content

Commit

Permalink
Release 0.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
brett-smith committed May 18, 2024
1 parent 57ff7a5 commit e664cac
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 6 deletions.
2 changes: 1 addition & 1 deletion config/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<artifactId>jini</artifactId>
<groupId>com.sshtools</groupId>
<version>0.3.2-SNAPSHOT</version>
<version>0.3.2</version>
<relativePath>../</relativePath>
</parent>
<artifactId>jini-config</artifactId>
Expand Down
15 changes: 15 additions & 0 deletions config/src/main/java/com/sshtools/jini/config/INISet.java
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,21 @@ public Builder withDefault(Class<?> base, String resource) {
}
}

public Builder withOptionalDefault(Class<?> base, String resource) {
try {
var in = base.getResourceAsStream(resource);
if(in == null)
return this;
try {
return withDefault(in);
} finally {
in.close();
}
} catch (IOException ioe) {
throw new UncheckedIOException(ioe);
}
}

public Builder withSchema(Path path) {
return withSchema(INISchema.fromFile(path));
}
Expand Down
2 changes: 1 addition & 1 deletion lib/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<artifactId>jini</artifactId>
<groupId>com.sshtools</groupId>
<version>0.3.2-SNAPSHOT</version>
<version>0.3.2</version>
<relativePath>../</relativePath>
</parent>
<artifactId>jini-lib</artifactId>
Expand Down
5 changes: 4 additions & 1 deletion lib/src/main/java/com/sshtools/jini/INIReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,10 @@ else if (oldValues == null ||
lastAppendedLine != lineNo
) ) {
/* Doesn't exist, just add */
sectionProperties.put(key, new String[] { val });
if(val.equals(""))
sectionProperties.put(key, new String[0]);
else
sectionProperties.put(key, new String[] { val });
lastAppendedLine = lineNo;
} else {
switch (duplicateKeysAction) {
Expand Down
14 changes: 14 additions & 0 deletions lib/src/test/java/com/sshtools/jini/INIReaderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,20 @@ public void testIgnoreDuplicateKeys() throws IOException, ParseException {
assertEquals("V2", ini.get("S1bK1"));
}

@Test
public void testKeysOnly() throws IOException, ParseException {
var ini = new INIReader.Builder()
.build().read(
"S1aK1\n" +
"S1bK1\n");
assertEquals(2, ini.values().size());
assertEquals(0, ini.getAll("S1aK1").length);
assertEquals(0, ini.getAll("S1bK1").length);
assertEquals("DEF", ini.get("S1aK2", "DEF"));
assertEquals(123, ini.getInt("S1aK2", 123));
assertThrows(IllegalArgumentException.class, () -> ini.get("S1aK1"));
}

@Test
public void testReplaceDuplicateKeys() throws IOException, ParseException {
var ini = new INIReader.Builder().withDuplicateKeysAction(DuplicateAction.REPLACE)
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.sshtools</groupId>
<artifactId>jini</artifactId>
<version>0.3.2-SNAPSHOT</version>
<version>0.3.2</version>
<name>Java INI file reader and writer</name>
<packaging>pom</packaging>
<properties>
Expand Down
2 changes: 1 addition & 1 deletion prefs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<artifactId>jini</artifactId>
<groupId>com.sshtools</groupId>
<version>0.3.2-SNAPSHOT</version>
<version>0.3.2</version>
<relativePath>../</relativePath>
</parent>
<artifactId>jini-prefs</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion schema/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<artifactId>jini</artifactId>
<groupId>com.sshtools</groupId>
<version>0.3.2-SNAPSHOT</version>
<version>0.3.2</version>
<relativePath>../</relativePath>
</parent>
<artifactId>jini-schema</artifactId>
Expand Down

0 comments on commit e664cac

Please sign in to comment.