Package org.rumbledb.items.parsing
Class ItemParser
java.lang.Object
org.rumbledb.items.parsing.ItemParser
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ItemconvertValueToItem(Object o, org.apache.spark.sql.types.DataType fieldType, ExceptionMetadata metadata, ItemType itemType) static intfindNonObjectColumnIndexAndCheckConsistency(String[] fieldNames) Check fields columns consistency and return the index of the non-object JSONiq item column if present.static DocumentItemgetDocumentItemFromXML(Node currentNode, String path, boolean removeParentPointers) static ItemgetItemFromJSONString(String string, JSONParsingOptions options, String xmlVersion, boolean isJSONiq10, ExceptionMetadata metadata) static ItemgetItemFromObject(com.google.gson.stream.JsonReader object, boolean isJSONiq10, String numberFormat, ExceptionMetadata metadata, boolean mutable) Parses a JSON object from the given reader.static ItemgetItemFromObject(com.google.gson.stream.JsonReader object, ExceptionMetadata metadata, boolean mutable) Deprecated.static ItemgetItemFromRow(org.apache.spark.sql.Row row, ExceptionMetadata metadata, ItemType itemType) Converts a DataFrame row to an item.static ItemgetItemFromString(String string, ExceptionMetadata metadata, boolean mutable) Deprecated.static ItemgetItemFromXML(Node currentNode, String path, boolean removeParentPointers) Parses an XML document to an item.static ItemgetItemFromYAML(com.fasterxml.jackson.dataformat.yaml.YAMLParser parser, com.fasterxml.jackson.core.JsonToken lookahead, ExceptionMetadata metadata) Parses a JSON string, accessible via a reader, to an item.static ItemparseOptionlessJSON(com.google.gson.stream.JsonReader object, boolean isJSONiq10, String numberFormat, ExceptionMetadata metadata, boolean mutable) Parses a JSON string, accessible via a reader, to an item.static ItemparseOptionlessJSON(com.google.gson.stream.JsonReader object, ExceptionMetadata metadata, boolean mutable) Deprecated.
-
Constructor Details
-
ItemParser
public ItemParser()
-
-
Method Details
-
getItemFromString
@Deprecated public static Item getItemFromString(String string, ExceptionMetadata metadata, boolean mutable) Deprecated.Parses a JSON string to an item.- Parameters:
string- the JSON string.metadata- exception metadata is an error is thrown.- Returns:
- the parsed item.
-
getItemFromJSONString
public static Item getItemFromJSONString(String string, JSONParsingOptions options, String xmlVersion, boolean isJSONiq10, ExceptionMetadata metadata) -
getItemFromObject
@Deprecated public static Item getItemFromObject(com.google.gson.stream.JsonReader object, ExceptionMetadata metadata, boolean mutable) Deprecated.UsegetItemFromObject(JsonReader, boolean, String, ExceptionMetadata, boolean)instead. This method is kept for backward compatibility and defaults to JSONiq mode. -
getItemFromObject
public static Item getItemFromObject(com.google.gson.stream.JsonReader object, boolean isJSONiq10, String numberFormat, ExceptionMetadata metadata, boolean mutable) Parses a JSON object from the given reader.- Parameters:
object- the JSON reader.metadata- exception metadata if an error is thrown.- Returns:
- the parsed item.
-
parseOptionlessJSON
@Deprecated public static Item parseOptionlessJSON(com.google.gson.stream.JsonReader object, ExceptionMetadata metadata, boolean mutable) Deprecated.UseparseOptionlessJSON(JsonReader, boolean, String, ExceptionMetadata, boolean)instead. This method is kept for backward compatibility and defaults to JSONiq mode. -
parseOptionlessJSON
public static Item parseOptionlessJSON(com.google.gson.stream.JsonReader object, boolean isJSONiq10, String numberFormat, ExceptionMetadata metadata, boolean mutable) Parses a JSON string, accessible via a reader, to an item.- Parameters:
object- the JSON reader.metadata- exception metadata is an error is thrown.- Returns:
- the parsed item.
-
getItemFromYAML
public static Item getItemFromYAML(com.fasterxml.jackson.dataformat.yaml.YAMLParser parser, com.fasterxml.jackson.core.JsonToken lookahead, ExceptionMetadata metadata) Parses a JSON string, accessible via a reader, to an item.- Parameters:
parser- the YAML parser.lookahead- the lookahead token.metadata- exception metadata is an error is thrown.- Returns:
- the parsed item.
-
findNonObjectColumnIndexAndCheckConsistency
Check fields columns consistency and return the index of the non-object JSONiq item column if present.- Parameters:
fieldNames- the field names of the DataFrame schema.- Returns:
- the index of the non-object JSONiq item column if present, -1 otherwise.
-
getItemFromRow
public static Item getItemFromRow(org.apache.spark.sql.Row row, ExceptionMetadata metadata, ItemType itemType) Converts a DataFrame row to an item.- Parameters:
row- the DataFrame row.metadata- exception metadata is an error is thrown.itemType- the type to annotate the output item with (for now, it can be null for no annotation).- Returns:
- the converted item.
-
convertValueToItem
public static Item convertValueToItem(Object o, org.apache.spark.sql.types.DataType fieldType, ExceptionMetadata metadata, ItemType itemType) -
getItemFromXML
Parses an XML document to an item.- Parameters:
currentNode- The current nodepath- The path of the original file- Returns:
- the parsed item
-
getDocumentItemFromXML
public static DocumentItem getDocumentItemFromXML(Node currentNode, String path, boolean removeParentPointers)
-
getItemFromObject(JsonReader, boolean, String, ExceptionMetadata, boolean)instead.