All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.palindromicity.syslog.Simple Maven / Gradle / Ivy

package com.github.palindromicity.syslog;

import java.io.Reader;
import java.util.List;
import java.util.Map;
import java.util.function.Consumer;
import org.jspecify.nullness.NullMarked;
import org.jspecify.nullness.Nullable;

@NullMarked
public class Simple {
  /**
   * Parse a RFC 5424 {@code String} to a {@code Map simpleNested5424(String line) {
    SyslogParser> parser =
        new SyslogParserBuilder>().withSyslogBuilder(
            new MapOfMaps5424MessageHandler()).build();
    return parser.parseLine(line);
  }

  /**
   * Parse a RFC 5424 {@code String} to a {@code Map> consumer) {
    SyslogParser> parser =
        new SyslogParserBuilder>().withSyslogBuilder(
            new MapOfMaps5424MessageHandler()).build();
    parser.parseLine(line, consumer);
  }

  /**
   * Reads each line RFC 5424 from the {@code Reader} and parses it to
   * a {@code List} of {@code Map}.
   * Uses:
   * {@code DefaultKeyProvider}
   * {@code NilPolicy.OMIT}
   * No Deviations**
   *
   * @param reader {@code Reader} used.  It is not closed in this method.
   * @return {@code List} of {@code Map}
   * @throws com.github.palindromicity.syslog.dsl.ParseException if there is an error parsing
   * @throws IllegalArgumentException                            if reader is null
   */
  public static List> simpleNested5424(Reader reader) {
    SyslogParser> parser =
        new SyslogParserBuilder>().withSyslogBuilder(
            new MapOfMaps5424MessageHandler()).build();
    return parser.parseLines(reader);
  }

  /**
   * Reads each line of RFC 5424 from the {@code Reader} and parses it
   * to {@code Map}, which is passed to the provided {@code Consumer}.
   * Uses:
   * {@code DefaultKeyProvider}
   * {@code NilPolicy.OMIT}
   * No Deviations**
   *
   * @param reader   {@code Reader} used.  It is not closed in this method.
   * @param consumer the {@code Consumer}
   * @throws com.github.palindromicity.syslog.dsl.ParseException if there is an error parsing
   * @throws IllegalArgumentException                            if reader or consumer are null
   */
  public static void simpleNested5424(Reader reader,
                                      Consumer> consumer) {
    SyslogParser> parser =
        new SyslogParserBuilder>().withSyslogBuilder(
            new MapOfMaps5424MessageHandler()).build();
    parser.parseLines(reader, consumer);
  }

  /**
   * Parse a RFC 5424 {@code String} to a {@code Map}.
   * Uses:
   * {@code DefaultKeyProvider}
   * {@code NilPolicy.OMIT}
   * No Deviations
   *
   * @param line the line of 5424 Syslog to parse
   * @return a {@code Map}
   * @throws com.github.palindromicity.syslog.dsl.ParseException if there is an error parsing
   */
  public static Map simpleFlat5424(String line) {
    SyslogParser> parser =
        new SyslogParserBuilder>().withSyslogBuilder(
            new Flat5424MessageHandler()).build();
    return parser.parseLine(line);
  }

  /**
   * Parse a RFC 5424 {@code String} to a {@code Map> consumer) {
    SyslogParser> parser =
        new SyslogParserBuilder>().withSyslogBuilder(
            new Flat5424MessageHandler()).build();
    parser.parseLine(line, consumer);
  }

  /**
   * Reads each line of RFC 5424 from the {@code Reader} and parses it
   * to a {@code List} of {@code Map}.
   * Uses:
   * {@code DefaultKeyProvider}
   * {@code NilPolicy.OMIT}
   * No Deviations*
   *
   * @param reader {@code Reader} used.  It is not closed in this method.
   * @return {@code List} of {@code Map}
   * @throws com.github.palindromicity.syslog.dsl.ParseException if there is an error parsing
   * @throws IllegalArgumentException                            if reader is null
   */
  public static List> simpleFlat5424(Reader reader) {
    SyslogParser> parser =
        new SyslogParserBuilder>().withSyslogBuilder(
            new Flat5424MessageHandler()).build();
    return parser.parseLines(reader);
  }

  /**
   * Reads each line of RFC 5424 from the {@code Reader} and parses it
   * to {@code Map}, which is passed to the
   * provided {@code Consumer}.
   * Uses:
   * {@code DefaultKeyProvider}
   * {@code NilPolicy.OMIT}
   * No Deviations
   *
   * @param reader   {@code Reader} used.  It is not closed in this method.
   * @param consumer the {@code Consumer}
   * @throws com.github.palindromicity.syslog.dsl.ParseException if there is an error parsing
   * @throws IllegalArgumentException                            if reader or consumer are null
   */
  public static void simpleFlat5424(Reader reader,
                                    Consumer> consumer) {
    SyslogParser> parser =
        new SyslogParserBuilder>().withSyslogBuilder(
            new Flat5424MessageHandler()).build();
    parser.parseLines(reader, consumer);
  }

  /**
   * Parse a RFC 3164 {@code String} to a {@code Map simple3164(String line) {
    SyslogParser> parser =
        new SyslogParserBuilder>().forSpecification(
                SyslogSpecification.RFC_3164).withSyslogBuilder(new Default3164MessageHandler())
            .build();
    return parser.parseLine(line);
  }

  /**
   * Parse a RFC 3164 {@code String} to a {@code Map> consumer) {
    SyslogParser> parser =
        new SyslogParserBuilder>().forSpecification(
                SyslogSpecification.RFC_3164).withSyslogBuilder(new Default3164MessageHandler())
            .build();
    parser.parseLine(line, consumer);
  }

  /**
   * Reads each line of RFC 3164 from the {@code Reader} and parses it
   * to a {@code List} of {@code Map}.
   * Uses:
   * {@code DefaultKeyProvider}
   * No Deviations*
   *
   * @param reader {@code Reader} used.  It is not closed in this method.
   * @return {@code List} of {@code Map}
   * @throws com.github.palindromicity.syslog.dsl.ParseException if there is an error parsing
   * @throws IllegalArgumentException                            if reader is null
   */
  public static List> simple3164(Reader reader) {
    SyslogParser> parser =
        new SyslogParserBuilder>().forSpecification(
                SyslogSpecification.RFC_3164).withSyslogBuilder(new Default3164MessageHandler())
            .build();
    return parser.parseLines(reader);
  }

  /**
   * Reads each line from the {@code Reader} and parses it
   * to {@code Map}, which is passed to the
   * provided {@code Consumer}.
   * Uses:
   * {@code DefaultKeyProvider}
   * No Deviations
   *
   * @param reader   {@code Reader} used.  It is not closed in this method.
   * @param consumer the {@code Consumer}
   * @throws com.github.palindromicity.syslog.dsl.ParseException if there is an error parsing
   * @throws IllegalArgumentException                            if reader or consumer are null
   */
  public static void simple3164(Reader reader, Consumer> consumer) {
    SyslogParser> parser =
        new SyslogParserBuilder>().forSpecification(
                SyslogSpecification.RFC_3164).withSyslogBuilder(new Default3164MessageHandler())
            .build();
    parser.parseLines(reader, consumer);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy