Tabnine Logo
CommandLine$Model$ParserSpec.splitQuotedStrings
Code IndexAdd Tabnine to your IDE (free)

How to use
splitQuotedStrings
method
in
picocli.CommandLine$Model$ParserSpec

Best Java code snippets using picocli.CommandLine$Model$ParserSpec.splitQuotedStrings (Showing top 18 results out of 315)

origin: remkop/picocli

String[] splitValue(String value, ParserSpec parser, Range arity, int consumed) {
  if (splitRegex().length() == 0) { return new String[] {value}; }
  int limit = parser.limitSplit() ? Math.max(arity.max - consumed, 0) : 0;
  if (parser.splitQuotedStrings()) {
    return debug(value.split(splitRegex(), limit), "Split (ignoring quotes)", value);
  }
  return debug(splitRespectingQuotedStrings(value, limit, parser, this, splitRegex()), "Split", value);
}
private String[] debug(String[] result, String msg, String value) {
origin: remkop/picocli

/** Sets whether the parser is allowed to split quoted Strings. The default is {@code false}.
 * <p>The specified setting will be registered with this {@code CommandLine} and the full hierarchy of its
 * subcommands and nested sub-subcommands <em>at the moment this method is called</em>. Subcommands added
 * later will have the default setting. To ensure a setting is applied to all
 * subcommands, call the setter last, after adding subcommands.</p>
 * @param newValue the new setting
 * @return this {@code CommandLine} object, to allow method chaining
 * @see ArgSpec#splitRegex()
 * @since 3.7
 */
public CommandLine setSplitQuotedStrings(boolean newValue) {
  getCommandSpec().parser().splitQuotedStrings(newValue);
  for (CommandLine command : getCommandSpec().subcommands().values()) {
    command.setSplitQuotedStrings(newValue);
  }
  return this;
}
origin: remkop/picocli

@Test
public void testArgSpecSplitWithEscapedBackslashInsideQuote() {
  PositionalParamSpec positional = PositionalParamSpec.builder().splitRegex(";").build();
  System.setProperty("picocli.trace", "DEBUG");
  String value = "\"abc\\\\\\\";def\"";
  String[] values = positional.splitValue(value, new CommandLine.Model.ParserSpec().splitQuotedStrings(false), CommandLine.Range.valueOf("1"), 1);
  System.clearProperty("picocli.trace");
  assertArrayEquals(new String[] {"\"abc\\\\\\\";def\""}, values);
}
origin: hazelcast/hazelcast-jet

/** Sets whether the parser is allowed to split quoted Strings. The default is {@code false}.
 * <p>The specified setting will be registered with this {@code CommandLine} and the full hierarchy of its
 * subcommands and nested sub-subcommands <em>at the moment this method is called</em>. Subcommands added
 * later will have the default setting. To ensure a setting is applied to all
 * subcommands, call the setter last, after adding subcommands.</p>
 * @param newValue the new setting
 * @return this {@code CommandLine} object, to allow method chaining
 * @see ArgSpec#splitRegex()
 * @since 3.7
 */
public CommandLine setSplitQuotedStrings(boolean newValue) {
  getCommandSpec().parser().splitQuotedStrings(newValue);
  for (CommandLine command : getCommandSpec().subcommands().values()) {
    command.setSplitQuotedStrings(newValue);
  }
  return this;
}
origin: info.picocli/picocli

@Test
public void testArgSpecSplitUnbalancedQuotedValueDebug() {
  PositionalParamSpec positional = PositionalParamSpec.builder().splitRegex(";").build();
  System.setProperty("picocli.trace", "DEBUG");
  String value = "\"abc\\\";def";
  String[] values = positional.splitValue(value, new CommandLine.Model.ParserSpec().splitQuotedStrings(false), CommandLine.Range.valueOf("1"), 1);
  System.clearProperty("picocli.trace");
  assertArrayEquals(new String[] {"\"abc\\\"", "def"}, values);
}
@Test
origin: info.picocli/picocli

@Test
public void testArgSpecSplitValueDebug() {
  PositionalParamSpec positional = PositionalParamSpec.builder().splitRegex("b").build();
  System.setProperty("picocli.trace", "DEBUG");
  String[] values = positional.splitValue("abc", new CommandLine.Model.ParserSpec().splitQuotedStrings(true), CommandLine.Range.valueOf("1"), 1);
  System.clearProperty("picocli.trace");
  assertArrayEquals(new String[] {"a", "c"}, values);
}
origin: info.picocli/picocli

@Test
public void testArgSpecSplitValue_SplitsQuotedValuesIfConfigured() {
  ParserSpec parser = new ParserSpec().splitQuotedStrings(true);
  ArgSpec spec = PositionalParamSpec.builder().splitRegex(",").build();
  String[] actual = spec.splitValue("a,b,\"c,d,e\",f", parser, Range.valueOf("0"), 0);
  assertArrayEquals(new String[]{"a", "b", "\"c", "d" , "e\"", "f"}, actual);
}
origin: info.picocli/picocli

@Test
public void testArgSpecSplitWithEscapedBackslashOutsideQuote() {
  PositionalParamSpec positional = PositionalParamSpec.builder().splitRegex(";").build();
  System.setProperty("picocli.trace", "DEBUG");
  String value = "\\\\\"abc\\\";def\";\\\"a\\";
  String[] values = positional.splitValue(value, new CommandLine.Model.ParserSpec().splitQuotedStrings(false), CommandLine.Range.valueOf("1"), 1);
  System.clearProperty("picocli.trace");
  assertArrayEquals(new String[] {"\\\\\"abc\\\";def\"", "\\\"a\\"}, values);
}
origin: info.picocli/picocli

@Test
public void testArgSpecSplitBalancedQuotedValueDebug() {
  PositionalParamSpec positional = PositionalParamSpec.builder().splitRegex(";").build();
  System.setProperty("picocli.trace", "DEBUG");
  String value = "\"abc\\\";def\"";
  String[] values = positional.splitValue(value, new CommandLine.Model.ParserSpec().splitQuotedStrings(false), CommandLine.Range.valueOf("1"), 1);
  System.clearProperty("picocli.trace");
  assertArrayEquals(new String[] {"\"abc\\\";def\""}, values);
}
origin: info.picocli/picocli

@Test
public void testArgSpecSplitWithEscapedBackslashInsideQuote() {
  PositionalParamSpec positional = PositionalParamSpec.builder().splitRegex(";").build();
  System.setProperty("picocli.trace", "DEBUG");
  String value = "\"abc\\\\\\\";def\"";
  String[] values = positional.splitValue(value, new CommandLine.Model.ParserSpec().splitQuotedStrings(false), CommandLine.Range.valueOf("1"), 1);
  System.clearProperty("picocli.trace");
  assertArrayEquals(new String[] {"\"abc\\\\\\\";def\""}, values);
}
origin: hazelcast/hazelcast-jet

String[] splitValue(String value, ParserSpec parser, Range arity, int consumed) {
  if (splitRegex().length() == 0) { return new String[] {value}; }
  int limit = parser.limitSplit() ? Math.max(arity.max - consumed, 0) : 0;
  if (parser.splitQuotedStrings()) {
    return debug(value.split(splitRegex(), limit), "Split (ignoring quotes)", value);
  }
  return debug(splitRespectingQuotedStrings(value, limit, parser), "Split", value);
}
private String[] debug(String[] result, String msg, String value) {
origin: hazelcast/hazelcast-jet

/** Returns whether the parser is allowed to split quoted Strings or not. The default is {@code false},
 * so quoted strings are treated as a single value that cannot be split.
 * @return {@code true} if the parser is allowed to split quoted Strings, {@code false} otherwise;
 * @see ArgSpec#splitRegex()
 * @since 3.7 */
public boolean isSplitQuotedStrings() { return getCommandSpec().parser().splitQuotedStrings(); }
origin: remkop/picocli

@Test
public void testArgSpecSplitUnbalancedQuotedValueDebug() {
  PositionalParamSpec positional = PositionalParamSpec.builder().splitRegex(";").build();
  System.setProperty("picocli.trace", "DEBUG");
  String value = "\"abc\\\";def";
  String[] values = positional.splitValue(value, new CommandLine.Model.ParserSpec().splitQuotedStrings(false), CommandLine.Range.valueOf("1"), 1);
  System.clearProperty("picocli.trace");
  assertArrayEquals(new String[] {"\"abc\\\"", "def"}, values);
}
@Test
origin: remkop/picocli

@Test
public void testArgSpecSplitValue_SplitsQuotedValuesIfConfigured() {
  ParserSpec parser = new ParserSpec().splitQuotedStrings(true);
  ArgSpec spec = PositionalParamSpec.builder().splitRegex(",").build();
  String[] actual = spec.splitValue("a,b,\"c,d,e\",f", parser, Range.valueOf("0"), 0);
  assertArrayEquals(new String[]{"a", "b", "\"c", "d" , "e\"", "f"}, actual);
}
origin: remkop/picocli

@Test
public void testArgSpecSplitBalancedQuotedValueDebug() {
  PositionalParamSpec positional = PositionalParamSpec.builder().splitRegex(";").build();
  System.setProperty("picocli.trace", "DEBUG");
  String value = "\"abc\\\";def\"";
  String[] values = positional.splitValue(value, new CommandLine.Model.ParserSpec().splitQuotedStrings(false), CommandLine.Range.valueOf("1"), 1);
  System.clearProperty("picocli.trace");
  assertArrayEquals(new String[] {"\"abc\\\";def\""}, values);
}
origin: remkop/picocli

/** Returns whether the parser is allowed to split quoted Strings or not. The default is {@code false},
 * so quoted strings are treated as a single value that cannot be split.
 * @return {@code true} if the parser is allowed to split quoted Strings, {@code false} otherwise;
 * @see ArgSpec#splitRegex()
 * @since 3.7 */
public boolean isSplitQuotedStrings() { return getCommandSpec().parser().splitQuotedStrings(); }
origin: remkop/picocli

@Test
public void testArgSpecSplitWithEscapedBackslashOutsideQuote() {
  PositionalParamSpec positional = PositionalParamSpec.builder().splitRegex(";").build();
  System.setProperty("picocli.trace", "DEBUG");
  String value = "\\\\\"abc\\\";def\";\\\"a\\";
  String[] values = positional.splitValue(value, new CommandLine.Model.ParserSpec().splitQuotedStrings(false), CommandLine.Range.valueOf("1"), 1);
  System.clearProperty("picocli.trace");
  assertArrayEquals(new String[] {"\\\\\"abc\\\";def\"", "\\\"a\\"}, values);
}
origin: remkop/picocli

@Test
public void testArgSpecSplitValueDebug() {
  PositionalParamSpec positional = PositionalParamSpec.builder().splitRegex("b").build();
  System.setProperty("picocli.trace", "DEBUG");
  String[] values = positional.splitValue("abc", new CommandLine.Model.ParserSpec().splitQuotedStrings(true), CommandLine.Range.valueOf("1"), 1);
  System.clearProperty("picocli.trace");
  assertArrayEquals(new String[] {"a", "c"}, values);
}
picocliCommandLine$Model$ParserSpecsplitQuotedStrings

Popular methods of CommandLine$Model$ParserSpec

  • separator
  • aritySatisfiedByAttachedOptionParam
  • caseInsensitiveEnumValuesAllowed
  • collectErrors
  • limitSplit
  • posixClusteredShortOptionsAllowed
  • unmatchedOptionsArePositionalParams
  • trimQuotes
  • useSimplifiedAtFiles
  • atFileCommentChar
  • endOfOptionsDelimiter
  • expandAtFiles
  • endOfOptionsDelimiter,
  • expandAtFiles,
  • overwrittenOptionsAllowed,
  • stopAtPositional,
  • stopAtUnmatched,
  • toggleBooleanFlags,
  • unmatchedArgumentsAllowed,
  • <init>,
  • initFrom

Popular in Java

  • Making http requests using okhttp
  • onRequestPermissionsResult (Fragment)
  • runOnUiThread (Activity)
  • setContentView (Activity)
  • Container (java.awt)
    A generic Abstract Window Toolkit(AWT) container object is a component that can contain other AWT co
  • Window (java.awt)
    A Window object is a top-level window with no borders and no menubar. The default layout for a windo
  • FileWriter (java.io)
    A specialized Writer that writes to a file in the file system. All write requests made by calling me
  • SocketTimeoutException (java.net)
    This exception is thrown when a timeout expired on a socket read or accept operation.
  • Selector (java.nio.channels)
    A controller for the selection of SelectableChannel objects. Selectable channels can be registered w
  • NoSuchElementException (java.util)
    Thrown when trying to retrieve an element past the end of an Enumeration or Iterator.
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now