Class NJsonDocUtils
java.lang.Object
gov.nasa.pds.registry.common.util.json.NJsonDocUtils
Utility class to write NJSON (new-line delimited JSON) documents.
- Author:
- karpenko
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringcreatePKJson(String id) Create primary key JSON (first line in NJSON record)static StringtoEsFieldName(String fieldName) Convert registry field name to the valid Elasticsearch field name.static voidwriteArray(com.google.gson.stream.JsonWriter jw, String key, Collection<String> values) Write multivalued field as an arraystatic voidwriteField(com.google.gson.stream.JsonWriter jw, String key, float value) Write a field.static voidwriteField(com.google.gson.stream.JsonWriter jw, String key, long value) Write a field.static voidwriteField(com.google.gson.stream.JsonWriter jw, String key, String value) Write a field.static voidwriteField(com.google.gson.stream.JsonWriter jw, String key, Collection<String> values) Write a field.static voidWrite primary key (first line in NJSON record)
-
Constructor Details
-
NJsonDocUtils
public NJsonDocUtils()
-
-
Method Details
-
createPKJson
Create primary key JSON (first line in NJSON record)- Parameters:
id- primary key- Returns:
- primary key JSON
- Throws:
Exception- Generic exception
-
writePK
Write primary key (first line in NJSON record)- Parameters:
writer- Generic writerid- primary key- Throws:
Exception- Generic exception
-
writeField
public static void writeField(com.google.gson.stream.JsonWriter jw, String key, String value) throws Exception Write a field.- Parameters:
jw- JSON writerkey- a key / field namevalue- a value- Throws:
Exception- Generic exception
-
writeField
public static void writeField(com.google.gson.stream.JsonWriter jw, String key, long value) throws Exception Write a field.- Parameters:
jw- JSON writerkey- a key / field namevalue- a value- Throws:
Exception- Generic exception
-
writeField
public static void writeField(com.google.gson.stream.JsonWriter jw, String key, float value) throws Exception Write a field.- Parameters:
jw- JSON writerkey- a key / field namevalue- a value- Throws:
Exception- Generic exception
-
writeField
public static void writeField(com.google.gson.stream.JsonWriter jw, String key, Collection<String> values) throws Exception Write a field.- Parameters:
jw- JSON writerkey- a key / field namevalues- collection of values- Throws:
Exception- Generic exception
-
writeArray
public static void writeArray(com.google.gson.stream.JsonWriter jw, String key, Collection<String> values) throws Exception Write multivalued field as an array- Parameters:
jw- JSON writerkey- key / field namevalues- collection of values- Throws:
Exception- an exception
-
toEsFieldName
Convert registry field name to the valid Elasticsearch field name. (Replace '.' with '/').- Parameters:
fieldName- a field name- Returns:
- valid Elasticsearch field name
-