public class HCLParser
extends java.lang.Object
Map.
This parser utilizes a lexer to generate symbols based on the HCL spec. String interpolation is not evaluated at this point in the parsing.
Below is an example of how HCL might be parsed.
import com.bertramlabs.plugins.hcl4j.HCLParser;
File terraformFile = new File("terraform.tf");
Map results = new HCLParser().parse(terraformFile);
| Constructor and Description |
|---|
HCLParser() |
| Modifier and Type | Method and Description |
|---|---|
java.util.Map<java.lang.String,java.lang.Object> |
parse(java.io.File input)
Parses terraform syntax as it comes from a File.
|
java.util.Map<java.lang.String,java.lang.Object> |
parse(java.io.File input,
java.lang.Boolean ignoreParserExceptions)
Parses terraform syntax as it comes from a File.
|
java.util.Map<java.lang.String,java.lang.Object> |
parse(java.io.File input,
java.nio.charset.Charset cs)
Parses terraform syntax as it comes from a File.
|
java.util.Map<java.lang.String,java.lang.Object> |
parse(java.io.File input,
java.lang.String charsetName)
Parses terraform syntax as it comes from a File.
|
java.util.Map<java.lang.String,java.lang.Object> |
parse(java.io.File input,
java.lang.String charsetName,
java.lang.Boolean ignoreParserExceptions)
Parses terraform syntax as it comes from a File.
|
java.util.Map<java.lang.String,java.lang.Object> |
parse(java.io.InputStream input)
Parses terraform syntax as it comes from an input stream.
|
java.util.Map<java.lang.String,java.lang.Object> |
parse(java.io.InputStream input,
java.nio.charset.Charset cs)
Parses terraform syntax as it comes from an input stream.
|
java.util.Map<java.lang.String,java.lang.Object> |
parse(java.io.InputStream input,
java.lang.String charsetName)
Parses terraform syntax as it comes from an input stream.
|
java.util.Map<java.lang.String,java.lang.Object> |
parse(java.io.InputStream input,
java.lang.String charsetName,
java.lang.Boolean ignoreParserExceptions)
Parses terraform syntax as it comes from an input stream.
|
java.util.Map<java.lang.String,java.lang.Object> |
parse(java.io.Reader reader)
Parses terraform configuration language from a Reader
|
java.util.Map<java.lang.String,java.lang.Object> |
parse(java.io.Reader reader,
java.lang.Boolean ignoreParserExceptions)
Parses terraform configuration language from a Reader
|
java.util.Map<java.lang.String,java.lang.Object> |
parse(java.lang.String input)
Parses terraform configuration language from a String
|
java.util.Map<java.lang.String,java.lang.Object> |
parse(java.lang.String input,
java.lang.Boolean ignoreParserExceptions)
Parses terraform configuration language from a String
|
protected java.lang.Object |
processEvaluation(EvalSymbol evalSymbol) |
protected java.lang.Object |
processValue(HCLValue value) |
public java.util.Map<java.lang.String,java.lang.Object> parse(java.lang.String input)
throws HCLParserException,
java.io.IOException
input - String input containing HCL syntaxHCLParserException - Any type of parsing errors are returned as this exception if the syntax is invalid.java.io.IOException - In the event the reader is unable to pull from the input source this exception is thrown.public java.util.Map<java.lang.String,java.lang.Object> parse(java.lang.String input,
java.lang.Boolean ignoreParserExceptions)
throws HCLParserException,
java.io.IOException
input - String input containing HCL syntaxignoreParserExceptions - if set to true, we ignore any parse exceptions and still return the symbol mapHCLParserException - Any type of parsing errors are returned as this exception if the syntax is invalid.java.io.IOException - In the event the reader is unable to pull from the input source this exception is thrown.public java.util.Map<java.lang.String,java.lang.Object> parse(java.io.File input,
java.lang.Boolean ignoreParserExceptions)
throws HCLParserException,
java.io.IOException,
java.io.UnsupportedEncodingException
input - A source file to process with a default charset of UTF-8ignoreParserExceptions - if set to true, we ignore any parse exceptions and still return the symbol mapHCLParserException - Any type of parsing errors are returned as this exception if the syntax is invalid.java.io.IOException - In the event the reader is unable to pull from the input source this exception is thrown.java.io.UnsupportedEncodingExceptionpublic java.util.Map<java.lang.String,java.lang.Object> parse(java.io.File input)
throws HCLParserException,
java.io.IOException,
java.io.UnsupportedEncodingException
input - A source file to process with a default charset of UTF-8HCLParserException - Any type of parsing errors are returned as this exception if the syntax is invalid.java.io.IOException - In the event the reader is unable to pull from the input source this exception is thrown.java.io.UnsupportedEncodingExceptionpublic java.util.Map<java.lang.String,java.lang.Object> parse(java.io.File input,
java.nio.charset.Charset cs)
throws HCLParserException,
java.io.IOException
input - A source file to processcs - A charsetHCLParserException - Any type of parsing errors are returned as this exception if the syntax is invalid.java.io.IOException - In the event the reader is unable to pull from the input source this exception is thrown.public java.util.Map<java.lang.String,java.lang.Object> parse(java.io.File input,
java.lang.String charsetName)
throws HCLParserException,
java.io.IOException
input - A source file to processcharsetName - The name of a supported charsetHCLParserException - Any type of parsing errors are returned as this exception if the syntax is invalid.java.io.IOException - In the event the reader is unable to pull from the input source this exception is thrown.java.io.UnsupportedEncodingException - If the charset ( UTF-8 by default if unspecified) encoding is not supportedpublic java.util.Map<java.lang.String,java.lang.Object> parse(java.io.File input,
java.lang.String charsetName,
java.lang.Boolean ignoreParserExceptions)
throws HCLParserException,
java.io.IOException
input - A source file to processcharsetName - The name of a supported charsetignoreParserExceptions - if set to true, we ignore any parse exceptions and still return the symbol mapHCLParserException - Any type of parsing errors are returned as this exception if the syntax is invalid.java.io.IOException - In the event the reader is unable to pull from the input source this exception is thrown.java.io.UnsupportedEncodingException - If the charset ( UTF-8 by default if unspecified) encoding is not supportedpublic java.util.Map<java.lang.String,java.lang.Object> parse(java.io.InputStream input)
throws HCLParserException,
java.io.IOException
input - Streamable input of text going to the lexerHCLParserException - Any type of parsing errors are returned as this exception if the syntax is invalid.java.io.IOException - In the event the reader is unable to pull from the input source this exception is thrown.public java.util.Map<java.lang.String,java.lang.Object> parse(java.io.InputStream input,
java.nio.charset.Charset cs)
throws HCLParserException,
java.io.IOException
input - Streamable input of text going to the lexercs - CharSet with which to read the contents of the stream (default UTF-8)HCLParserException - Any type of parsing errors are returned as this exception if the syntax is invalid.java.io.IOException - In the event the reader is unable to pull from the input source this exception is thrown.public java.util.Map<java.lang.String,java.lang.Object> parse(java.io.InputStream input,
java.lang.String charsetName)
throws HCLParserException,
java.io.IOException,
java.io.UnsupportedEncodingException
input - Streamable input of text going to the lexercharsetName - String lookup of the character set this stream is providing (default UTF-8)HCLParserException - Any type of parsing errors are returned as this exception if the syntax is invalid.java.io.IOException - In the event the reader is unable to pull from the input source this exception is thrown.java.io.UnsupportedEncodingException - If the charset ( UTF-8 by default if unspecified) encoding is not supported.public java.util.Map<java.lang.String,java.lang.Object> parse(java.io.InputStream input,
java.lang.String charsetName,
java.lang.Boolean ignoreParserExceptions)
throws HCLParserException,
java.io.IOException,
java.io.UnsupportedEncodingException
input - Streamable input of text going to the lexercharsetName - String lookup of the character set this stream is providing (default UTF-8)ignoreParserExceptions - if set to true, we ignore any parse exceptions and still return the symbol mapHCLParserException - Any type of parsing errors are returned as this exception if the syntax is invalid.java.io.IOException - In the event the reader is unable to pull from the input source this exception is thrown.java.io.UnsupportedEncodingException - If the charset ( UTF-8 by default if unspecified) encoding is not supported.public java.util.Map<java.lang.String,java.lang.Object> parse(java.io.Reader reader)
throws HCLParserException,
java.io.IOException
reader - A reader object used for absorbing various streams or String variables containing the hcl codeHCLParserException - Any type of parsing errors are returned as this exception if the syntax is invalid.java.io.IOException - In the event the reader is unable to pull from the input source this exception is thrown.public java.util.Map<java.lang.String,java.lang.Object> parse(java.io.Reader reader,
java.lang.Boolean ignoreParserExceptions)
throws HCLParserException,
java.io.IOException
reader - A reader object used for absorbing various streams or String variables containing the hcl codeignoreParserExceptions - if set to true, we ignore any parse exceptions and still return the symbol mapHCLParserException - Any type of parsing errors are returned as this exception if the syntax is invalid.java.io.IOException - In the event the reader is unable to pull from the input source this exception is thrown.protected java.lang.Object processValue(HCLValue value) throws HCLParserException
HCLParserExceptionprotected java.lang.Object processEvaluation(EvalSymbol evalSymbol)