Class AlignmentSerializer
java.lang.Object
de.uni_mannheim.informatik.dws.melt.yet_another_alignment_api.AlignmentSerializer
The AlignmentSerializer writes an
Alignment
to a file.- Author:
- Sven Hertling, Jan Portisch
-
Field Summary
Modifier and TypeFieldDescriptionprivate static final Charset
Constant for UTF-8 encoding.private static final org.apache.commons.text.translate.CharSequenceTranslator
XML Text escaper which do no escape double-quotes (heavily used by JSON serializations.private static final com.google.gson.Gson
private static final String
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprivate static void
static String
Returns the extension label of a full URI.static String
getExtensionLabel
(String uri) Returns the extension label of a full URI.private static String
getXmlIntro
(Alignment alignment) XML header.private static String
private static String
Returns the XML footer.private static boolean
isBlank
(CharSequence cs) static String
Serializes an alignment as String.static void
Method to write the specified alignment to the specified file in the default XML format.static void
serialize
(Alignment alignment, OutputStream stream) Method to write the specified alignment to the specified outputstream in the default XML format.private static void
serializeOntoInfo
(StringBuilder sb, OntoInfo o, String name) static void
serializeToCSV
(Alignment alignment, File file) Method to write the specified alignment to the specified file (in CSV format).static void
serializeToCSVWithExtensions
(Alignment alignment, File file) Method to write the specified alignment to the specified file (in CSV format).
-
Field Details
-
ENCODING
Constant for UTF-8 encoding. -
newline
-
GSON
private static final com.google.gson.Gson GSON -
ESCAPE_XML_TEXT
private static final org.apache.commons.text.translate.CharSequenceTranslator ESCAPE_XML_TEXTXML Text escaper which do no escape double-quotes (heavily used by JSON serializations.
-
-
Constructor Details
-
AlignmentSerializer
public AlignmentSerializer()
-
-
Method Details
-
serialize
Method to write the specified alignment to the specified file in the default XML format.- Parameters:
alignment
- The alignment that shall be written.file
- The file to which the alignment shall be written.- Throws:
IOException
- Exception that occurred while serializing the alignment.
-
serialize
Method to write the specified alignment to the specified outputstream in the default XML format.- Parameters:
alignment
- The alignment that shall be written.stream
- the stream where the serialized alignment should be written to (the stream is not closed)- Throws:
IOException
- Exception that occurred while serializing the alignment.
-
serialize
Serializes an alignment as String.- Parameters:
alignment
- The alignment to be serialized.- Returns:
- Alignment as String.
-
getXmlIntro
XML header.- Parameters:
alignment
- Alignment to be serialized.- Returns:
- XML header as String.
-
getXmlMappingCellMultiLine
-
getXmlOutro
Returns the XML footer.- Returns:
- XML footer as string.
-
serializeOntoInfo
-
getExtensionLabel
Returns the extension label of a full URI.- Parameters:
uri
- Extension URI with base URI and appended extension label. Example: http://purl.org/dc/elements/1.1/creator or http://exmo.inrialpes.fr/align/ext/1.0/#pretty- Returns:
- Only the extension label. Example: creator or pretty
-
getExtensionBaseUri
Returns the extension label of a full URI.- Parameters:
uri
- Extension URI with base URI and appended extension label. Example: http://purl.org/dc/elements/1.1/creator or http://exmo.inrialpes.fr/align/ext/1.0/#pretty- Returns:
- Only the extension label. Example: http://purl.org/dc/elements/1.1/ or http://exmo.inrialpes.fr/align/ext/1.0/#
-
isBlank
-
serializeToCSV
Method to write the specified alignment to the specified file (in CSV format).- Parameters:
alignment
- The alignment that shall be written.file
- The file to which the alignment shall be written.- Throws:
IOException
- Exception that occurred while serializing the alignment.
-
serializeToCSVWithExtensions
Method to write the specified alignment to the specified file (in CSV format).- Parameters:
alignment
- The alignment that shall be written.file
- The file to which the alignment shall be written.- Throws:
IOException
- Exception that occurred while serializing the alignment.
-
checkFile
- Throws:
IOException
-