Top Description Inners Fields Constructors Methods
org.eclipse.jgit.util

public abstract Class QuotedString

extends Object
Class Inheritance
Known Direct Subclasses
org.eclipse.jgit.util.QuotedString.BourneStyle, org.eclipse.jgit.util.QuotedString.GitPathStyle
Static Imports
java.nio.charset.StandardCharsets.UTF_8

Utility functions related to quoted string handling.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
QuotedString.BourneStyle

Quoting style used by the Bourne shell.

public static class
QuotedString.BourneUserPathStyle

Bourne style, but permits ~user at the start of the string.

public static class
QuotedString.GitPathStyle

Quoting style that obeys the rules Git applies to file names

Field Summary

Modifier and TypeField and Description
public static final QuotedString.BourneStyle
BOURNE

Quoting style used by the Bourne shell.

public static final QuotedString.BourneUserPathStyle
BOURNE_USER_PATH

Bourne style, but permits ~user at the start of the string.

public static final QuotedString.GitPathStyle
GIT_PATH

Quoting style that obeys the rules Git applies to file names

public static final QuotedString
GIT_PATH_MINIMAL

Quoting style that obeys the rules Git applies to file names when core.quotePath = false.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

the cleaned string.
dequote
(String
a Unicode string to remove quoting from.
in
)

Clean a previously quoted input, decoding the result via UTF-8.

public abstract String

Returns:

the cleaned string.
dequote
(byte[]
the input buffer to parse.
in
,
int
first position within in to scan.
offset
,
int
one position past in in to scan.
end
)

Decode a previously quoted input, scanning a UTF-8 encoded buffer.

public abstract String

Returns:

a quoted string. See above for details.
quote
(String
any non-null Unicode string.
in
)

Quote an input string by the quoting rules.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

BOURNEback to summary
public static final QuotedString.BourneStyle BOURNE

Quoting style used by the Bourne shell.

Quotes are unconditionally inserted during quote(String). This protects shell meta-characters like $ or ~ from being recognized as special.

BOURNE_USER_PATHback to summary
public static final QuotedString.BourneUserPathStyle BOURNE_USER_PATH

Bourne style, but permits ~user at the start of the string.

GIT_PATHback to summary
public static final QuotedString.GitPathStyle GIT_PATH

Quoting style that obeys the rules Git applies to file names

GIT_PATH_MINIMALback to summary
public static final QuotedString GIT_PATH_MINIMAL

Quoting style that obeys the rules Git applies to file names when core.quotePath = false.

Since
5.6

Constructor Detail

QuotedStringback to summary
public QuotedString()

Method Detail

dequoteback to summary
public String dequote(String in)

Clean a previously quoted input, decoding the result via UTF-8.

This method must match quote such that:

a.equals(dequote(quote(a)));
is true for any a.
Parameters
in:String

a Unicode string to remove quoting from.

Returns:String

the cleaned string.

See Also
dequote(byte[], int, int)
dequoteback to summary
public abstract String dequote(byte[] in, int offset, int end)

Decode a previously quoted input, scanning a UTF-8 encoded buffer.

This method must match quote such that:

a.equals(dequote(Constants.encode(quote(a))));
is true for any a.

This method removes any opening/closing quotation marks added by quote(String).

Parameters
in:byte[]

the input buffer to parse.

offset:int

first position within in to scan.

end:int

one position past in in to scan.

Returns:String

the cleaned string.

quoteback to summary
public abstract String quote(String in)

Quote an input string by the quoting rules.

If the input string does not require any quoting, the same String reference is returned to the caller.

Otherwise a quoted string is returned, including the opening and closing quotation marks at the start and end of the string. If the style does not permit raw Unicode characters then the string will first be encoded in UTF-8, with unprintable sequences possibly escaped by the rules.

Parameters
in:String

any non-null Unicode string.

Returns:String

a quoted string. See above for details.

org.eclipse.jgit.util back to summary

public Class QuotedString.BourneStyle

extends QuotedString
Class Inheritance
Known Direct Subclasses
org.eclipse.jgit.util.QuotedString.BourneUserPathStyle

Quoting style used by the Bourne shell.

Quotes are unconditionally inserted during quote(String). This protects shell meta-characters like $ or ~ from being recognized as special.

Field Summary

Inherited from org.eclipse.jgit.util.QuotedString:
BOURNEBOURNE_USER_PATHGIT_PATHGIT_PATH_MINIMAL

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public String
dequote(byte[]
the input buffer to parse.
in
,
int
first position within in to scan.
ip
,
int
one position past in in to scan.
ie
)

Implements abstract org.eclipse.jgit.util.QuotedString.dequote.

Decode a previously quoted input, scanning a UTF-8 encoded buffer.

public String
quote(String
any non-null Unicode string.
in
)

Implements abstract org.eclipse.jgit.util.QuotedString.quote.

Quote an input string by the quoting rules.

Inherited from org.eclipse.jgit.util.QuotedString:
dequote

Constructor Detail

BourneStyleback to summary
public BourneStyle()

Method Detail

dequoteback to summary
public String dequote(byte[] in, int ip, int ie)

