org.thewonderlemming.c4plantuml.graphml

## Class C4Graph

- java.lang.Object
- - org.thewonderlemming.c4plantuml.graphml.C4Graph

-     public class C4Graph
      extends Object

  The C4 to GraphML transformation engine.

  It relies on JAXB for the XML marshalling.

  Author:
    thewonderlemming

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `C4Graph(Charset charset, boolean formatOutput)` A constructor that turns on a strict validation of the XML output and that turns off the C4 parsing errors.
    `C4Graph(Charset charset, boolean formatOutput, boolean thrownOnParseError)` A constructor that turns on a strict validation of the XML output.
    `C4Graph(Charset charset, boolean formatOutput, boolean validateOutput, boolean strictValidation, boolean thrownOnParseError)` Default constructor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `C4Graph` | `addAndProcessC4Files(List<Path> c4Files)` Adds a `List` of C4 files to parse and returns the current instance to allow method chaining.
    `Optional<String>` | `export()` Transforms the parsed C4 files to a single GraphML output and returns the result as a string.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### C4Graph

          public C4Graph(Charset charset,
                         boolean formatOutput)

      A constructor that turns on a strict validation of the XML output and that turns off the C4 parsing errors.
      Parameters:
        `charset` - the `Charset` to use to read the C4 files.
        `formatOutput` - a flag to tell whether the output XML should fit on a single line or not.

    - #### C4Graph

          public C4Graph(Charset charset,
                         boolean formatOutput,
                         boolean thrownOnParseError)

      A constructor that turns on a strict validation of the XML output.
      Parameters:
        `charset` - the `Charset` to use to read the C4 files.
        `formatOutput` - a flag to tell whether the output XML should fit on a single line or not.
        `thrownOnParseError` - a flag to tell whether a parsing error should fail the transformation.

    - #### C4Graph

          public C4Graph(Charset charset,
                         boolean formatOutput,
                         boolean validateOutput,
                         boolean strictValidation,
                         boolean thrownOnParseError)

      Default constructor.
      Parameters:
        `charset` - the `Charset` to use to read the C4 files.
        `formatOutput` - a flag to tell whether the output XML should fit on a single line or not.
        `validateOutput` - a flag to tell whether the output XML should be validated against the GraphML XSDs.
        `strictValidation` - a flag to tell whether a validation error should fail the transformation.
        `thrownOnParseError` - a flag to tell whether a parsing error should fail the transformation.

  - ### Method Detail

    - #### addAndProcessC4Files

          public C4Graph addAndProcessC4Files(List<Path> c4Files)

      Adds a `List` of C4 files to parse and returns the current instance to allow method chaining.

      It is better to call that method with every C4 file to parse at once, because they will be sorted alphabetically, while if you call that method more than once per generation, you should take responsibility of the ordering of these source files.

      Parameters:
        `c4Files` - the `List` of C4 files to parse.
      Returns:
        the current instance of `C4Graph` to allow method chaining.

    - #### export

          public Optional<String> export()
                                  throws Throwable

      Transforms the parsed C4 files to a single GraphML output and returns the result as a string.
      Returns:
        the XML output GraphML that represents the parsed C4 files. Returns empty if any silent error occurred.
      Throws:
        `Throwable` - on parsing errors and/or validation errors, depending on the values of the flags in the constructor.

Copyright © 2020. All rights reserved.