public class JsonSerializer extends Object implements EntityDocumentDumpProcessor
EntityDocumentDumpProcessor
to provide a
serializer for EntityDocument
objects in JSON.
The implementation does not check if open()
has been called before
the first document is serialized. It is the responsibility of the caller to
do this.
Implementations of the data model are expected to be appropriately serializable to JSON with Jackson.
Modifier and Type | Field and Description |
---|---|
protected static com.fasterxml.jackson.databind.ObjectMapper |
mapper
Object mapper that is used to serialize JSON.
|
Constructor and Description |
---|
JsonSerializer(OutputStream outputStream)
Creates a new JSON serializer that writes its output to the given stream.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Finishes the processing by performing any final steps, such as closing
resources.
|
int |
getEntityDocumentCount()
Returns the number of entity documents serialized so far.
|
static String |
getJsonString(EntityDocument entityDocument)
Serializes the given object in JSON and returns the resulting string.
|
static String |
getJsonString(EntityUpdate update)
Serializes the given object in JSON and returns the resulting string.
|
static String |
getJsonString(ItemDocument itemDocument)
Serializes the given object in JSON and returns the resulting string.
|
static String |
getJsonString(MediaInfoDocument mediaInfoDocument)
Serializes the given object in JSON and returns the resulting string.
|
static String |
getJsonString(PropertyDocument propertyDocument)
Serializes the given object in JSON and returns the resulting string.
|
static String |
getJsonString(Statement statement)
Serializes the given object in JSON and returns the resulting string.
|
void |
open()
Starts the processing by performing any initial steps to prepare
processing.
|
void |
processItemDocument(ItemDocument itemDocument)
Processes the given ItemDocument.
|
void |
processLexemeDocument(LexemeDocument lexemeDocument)
Processes the given LexemeDocument.
|
void |
processMediaInfoDocument(MediaInfoDocument mediaInfoDocument)
Processes the given MediaInfoDocument.
|
void |
processPropertyDocument(PropertyDocument propertyDocument)
Processes the given PropertyDocument.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
processEntityRedirectDocument
protected static final com.fasterxml.jackson.databind.ObjectMapper mapper
public JsonSerializer(OutputStream outputStream)
close()
is call ed.outputStream
- the output stream to write topublic void open()
EntityDocumentDumpProcessor
open
in interface EntityDocumentDumpProcessor
public void processItemDocument(ItemDocument itemDocument)
EntityDocumentProcessor
processItemDocument
in interface EntityDocumentProcessor
itemDocument
- the ItemDocumentpublic void processPropertyDocument(PropertyDocument propertyDocument)
EntityDocumentProcessor
processPropertyDocument
in interface EntityDocumentProcessor
propertyDocument
- the PropertyDocumentpublic void processLexemeDocument(LexemeDocument lexemeDocument)
EntityDocumentProcessor
processLexemeDocument
in interface EntityDocumentProcessor
lexemeDocument
- the LexemeDocumentpublic void processMediaInfoDocument(MediaInfoDocument mediaInfoDocument)
EntityDocumentProcessor
processMediaInfoDocument
in interface EntityDocumentProcessor
mediaInfoDocument
- the MediaInfoDocumentpublic void close()
EntityDocumentDumpProcessor
close
in interface EntityDocumentDumpProcessor
public int getEntityDocumentCount()
public static String getJsonString(EntityDocument entityDocument) throws com.fasterxml.jackson.core.JsonProcessingException
entityDocument
- object to serializecom.fasterxml.jackson.core.JsonProcessingException
- if the object cannot be serializedpublic static String getJsonString(ItemDocument itemDocument) throws com.fasterxml.jackson.core.JsonProcessingException
itemDocument
- object to serializecom.fasterxml.jackson.core.JsonProcessingException
- if the object cannot be serializedpublic static String getJsonString(PropertyDocument propertyDocument) throws com.fasterxml.jackson.core.JsonProcessingException
propertyDocument
- object to serializecom.fasterxml.jackson.core.JsonProcessingException
- if the object cannot be serializedpublic static String getJsonString(MediaInfoDocument mediaInfoDocument) throws com.fasterxml.jackson.core.JsonProcessingException
mediaInfoDocument
- object to serializecom.fasterxml.jackson.core.JsonProcessingException
- if the object cannot be serializedpublic static String getJsonString(Statement statement) throws com.fasterxml.jackson.core.JsonProcessingException
statement
- object to serializecom.fasterxml.jackson.core.JsonProcessingException
- if the object cannot be serializedpublic static String getJsonString(EntityUpdate update) throws com.fasterxml.jackson.core.JsonProcessingException
update
- object to serializecom.fasterxml.jackson.core.JsonProcessingException
- if the object cannot be serializedCopyright © 2014–2024 Wikidata Toolkit Developers. Generated from source code published under the Apache License 2.0. For more information, see the Wikidata Toolkit homepage