com.perforce.p4java.impl.mapbased.rpc.sys
Enum RpcPerforceFileType

java.lang.Object
  extended by java.lang.Enum<RpcPerforceFileType>
      extended by com.perforce.p4java.impl.mapbased.rpc.sys.RpcPerforceFileType
All Implemented Interfaces:
Serializable, Comparable<RpcPerforceFileType>

public enum RpcPerforceFileType
extends Enum<RpcPerforceFileType>

Definitions for Perforce client and server file types.

Perforce defines a surprising variety of basic file types and associated modifiers that determine things like how to send and receive file contents between the client and the server (UTF-8 vs UTF-16, compressed binary vs. uncompressed binary, plain old "text", etc.) and how to interpret file metadata. These types and the associated panoply of methods, etc., are mostly used in the clientCheckFile, clientOpen, clientClose, clientWrite, etc. methods on the various client function classes.

A file's type is stored in the server for all known files, (see e.g. "p4 help filemap" and "p4 help filetypes"), and in most cases we simply accept what we're given if we can cope with that type (there are some types we don't process at all here -- see below). What sort of file types a server (as opposed to the client) knows about and can process depends on the server's xlevel protocol variable:

        - xfiles unset: return text, binary.
        - xfiles >= 0: also return xtext, xbinary.
        - xfiles >= 1: also return symlink.
        - xfiles >= 2; also return resource (mac resource file).  
        - xfiles >= 3; also return ubinary
        - xfiles >= 4; also return apple
 
In general, the client has to honour the server's xlevel capabilities, so the client may have to do a bit of work to get things right here. Unfortunately, in some cases it's very difficult to know what Perforce type a file should be, and there's a bunch of digging around that must be done to intuit the proper type for files the server doesn't (yet) know about.

Also somewhat unfortunately, the file type is encoded quite differently depending on whether it's coming from the server (usually encoded as a string representation of hex numbers) or going to the server (where it's usually done as plain old "text" or "ubinary", etc.).


Nested Class Summary
static class RpcPerforceFileType.RpcServerTypeStringSpec
           
 
Enum Constant Summary
FST_APPLEFILE
           
FST_APPLETEXT
           
FST_ATEXT
           
FST_BINARY
           
FST_CANTTELL
           
FST_CBINARY
           
FST_DIRECTORY
           
FST_EMPTY
           
FST_GUNZIP
           
FST_GZIP
           
FST_MISSING
           
FST_RCS
           
FST_RESOURCE
           
FST_RTEXT
           
FST_RXTEXT
           
FST_SPECIAL
           
FST_SYMLINK
           
FST_TEXT
           
FST_UNICODE
           
FST_UTF16
           
FST_XAPPLEFILE
           
FST_XAPPLETEXT
           
FST_XBINARY
           
FST_XGUNZIP
           
FST_XRESOURCE
           
FST_XRTEXT
           
FST_XSYMLINK
           
FST_XTEXT
           
FST_XUNICODE
           
FST_XUTF16
           
 
Field Summary
static String TRACE_PREFIX
           
 
Method Summary
static RpcPerforceFileType decodeFromServerString(String str)
          Decode the file type from the string sent by the server.
static RpcPerforceFileType.RpcServerTypeStringSpec getServerFileTypeString(String clientPath, RpcPerforceFileType fileType, String forceType, int xfiles)
          Given a Perforce file type and the Perforce server's xfiles level (from the protocol parameters), determine what server file type to send to the server to represent the passed-in file type as a string, and / or what error or info message to send to the user.
static RpcPerforceFileType inferFileType(File file, boolean isUnicodeServer, Charset clientCharset)
          Infer (or even intuit) the Perforce file type of the passed-in Perforce file.
 boolean isExecutable()
          Checking for executable file types - excluding "forbidden" types.
static boolean isProbablySymLink(File file)
          Return true if there's some reason to believe this file is a Unix or Linux symbolic link.
static RpcPerforceFileType valueOf(String name)
          Returns the enum constant of this type with the specified name.
static RpcPerforceFileType[] values()
          Returns an array containing the constants of this enum type, in the order they are declared.
 
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

FST_TEXT

public static final RpcPerforceFileType FST_TEXT

FST_BINARY

