In package com.eden.orchid.api.compilers

class com.eden.orchid.api.compilers.OrchidParser

A generic Parser used to convert structured text input into a usable JSONObject. Commonly used for extracting data from configuration files or from blocks embedded within content files.

Fields

public final static arrayAsObjectKey

If the Parser evaluates the input to be an Array structure rather than Object structure, the resulting array data should be wrapped in a JSONObject with this value as its only key, pointing to the Array contents.

Constructors

public <init>(kotlin.Int)

Initialize the OrchidParser with a set priority. Parsers with a higher priority are chosen first to process a given input content when multiple Parsers can process the same input extension.

Parameters:
  • priority: Int

Methods

public open getDelimiterString(): String

Return the un-quoted delimiter string so it can be displayed to the user.

Parameters:
  • No parameters
public open getDelimiter(): String

In some cases, the routine choosing a Parser may lookup a parser by its delimiter instead of just its extension. If a returned character is not null, it will be accessible by its delimiter as well as its extensions, otherwise the parser may only be found by its extensions. A Parser should decide for itself which of its extensions is interpreted by the delimiting character. A delimiter is also expected to prepare itself for insertion into a Regex pattern (such as by Pattern.quote()), in the case that it is a string that contains normal Regex special characters.

Parameters:
  • No parameters
public abstract parse(kotlin.String, kotlin.String): MutableMap

Processes content according to a particular extension. The Parser expects to return a JSON object, regardless of whether it parsed JSONObject- or JSONArray-type content. If the result of processing is a JSONArray, it is expected that the array data will exist in a JSONObject at the OrchidParser.arrayAsObjectKey.

Parameters:
  • extension: String
  • input: String
public abstract getSourceExtensions(): Array

Returns the file extensions which are able to be processed by this Parser. When content needs to be processed by a parser, it looks for the highest-priority parser which accepts the given extension.

Parameters:
  • No parameters
public abstract serialize(kotlin.String, kotlin.Any): String

Processes content according to a particular extension. The Parser expects to return a JSON object, regardless of whether it parsed JSONObject- or JSONArray-type content. If the result of processing is a JSONArray, it is expected that the array data will exist in a JSONObject at the OrchidParser.arrayAsObjectKey.

Parameters:
  • extension: String
  • input: Any