private Object parseBooleanDefaultParam( String defaultValue, CSVTokenizer csvt ) { if ( csvt.countTokens() == 1 ) { return Boolean.parseBoolean( csvt.nextToken() ); } else { ArrayList<Boolean> vals = new ArrayList<Boolean>(); while ( csvt.hasMoreTokens() ) { String token = csvt.nextToken(); vals.add( Boolean.parseBoolean( token ) ); } return vals.toArray( new Boolean[0] ); } }
private Object parseDoubleDefaultParam( String defaultValue, CSVTokenizer csvt ) { if ( csvt.countTokens() == 1 ) { return Double.parseDouble( csvt.nextToken() ); } else { ArrayList<Double> vals = new ArrayList<Double>(); while ( csvt.hasMoreTokens() ) { String token = csvt.nextToken(); vals.add( Double.parseDouble( token ) ); } return vals.toArray( new Double[0] ); } }
private Object parseStringDefaultParam( String defaultValue, CSVTokenizer csvt ) { if ( csvt.countTokens() == 1 ) { return csvt.nextToken(); } else { ArrayList<String> vals = new ArrayList<String>(); while ( csvt.hasMoreTokens() ) { String token = csvt.nextToken(); vals.add( token ); } return vals.toArray( new String[0] ); } }
/** * Splits a given string at the given separator string. Duplicate separators will be merged into a single separator * occurance. * * @param string the text to be split. * @param separator the separator chacters used for the split. * @param quate the quoting character. * @return the splitted array. */ public static String[] split( final String string, final String separator, final String quate ) { final CSVTokenizer strtok = new CSVTokenizer( string, separator, quate, false ); final String[] tokens = new String[ strtok.countTokens() ]; int i = 0; while ( strtok.hasMoreTokens() ) { final String token = strtok.nextToken(); if ( token.length() > 0 ) { tokens[ i ] = ( token ); i += 1; } } if ( i == tokens.length ) { return tokens; } final String[] retval = new String[ i ]; System.arraycopy( tokens, 0, retval, 0, i ); return retval; }
final int length = csvTokenizer.countTokens(); final String[] rolesArray = new String[length]; for ( int i = 0; i < length; i += 1 ) {
final String[] tokens = new String[strtok.countTokens()]; int i = 0; while (strtok.hasMoreTokens())
/** * Creates the list of column names that should be mapped into the method or constructor parameters. * * @param query * the query-string. * @param parameterStartIdx * the index from where to read the parameter list. * @return an array with column names. * @throws ReportDataFactoryException * if something goes wrong. */ private String[] createParameterList( final String query, final int parameterStartIdx ) throws ReportDataFactoryException { final int parameterEndIdx = query.lastIndexOf( ')' ); if ( parameterEndIdx < parameterStartIdx ) { throw new ReportDataFactoryException( "Malformed query: " + query ); //$NON-NLS-1$ } final String parameterText = query.substring( parameterStartIdx + 1, parameterEndIdx ); final CSVTokenizer tokenizer = new CSVTokenizer( parameterText, ",", "\"", false ); final int size = tokenizer.countTokens(); final String[] parameterNames = new String[size]; int i = 0; while ( tokenizer.hasMoreTokens() ) { parameterNames[i] = tokenizer.nextToken(); i += 1; } return parameterNames; }
/** * Splits a given string at the given separator string. Duplicate separators will result in empty strings thus * preserving the number of fields specified in the original string. * * @param string the text to be split. * @param separator the separator chacters used for the split. * @param quate the quoting character. * @return the splitted array. */ public static String[] splitCSV( final String string, final String separator, final String quate ) { final CSVTokenizer strtok = new CSVTokenizer( string, separator, quate, false ); final String[] tokens = new String[ strtok.countTokens() ]; int i = 0; while ( strtok.hasMoreTokens() ) { final String token = strtok.nextToken(); tokens[ i ] = ( token ); i += 1; } return tokens; }
/** * Splits a given string at the given separator string. Duplicate separators will result in empty strings thus * preserving the number of fields specified in the original string. * * @param string the text to be split. * @param separator the separator chacters used for the split. * @param quate the quoting character. * @return the splitted array. */ public static String[] splitCSV(final String string, final String separator, final String quate) { final CSVTokenizer strtok = new CSVTokenizer(string, separator, quate, false); final String[] tokens = new String[strtok.countTokens()]; int i = 0; while (strtok.hasMoreTokens()) { final String token = strtok.nextToken(); tokens[i] = (token); i += 1; } return tokens; }
} else { final CSVTokenizer strtokenizer = new CSVTokenizer( sequence, separator, quote, false ); resultList = new ArrayList( strtokenizer.countTokens() ); strtok = strtokenizer;
resultList = new ArrayList(strtokenizer.countTokens()); strtok = strtokenizer;