Enum ClientLineEnding
- java.lang.Object
-
- java.lang.Enum<ClientLineEnding>
-
- com.perforce.p4java.impl.generic.client.ClientLineEnding
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<ClientLineEnding>
public enum ClientLineEnding extends java.lang.Enum<ClientLineEnding>
Defines the various line ending mappings needed for text files in the transfer between client and server.Crucially important for Windows / Mac / Linux / Nintendo (etc.) text files; explanations are given elsewhere...
-
-
Enum Constant Summary
Enum Constants Enum Constant Description FST_L_CR
FST_L_CR_UTF_16BE
FST_L_CR_UTF_16LE
FST_L_CRLF
FST_L_CRLF_UTF_16BE
FST_L_CRLF_UTF_16LE
FST_L_LF
FST_L_LF_UTF_16BE
FST_L_LF_UTF_16LE
FST_L_LFCRLF
FST_L_LFCRLF_UTF_16BE
FST_L_LFCRLF_UTF_16LE
FST_L_LOCAL
-
Field Summary
Fields Modifier and Type Field Description static boolean
CONVERT_TEXT
static byte[]
FST_L_CR_BYTES
static char
FST_L_CR_CHAR
static byte[]
FST_L_CR_UTF_16BE_BYTES
static byte[]
FST_L_CR_UTF_16LE_BYTES
static byte[]
FST_L_CRLF_BYTES
static byte[]
FST_L_CRLF_UTF_16BE_BYTES
static byte[]
FST_L_CRLF_UTF_16LE_BYTES
static byte[]
FST_L_LF_BYTES
static char
FST_L_LF_CHAR
static byte[]
FST_L_LF_UTF_16BE_BYTES
static byte[]
FST_L_LF_UTF_16LE_BYTES
static byte[]
FST_L_LFCRLF_BYTES
static byte[]
FST_L_LFCRLF_UTF_16BE_BYTES
static byte[]
FST_L_LFCRLF_UTF_16LE_BYTES
static byte[]
FST_L_LOCAL_BYTES
static java.lang.String
LINESEP_PROPS_KEY
The key for the system-wide line separator.static java.lang.String
localLineEndStr
The local line end string, as retrieved from the system properties.static byte
PERFORCE_SERVER_LINE_END_BYTE
What the Perforce server uses internally to signal line end.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
convertMap(java.util.Map<java.lang.String,java.lang.Object> map)
Convert the line endings for any string found in the map to theFST_L_LF_BYTES
values fromlocalLineEndStr
.static ClientLineEnding
decodeFromServerString(java.lang.String str, RpcPerforceFileType fileType)
Decode the file's actual or intended line ending type from the passed-in string.static byte[]
getLineEndBytes(ClientLineEnding lineEndSpec)
Return the byte array corresponding to the client line ending.static boolean
needsLineEndFiltering(ClientLineEnding lineEndSpec)
Determine whether we really need to translate newlines.static ClientLineEnding
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.static ClientLineEnding[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
FST_L_LOCAL
public static final ClientLineEnding FST_L_LOCAL
-
FST_L_LF
public static final ClientLineEnding FST_L_LF
-
FST_L_CR
public static final ClientLineEnding FST_L_CR
-
FST_L_CRLF
public static final ClientLineEnding FST_L_CRLF
-
FST_L_LFCRLF
public static final ClientLineEnding FST_L_LFCRLF
-
FST_L_LF_UTF_16BE
public static final ClientLineEnding FST_L_LF_UTF_16BE
-
FST_L_CR_UTF_16BE
public static final ClientLineEnding FST_L_CR_UTF_16BE
-
FST_L_CRLF_UTF_16BE
public static final ClientLineEnding FST_L_CRLF_UTF_16BE
-
FST_L_LFCRLF_UTF_16BE
public static final ClientLineEnding FST_L_LFCRLF_UTF_16BE
-
FST_L_LF_UTF_16LE
public static final ClientLineEnding FST_L_LF_UTF_16LE
-
FST_L_CR_UTF_16LE
public static final ClientLineEnding FST_L_CR_UTF_16LE
-
FST_L_CRLF_UTF_16LE
public static final ClientLineEnding FST_L_CRLF_UTF_16LE
-
FST_L_LFCRLF_UTF_16LE
public static final ClientLineEnding FST_L_LFCRLF_UTF_16LE
-
-
Field Detail
-
LINESEP_PROPS_KEY
public static final java.lang.String LINESEP_PROPS_KEY
The key for the system-wide line separator.- See Also:
- Constant Field Values
-
localLineEndStr
public static final java.lang.String localLineEndStr
The local line end string, as retrieved from the system properties. The JVM apparently guarantees that this is accurate....
-
PERFORCE_SERVER_LINE_END_BYTE
public static final byte PERFORCE_SERVER_LINE_END_BYTE
What the Perforce server uses internally to signal line end. Not coincidentally, the same as the Unix, Linux, and Mac OS X line end byte.- See Also:
- Constant Field Values
-
FST_L_LOCAL_BYTES
public static final byte[] FST_L_LOCAL_BYTES
-
FST_L_LF_CHAR
public static final char FST_L_LF_CHAR
- See Also:
- Constant Field Values
-
FST_L_CR_CHAR
public static final char FST_L_CR_CHAR
- See Also:
- Constant Field Values
-
FST_L_LF_BYTES
public static final byte[] FST_L_LF_BYTES
-
FST_L_CR_BYTES
public static final byte[] FST_L_CR_BYTES
-
FST_L_CRLF_BYTES
public static final byte[] FST_L_CRLF_BYTES
-
FST_L_LFCRLF_BYTES
public static final byte[] FST_L_LFCRLF_BYTES
-
FST_L_LF_UTF_16BE_BYTES
public static final byte[] FST_L_LF_UTF_16BE_BYTES
-
FST_L_CR_UTF_16BE_BYTES
public static final byte[] FST_L_CR_UTF_16BE_BYTES
-
FST_L_CRLF_UTF_16BE_BYTES
public static final byte[] FST_L_CRLF_UTF_16BE_BYTES
-
FST_L_LFCRLF_UTF_16BE_BYTES
public static final byte[] FST_L_LFCRLF_UTF_16BE_BYTES
-
FST_L_LF_UTF_16LE_BYTES
public static final byte[] FST_L_LF_UTF_16LE_BYTES
-
FST_L_CR_UTF_16LE_BYTES
public static final byte[] FST_L_CR_UTF_16LE_BYTES
-
FST_L_CRLF_UTF_16LE_BYTES
public static final byte[] FST_L_CRLF_UTF_16LE_BYTES
-
FST_L_LFCRLF_UTF_16LE_BYTES
public static final byte[] FST_L_LFCRLF_UTF_16LE_BYTES
-
CONVERT_TEXT
public static final boolean CONVERT_TEXT
-
-
Method Detail
-
values
public static ClientLineEnding[] 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 (ClientLineEnding c : ClientLineEnding.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static ClientLineEnding valueOf(java.lang.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:
java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is null
-
decodeFromServerString
public static ClientLineEnding decodeFromServerString(java.lang.String str, RpcPerforceFileType fileType)
Decode the file's actual or intended line ending type from the passed-in string. The line ending stuff is usually the second char (if it exists), but that may be overridden if the associated file type is a raw text type (usually something to do with merges or diff / resolve, apparently), in which case we return FST_L_LF.Hence the anomalous-looking second parameter here....
- Parameters:
str
- line ending stringfileType
- file type- Returns:
- Client line-ending
-
needsLineEndFiltering
public static boolean needsLineEndFiltering(ClientLineEnding lineEndSpec)
Determine whether we really need to translate newlines. Since the server stores them internally as "\n" characters, we only need to translate on systems where that's not the default -- currently win and mac, but we use the system prop just to be sure...- Parameters:
lineEndSpec
- client line-ending- Returns:
- true if line-ending filtering is required
-
getLineEndBytes
public static byte[] getLineEndBytes(ClientLineEnding lineEndSpec)
Return the byte array corresponding to the client line ending. The default isFST_L_LOCAL_BYTES
.- Parameters:
lineEndSpec
- client line-ending- Returns:
- bytes
-
convertMap
public static void convertMap(java.util.Map<java.lang.String,java.lang.Object> map)
Convert the line endings for any string found in the map to theFST_L_LF_BYTES
values fromlocalLineEndStr
. The conversion will be done in place.- Parameters:
map
- map spec
-
-