Package org.apache.wicket.util.parse.metapattern.parsers

Examples of org.apache.wicket.util.parse.metapattern.parsers.CommaSeparatedVariableParser


  /**
   * Test parsing of comma separated variables.
   */
  public void testCommaSeparatedVariableParser()
  {
    CommaSeparatedVariableParser parser = new CommaSeparatedVariableParser("a,b,c");
    assertTrue(parser.matches());
    assertEquals(3, parser.getValues().size());
    assertEquals("a", parser.getValues().get(0));
    assertEquals("b", parser.getValues().get(1));
    assertEquals("c", parser.getValues().get(2));

    // no whitespaces will be removed
    parser = new CommaSeparatedVariableParser(" a ,b, c , d ");
    assertTrue(parser.matches());
    assertEquals(4, parser.getValues().size());
    assertEquals(" a ", parser.getValues().get(0));
    assertEquals("b", parser.getValues().get(1));
    assertEquals(" c ", parser.getValues().get(2));
    assertEquals(" d ", parser.getValues().get(3));

    // It'll care for "" and '' but it'll not remove them
    parser = new CommaSeparatedVariableParser("'a ',\" b\",'c,d'");
    assertTrue(parser.matches());
    assertEquals(3, parser.getValues().size());
    assertEquals("'a '", parser.getValues().get(0));
    assertEquals("\" b\"", parser.getValues().get(1));
    assertEquals("'c,d'", parser.getValues().get(2));

    // But no escapes. Because no separator is following the 2nd "'",
    // it'll stop parsing the string.
    parser = new CommaSeparatedVariableParser("'a\'b, c");
    assertTrue(parser.matches());
    assertEquals(1, parser.getValues().size());
    assertEquals("'a'", parser.getValues().get(0));

    parser = new CommaSeparatedVariableParser("a");
    assertTrue(parser.matches());
    assertEquals(1, parser.getValues().size());
    assertEquals("a", parser.getValues().get(0));

    // Empty elements are not supported
    parser = new CommaSeparatedVariableParser("a,,");
    assertTrue(parser.matches());
    assertEquals(1, parser.getValues().size());
    assertEquals("a", parser.getValues().get(0));
  }
View Full Code Here


  /**
   * Test parsing of comma separated variables.
   */
  public void testCommaSeparatedVariableParser()
  {
    CommaSeparatedVariableParser parser = new CommaSeparatedVariableParser("a,b,c");
    assertTrue(parser.matches());
    assertEquals(3, parser.getValues().size());
    assertEquals("a", parser.getValues().get(0));
    assertEquals("b", parser.getValues().get(1));
    assertEquals("c", parser.getValues().get(2));

    // no whitespaces will be removed
    parser = new CommaSeparatedVariableParser(" a ,b, c , d ");
    assertTrue(parser.matches());
    assertEquals(4, parser.getValues().size());
    assertEquals(" a ", parser.getValues().get(0));
    assertEquals("b", parser.getValues().get(1));
    assertEquals(" c ", parser.getValues().get(2));
    assertEquals(" d ", parser.getValues().get(3));

    // It'll care for "" and '' but it'll not remove them
    parser = new CommaSeparatedVariableParser("'a ',\" b\",'c,d'");
    assertTrue(parser.matches());
    assertEquals(3, parser.getValues().size());
    assertEquals("'a '", parser.getValues().get(0));
    assertEquals("\" b\"", parser.getValues().get(1));
    assertEquals("'c,d'", parser.getValues().get(2));

    // But no escapes. Because no separator is following the 2nd "'",
    // it'll stop parsing the string.
    parser = new CommaSeparatedVariableParser("'a\'b, c");
    assertTrue(parser.matches());
    assertEquals(1, parser.getValues().size());
    assertEquals("'a'", parser.getValues().get(0));

    parser = new CommaSeparatedVariableParser("a");
    assertTrue(parser.matches());
    assertEquals(1, parser.getValues().size());
    assertEquals("a", parser.getValues().get(0));

    // Empty elements are not supported
    parser = new CommaSeparatedVariableParser("a,,");
    assertTrue(parser.matches());
    assertEquals(1, parser.getValues().size());
    assertEquals("a", parser.getValues().get(0));
  }
View Full Code Here

  /**
   * Test parsing of comma separated variables.
   */
  public void testCommaSeparatedVariableParser()
  {
    CommaSeparatedVariableParser parser = new CommaSeparatedVariableParser("a,b,c");
    assertTrue(parser.matches());
    assertEquals(3, parser.getValues().size());
    assertEquals("a", parser.getValues().get(0));
    assertEquals("b", parser.getValues().get(1));
    assertEquals("c", parser.getValues().get(2));

    // no whitespaces will be removed
    parser = new CommaSeparatedVariableParser(" a ,b, c , d ");
    assertTrue(parser.matches());
    assertEquals(4, parser.getValues().size());
    assertEquals(" a ", parser.getValues().get(0));
    assertEquals("b", parser.getValues().get(1));
    assertEquals(" c ", parser.getValues().get(2));
    assertEquals(" d ", parser.getValues().get(3));

    // It'll care for "" and '' but it'll not remove them
    parser = new CommaSeparatedVariableParser("'a ',\" b\",'c,d'");
    assertTrue(parser.matches());
    assertEquals(3, parser.getValues().size());
    assertEquals("'a '", parser.getValues().get(0));
    assertEquals("\" b\"", parser.getValues().get(1));
    assertEquals("'c,d'", parser.getValues().get(2));

    // But no escapes. Because no separator is following the 2nd "'",
    // it'll stop parsing the string.
    parser = new CommaSeparatedVariableParser("'a\'b, c");
    assertTrue(parser.matches());
    assertEquals(1, parser.getValues().size());
    assertEquals("'a'", parser.getValues().get(0));

    parser = new CommaSeparatedVariableParser("a");
    assertTrue(parser.matches());
    assertEquals(1, parser.getValues().size());
    assertEquals("a", parser.getValues().get(0));

    // Empty elements are not supported
    parser = new CommaSeparatedVariableParser("a,,");
    assertTrue(parser.matches());
    assertEquals(1, parser.getValues().size());
    assertEquals("a", parser.getValues().get(0));
  }
