java.lang.Object
de.uni_mannheim.informatik.dws.melt.yet_another_alignment_api.AlignmentSerializer

public class AlignmentSerializer extends Object
The AlignmentSerializer writes an Alignment to a file.
Author:
Sven Hertling, Jan Portisch
  • Field Details

    • ENCODING

      private static final Charset ENCODING
      Constant for UTF-8 encoding.
    • newline

      private static final String newline
    • GSON

      private static final com.google.gson.Gson GSON
    • ESCAPE_XML_TEXT

      private static final org.apache.commons.text.translate.CharSequenceTranslator ESCAPE_XML_TEXT
      XML Text escaper which do no escape double-quotes (heavily used by JSON serializations.
  • Constructor Details

    • AlignmentSerializer

      public AlignmentSerializer()
  • Method Details

    • serialize

      public static void serialize(Alignment alignment, File file) throws IOException
      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

      public static void serialize(Alignment alignment, OutputStream stream) throws IOException
      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

      public static String serialize(Alignment alignment)
      Serializes an alignment as String.
      Parameters:
      alignment - The alignment to be serialized.
      Returns:
      Alignment as String.
    • getXmlIntro

      private static String getXmlIntro(Alignment alignment)
      XML header.
      Parameters:
      alignment - Alignment to be serialized.
      Returns:
      XML header as String.
    • getXmlMappingCellMultiLine

      private static String getXmlMappingCellMultiLine(Correspondence cell)
    • getXmlOutro

      private static String getXmlOutro()
      Returns the XML footer.
      Returns:
      XML footer as string.
    • serializeOntoInfo

      private static void serializeOntoInfo(StringBuilder sb, OntoInfo o, String name)
    • getExtensionLabel

      public static String getExtensionLabel(String uri)
      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

      public static String getExtensionBaseUri(String uri)
      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

      private static boolean isBlank(CharSequence cs)
    • serializeToCSV

      public static void serializeToCSV(Alignment alignment, File file) throws IOException
      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

      public static void serializeToCSVWithExtensions(Alignment alignment, File file) throws IOException
      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

      private static void checkFile(File file) throws IOException
      Throws:
      IOException