- java.lang.Object
-
- org.eclipse.jgit.util.QuotedString
-
- Direct Known Subclasses:
QuotedString.BourneStyle,QuotedString.GitPathStyle
public abstract class QuotedString extends Object
Utility functions related to quoted string handling.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classQuotedString.BourneStyleQuoting style used by the Bourne shell.static classQuotedString.BourneUserPathStyleBourne style, but permits~userat the start of the string.static classQuotedString.GitPathStyleQuoting style that obeys the rules Git applies to file names
-
Field Summary
Fields Modifier and Type Field Description static QuotedString.BourneStyleBOURNEQuoting style used by the Bourne shell.static QuotedString.BourneUserPathStyleBOURNE_USER_PATHBourne style, but permits~userat the start of the string.static QuotedString.GitPathStyleGIT_PATHQuoting style that obeys the rules Git applies to file namesstatic QuotedStringGIT_PATH_MINIMALQuoting style that obeys the rules Git applies to file names whencore.quotePath = false.
-
Constructor Summary
Constructors Constructor Description QuotedString()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract Stringdequote(byte[] in, int offset, int end)Decode a previously quoted input, scanning a UTF-8 encoded buffer.Stringdequote(String in)Clean a previously quoted input, decoding the result via UTF-8.abstract Stringquote(String in)Quote an input string by the quoting rules.
-
-
-
Field Detail
-
GIT_PATH
public static final QuotedString.GitPathStyle GIT_PATH
Quoting style that obeys the rules Git applies to file names
-
GIT_PATH_MINIMAL
public static final QuotedString GIT_PATH_MINIMAL
Quoting style that obeys the rules Git applies to file names whencore.quotePath = false.- Since:
- 5.6
-
BOURNE
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_PATH
public static final QuotedString.BourneUserPathStyle BOURNE_USER_PATH
Bourne style, but permits~userat the start of the string.
-
-
Method Detail
-
quote
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- any non-null Unicode string.- Returns:
- a quoted string. See above for details.
-
dequote
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 anya.- Parameters:
in- a Unicode string to remove quoting from.- Returns:
- the cleaned string.
- See Also:
dequote(byte[], int, int)
-
dequote
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 anya.This method removes any opening/closing quotation marks added by
quote(String).- Parameters:
in- the input buffer to parse.offset- first position withininto scan.end- one position past ininto scan.- Returns:
- the cleaned string.
-
-