Skip to content

Commit

Permalink
Implement code quality suggestions #323
Browse files Browse the repository at this point in the history
  • Loading branch information
pkiraly committed Mar 6, 2024
1 parent 0c57f46 commit d248581
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,16 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;

public class PicaSchemaReader {

private static final Logger logger = Logger.getLogger(PicaSchemaReader.class.getCanonicalName());

private JSONParser parser = new JSONParser(JSONParser.MODE_RFC4627);
private Map<String, PicaFieldDefinition> map = new HashMap<>();
private PicaSchemaManager schema = new PicaSchemaManager();
private final JSONParser parser = new JSONParser(JSONParser.MODE_RFC4627);
private final Map<String, PicaFieldDefinition> map = new HashMap<>();
private final PicaSchemaManager schema = new PicaSchemaManager();

private PicaSchemaReader(String fileName) {
try {
Expand Down Expand Up @@ -74,7 +75,7 @@ public static PicaSchemaManager createSchemaManager(String picaSchemaFile) {
}

if (schemaFile != null && new File(schemaFile).exists()) {
logger.info("read from file: " + schemaFile);
logger.log(Level.INFO, "read from file: {0}", schemaFile);
picaSchemaManager = PicaSchemaReader.createSchema(schemaFile);
} else {
logger.info("read from resource");
Expand Down Expand Up @@ -111,7 +112,7 @@ private void process(JSONObject jsonObject) throws IOException, ParseException,
tag.setOccurrence((String) field.get("occurrence"));
tag.setCounter((String) field.get("counter"));
if (tag.getCounter() != null && tag.getOccurrence() != null) {
logger.info(id + " has both counter and occurrence");
logger.log(Level.INFO, "{0} has both counter and occurrence", id);
}
processSubfields(field, tag);
PicaFieldDefinition definition = new PicaFieldDefinition(tag);
Expand Down Expand Up @@ -167,11 +168,11 @@ private SubfieldDefinition extractSubfield(Object o) {
} else if (key.equals("pica3")) {
// skip
} else {
logger.warning("unhandled key in subfield: " + key);
logger.log(Level.WARNING, "unhandled key in subfield: {0}", key);
}
}
} else {
logger.warning("the JSON node's type is not JSONObject, but " + o.getClass().getCanonicalName());
logger.log(Level.WARNING, "the JSON node's type is not JSONObject, but {0}", o.getClass().getCanonicalName());
}
return definition;
}
Expand Down

0 comments on commit d248581

Please sign in to comment.