public class DataStorages extends Object
DataStorage.
TODO Should move here all others methods storage-centric from CommonService.
Created on 3/7/14.| Constructor and Description |
|---|
DataStorages() |
| Modifier and Type | Method and Description |
|---|---|
static DataStorage |
load(File file)
Load a csv file using the default csv char separator
(
CoserConstants.CSV_SEPARATOR_CHAR). |
static DataStorage |
load(File file,
char separator)
Load a csv file using the given csv char separator.
|
static <P extends com.google.common.base.Predicate<String[]>> |
match(DataStorage storage,
P predicate,
boolean skipHeader)
//TODO Use a walker
|
static File |
save(DataStorage dataStorage,
String prefix,
String suffix)
Save a datastorage to a file and return its.
|
static void |
save(DataStorage dataStorage,
Writer writer)
Save a datastorage to a writer.
|
static <P extends com.google.common.base.Predicate<String[]>> |
sub(DataStorage storage,
P predicate,
String... header)
Gets a sub storage of all matching rows for the given predicate on the given storage.
|
static String |
toString(DataStorage storage) |
static <P extends com.google.common.base.Predicate<String[]>,W extends DataStorageWalker> |
walk(DataStorage storage,
P predicate,
W walker) |
static <W extends DataStorageWalker> |
walk(DataStorage storage,
W walker) |
public static DataStorage load(File file)
CoserConstants.CSV_SEPARATOR_CHAR).file - file to loadpublic static DataStorage load(File file, char separator)
file - file to loadseparator - separator to use to load filepublic static File save(DataStorage dataStorage, String prefix, String suffix) throws CoserTechnicalException
File.createTempFile(String, String) using the given prefix
and suffix.dataStorage - the storage to saveprefix - prefix of generated file namesuffix - suffix of generated file nameCoserTechnicalExceptionpublic static String toString(DataStorage storage)
public static void save(DataStorage dataStorage, Writer writer) throws CoserTechnicalException
dataStorage - the storage to savewriter - where to save storageCoserTechnicalExceptionpublic static <P extends com.google.common.base.Predicate<String[]>> boolean match(DataStorage storage, P predicate, boolean skipHeader)
P - type of predicatestorage - the storage to testpredicate - predicate to match at least on one rowskipHeader - to skip the header of storagetrue if a row matchs the predicatepublic static <P extends com.google.common.base.Predicate<String[]>> DataStorage sub(DataStorage storage, P predicate, String... header)
header.P - type of predicatestorage - storage to readpredicate - predicate to match rows to include in sub storageheader - new header to usepublic static <W extends DataStorageWalker> void walk(DataStorage storage, W walker)
public static <P extends com.google.common.base.Predicate<String[]>,W extends DataStorageWalker> void walk(DataStorage storage, P predicate, W walker)
Copyright © 2010–2015 Ifremer. All rights reserved.