Class RpcOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- java.io.FileOutputStream
-
- com.perforce.p4java.impl.mapbased.rpc.sys.RpcOutputStream
-
- All Implemented Interfaces:
java.io.Closeable
,java.io.Flushable
,java.lang.AutoCloseable
public class RpcOutputStream extends java.io.FileOutputStream
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
Constructors Constructor Description RpcOutputStream(RpcPerforceFile file, RpcConnection rpcConnection, boolean useLocalDigester)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
RpcPerforceFile
getFile()
MD5Digester
getLocalDigester()
java.lang.String
getServerDigest()
static RpcOutputStream
getTmpOutputStream(RpcPerforceFile file)
void
setLocalDigester(MD5Digester localDigester)
void
setServerDigest(java.lang.String serverDigest)
void
write(byte[] b)
void
write(byte[] sourceBytes, int off, int len)
void
write(int b)
long
write(java.util.Map<java.lang.String,java.lang.Object> map)
Specialized write method to write a map containing a byte array with the key RpcFunctionMapKey.DATA (all other fields are ignored).long
writeConverted(byte[] sourceBytes)
Write an array of bytes with being aware of encodings, line ending conversions, and compression.
-
-
-
Constructor Detail
-
RpcOutputStream
public RpcOutputStream(RpcPerforceFile file, RpcConnection rpcConnection, boolean useLocalDigester) throws java.io.IOException
- Throws:
java.io.IOException
-
-
Method Detail
-
getTmpOutputStream
public static RpcOutputStream getTmpOutputStream(RpcPerforceFile file) throws java.io.IOException
- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classjava.io.FileOutputStream
- Throws:
java.io.IOException
-
write
public long write(java.util.Map<java.lang.String,java.lang.Object> map) throws java.io.IOException, FileDecoderException, FileEncoderException
Specialized 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 errorjava.io.IOException
- on error
-
write
public void write(byte[] sourceBytes, int off, int len) throws java.io.IOException
- Overrides:
write
in classjava.io.FileOutputStream
- Throws:
java.io.IOException
-
write
public void write(byte[] b) throws java.io.IOException
- Overrides:
write
in classjava.io.FileOutputStream
- Throws:
java.io.IOException
-
writeConverted
public long writeConverted(byte[] sourceBytes) throws java.io.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:
java.io.IOException
- on errorFileEncoderException
- on errorFileDecoderException
- on error
-
write
public void write(int b) throws java.io.IOException
- Overrides:
write
in classjava.io.FileOutputStream
- Throws:
java.io.IOException
-
getFile
public RpcPerforceFile getFile()
-
getServerDigest
public java.lang.String getServerDigest()
-
setServerDigest
public void setServerDigest(java.lang.String serverDigest)
-
getLocalDigester
public MD5Digester getLocalDigester()
-
setLocalDigester
public void setLocalDigester(MD5Digester localDigester)
-
-