if (StringUtils.isNotBlank(line)) { String[] fields = StringUtils.splitPreserveAllTokens(line, ','); if (fields.length < 3) { throw new IllegalStateException("Not enough fields on line " + lineNumber);
/** * Key Based Constructor. Required by JPOX. * * @param key the String representing this object's values. */ public AbstractProjectKey( String key ) { String parts[] = StringUtils.splitPreserveAllTokens( key, ":" ); groupId = parts[0]; artifactId = parts[1]; }
/** * Key Based Constructor. Required by JPOX. * * @param key the String representing this object's values. */ public AbstractVersionedKey( String key ) { String parts[] = StringUtils.splitPreserveAllTokens( key, ":" ); groupId = parts[0]; artifactId = parts[1]; version = parts[2]; }
/** * Splits the given strings on tabs (<code>\t</code>) * @param string string to be split * @return split string */ public static String[] splitOnTabs(String string) { return StringUtils.splitPreserveAllTokens(string, '\t'); }
/** * Key Based Constructor. Required by JPOX. * * @param key the String representing this object's values. */ public AbstractArtifactKey( String key ) { String parts[] = StringUtils.splitPreserveAllTokens( key, ":" ); groupId = parts[0]; artifactId = parts[1]; version = parts[2]; classifier = parts[3]; type = parts[4]; }
public static final String[] identifyingStringToPath(String str) { return StringUtils.splitPreserveAllTokens(str, IDENTIFYING_STRING_SEPARATOR); }
/** * Splits the given strings on newlines (<code>\n</code>) * @param string string to be split * @return split string */ public static String[] splitNewlines(String string) { return StringUtils.splitPreserveAllTokens(StringUtils.replace(string, "\r", ""), '\n'); }
/** * since quota can be null, we need to preserve null in the list */ private ArrayList<String> splitPreserveAllTokens(String str) { if (StringUtils.isEmpty(str)) { return null; } return new ArrayList<>(Arrays.asList(StringUtils.splitPreserveAllTokens(str, SEPARATOR))); }
private void open(String filePath) throws IOException { this.reader = new BufferedReader(new FileReader(filePath)); String headerLine = reader.readLine(); this.header = StringUtils.splitPreserveAllTokens(headerLine, delimiter); }
Map<String, String[]> parseParameters(final String parameters) { final Map<String, String[]> map = new LinkedHashMap<>(); final String[] params = StringUtils.split(parameters, '\n'); for (final String param : params) { final String[] nameAndValues = StringUtils.splitPreserveAllTokens(param, '='); map.put(nameAndValues[0], nameAndValues.length > 1 && StringUtils.isNotBlank(nameAndValues[1]) ? StringUtils.split(nameAndValues[1], '\t') : new String[] { "" }); } return map; }
@Override public void configure(Map<String, String> configuration) { if(configuration.get(GROUP_BY) != null) groupByFields = StringUtils.splitPreserveAllTokens(configuration.get(GROUP_BY), GROUP_BY_DELIM); if(configuration.get(OUTPUT_FIELD) != null) outputField = configuration.get(OUTPUT_FIELD); if(configuration.get(SUM_FIELD) != null) sumField = configuration.get(SUM_FIELD); else throw new RuntimeException("Sum aggregator needs a field to sum. Property missing: " + SUM_FIELD); }
private Map<String, String> deserialize(byte[] plain) throws UnsupportedEncodingException { String base = new String(plain, UTF8); // replaces [&=] regex String[] items = StringUtils.splitPreserveAllTokens(base, "&="); Map<String, String> map = Maps.newHashMapWithExpectedSize(items.length); for (int i=0; i < items.length; ) { String key = URLDecoder.decode(items[i++], UTF8); String val = URLDecoder.decode(items[i++], UTF8); map.put(key, val); } return map; }
private Map<String, String> deserialize(byte[] plain) throws UnsupportedEncodingException { String base = new String(plain, UTF8); // replaces [&=] regex String[] items = StringUtils.splitPreserveAllTokens(base, "&="); Map<String, String> map = Maps.newHashMapWithExpectedSize(items.length); for (int i=0; i < items.length; ) { String key = URLDecoder.decode(items[i++], UTF8); String val = URLDecoder.decode(items[i++], UTF8); map.put(key, val); } return map; }
@Override public Map<String, String> next() { if(!hasNext()) { return null; } String[] vars = StringUtils.splitPreserveAllTokens(nextLine, delimiter); Map<String, String> varMap = new HashMap<String, String>(); for(int i = 0; i < this.header.length; i++) { varMap.put(this.header[i], vars[i]); } nextLine = null; return varMap; }
static JSONObject parametersToJsonObject(Map<String, String> params) throws JSONException { JSONObject root = new JSONObject(); for (Map.Entry<String, String> entry : params.entrySet()) { String[] path = StringUtils.splitPreserveAllTokens(entry.getKey(), '.'); JSONObject holder = buildHolder(root, path, 0); if (path.length > 1) { holder.put(path[path.length - 1], convertToJsonValue(entry.getValue())); } else { holder.put(path[0], convertToJsonValue(entry.getValue())); } } return root; }
@Override protected Entity buildTupleCollectionFromKey(Key k) { String[] typeId = StringUtils.splitPreserveAllTokens(k.getColumnFamily().toString(), ONE_BYTE); return new BaseEntity(typeId[0], typeId[1]); } }
static JSONObject parametersToJsonObject(Map<String, String> params) throws JSONException { JSONObject root = new JSONObject(); for (Map.Entry<String, String> entry : params.entrySet()) { String[] path = StringUtils.splitPreserveAllTokens(entry.getKey(), '.'); JSONObject holder = buildHolder(root, path, 0); if (path.length > 1) { holder.put(path[path.length - 1], convertToJsonValue(entry.getValue())); } else { holder.put(path[0], convertToJsonValue(entry.getValue())); } } return root; }
@Override protected Entity buildEntryFromKey(Key k) { String[] typeId = StringUtils.splitPreserveAllTokens(k.getColumnFamily().toString(), ONE_BYTE); return new BaseEntity(typeId[0], typeId[1]); }
public T decode(String token) { String[] parts = StringUtils.splitPreserveAllTokens(token, TOKEN_SEPARATOR); String[] unescapedParts = new String[parts.length]; for (int i = 0; i < parts.length; i++) { unescapedParts[i] = unescapeSpecialChars(parts[i]); } return build(parts); }
public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int line, int charPositionInLine, String msg, RecognitionException e) { CommonTokenStream tokens = (CommonTokenStream) recognizer.getInputStream(); String input = tokens.getTokenSource().getInputStream().toString(); Token token = (Token) offendingSymbol; String[] lines = StringUtils.splitPreserveAllTokens(input, '\n'); String errorLine = lines[line - 1]; String simpleMessage = "syntax error at or near \"" + token.getText() + "\""; throw new SQLParseError(token, line, charPositionInLine, simpleMessage, errorLine); } }