Package javajs.util
Class OC
java.lang.Object
java.io.OutputStream
javajs.util.OC
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable,GenericOutputChannel
A generic output method. JmolOutputChannel can be used to:
add characters to a StringBuffer using fileName==null, append() and
toString()
add bytes utilizing ByteArrayOutputStream using writeBytes(),
writeByteAsInt(), append()*, and bytesAsArray() *append() can be used as long
as os==ByteArrayOutputStream or it is not used before one of the writeByte
methods.
output characters to a FileOutputStream using os==FileOutputStream,
asWriter==true, append(), and closeChannel()
output bytes to a FileOutputStream using os==FileOutputStream, writeBytes(),
writeByteAsInt(), append(), and closeChannel()
post characters or bytes to a remote server using fileName=="http://..." or
"https://...", writeBytes(), writeByteAsInt(), append(), and closeChannel()
send characters or bytes to a JavaScript function when JavaScript and (typeof
fileName == "function")
if fileName equals ";base64,", then the data are base64-encoded prior to
writing, and closeChannel() returns the data.
- Author:
- hansonr Bob Hanson hansonr@stolaf.edu 9/2013
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionwill go to string buffer if bw == null and os == nullvoidcancel()voidclose()Deprecated.intgetName()getType()booleanisBase64()booleanstatic booleanstatic booleanvoidreset()voidsetBigEndian(boolean TF) setBytes(byte[] b) setParams(BytePoster bytePoster, String fileName, boolean asWriter, OutputStream os) Set up an output channel.voidbyte[]toString()static inturlTypeIndex(String name) voidwrite(byte[] buf, int i, int len) voidwrite(int b) Deprecated.voidwriteByteAsInt(int b) voidwriteFloat(float x) voidwriteInt(int i) voidwriteLong(long b) voidwriteShort(short i) Methods inherited from class java.io.OutputStream
flush, nullOutputStream, write
-
Field Details
-
bigEndian
public boolean bigEndian -
urlPrefixes
-
URL_LOCAL
public static final int URL_LOCAL- See Also:
-
URL_CACHE
public static final int URL_CACHE- See Also:
-
-
Constructor Details
-
OC
public OC() -
OC
-
-
Method Details
-
setParams
Set up an output channel. String or byte data can be added without problem.- Parameters:
bytePoster- a byte poster can take the output byte[] when closing and do something with themfileName- TODO: It is possible that JavaScript will call this with a function name for fileNameasWriter- string-basedos- the desired target OutputStream - not the calling stream!- Returns:
- OC
-
isBigEndian
public boolean isBigEndian()- Specified by:
isBigEndianin interfaceGenericOutputChannel
-
setBigEndian
public void setBigEndian(boolean TF) -
setBytes
-
getFileName
-
getName
-
getByteCount
public int getByteCount() -
setType
- Parameters:
type- user-identified type (PNG, JPG, etc)
-
getType
-
append
will go to string buffer if bw == null and os == null- Parameters:
s-- Returns:
- this, for chaining like a standard StringBuffer
-
reset
public void reset()- Specified by:
resetin interfaceGenericOutputChannel
-
writeByteAsInt
public void writeByteAsInt(int b) - Specified by:
writeByteAsIntin interfaceGenericOutputChannel- Parameters:
b-
-
write
public void write(byte[] buf, int i, int len) - Specified by:
writein interfaceGenericOutputChannel- Overrides:
writein classOutputStream
-
writeShort
public void writeShort(short i) - Specified by:
writeShortin interfaceGenericOutputChannel
-
writeLong
public void writeLong(long b) - Specified by:
writeLongin interfaceGenericOutputChannel
-
write
Deprecated.Will break JavaScript if used.- Specified by:
writein classOutputStream- Parameters:
b-
-
cancel
public void cancel() -
closeChannel
- Specified by:
closeChannelin interfaceGenericOutputChannel
-
isBase64
public boolean isBase64() -
getBase64
-
toByteArray
public byte[] toByteArray() -
close
Deprecated.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream
-
toString
-
isRemote
-
isLocal
-
urlTypeIndex
-
writeInt
public void writeInt(int i) - Specified by:
writeIntin interfaceGenericOutputChannel
-
writeFloat
public void writeFloat(float x)
-