@Override public <T> T readValue( File src, Class<T> valueType ) { return this.parserFactory.create().parseFile( valueType, src.toString() ); }
@Override public <T> T readValue( File src, Class<T> valueType ) { return this.parserFactory.create().parseFile( valueType, src.toString() ); }
@Override public <T> T readValue( File src, Class<T> valueType ) { return this.parserFactory.create().parseFile( valueType, src.toString() ); }
public static <T> T loadFromFileLocation(Class<T> clazz, String... fileLocations) { for (String fileLocation : fileLocations) { if (fileLocation != null && IO.exists(fileLocation)) { try { return new JsonParserFactory().create().parseFile(clazz, fileLocation); } catch (Exception ex) { ex.printStackTrace(); Exceptions.handle(ex, "Unable to read file from ", fileLocation); return null; } } } try { return clazz.newInstance(); } catch (InstantiationException | IllegalAccessException e) { Exceptions.handle(e, "Unable to create instance of " + clazz.getName()); return null; } } }
public static <T> T loadFromFileLocation(Class<T> clazz, String... fileLocations) { for (String fileLocation : fileLocations) { if (fileLocation != null && IO.exists(fileLocation)) { try { return new JsonParserFactory().create().parseFile(clazz, fileLocation); } catch (Exception ex) { ex.printStackTrace(); Exceptions.handle(ex, "Unable to read file from ", fileLocation); return null; } } } try { return clazz.newInstance(); } catch (InstantiationException | IllegalAccessException e) { Exceptions.handle(e, "Unable to create instance of " + clazz.getName()); return null; } } }
public static <T> T loadFromFileLocation(Class<T> clazz, String... fileLocations) { for (String fileLocation : fileLocations) { if (fileLocation != null && IO.exists(fileLocation)) { try { return new JsonParserFactory().create().parseFile(clazz, fileLocation); } catch (Exception ex) { ex.printStackTrace(); Exceptions.handle(ex, "Unable to read file from ", fileLocation); return null; } } } try { return clazz.newInstance(); } catch (InstantiationException | IllegalAccessException e) { Exceptions.handle(e, "Unable to create instance of " + clazz.getName()); return null; } } }
public static DataStoreConfig load() { try { if (IO.exists(FILE_LOCATION)) { return new JsonParserFactory().create().parseFile(DataStoreConfig.class, FILE_LOCATION); } else { return new DataStoreConfig(); } } catch (Exception ex) { ex.printStackTrace(); Exceptions.handle(ex, "Unable to read file from ", FILE_LOCATION); return null; } }
public static DataStoreServerConfig load() { if (IO.exists(FILE_LOCATION)) { return new JsonParserFactory().create().parseFile(DataStoreServerConfig.class, FILE_LOCATION); } else { return new DataStoreServerConfig(); } }
@Test public void testGetWalk() { List<String> files = IO.listByFileExtension ( "./files/", "json" ); for ( String file : files) { //outputs ( file ); JsonParserAndMapper parser = new JsonParserFactory().createFastParser(); Object object = parser.parseFile ( Map.class, file.toString () ); walkGetObject( object, null, null ); } //outputs ( "leaf", leafCount, "map", mapCount, "list", listCount ); //outputs ( "integer", integerCount, "long", longCount, "double", doubleCount ); //outputs ( "string", stringCount, "date", dateCount, "null", nullCount ); }
public static DataStoreClientConfig load() { puts("Config for data store client", FILE_LOCATION); if (IO.exists(FILE_LOCATION)) { try { return new JsonParserFactory().create().parseFile(DataStoreClientConfig.class, FILE_LOCATION); } catch (Exception ex) { Exceptions.handle(ex, "Unable to read config file", FILE_LOCATION, "for data store client config"); return null; } } else { puts("WARNING", FILE_LOCATION, "does not exist for data store client config!!!"); return new DataStoreClientConfig(); } }
@Test public void test() { List<String> files = IO.listByFileExtension ( "./files/", "json" ); for ( String file : files) { //outputs ( file ); Object object = new JsonParserFactory().createFastParser().parseFile ( Map.class, file.toString () ); walkObject( object, null, null ); } //outputs ( "leaf", leafCount, "map", mapCount, "collection", collectionCount ); //outputs ( "integer", integerCount, "long", longCount, "double", doubleCount, "boolean", booleanCount ); //outputs ( "string", stringCount, "date", dateCount, "null", nullCount ); }
jsonObject = boonMapper.parseFile(path);