XInterface x = (XInterface)tEnv.getObjRelation("StreamWriter") ;
oStream = UnoRuntime.queryInterface(XDataOutputStream.class, x);
List<Object> data = (List<Object>) tEnv.getObjRelation("StreamData") ; if (data == null || oStream == null) { thrownew StatusException(Status.failed("Object relation not found."));
}
// extract data from vector
Object dataElem = null ; for (int i = 0; i < data.size(); i++) {
dataElem = data.get(i) ;
if (dataElem instanceofBoolean) {
writeBoolean = ((Boolean)dataElem).booleanValue();
} else if (dataElem instanceofByte) {
writeByte = ((Byte)dataElem).byteValue();
} else if (dataElem instanceof Character) {
writeChar = ((Character)dataElem).charValue();
} else if (dataElem instanceofShort) {
writeShort = ((Short)dataElem).shortValue();
} else if (dataElem instanceof Integer) {
writeLong = ((Integer)dataElem).intValue();
} else if (dataElem instanceofLong) {
writeHyper = ((Long)dataElem).longValue();
} else if (dataElem instanceofFloat) {
writeFloat = ((Float)dataElem).floatValue();
} else if (dataElem instanceofDouble) {
writeDouble = ((Double)dataElem).doubleValue();
} else if (dataElem instanceof String) {
writeUTF = (String)dataElem;
}
}
}
/** *FirstwritesavaluetooutStreamthenreadsitfrominput.<p> * *Has<b>OK</b>statusifreadandwrittenvaluesareequal.<p>
*/ publicvoid _readBoolean() { boolean res = true ; try {
oStream.writeBoolean(writeBoolean);
} catch (com.sun.star.io.IOException e) {
e.printStackTrace(log); thrownew StatusException("Can't write data to the stream", e);
} byte readElem; try {
readElem = oObj.readBoolean();
res = ((readElem != 0) == writeBoolean);
if (!res)
log.println("Must be read " +
writeBoolean + " but was read " + (readElem != 0)) ;
} catch (com.sun.star.io.IOException e) {
log.println("Couldn't read Boolean from stream");
e.printStackTrace(log);
res = false;
}
tRes.tested("readBoolean()", res) ;
}
/** *FirstwritesavaluetooutStreamthenreadsitfrominput.<p> * *Has<b>OK</b>statusifreadandwrittenvaluesareequal.<p>
*/ publicvoid _readByte() { boolean res = true ; try {
oStream.writeByte(writeByte);
} catch (com.sun.star.io.IOException e) {
e.printStackTrace(log); thrownew StatusException("Can't write data to the stream", e);
} byte readElem; try {
readElem = oObj.readByte() ;
res = (readElem == writeByte);
if (!res)
log.println("Must be read " +
writeByte + " but was read " + readElem);
} catch(com.sun.star.io.IOException e) {
log.println("Couldn't read Byte from stream");
e.printStackTrace(log);
res = false;
}
tRes.tested("readByte()", res) ;
}
/** *FirstwritesavaluetooutStreamthenreadsitfrominput.<p> * *Has<b>OK</b>statusifreadandwrittenvaluesareequal.<p>
*/ publicvoid _readChar() { boolean res = true ; try {
oStream.writeChar(writeChar);
} catch (com.sun.star.io.IOException e) {
e.printStackTrace(log); thrownew StatusException("Can't write data to the stream", e);
} char readElem; try {
readElem = oObj.readChar() ;
res = (readElem == writeChar);
if (!res)
log.println("Must be read " +
writeChar + " but was read " + readElem) ;
} catch( com.sun.star.io.IOException e ) {
log.println("Couldn't read Char from stream");
e.printStackTrace(log);
res = false;
}
tRes.tested("readChar()", res);
}
/** *FirstwritesavaluetooutStreamthenreadsitfrominput.<p> * *Has<b>OK</b>statusifreadandwrittenvaluesareequal.<p>
*/ publicvoid _readShort() { boolean res = true ; try {
oStream.writeShort(writeShort);
} catch (com.sun.star.io.IOException e) {
e.printStackTrace(log); thrownew StatusException("Can't write data to the stream", e);
} short readElem; try {
readElem = oObj.readShort() ;
res = (readElem == writeShort);
if (!res)
log.println("Must be read " +
writeShort + " but was read " + readElem) ;
} catch( com.sun.star.io.IOException e ) {
log.println("Couldn't read Short from stream");
e.printStackTrace(log);
res = false;
}
tRes.tested("readShort()", res);
}
/** *FirstwritesavaluetooutStreamthenreadsitfrominput.<p> * *Has<b>OK</b>statusifreadandwrittenvaluesareequal.<p>
*/ publicvoid _readLong() { try {
oStream.writeLong(writeLong);
} catch (com.sun.star.io.IOException e) {
e.printStackTrace(log); thrownew StatusException("Can't write data to the stream", e);
} boolean res = true ; int readElem; try {
readElem = oObj.readLong() ;
res = (readElem == writeLong);
if (!res)
log.println("Must be read " +
writeLong + " but was read " + readElem) ;
} catch( com.sun.star.io.IOException e ) {
log.println("Couldn't read Long from stream");
e.printStackTrace(log);
res = false;
}
tRes.tested("readLong()", res);
}
/** *FirstwritesavaluetooutStreamthenreadsitfrominput.<p> * *Has<b>OK</b>statusifreadandwrittenvaluesareequal.<p>
*/ publicvoid _readHyper() { boolean res = true ; try {
oStream.writeHyper(writeHyper);
} catch (com.sun.star.io.IOException e) {
e.printStackTrace(log); thrownew StatusException("Can't write data to the stream", e);
} long readElem; try {
readElem = oObj.readHyper() ;
res = (readElem == writeHyper);
if (!res)
log.println("Must be read " +
writeHyper + " but was read " + readElem) ;
} catch( com.sun.star.io.IOException e ) {
log.println("Couldn't read Hyper from stream");
e.printStackTrace(log);
res = false;
}
tRes.tested("readHyper()", res);
}
/** *FirstwritesavaluetooutStreamthenreadsitfrominput.<p> * *Has<b>OK</b>statusifreadandwrittenvaluesareequal.<p>
*/ publicvoid _readFloat() { boolean res = true ; try {
oStream.writeFloat(writeFloat);
} catch (com.sun.star.io.IOException e) {
e.printStackTrace(log); thrownew StatusException("Can't write data to the stream", e);
} float readElem; try {
readElem = oObj.readFloat() ;
res = (readElem == writeFloat);
if (!res)
log.println("Must be read " +
writeFloat + " but was read " + readElem) ;
} catch( com.sun.star.io.IOException e ) {
log.println("Couldn't read Float from stream");
e.printStackTrace(log);
res = false;
}
tRes.tested("readFloat()", res);
}
/** *FirstwritesavaluetooutStreamthenreadsitfrominput.<p> * *Has<b>OK</b>statusifreadandwrittenvaluesareequal.<p>
*/ publicvoid _readDouble() { boolean res = true ; try {
oStream.writeDouble(writeDouble);
} catch (com.sun.star.io.IOException e) {
e.printStackTrace(log); thrownew StatusException("Can't write data to the stream", e);
} double readElem; try {
readElem = oObj.readDouble() ;
res = (readElem == writeDouble);
if (!res)
log.println("Must be read " +
writeDouble + " but was read " + readElem) ;
} catch( com.sun.star.io.IOException e ) {
log.println("Couldn't read Double from stream");
e.printStackTrace(log);
res = false;
}
tRes.tested("readDouble()", res);
}
/** *FirstwritesavaluetooutStreamthenreadsitfrominput.<p> * *Has<b>OK</b>statusifreadandwrittenvaluesareequal.<p>
*/ publicvoid _readUTF() { boolean res = true ; try {
oStream.writeUTF(writeUTF);
} catch (com.sun.star.io.IOException e) {
e.printStackTrace(log); thrownew StatusException("Can't write data to the stream", e);
}
String readElem; try {
readElem = oObj.readUTF() ;
res = writeUTF.equals(readElem) ;
if (!res)
log.println("Must be read '" +
writeUTF + "' but was read '" + readElem + "'") ;
} catch( com.sun.star.io.IOException e ) {
log.println("Couldn't read String from stream");
e.printStackTrace(log);
res = false;
}
tRes.tested("readUTF()", res);
}
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.24Bemerkung:
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.