Permalink
Browse files

Allow storage to be constructed from file.

  • Loading branch information...
1 parent 3309267 commit 2027db0ed648c951006c9a14ed945d6d164e90a7 @GraylinKim GraylinKim committed Feb 27, 2013
Showing with 14 additions and 6 deletions.
  1. +14 −6 src/main/java/gov/nysenate/openleg/util/Storage.java
@@ -19,7 +19,7 @@
public class Storage {
- private final String storage;
+ private final File storage;
private final Logger logger;
private final JsonFactory jsonFactory;
private final ObjectMapper objectMapper;
@@ -33,19 +33,27 @@
public static enum Status { NEW , MODIFIED, DELETED };
- public Storage(String filepath) {
- this(filepath, true);
+ public Storage(String storagePath) {
+ this(storagePath, true);
}
- public Storage(String filepath, Boolean autoFlush) {
- this.storage = filepath;
+ public Storage(File storageDir) {
+ this(storageDir, true);
+ }
+
+ public Storage(String storagePath, Boolean autoFlush) {
+ this(new File(storagePath),autoFlush);
+ }
+
+ public Storage(File storageDir, Boolean autoFlush) {
+ this.storage = storageDir;
this.logger = Logger.getLogger(this.getClass());
this.memory = new HashMap<String, Object>();
this.dirty = new HashSet<String>();
this.autoFlush = autoFlush;
this.objectMapper = new ObjectMapper();
- this.objectMapper.getSerializationConfig().enable(Feature.INDENT_OUTPUT);
+ this.objectMapper.enable(Feature.INDENT_OUTPUT);
this.jsonFactory = this.objectMapper.getJsonFactory();
this.prettyPrinter = new DefaultPrettyPrinter();

0 comments on commit 2027db0

Please sign in to comment.