Ejemplo n.º 1
0
  public List<List<String>> parseSampleContents() {
    String delim = getDelimiter();
    if (contents == null) {
      throw new IllegalStateException("Sample Contents is null, nothing to parse"); // $NON-NLS-1$
    } else if (delim == null || "".equals(delim)) { // $NON-NLS-1$
      // use a random delimiter that will result in an un-parsed list
      delim = "~!@#$%";
    }
    List<List<String>> sample = new ArrayList<List<String>>();
    CSVTokenizer csvTokenizer;
    String enclosure = null;
    if (!"".equals(getEnclosure())) {
      enclosure = getEnclosure();
    }
    for (String line : contents) {
      csvTokenizer = new CSVTokenizer(line, delim, enclosure);

      List<String> rowData = new ArrayList<String>();
      int count = 0;

      while (csvTokenizer.hasMoreTokens()) {
        // get next token and store it in the list
        rowData.add(csvTokenizer.nextToken());
        count++;
      }

      sample.add(rowData);
    }
    return sample;
  }
 /**
  * Boots modules, which have been spcified in the
  * "org.pentaho.reporting.engine.classic.core.boot.Modules" configuration parameter.
  */
 private void bootAdditionalModules() {
   try {
     final String bootModules =
         getGlobalConfig()
             .getConfigProperty(
                 "org.pentaho.reporting.engine.classic.core.boot.Modules"); // NON-NLS
     if (bootModules != null) {
       final CSVTokenizer csvToken = new CSVTokenizer(bootModules, ",");
       while (csvToken.hasMoreTokens()) {
         final String token = csvToken.nextToken();
         getPackageManager().load(token);
       }
     }
   } catch (SecurityException se) {
     // we'll ignore any Security exception ..
     ClassicEngineBoot.logger.info(
         "Security settings forbid to check the system properties for extension modules."); // NON-NLS
   } catch (Exception se) {
     ClassicEngineBoot.logger.error(
         "An error occured while checking the system properties for extension modules.", // NON-NLS
         se);
   }
 }
  /**
   * Returns the value of the function, expression or column using its specific name. The given name
   * is translated into a valid column number and the the column is queried. For functions and
   * expressions, the <code>getValue()</code> method is called and for columns from the tablemodel
   * the tablemodel method <code>getValueAt(row, column)</code> gets called.
   *
   * @param col the item index.
   * @return the value.
   */
  public Object get(final String col) {
    final String envName = columnMap.get(col);
    if (envName == null) {
      return null;
    }
    if (envName.endsWith("-array")) // NON-NLS
    {
      final String name = envName.substring(0, envName.length() - 6);
      final Object s = environment.getEnvironmentProperty(name);
      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);
  }