Enum Class NewLinePatternConverter

java.lang.Object
java.lang.Enum<NewLinePatternConverter>
repast.simphony.integration.NewLinePatternConverter
All Implemented Interfaces:
Serializable, Comparable<NewLinePatternConverter>, java.lang.constant.Constable

public enum NewLinePatternConverter extends Enum<NewLinePatternConverter>
Handles converting newline patterns into different newline patterns. This means it will convert patterns matching "\n" to a pattern that matches Windows newlines "\r\n", unix newlines "\n", system dependent (currently only windows or unix types), or do no conversion.

This is NOT for doing "\n" -> "\r\n" type conversions, but is for converting regular expressions that match newline characters from matching "\n" to matching some other type.

Author:
Jerry Vos
  • Enum Constant Details

    • NONE

      public static final NewLinePatternConverter NONE
      Performs no conversion
    • SYSTEM

      public static final NewLinePatternConverter SYSTEM
      If the system's line separator is "\r\n" it will do the same as a WINDOWS converter, if the pattern is "\n" it will return a UNIX one, otherwise it will just return the string.
    • WINDOWS

      public static final NewLinePatternConverter WINDOWS
      Replaces "\n" matches with "\r\n" matches.
    • UNIX

      public static final NewLinePatternConverter UNIX
      Returns the string as it is. This does NOT convert "\r\n" matchers to "\n".
  • Method Details

    • values

      public static NewLinePatternConverter[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static NewLinePatternConverter valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • getNewLineConverter

      public static NewLinePatternConverter getNewLineConverter(String handleType)
      Returns the converter that has the specified type as it type.
      Parameters:
      handleType - the type to find a converter for.
      Returns:
      a NewLinePatternConverter or NewLinePatternConverter.NONE if no matching one can be found
    • getType

      public String getType()
    • convert

      public abstract String convert(String string)
      Converts the newline patterns to those specified by its type.
      Parameters:
      string - a string with newline matching patterns
      Returns:
      a converted string