public class Importables extends Object
| Constructor and Description |
|---|
Importables() |
| Modifier and Type | Method and Description |
|---|---|
static String |
delimitedStringToJsonArray(String lines,
String resolveKey,
char delimiter,
List<String> header,
Transformer transformer)
Given a string of
lines, where is line has tokens that are
separated by a delimiter character, covert each line to a JSON
object and return a single string that contains a JSON array of the
objects. |
static String |
delimitedStringToJsonObject(String line,
String resolveKey,
char delimiter,
List<String> header,
Transformer transformer)
Given a
line that is separated by a delimiter character,
convert each token to fields within a single JSON object. |
static void |
delimitedStringToJsonObject(String line,
String resolveKey,
char delimiter,
List<String> header,
Transformer transformer,
StringBuilder builder)
Given a
line that is separated by a delimiter character,
convert each token to fields within a single JSON object. |
protected static void |
writeJsonValue(JsonWriter out,
String value)
Intelligently write the appropriate JSON representation for
value
to out. |
public static String delimitedStringToJsonArray(String lines, @Nullable String resolveKey, char delimiter, List<String> header, @Nullable Transformer transformer)
lines, where is line has tokens that are
separated by a delimiter character, covert each line to a JSON
object and return a single string that contains a JSON array of the
objects.lines - the data to convertresolveKey - a key that the
importer uses
to determine the existing records into which the data should
be imported. The method places the appropriate resolve
instruction in the JSON blob so Concourse Server can perform
the resolution during the importdelimiter - the delimiter characterheader - the list of header keys. If this list is empty, it is
assumed that the first line of lines contains the
headertransformer - the Transformer that is used to potentially
alter key/value pairs before importlines in the new
formatIndexOutOfBoundsException - if a line has more columns that there
are header keys; it is fine for a line to have fewer columns
that header keys@Nullable public static String delimitedStringToJsonObject(String line, @Nullable String resolveKey, char delimiter, List<String> header, @Nullable Transformer transformer)
line that is separated by a delimiter character,
convert each token to fields within a single JSON object.line - the data to convertresolveKey - a key that the
importer uses
to determine the existing records into which the data should
be imported. The method places the appropriate resolve
instruction in the JSON blob so Concourse Server can perform
the resolution during the importdelimiter - the delimiter characterheader - the list of header keys. If this list is empty, this method
will return null and instead place the tokens from the
line into the listtransformer - the Transformer that is used to potentially
alter key/value pairs before importline in the new
format or null if header is
emptyIndexOutOfBoundsException - if the line has more columns that there
are header keys (as long as the number of header keys is >
0); it is fine for a line to have fewer columns that header
keyspublic static void delimitedStringToJsonObject(String line, @Nullable String resolveKey, char delimiter, List<String> header, @Nullable Transformer transformer, StringBuilder builder)
line that is separated by a delimiter character,
convert each token to fields within a single JSON object.
This method does not return anything. It writes the JSON blob to the
provided builder.
line - the data to convertresolveKey - a key that the
importer uses
to determine the existing records into which the data should
be imported. The method places the appropriate resolve
instruction in the JSON blob so Concourse Server can perform
the resolution during the importdelimiter - the delimiter characterheader - the list of header keys. If this list is empty, this method
will return null and instead place the tokens from the
line into the listtransformer - the Transformer that is used to potentially
alter key/value pairs before importbuilder - the StringBuilder where the JSON blob should be
writtenIndexOutOfBoundsException - if the line has more columns that there
are header keys (as long as the number of header keys is >
0); it is fine for a line to have fewer columns that header
keysprotected static void writeJsonValue(JsonWriter out,
String value)
throws IOException
value
to out.out - the JsonWriter to use for writingvalue - the value to writeIOException