Class OmlWriter

java.lang.Object
dev.omnist.oml.OmlWriter

public class OmlWriter extends Object
OML (Omnist Markup Language) Canonical Writer (omnist-spec §4 and §9.5). Serializes a Document into canonical OML text format.
  • Method Details

    • write

      public static String write(Document doc)
      Serializes a Document to canonical indented OML text (omnist-spec §4 and §9.5). Nested objects are indented by two spaces per level; edges are separated by newlines.
      Parameters:
      doc - the document to serialize; must not be null
      Returns:
      the canonical OML text; never null
      Throws:
      WriteException - with write.unsupported-value (C-9) if a string value or an edge label has no UTF-8 encoding (a lone surrogate)
    • write

      public static String write(Document doc, WriteReport report)
      Like write(Document), and records in report every value the OML grammar cannot hold exactly: a time or datetime whose fraction needs more than six digits (the grammar is 1*6DIGIT) is written as a quoted string holding every digit, with a format.temporal-stringified adjustment (E-37: a value is never altered).
      Parameters:
      doc - the document to serialize; must not be null
      report - receives the adjustments; may be null
      Returns:
      the canonical OML text; never null
      Throws:
      WriteException - with write.unsupported-value (C-9) as write(Document)
    • writeCompact

      public static String writeCompact(Document doc)
      Serializes a Document to compact inline OML text. Edges are separated by "; " instead of newlines and indentation is suppressed, producing output suitable for single-line display or embedding in other formats.
      Parameters:
      doc - the document to serialize; must not be null
      Returns:
      the compact OML text; never null
      Throws:
      WriteException - with write.unsupported-value (C-9) if a string value or an edge label has no UTF-8 encoding (a lone surrogate)
    • writeCompact

      public static String writeCompact(Document doc, WriteReport report)
      Like writeCompact(Document), recording the temporal adjustments in report as write(Document, WriteReport) does.
      Parameters:
      doc - the document to serialize; must not be null
      report - receives the adjustments; may be null
      Returns:
      the compact OML text; never null
      Throws:
      WriteException - with write.unsupported-value (C-9) as write(Document)