com.perforce.p4java.impl.mapbased.rpc.sys
Class RpcOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by java.io.FileOutputStream
          extended by com.perforce.p4java.impl.mapbased.rpc.sys.RpcOutputStream
All Implemented Interfaces:
Closeable, Flushable

public class RpcOutputStream
extends 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
RpcOutputStream(RpcPerforceFile file)
           
RpcOutputStream(RpcPerforceFile file, boolean useLocalDigester)
           
RpcOutputStream(RpcPerforceFile file, Charset charset, boolean isUnicodeServer, boolean useLocalDigester)
           
 
Method Summary
 void close()
           
 void flush()
           
 RpcPerforceFile getFile()
           
 MD5Digester getLocalDigester()
           
 String getServerDigest()
           
 void setLocalDigester(MD5Digester localDigester)
           
 void setServerDigest(String serverDigest)
           
 void write(byte[] b)
           
 void write(byte[] sourceBytes, int off, int len)
           
 void write(int b)
           
 long write(Map<String,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.
 
Methods inherited from class java.io.FileOutputStream
finalize, getChannel, getFD
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RpcOutputStream

public RpcOutputStream(RpcPerforceFile file)
                throws IOException
Throws:
IOException

RpcOutputStream

public RpcOutputStream(RpcPerforceFile file,
                       boolean useLocalDigester)
                throws IOException
Throws:
IOException

RpcOutputStream

public RpcOutputStream(RpcPerforceFile file,
                       Charset charset,
                       boolean isUnicodeServer,
                       boolean useLocalDigester)
                throws IOException
Throws:
IOException
Method Detail

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Overrides:
close in class FileOutputStream
Throws:
IOException

flush

public void flush()
           throws IOException
Specified by:
flush in interface Flushable
Overrides:
flush in class OutputStream
Throws:
IOException
See Also:
OutputStream.flush()

write

public long write(Map<String,Object> map)
           throws IOException
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.

Throws:
IOException

write

public void write(byte[] sourceBytes,
                  int off,
                  int len)
           throws IOException
Overrides:
write in class FileOutputStream
Throws:
IOException

write

public void write(byte[] b)
           throws IOException
Overrides:
write in class FileOutputStream
Throws:
IOException

writeConverted

public long writeConverted(byte[] sourceBytes)
                    throws IOException
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 -
Throws:
IOException

write

public void write(int b)
           throws IOException
Overrides:
write in class FileOutputStream
Throws:
IOException

getFile

public RpcPerforceFile getFile()

getServerDigest

public String getServerDigest()

setServerDigest

public void setServerDigest(String serverDigest)

getLocalDigester

public MD5Digester getLocalDigester()

setLocalDigester

public void setLocalDigester(MD5Digester localDigester)


Copyright © 2015 Perforce Software. All Rights Reserved.