public class MemoryDataStorage extends Object implements DataStorage
Modifier and Type | Class and Description |
---|---|
class |
MemoryDataStorage.StringListIterator
Iterator sur les donnnées.
|
Modifier and Type | Field and Description |
---|---|
protected static char |
escapechar |
protected List<String> |
lineIndexStorage
Stockage des numero de ligne (String) pour une recherche indexOf plus rapide.
|
protected Map<String,Integer> |
lineIndexStorageCache
Cache pour les indexOf encore plus rapide (invalidé lors d'un delete).
|
protected List<String> |
listStorage
Stockage des données.
|
protected static char |
quotechar |
protected static char |
separator |
Constructor and Description |
---|
MemoryDataStorage() |
Modifier and Type | Method and Description |
---|---|
void |
add(int index,
String[] data)
Add new data into storage.
|
void |
add(String[] data)
Add new data into storage.
|
protected String |
arrayToString(String[] nextLine) |
String[] |
get(int index)
Get data at specified index.
|
int |
indexOf(String lineNumber)
Real storage index of lineNumber.
|
protected boolean |
isNextCharacterEscapable(String nextLine,
boolean inQuotes,
int i) |
protected boolean |
isNextCharacterEscapedQuote(String nextLine,
boolean inQuotes,
int i) |
Iterator<String[]> |
iterator() |
Iterator<String[]> |
iterator(boolean skipFirstLine)
Return a new iterator, but skip first iterator element (csv header)
by calling
next() once. |
protected String[] |
parseLine(String nextLine) |
protected StringBuilder |
processLine(String nextElement) |
String[] |
remove(int index)
Remove value at index.
|
String[] |
set(int index,
String[] element)
Replace data at specified index.
|
int |
size()
Storage size.
|
protected String[] |
stringToArray(String data) |
String |
toString() |
protected String |
writeNext(String[] nextLine) |
protected List<String> lineIndexStorage
protected Map<String,Integer> lineIndexStorageCache
protected static final char separator
protected static final char quotechar
protected static final char escapechar
public Iterator<String[]> iterator(boolean skipFirstLine)
next()
once.iterator
in interface DataStorage
skipFirstLine
- if true
, skip first linepublic void add(String[] data)
DataStorage
add
in interface DataStorage
data
- data to addpublic void add(int index, String[] data)
DataStorage
add
in interface DataStorage
index
- index to insert datadata
- data to addpublic String[] get(int index)
DataStorage
get
in interface DataStorage
index
- indexpublic int indexOf(String lineNumber)
DataStorage
indexOf
in interface DataStorage
lineNumber
- line numberpublic int size()
DataStorage
size
in interface DataStorage
public String[] set(int index, String[] element)
DataStorage
set
in interface DataStorage
index
- indexelement
- data to setpublic String[] remove(int index)
DataStorage
remove
in interface DataStorage
index
- indexprotected StringBuilder processLine(String nextElement)
protected boolean isNextCharacterEscapedQuote(String nextLine, boolean inQuotes, int i)
protected boolean isNextCharacterEscapable(String nextLine, boolean inQuotes, int i)
Copyright © 2010–2015 Ifremer. All rights reserved.