Class 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 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 interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class java.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 error
        FileDecoderException - on error
        java.io.IOException - on error
      • write

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

        public void write​(byte[] b)
                   throws java.io.IOException
        Overrides:
        write in class java.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 error
        FileEncoderException - on error
        FileDecoderException - on error
      • write

        public void write​(int b)
                   throws java.io.IOException
        Overrides:
        write in class java.io.FileOutputStream
        Throws:
        java.io.IOException
      • getServerDigest

        public java.lang.String getServerDigest()
      • setServerDigest

        public void setServerDigest​(java.lang.String serverDigest)
      • getLocalDigester

        public MD5Digester getLocalDigester()
      • setLocalDigester

        public void setLocalDigester​(MD5Digester localDigester)