org.eclipse.jgit.util
Class QuotedString.BourneStyle

java.lang.Object
  extended by org.eclipse.jgit.util.QuotedString
      extended by org.eclipse.jgit.util.QuotedString.BourneStyle
Direct Known Subclasses:
QuotedString.BourneUserPathStyle
Enclosing class:
QuotedString

public static class QuotedString.BourneStyle
extends QuotedString

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.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.eclipse.jgit.util.QuotedString
QuotedString.BourneStyle, QuotedString.BourneUserPathStyle, QuotedString.GitPathStyle
 
Field Summary
 
Fields inherited from class org.eclipse.jgit.util.QuotedString
BOURNE, BOURNE_USER_PATH, GIT_PATH
 
Constructor Summary
QuotedString.BourneStyle()
           
 
Method Summary
 String dequote(byte[] in, int ip, int ie)
          Decode a previously quoted input, scanning a UTF-8 encoded buffer.
 String quote(String in)
          Quote an input string by the quoting rules.
 
Methods inherited from class org.eclipse.jgit.util.QuotedString
dequote
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QuotedString.BourneStyle

public QuotedString.BourneStyle()
Method Detail

quote

public String quote(String in)
Description copied from class: QuotedString
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.

Specified by:
quote in class QuotedString
Parameters:
in - any non-null Unicode string.
Returns:
a quoted string. See above for details.

dequote

public String dequote(byte[] in,
                      int ip,
                      int ie)
Description copied from class: QuotedString
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 QuotedString.quote(String).

Specified by:
dequote in class QuotedString
Parameters:
in - the input buffer to parse.
ip - first position within in to scan.
ie - one position past in in to scan.
Returns:
the cleaned string.


Copyright © 2012. All Rights Reserved.