ACLFileReaderpublic class ACLFileReader extends Object This class represents file reader for file that describes access control
information. |
Fields Summary |
---|
Reader | inInput data reader. | char[] | lineBufferTemporary data array. | protected static final int | HTHorizontal Tab - Unicode character 0x09. | protected static final int | LFLine Feed - Unicode character 0x0A. | protected static final int | CRCarrage Return - Unicode character 0x0D. | protected static final int | EOFEnd Of File - Unicode character 0x1A. | protected static final int | SPSPace - Unicode character 0x20. | protected int | lineNumberCurrent line number. | protected char | savedCharTemporary variable used in parsing. |
Constructors Summary |
---|
public ACLFileReader(Reader r)Constructor.
lineBuffer = new char[128];
in = r;
|
Methods Summary |
---|
public void | checkWord(java.lang.String s)Check that the next word is equal to specified one.
if (! readWord().equals(s)) {
throw new IOException();
}
| public int | getLineNumber()Returns the current line number.
return lineNumber;
| public int | readByte()Reads one word, converts it into unsigned byte value.
return Integer.parseInt(readWord(), 16) & 0xff;
| public java.lang.String | readLine()Read current line without any modification.
int room;
int offset = 0;
int c;
char[] temp;
room = lineBuffer.length;
for (;;) {
c = in.read();
if (c == LF) {
lineNumber++;
}
if (c == -1 || c == LF) {
// LF or CR LF ends a line
break;
}
/*
* throw away carrage returns and the end of file character.
*/
if (c == CR || c == EOF) {
continue;
}
if (--room < 0) {
temp = new char[offset + 128];
room = temp.length - offset - 1;
System.arraycopy(lineBuffer, 0, temp, 0, offset);
lineBuffer = temp;
}
lineBuffer[offset++] = (char) c;
}
if ((c == -1) && (offset <= 0)) {
return null;
}
return new String(lineBuffer, 0, offset).trim();
| public java.lang.String | readWord()Read one word.
if (savedChar == '{") {
savedChar = 0;
return "{";
}
if (savedChar == '}") {
savedChar = 0;
return "}";
}
int room = lineBuffer.length;
int offset = 0;
boolean comment = false;
int c;
for (;;) {
c = in.read();
if (c == -1) {
// LF or CR LF ends a line
break;
}
if (c == '#") {
comment = true;
}
if (c == LF) {
lineNumber++;
comment = false;
}
if (comment) {
continue;
}
if (c == LF || c == CR || c == EOF || c == HT || c == SP) {
if (offset == 0) {
continue;
}
break;
}
if (c == '{" || c == '}") {
if (offset == 0) {
lineBuffer[offset++] = (char) c;
} else {
savedChar = (char) c;
}
break;
}
if (--room < 0) {
char[] temp = new char[offset + 128];
room = temp.length - offset - 1;
System.arraycopy(lineBuffer, 0, temp, 0, offset);
lineBuffer = temp;
}
lineBuffer[offset++] = (char) c;
}
if ((c == -1) && (offset <= 0)) {
return null;
}
return new String(lineBuffer, 0, offset).trim();
|
|