|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.nuiton.jrst.AdvancedReader
public class AdvancedReader
Le principe est d'avoir dans cette classe le moyen de lire, et de retourner
la ou on etait avant la lecture (mark et reset de BufferedReader).
Mais il faut aussi pouvoir dire qu'en fin de compte on ne souhaite pas lire
les caracteres que l'on vient de lire (unread(int) a peu pres egal a
PushbackReader)
Le pointer nextChar pointe toujours sur le prochain caractere qui sera lu
Lorsque l'on appelle la method mark() on vide aussi le buffer pour
liberer de la place, car on a plus le moyen de retourner avant le mark que
l'on vient de positionner.
On contraire du mark de BufferedReader ou LineNumberReader il
n'y a pas a specifier le nombre de caractere a garder au maximum, seul la
memoire nous limite. Du coup si l'on utilise cette classe sans mark, au final
on aura dans le buffer tout le contenu du reader, il faut donc utiliser mark
avec cette classe
buffer
#########################
0 ˆ ˆ
| |
| + nextChar
+ markChar
Created: 27 oct. 06 00:24:57
| Field Summary | |
|---|---|
protected org.apache.commons.collections.primitives.CharList |
buffer
|
protected int |
charNumber
|
protected int |
charNumberMark
|
protected Reader |
in
|
protected int |
lineNumber
|
protected int |
lineNumberMark
|
protected int |
markChar
|
protected int |
nextChar
|
protected static int |
READ_AHEAD
nombre de caractere lu au minimum sur le vrai reader |
protected int |
readInMark
|
protected static String |
TAB
le nombre d'espace pour remplacer les tabulations |
| Constructor Summary | |
|---|---|
AdvancedReader(Reader in)
|
|
| Method Summary | |
|---|---|
boolean |
eof()
|
int |
getCharNumber()
|
int |
getLineNumber()
|
void |
mark()
|
int |
read()
read one char in buffer |
String |
readLine()
read one line |
String[] |
readLines(int count)
lit un certain nombre de lignes |
int |
readSinceMark()
|
String[] |
readUntil(String pattern)
lit les lignes jusqu'a la ligne qui correspond pas au pattern, cette ligne n'est pas mise dans le resultat retourne |
String[] |
readUntilBlank()
lit les lignes jusqu'a la premiere ligne blanche (non retournée) |
String[] |
readWhile(String pattern)
lit les lignes tant que les lignes correspondent au pattern |
void |
reset()
|
int |
skip(int number)
|
void |
skipBlankLines()
passe les lignes blanches |
int |
unread(int number)
go left in reading char buffer |
int |
unread(String[] lines,
boolean addNewLine)
Unread the line length |
int |
unread(String line,
boolean addNewLine)
Unread the line length |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final String TAB
protected static final int READ_AHEAD
protected Reader in
protected org.apache.commons.collections.primitives.CharList buffer
protected int charNumber
protected int charNumberMark
protected int lineNumber
protected int lineNumberMark
protected int nextChar
protected int markChar
protected int readInMark
| Constructor Detail |
|---|
public AdvancedReader(Reader in)
in - the io reader| Method Detail |
|---|
public void mark()
throws IOException
IOException
public void reset()
throws IOException
IOExceptionpublic int readSinceMark()
public int getCharNumber()
public int getLineNumber()
public boolean eof()
throws IOException
IOException
public int skip(int number)
throws IOException
IOExceptionpublic int unread(int number)
number -
public int unread(String line,
boolean addNewLine)
line - line used to know the length to unreadaddNewLine - if true then add +1 to unread lenght for not present '\n'
public int unread(String[] lines,
boolean addNewLine)
lines - lines used to know the length to unreadaddNewLine - if true then add +1 for each line to unread lenght for not
present '\n'
public int read()
throws IOException
IOException - pour tout pb de lecture
public String readLine()
throws IOException
IOException - pour tout pb de lecture
public void skipBlankLines()
throws IOException
IOException
public String[] readLines(int count)
throws IOException
count - si negatif lit toutes les lignes
IOException - pour tout pb de lecture
public String[] readUntilBlank()
throws IOException
IOException - pour tout pb de lecture
public String[] readUntil(String pattern)
throws IOException
pattern - ?
IOException - pour tout pb de lecture
public String[] readWhile(String pattern)
throws IOException
pattern - ?
IOException - pour tout pb de lecture
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||