View Full Code Here

   * Test parsing of comma separated variables.
   */
  @Test
  public void commaSeparatedVariableParser()
  {
    CommaSeparatedVariableParser parser = new CommaSeparatedVariableParser("a,b,c");
    assertTrue(parser.matches());
    assertEquals(3, parser.getValues().size());
    assertEquals("a", parser.getValues().get(0));
    assertEquals("b", parser.getValues().get(1));
    assertEquals("c", parser.getValues().get(2));

    // no whitespaces will be removed
    parser = new CommaSeparatedVariableParser(" a ,b, c , d ");
    assertTrue(parser.matches());
    assertEquals(4, parser.getValues().size());
    assertEquals(" a ", parser.getValues().get(0));
    assertEquals("b", parser.getValues().get(1));
    assertEquals(" c ", parser.getValues().get(2));
    assertEquals(" d ", parser.getValues().get(3));

    // It'll care for "" and '' but it'll not remove them
    parser = new CommaSeparatedVariableParser("'a ',\" b\",'c,d'");
    assertTrue(parser.matches());
    assertEquals(3, parser.getValues().size());
    assertEquals("'a '", parser.getValues().get(0));
    assertEquals("\" b\"", parser.getValues().get(1));
    assertEquals("'c,d'", parser.getValues().get(2));

    // But no escapes. Because no separator is following the 2nd "'",
    // it'll stop parsing the string.
    parser = new CommaSeparatedVariableParser("'a\'b, c");
    assertTrue(parser.matches());
    assertEquals(1, parser.getValues().size());
    assertEquals("'a'", parser.getValues().get(0));

    parser = new CommaSeparatedVariableParser("a");
    assertTrue(parser.matches());
    assertEquals(1, parser.getValues().size());
    assertEquals("a", parser.getValues().get(0));

    // Empty elements are not supported
    parser = new CommaSeparatedVariableParser("a,,");
    assertTrue(parser.matches());
    assertEquals(1, parser.getValues().size());
    assertEquals("a", parser.getValues().get(0));
  }
View Full Code Here

    /**
     * Test parsing of comma separated variables.
     */
    public void testCommaSeparatedVariableParser()
    {
        CommaSeparatedVariableParser parser = new CommaSeparatedVariableParser("a,b,c");
      assertTrue(parser.matches());
      assertEquals(3, parser.getValues().size());
      assertEquals("a", parser.getValues().get(0));
      assertEquals("b", parser.getValues().get(1));
      assertEquals("c", parser.getValues().get(2));
     
      // no whitespaces will be removed
      parser = new CommaSeparatedVariableParser(" a ,b, c , d ");
      assertTrue(parser.matches());
      assertEquals(4, parser.getValues().size());
      assertEquals(" a ", parser.getValues().get(0));
      assertEquals("b", parser.getValues().get(1));
      assertEquals(" c ", parser.getValues().get(2));
      assertEquals(" d ", parser.getValues().get(3));

      // It'll care for "" and '' but it'll not remove them
      parser = new CommaSeparatedVariableParser("'a ',\" b\",'c,d'");
      assertTrue(parser.matches());
      assertEquals(3, parser.getValues().size());
      assertEquals("'a '", parser.getValues().get(0));
      assertEquals("\" b\"", parser.getValues().get(1));
      assertEquals("'c,d'", parser.getValues().get(2));

      // But no escapes. Because no separator is following the 2nd "'",
      // it'll stop parsing the string.
      parser = new CommaSeparatedVariableParser("'a\'b, c");
      assertTrue(parser.matches());
      assertEquals(1, parser.getValues().size());
      assertEquals("'a'", parser.getValues().get(0));
     
      parser = new CommaSeparatedVariableParser("a");
      assertTrue(parser.matches());
      assertEquals(1, parser.getValues().size());
      assertEquals("a", parser.getValues().get(0));

      // Empty elements are not supported
      parser = new CommaSeparatedVariableParser("a,,");
      assertTrue(parser.matches());
      assertEquals(1, parser.getValues().size());
      assertEquals("a", parser.getValues().get(0));
    }
View Full Code Here

TOP

Related Classes of org.apache.wicket.util.parse.metapattern.parsers.CommaSeparatedVariableParser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.