/** * Gets the next token from the String. * Equivalent to {@link #next()} except it returns null rather than * throwing {@link NoSuchElementException} when no tokens remain. * * @return the next sequential token, or null when no more tokens are found */ public String nextToken() { if (hasNext()) { return tokens[tokenPos++]; } return null; }
/** * Gets a new tokenizer instance which parses Tab Separated Value strings. * The default for CSV processing will be trim whitespace from both ends * (which can be overridden with the setTrimmer method). * @param input the string to parse * @return a new tokenizer instance which parses Tab Separated Value strings. */ public static StrTokenizer getTSVInstance(String input) { StrTokenizer tok = getTSVClone(); tok.reset(input); return tok; }
/** * Constructs a tokenizer splitting on the specified delimiter character * and handling quotes using the specified quote character. * * @param input the string which is to be parsed * @param delim the field delimiter character * @param quote the field quoted string character */ public StrTokenizer(String input, char delim, char quote) { this(input, delim); setQuoteChar(quote); }
/** * Gets a new tokenizer instance which parses Comma Separated Value strings * initializing it with the given input. The default for CSV processing * will be trim whitespace from both ends (which can be overridden with * the setTrimmer method). * * @param input the text to parse * @return a new tokenizer instance which parses Comma Separated Value strings */ public static StrTokenizer getCSVInstance(char[] input) { StrTokenizer tok = getCSVClone(); tok.reset(input); return tok; }
/** * Converts a String back to connection parameters. * @param input String from configuration * @return JDBC connection parameters */ public static Properties propertiesFromString(String input) { if (input != null && !input.isEmpty()) { Properties result = new Properties(); StrTokenizer propertyTokenizer = StrTokenizer.getCSVInstance(input); StrTokenizer valueTokenizer = StrTokenizer.getCSVInstance(); valueTokenizer.setDelimiterChar('='); while (propertyTokenizer.hasNext()) { valueTokenizer.reset(propertyTokenizer.nextToken()); String[] values = valueTokenizer.getTokenArray(); if (values.length == 2) { result.put(values[0], values[1]); } } return result; } else { return null; } } public boolean isDirect(){
public UriTemplate(String pattern) { this.pattern = pattern; this.segments = new ArrayList<Segment>(); StrTokenizer tokenizer = new StrTokenizer(pattern, '/'); while (tokenizer.hasNext()) { segments.add(new Segment(tokenizer.nextToken())); } }
/** * Transform an input string into a list of identifiers. * @param input A comma, new line, or tab delimited set of identifiers, * with optional double quoting. * @return A list of identifiers. */ public List<String> tokenise(String input) { List<String> ret = new LinkedList<String>(); StrTokenizer tokeniser = new StrTokenizer(input, charSetMatcher); tokeniser.setQuoteChar('"'); tokeniser.setIgnoreEmptyTokens(true); tokeniser.setTrimmerMatcher(StrMatcher.trimMatcher()); while (tokeniser.hasNext()) { String token = tokeniser.nextToken().trim(); ret.add(token); } return ret; } }
tokenizer = StrTokenizer.getCSVInstance(); else if (helper.getSeparator().equals("\\t")) tokenizer = StrTokenizer.getTSVInstance(); else tokenizer = new StrTokenizer(data, helper.getSeparator()); tokenizer.setIgnoreEmptyTokens(false); tokenizer.setEmptyTokenAsNull(true); tokenizer.reset(data); String[] dataFields = tokenizer.getTokenArray(); processFields(fields, dataFields);
/** Creates a new StrTokenizer based on the configuration. */ private StrTokenizer createTokenizer() { final StrTokenizer tokenizer; if (csvHelper.getSeparator().equals(",")) { tokenizer = StrTokenizer.getCSVInstance(); } else if (csvHelper.getSeparator().equals("\\t")) { tokenizer = StrTokenizer.getTSVInstance(); } else { tokenizer = new StrTokenizer(); tokenizer.setDelimiterString(csvHelper.getSeparator()); } tokenizer.setIgnoreEmptyTokens(false); tokenizer.setEmptyTokenAsNull(true); return tokenizer; }
private void includeResourcesDefinedInModules() { for (final StrTokenizer csvTokenizer = StrTokenizer.getCSVInstance(modules); csvTokenizer.hasNext();) { final String aRequiredWebResourceModule = csvTokenizer.nextToken(); getWebResourceManager().requireResource(aRequiredWebResourceModule); } }
private void execute(SchemaToolTask task, String taskArgs) throws HiveMetaException { try { StrTokenizer tokenizer = new StrTokenizer(argsBase + taskArgs, ' ', '\"'); SchemaToolCommandLine cl = new SchemaToolCommandLine(tokenizer.getTokenArray(), null); task.setCommandLineArguments(cl); } catch (Exception e) { throw new IllegalStateException("Could not parse comman line \n" + argsBase + taskArgs, e); } task.setHiveSchemaTool(schemaTool); task.execute(); } }
/** * Returns an array of a param values, given its key and the values delimiter * Values can be decoded or not * * @param key the param key * @param delimiter the values delimiter * @param decode whether to decode values * @return the list of vaalues */ public String[] getValues(String key, String delimiter, boolean decode) { String value = params.get(key); if (value != null) { if (decode) { value = decode(value); } return new StrTokenizer(value, delimiter).setIgnoreEmptyTokens(false).getTokenArray(); } return EMPTY; }
public static String[] matchStringArray(String text) { StrTokenizer strTokenizer = StrTokenizer.getCSVInstance(text); return strTokenizer.getTokenArray(); }
public List<String> split(String input) { List<String> statements = new ArrayList<String>(); StrBuilder currentSql = new StrBuilder(); StrTokenizer lineTokenizer = new StrTokenizer(input); lineTokenizer.setDelimiterMatcher(StrMatcher.charSetMatcher("\r\n")); for (String line : lineTokenizer.getTokenArray()) { String strippedLine = StringUtils.stripEnd(line, null); if (!currentSql.isEmpty()) { currentSql.append(lineEnding.get()); } currentSql.append(strippedLine); if (delimiterType.matches(strippedLine, delimiter)) { statements.add(currentSql.substring(0, currentSql.length() - delimiter.length())); currentSql.clear(); } } if (!currentSql.isEmpty()) { statements.add(currentSql.toString()); } return statements; }
/** * Parses the methodToCall parameter which contains the lock information in a known format. Populates a * BudgetConstructionLockSummary that represents the record to unlock. * * @param methodToCallString - request parameter containing lock information * @return lockSummary populated from request parameter */ protected BudgetConstructionLockSummary populateLockSummary(String methodToCallString) { BudgetConstructionLockSummary lockSummary = new BudgetConstructionLockSummary(); // parse lock fields from methodToCall parameter String lockType = StringUtils.substringBetween(methodToCallString, KFSConstants.METHOD_TO_CALL_PARM1_LEFT_DEL, KFSConstants.METHOD_TO_CALL_PARM1_RIGHT_DEL); String lockFieldsString = StringUtils.substringBetween(methodToCallString, KFSConstants.METHOD_TO_CALL_PARM9_LEFT_DEL, KFSConstants.METHOD_TO_CALL_PARM9_RIGHT_DEL); String lockUser = StringUtils.substringBetween(methodToCallString, KFSConstants.METHOD_TO_CALL_PARM3_LEFT_DEL, KFSConstants.METHOD_TO_CALL_PARM3_RIGHT_DEL); // space was replaced by underscore for html lockSummary.setLockType(StringUtils.replace(lockType, "_", " ")); lockSummary.setLockUserId(lockUser); // parse key fields StrTokenizer strTokenizer = new StrTokenizer(lockFieldsString, BCConstants.LOCK_STRING_DELIMITER); strTokenizer.setIgnoreEmptyTokens(false); String fiscalYear = strTokenizer.nextToken(); if (fiscalYear != null) { lockSummary.setUniversityFiscalYear(Integer.parseInt(fiscalYear)); } lockSummary.setChartOfAccountsCode(strTokenizer.nextToken()); lockSummary.setAccountNumber(strTokenizer.nextToken()); lockSummary.setSubAccountNumber(strTokenizer.nextToken()); lockSummary.setPositionNumber(strTokenizer.nextToken()); return lockSummary; }
/** * Parse named parameters */ protected void parseParameters() { StrTokenizer t=new StrTokenizer(qlString); for (String s: (List<String>)t.getTokenList()){ if (StringUtils.startsWith(s, ":")){ parameters.put(StringUtils.substring(s, 1), null); } } }
/** * Constructs a tokenizer splitting using the specified delimiter matcher. * * @param input the string which is to be parsed * @param delim the field delimiter matcher */ public StrTokenizer(String input, StrMatcher delim) { this(input); setDelimiterMatcher(delim); }
private void translateJavadocText() throws IOException { writer.indent(); writer.write(" "); StrTokenizer tokenizer = new StrTokenizer(javadocText); String token = tokenizer.nextToken(); while (token != null) { String outputToken = trimAndStripJavadocPrefix(token); if (StringUtils.isNotBlank(outputToken)) { writer.write(" "); writer.write(outputToken); } token = tokenizer.nextToken(); } writer.newLine(); }
/** * Constructs a tokenizer splitting on the specified delimiter character. * * @param input the string which is to be parsed * @param delim the field delimiter character */ public StrTokenizer(String input, char delim) { this(input); setDelimiterChar(delim); }
_tokenizer.reset(rawEventRecordStr); final String[] rawEventFields = _tokenizer.getTokenArray(); final String[] header = csvHelper.getHeader();