public static final RpcPerforceFileType FST_BINARY

FST_GZIP

public static final RpcPerforceFileType FST_GZIP

FST_DIRECTORY

public static final RpcPerforceFileType FST_DIRECTORY

FST_SYMLINK

public static final RpcPerforceFileType FST_SYMLINK

FST_RESOURCE

public static final RpcPerforceFileType FST_RESOURCE

FST_SPECIAL

public static final RpcPerforceFileType FST_SPECIAL

FST_MISSING

public static final RpcPerforceFileType FST_MISSING

FST_CANTTELL

public static final RpcPerforceFileType FST_CANTTELL

FST_EMPTY

public static final RpcPerforceFileType FST_EMPTY

FST_UNICODE

public static final RpcPerforceFileType FST_UNICODE

FST_GUNZIP

public static final RpcPerforceFileType FST_GUNZIP

FST_UTF16

public static final RpcPerforceFileType FST_UTF16

FST_ATEXT

public static final RpcPerforceFileType FST_ATEXT

FST_XTEXT

public static final RpcPerforceFileType FST_XTEXT

FST_RTEXT

public static final RpcPerforceFileType FST_RTEXT

FST_RXTEXT

public static final RpcPerforceFileType FST_RXTEXT

FST_CBINARY

public static final RpcPerforceFileType FST_CBINARY

FST_XBINARY

public static final RpcPerforceFileType FST_XBINARY

FST_XSYMLINK

public static final RpcPerforceFileType FST_XSYMLINK

FST_XRESOURCE

public static final RpcPerforceFileType FST_XRESOURCE

FST_APPLETEXT

public static final RpcPerforceFileType FST_APPLETEXT

FST_APPLEFILE

public static final RpcPerforceFileType FST_APPLEFILE

FST_XAPPLEFILE

public static final RpcPerforceFileType FST_XAPPLEFILE

FST_XAPPLETEXT

public static final RpcPerforceFileType FST_XAPPLETEXT

FST_XUNICODE

public static final RpcPerforceFileType FST_XUNICODE

FST_XRTEXT

public static final RpcPerforceFileType FST_XRTEXT

FST_XUTF16

public static final RpcPerforceFileType FST_XUTF16

FST_XGUNZIP

public static final RpcPerforceFileType FST_XGUNZIP

FST_RCS

public static final RpcPerforceFileType FST_RCS
Field Detail

TRACE_PREFIX

public static final String TRACE_PREFIX
See Also:
Constant Field Values
Method Detail

values

public static RpcPerforceFileType[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
for (RpcPerforceFileType c : RpcPerforceFileType.values())
    System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are declared

valueOf

public static RpcPerforceFileType valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
IllegalArgumentException - if this enum type has no constant with the specified name
NullPointerException - if the argument is null

decodeFromServerString

public static RpcPerforceFileType decodeFromServerString(String str)
Decode the file type from the string sent by the server. This is (usually) a three-character hex encoding, e.g. "101" or "01D".


isExecutable

public boolean isExecutable()
Checking for executable file types - excluding "forbidden" types.


inferFileType

public static RpcPerforceFileType inferFileType(File file,
                                                boolean isUnicodeServer,
                                                Charset clientCharset)
Infer (or even intuit) the Perforce file type of the passed-in Perforce file. This is an arbitrarily complex operation, and may involve reading in the first few bytes of a file to see what the contents say about the type.

Note that Java does not allow us to directly access most file metadata. This probably doesn't matter in most cases, but we do need to keep an eye on this -- HR.


getServerFileTypeString

public static RpcPerforceFileType.RpcServerTypeStringSpec getServerFileTypeString(String clientPath,
                                                                                  RpcPerforceFileType fileType,
                                                                                  String forceType,
                                                                                  int xfiles)
Given a Perforce file type and the Perforce server's xfiles level (from the protocol parameters), determine what server file type to send to the server to represent the passed-in file type as a string, and / or what error or info message to send to the user.


isProbablySymLink

public static boolean isProbablySymLink(File file)
Return true if there's some reason to believe this file is a Unix or Linux symbolic link. This is just a hack that's here until I can do something better with native code...



Copyright © 2015 Perforce Software. All Rights Reserved.