/** Utility method to get the schema path for given list of schema path. */ public static String getSchemaPath(List<String> schemaPath) { return SCHEMA_PATH_JOINER.join(schemaPath); }
/** * Appends to {@code appendable} the string representation of each of the remaining arguments. */ @CanIgnoreReturnValue public final <A extends Appendable> A appendTo( A appendable, @Nullable Object first, @Nullable Object second, Object... rest) throws IOException { return appendTo(appendable, iterable(first, second, rest)); }
/** * Returns a string containing the string representation of each of {@code parts}, using the * previously configured separator between each. * * @since 11.0 */ public final String join(Iterator<?> parts) { return appendTo(new StringBuilder(), parts).toString(); }
@Override CharSequence toString(@Nullable Object part) { return (part == null) ? nullText : Joiner.this.toString(part); }
/** * Returns a joiner which automatically places {@code separator} between consecutive elements. */ public static Joiner on(String separator) { return new Joiner(separator); }
/** * Returns a string containing the string representation of each of {@code parts}, using the * previously configured separator between each. */ public final String join(Iterable<?> parts) { return join(parts.iterator()); }
/** * Appends to {@code builder} the string representation of each of the remaining arguments. * Identical to {@link #appendTo(Appendable, Object, Object, Object...)}, except that it does not * throw {@link IOException}. */ @CanIgnoreReturnValue public final StringBuilder appendTo( StringBuilder builder, @Nullable Object first, @Nullable Object second, Object... rest) { return appendTo(builder, iterable(first, second, rest)); }
/** * Appends the string representation of each of {@code parts}, using the previously configured * separator between each, to {@code builder}. Identical to * {@link #appendTo(Appendable, Iterable)}, except that it does not throw {@link IOException}. */ @CanIgnoreReturnValue public final StringBuilder appendTo(StringBuilder builder, Object[] parts) { return appendTo(builder, Arrays.asList(parts)); }
/** * Appends the string representation of each of {@code parts}, using the previously configured * separator between each, to {@code appendable}. * * @since 11.0 */ @CanIgnoreReturnValue public <A extends Appendable> A appendTo(A appendable, Iterator<?> parts) throws IOException { checkNotNull(appendable); if (parts.hasNext()) { appendable.append(toString(parts.next())); while (parts.hasNext()) { appendable.append(separator); appendable.append(toString(parts.next())); } } return appendable; }
/** * Returns a joiner which automatically places {@code separator} between consecutive elements. */ public static Joiner on(char separator) { return new Joiner(String.valueOf(separator)); }
/** * Returns a string containing the string representation of each of {@code parts}, using the * previously configured separator between each. */ public final String join(Object[] parts) { return join(Arrays.asList(parts)); }
/** * Appends the string representation of each of {@code parts}, using the previously configured * separator between each, to {@code appendable}. */ @CanIgnoreReturnValue public <A extends Appendable> A appendTo(A appendable, Iterable<?> parts) throws IOException { return appendTo(appendable, parts.iterator()); }
@Override public <A extends Appendable> A appendTo(A appendable, Iterator<?> parts) throws IOException { checkNotNull(appendable, "appendable"); checkNotNull(parts, "parts"); while (parts.hasNext()) { Object part = parts.next(); if (part != null) { appendable.append(Joiner.this.toString(part)); break; } } while (parts.hasNext()) { Object part = parts.next(); if (part != null) { appendable.append(separator); appendable.append(Joiner.this.toString(part)); } } return appendable; }
/** * Removes extra spaces and empty values in a CSV String * @param csv The CSV string to be sanitized * @return The sanitized CSV string */ public static String sanitizeCSV(String csv) { // tokenize String[] tokens = csv.split(","); ArrayList<String> sanitizedTokens = new ArrayList<String>(tokens.length); // check for empties for (String s : tokens) { String trimmedToken = s.trim(); if (trimmedToken.length() != 0) { sanitizedTokens.add(trimmedToken); } } String result = ""; if (sanitizedTokens.size() != 0) { result = Joiner.on(",").join(sanitizedTokens); } return result; }
/** Utility method to get the schema path for given schema instance. */ public static String getSchemaPath(SchemaPlus schema) { return SCHEMA_PATH_JOINER.join(getSchemaPathAsList(schema)); }
/** * Appends the string representation of each of {@code parts}, using the previously configured * separator between each, to {@code appendable}. */ @CanIgnoreReturnValue public final <A extends Appendable> A appendTo(A appendable, Object[] parts) throws IOException { return appendTo(appendable, Arrays.asList(parts)); }