Package org.pentaho.reporting.libraries.base.util

Examples of org.pentaho.reporting.libraries.base.util.CSVTokenizer


     * @return the translated value.
     */
    protected String lookupVariable(final String name)
    {

      final CSVTokenizer tokenizer = new CSVTokenizer(name, false);
      if (tokenizer.hasMoreTokens() == false)
      {
        return null;
      }

      final String parameterName = tokenizer.nextToken();
      final Object o = parameters.get(parameterName);
      collectedLists.add(parameterName);

      String subType = null;
      final StringBuilder b = new StringBuilder(name.length() + 4);
      b.append('{');
      b.append("0");
      while (tokenizer.hasMoreTokens())
      {
        b.append(',');
        final String token = tokenizer.nextToken();
        b.append(token);
        if (subType == null)
        {
          subType = token;
        }
View Full Code Here


    {
      throw new ResourceKeyCreationException("The source string does not start with the string ["
          + SERIALIZATION_PREFIX + "]");
    }

    final CSVTokenizer tokenizer = new CSVTokenizer(resourceKeyString, DELIMITER, "\"", false);
    if (tokenizer.hasMoreElements() == false)
    {
      throw new ResourceKeyCreationException("Schema is missing");
    }
    final String rawSchema = tokenizer.nextToken();
    if (rawSchema.startsWith(SERIALIZATION_PREFIX) == false)
    {
      throw new ResourceKeyCreationException("Prefix is wrong");
    }
    final String schema = rawSchema.substring(SERIALIZATION_PREFIX.length());

    if (tokenizer.hasMoreElements() == false)
    {
      throw new ResourceKeyCreationException("Identifier is missing");
    }
    final String id = tokenizer.nextToken();
    final Map parameters;
    if (tokenizer.hasMoreElements())
    {
      parameters = parseFactoryParametersFromString(tokenizer.nextToken());
    }
    else
    {
      parameters = null;
    }
View Full Code Here

    if (factoryParameters == null)
    {
      return null;
    }
    final Map<ParameterKey,Object> params = new HashMap<ParameterKey,Object>();
    final CSVTokenizer tokenizer = new CSVTokenizer(factoryParameters, ":", "\"", false);
    while (tokenizer.hasMoreTokens())
    {
      final String entry = tokenizer.nextToken();
      final CSVTokenizer innerTokenizer = new CSVTokenizer(entry, "=", "\"", false);
      final ParameterKey key;
      if (innerTokenizer.hasMoreElements())
      {
        final String keyString = innerTokenizer.nextToken();
        if (keyString.startsWith("f:"))
        {
          key = new FactoryParameterKey(keyString.substring(2));
        }
        else if (keyString.startsWith("l:"))
        {
          key = new LoaderParameterKey(keyString.substring(2));
        }
        else
        {
          throw new IllegalStateException("Invalid prefix: Key '" + keyString + "' must be either a loader-parameter-key or a factory-parameter-key");
        }
      }
      else
      {
        throw new IllegalStateException();
      }

      if (innerTokenizer.hasMoreElements())
      {
        final Object value = innerTokenizer.nextToken();
        if ("".equals(value))
        {
          params.put(key, null);
        }
        else
View Full Code Here

  {
    if (data == null)
    {
      return null;
    }
    final CSVTokenizer tokenizer = new CSVTokenizer(data, DELIMITER, "\"", false);
    if (tokenizer.hasMoreElements() == false)
    {
      return null;
    }

    final String tempData = tokenizer.nextToken();
    if (tempData.startsWith(SERIALIZATION_PREFIX))
    {
      return tempData.substring(SERIALIZATION_PREFIX.length());
    }
    return null;
View Full Code Here

      if (s == null)
      {
        return new String[0];
      }

      final CSVTokenizer csvTokenizer = new CSVTokenizer(String.valueOf(s), ",", "\"", false);
      final int length = csvTokenizer.countTokens();
      final String[] rolesArray = new String[length];
      for (int i = 0; i < length; i += 1)
      {
        rolesArray[i] = csvTokenizer.nextToken();
      }
      return rolesArray;
    }
    return environment.getEnvironmentProperty(envName);
  }
View Full Code Here

    super(name);
  }

  public void testHasMoreTokens()
  {
    CSVTokenizer tokeniser = new CSVTokenizer("", CSVTokenizer.SEPARATOR_COMMA,
            CSVTokenizer.DOUBLE_QUATE);
    assertTrue("Should have no more tokens.", (!tokeniser.hasMoreTokens()));

    tokeniser = new CSVTokenizer("a,b,c", CSVTokenizer.SEPARATOR_COMMA,
            CSVTokenizer.DOUBLE_QUATE);
    assertEquals("Should count tokens correctly", 3, tokeniser.countTokens());
    assertEquals("a", tokeniser.nextToken());
    assertEquals("b", tokeniser.nextToken());
    assertEquals("c", tokeniser.nextToken());

    tokeniser = new CSVTokenizer(",b,c", CSVTokenizer.SEPARATOR_COMMA,
            CSVTokenizer.DOUBLE_QUATE);
    assertEquals("Should count tokens correctly", 3, tokeniser.countTokens());
    assertEquals("", tokeniser.nextToken());
    assertEquals("b", tokeniser.nextToken());
    assertEquals("c", tokeniser.nextToken());

    tokeniser = new CSVTokenizer("a,,c", CSVTokenizer.SEPARATOR_COMMA,
            CSVTokenizer.DOUBLE_QUATE);
    assertEquals("Should count tokens correctly", 3, tokeniser.countTokens());
    assertEquals("a", tokeniser.nextToken());
    assertEquals("", tokeniser.nextToken());
    assertEquals("c", tokeniser.nextToken());

    tokeniser = new CSVTokenizer("a,b,", CSVTokenizer.SEPARATOR_COMMA,
            CSVTokenizer.DOUBLE_QUATE);
    assertEquals("Should count tokens correctly", 3, tokeniser.countTokens());
    assertEquals("a", tokeniser.nextToken());
    assertEquals("b", tokeniser.nextToken());
    assertEquals("", tokeniser.nextToken());

    tokeniser = new CSVTokenizer(",,", CSVTokenizer.SEPARATOR_COMMA,
            CSVTokenizer.DOUBLE_QUATE);
    assertEquals("Should count tokens correctly", 3, tokeniser.countTokens());
    assertEquals("", tokeniser.nextToken());
    assertEquals("", tokeniser.nextToken());
    assertEquals("", tokeniser.nextToken());

    tokeniser = new CSVTokenizer("\"\",\"\",\"\"", CSVTokenizer.SEPARATOR_COMMA,
            CSVTokenizer.DOUBLE_QUATE);
    assertEquals("Should count tokens correctly", 3, tokeniser.countTokens());
    assertEquals("", tokeniser.nextToken());
    assertEquals("", tokeniser.nextToken());
    assertEquals("", tokeniser.nextToken());
  }
View Full Code Here

TOP

Related Classes of org.pentaho.reporting.libraries.base.util.CSVTokenizer

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.