Class ExecParameterTokenizer


  • public class ExecParameterTokenizer
    extends java.lang.Object
    This class is used to tokenize strings used as parameters for RuntimeExec objects. Examples of such strings are as follows (ImageMagick-like parameters):
    • -font Helvetica -pointsize 50
    • -font Helvetica -pointsize 50 -draw "circle 100,100 150,150"
    • -font Helvetica -pointsize 50 -draw "gravity south fill black text 0,12 'CopyRight'"
    The first is the simple case which would be parsed into Strings as follows: "-font", "Helvetica", "-pointsize", "50"

    The second is more complex in that it includes a quoted parameter, which would be parsed as a single String: "-font", "Helvetica", "-pointsize", "50", "circle 100,100 150,150" Note however that the quotation characters will be stripped from the token.

    The third shows an example with embedded quotation marks, which would parse to: "-font", "Helvetica", "-pointsize", "50", "gravity south fill black text 0,12 'CopyRight'" In this case, the embedded quotation marks (which must be different from those surrounding the parameter) are preserved in the extracted token.

    The class does not understand escaped quotes such as p1 p2 "a b c \"hello\" d" p4

    Since:
    3.4.2
    Author:
    Neil Mc Erlean
    • Constructor Detail

      • ExecParameterTokenizer

        public ExecParameterTokenizer​(java.lang.String str)
    • Method Detail

      • getAllTokens

        public java.util.List<java.lang.String> getAllTokens()
        This method returns the tokens in a parameter string. Any tokens not contained within single or double quotes will be tokenized in the normal way i.e. by using whitespace separators and the standard StringTokenizer algorithm. Any tokens which are contained within single or double quotes will be returned as single String instances and will have their quote marks removed.

        See above for examples.

        Throws:
        java.lang.NullPointerException - if the string to be tokenized was null.