Implements abstract org.eclipse.jgit.util.QuotedString.dequote.

Doc from org.eclipse.jgit.util.QuotedString.dequote.

Decode a previously quoted input, scanning a UTF-8 encoded buffer.

This method must match quote such that:

a.equals(dequote(Constants.encode(quote(a))));
is true for any a.

This method removes any opening/closing quotation marks added by quote(String).

Parameters
in:byte[]

the input buffer to parse.

ip:int

first position within in to scan.

ie:int

one position past in in to scan.

Returns:String

the cleaned string.

Annotations
@Override
quoteback to summary
public String quote(String in)

Implements abstract org.eclipse.jgit.util.QuotedString.quote.

Doc from org.eclipse.jgit.util.QuotedString.quote.

Quote an input string by the quoting rules.

If the input string does not require any quoting, the same String reference is returned to the caller.

Otherwise a quoted string is returned, including the opening and closing quotation marks at the start and end of the string. If the style does not permit raw Unicode characters then the string will first be encoded in UTF-8, with unprintable sequences possibly escaped by the rules.

Parameters
in:String

any non-null Unicode string.

Returns:String

a quoted string. See above for details.

Annotations
@Override
org.eclipse.jgit.util back to summary

public Class QuotedString.BourneUserPathStyle

extends BourneStyle
Class Inheritance

Bourne style, but permits ~user at the start of the string.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public String
quote(String
any non-null Unicode string.
in
)

Overrides org.eclipse.jgit.util.QuotedString.BourneStyle.quote.

Quote an input string by the quoting rules.

Inherited from org.eclipse.jgit.util.QuotedString.BourneStyle:
dequote

Constructor Detail

BourneUserPathStyleback to summary
public BourneUserPathStyle()

Method Detail

quoteback to summary
public String quote(String in)

Overrides org.eclipse.jgit.util.QuotedString.BourneStyle.quote.

Doc from org.eclipse.jgit.util.QuotedString.quote.

Quote an input string by the quoting rules.

If the input string does not require any quoting, the same String reference is returned to the caller.

Otherwise a quoted string is returned, including the opening and closing quotation marks at the start and end of the string. If the style does not permit raw Unicode characters then the string will first be encoded in UTF-8, with unprintable sequences possibly escaped by the rules.

Parameters
in:String

any non-null Unicode string.

Returns:String

a quoted string. See above for details.

Annotations
@Override
org.eclipse.jgit.util back to summary

public final Class QuotedString.GitPathStyle

extends QuotedString
Class Inheritance

Quoting style that obeys the rules Git applies to file names

Field Summary

Modifier and TypeField and Description
private static final byte[]
private final boolean
Inherited from org.eclipse.jgit.util.QuotedString:
BOURNEBOURNE_USER_PATHGIT_PATHGIT_PATH_MINIMAL

Constructor Summary

AccessConstructor and Description
private
GitPathStyle(boolean doQuote)

Method Summary

Modifier and TypeMethod and Description
public String
dequote(byte[]
the input buffer to parse.
in
,
int
first position within in to scan.
inPtr
,
int
one position past in in to scan.
inEnd
)

Implements abstract org.eclipse.jgit.util.QuotedString.dequote.

Decode a previously quoted input, scanning a UTF-8 encoded buffer.

private static String
dq(byte[] in, int inPtr, int inEnd)

public String
quote(String
any non-null Unicode string.
instr
)

Implements abstract org.eclipse.jgit.util.QuotedString.quote.

Quote an input string by the quoting rules.

Inherited from org.eclipse.jgit.util.QuotedString:
dequote

Field Detail

quoteback to summary
private static final byte[] quote
quoteHighback to summary
private final boolean quoteHigh

Constructor Detail

GitPathStyleback to summary
private GitPathStyle(boolean doQuote)

Method Detail

dequoteback to summary
public String dequote(byte[] in, int inPtr, int inEnd)

Implements abstract org.eclipse.jgit.util.QuotedString.dequote.

Doc from org.eclipse.jgit.util.QuotedString.dequote.

Decode a previously quoted input, scanning a UTF-8 encoded buffer.

This method must match quote such that:

a.equals(dequote(Constants.encode(quote(a))));
is true for any a.

This method removes any opening/closing quotation marks added by quote(String).

Parameters
in:byte[]

the input buffer to parse.

inPtr:int

first position within in to scan.

inEnd:int

one position past in in to scan.

Returns:String

the cleaned string.

Annotations
@Override
dqback to summary
private static String dq(byte[] in, int inPtr, int inEnd)
quoteback to summary
public String quote(String instr)

Implements abstract org.eclipse.jgit.util.QuotedString.quote.

Doc from org.eclipse.jgit.util.QuotedString.quote.

Quote an input string by the quoting rules.

If the input string does not require any quoting, the same String reference is returned to the caller.

Otherwise a quoted string is returned, including the opening and closing quotation marks at the start and end of the string. If the style does not permit raw Unicode characters then the string will first be encoded in UTF-8, with unprintable sequences possibly escaped by the rules.

Parameters
instr:String

any non-null Unicode string.

Returns:String

a quoted string. See above for details.

Annotations
@Override