|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.io.Reader | +--condor.classad.ClassAdReader
Convert a serialized classified advertisement into a stream of characters.
The current Condor C++ classad library uses a rather peculiar representation
for transmitting classads (see read()
for details). ClassAdReader
may be used to wrap a CedarInputStream and turn it into a Reader (a stream
of input characters). A sequence of classads appears to be a stream of
ASCII characters containing the ASCII representations of the classads, each
followed by a semicolon and a newline. For example:
[myType="job";name="ad1";targetType="machine"]; [myType="job";name="ad2";targetType="machine"];There are plans to simplify the format used for transporting classads in a future release of Condor. When that happens, this class can be replaced by
java.io.InputStreamReader
.
The inverse transformation, from a classified advertisement to the "old"
serialized form, is performed by
RecordExpr.transmit
.
Fields inherited from class java.io.Reader |
lock |
Constructor Summary | |
ClassAdReader(condor.cedar.CedarInputStream in)
Create a new ClassAdReader. |
Method Summary | |
void |
close()
Throw away all remaining input and close the underlying input stream. |
int |
getByteCount()
Return the number of "raw" bytes read from the original input stream, including Cedar overhead. |
int |
read()
Returns one character from the translated input stream. |
int |
read(char[] buf,
int offset,
int len)
|
Methods inherited from class java.io.Reader |
mark, markSupported, read, ready, reset, skip |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public ClassAdReader(condor.cedar.CedarInputStream in)
in
- the underlying input stream.Method Detail |
public int read() throws IOException
Each character of input generates one or more characters of output, the first character of which is returned immediately, with the remaining characters (if any) stored in pushBack. The field attrCount indicates the number of strings remaining in the current ad, not including the current string. In particular, when the attribute count n is read, attrCount is set to n+1, attrCount==0 while the last string is being processed, and attrCount is -1 between ads.
Here is an example. In the input, the notation "{n}" represents the number n encoded as a Cedar integer (8 bytes binary, most significant byte first).
input {1}{2}a=b\0foo=bar\0xxx\0yyy\0{1}{0}uuu\0vvv\0{0} output [a=b; foo=bar; MyType="xxx"; TargetType="yyy"]; [MyType="uuu"; TargetType"vvv"]; EOF
Here is a trace of the finite-state machine that does the translation. The state consists of the values of attrCount and pushBack.
input output attrCont pushBack ----- ------ -------- -------- -1 {1}{2} [ 3 a=b a=b 3 \0 ; 2 \n foo=bar foo=bar 2 \0 ; 1 \nMyType=" xxx xxx 1 \0 " 0 ;\nTargetType=" yyy yyy 0 \0 " -1 ];\n {1}{0} [ 1 MyType=" uuu uuu 1 \0 " 0 ;\nTargetType=" vvv vvv 0 \0 " -1 ];\n {0} EOFNote that "special actions" only occur when attrCount == -1 at the start of this method, or when the input stream returns a null. Otherwise, this method simply returns the next character from pushBack, or the next character from the input stream if pushBack is empty.
Characters are retrieved from the input stream using readUTFchar, which has the same contract as Reader.read(): A return value of 0 means an encoded null was found. A return value of -1 means and "end-of-file" condition was encountered--in this case, a naked null byte indicating "end-of-string".
read
in class Reader
IOException
- if an I/O error occurs on the underlying input
stream.public int read(char[] buf, int offset, int len) throws IOException
read
in class Reader
public void close() throws IOException
close
in class Reader
IOException
- if an I/O error occurs on the underlying input
stream.public int getByteCount()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |