Class RpcOutputStream
java.lang.Object
java.io.OutputStream
java.io.FileOutputStream
com.perforce.p4java.impl.mapbased.rpc.sys.RpcOutputStream
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
Provides a Perforce-specific extension to the basic Java OuputStream to allow
us to intercept methods and implement our own extensions. The two main aims
here are for the GKUNZIP file type to stream unzip on the fly, and to do line
end processing for text files where needed; everything else is just currently
handled in the superclass without real intervention.
Note that for the unzipping we use a contained file output stream rather than ourself, mostly to avoid recursion...
Some of the raw GZUNZIP methods and definitions are copied pretty much as-is from the original gkzip stuff.
The 10.2 sync / transfer integrity checks are basically implemented here, with help from the RpcInflaterOutputStream class. The way this is done is the MD5 hashing has to be done against the incoming 'raw' bytes (i.e. the normalized server-side form of the file) unless the incoming file type is compressed binary, in which case we have to hash the uncompressed version. The non-binary hashing is done here; the compressed stuff is done in RpcInflaterOutputStream.
-
Constructor Summary
ConstructorsConstructorDescriptionRpcOutputStream(RpcPerforceFile file, RpcConnection rpcConnection, boolean useLocalDigester) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()getFile()static RpcOutputStreamvoidsetLocalDigester(MD5Digester localDigester) voidsetServerDigest(String serverDigest) voidwrite(byte[] b) voidwrite(byte[] sourceBytes, int off, int len) voidwrite(int b) longSpecialized write method to write a map containing a byte array with the key RpcFunctionMapKey.DATA (all other fields are ignored).longwriteConverted(byte[] sourceBytes) Write an array of bytes with being aware of encodings, line ending conversions, and compression.Methods inherited from class java.io.FileOutputStream
getChannel, getFDMethods inherited from class java.io.OutputStream
flush, nullOutputStream
-
Constructor Details
-
RpcOutputStream
public RpcOutputStream(RpcPerforceFile file, RpcConnection rpcConnection, boolean useLocalDigester) throws IOException - Throws:
IOException
-
-
Method Details
-
getTmpOutputStream
- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classFileOutputStream- Throws:
IOException
-
write
public long write(Map<String, Object> map) throws IOException, FileDecoderException, FileEncoderExceptionSpecialized write method to write a map containing a byte array with the key RpcFunctionMapKey.DATA (all other fields are ignored). This map is assumed to have been constructed as part of the writeFile() method or something similar.- Parameters:
map- map- Returns:
- source bytes
- Throws:
FileEncoderException- on errorFileDecoderException- on errorIOException- on error
-
write
- Overrides:
writein classFileOutputStream- Throws:
IOException
-
write
- Overrides:
writein classFileOutputStream- Throws:
IOException
-
writeConverted
public long writeConverted(byte[] sourceBytes) throws IOException, FileDecoderException, FileEncoderException Write an array of bytes with being aware of encodings, line ending conversions, and compression. Any 10.2+ sync integrity checks are done either here or in the unzip's stream, but (definitely) not in both places.- Parameters:
sourceBytes- sourceBytes- Returns:
- bytes written
- Throws:
IOException- on errorFileEncoderException- on errorFileDecoderException- on error
-
write
- Overrides:
writein classFileOutputStream- Throws:
IOException
-
getFile
-
getServerDigest
-
setServerDigest
-
getLocalDigester
-
setLocalDigester
-