Class EvaluatorImpl
- All Implemented Interfaces:
AutoCloseable,Evaluator
-
Constructor Summary
ConstructorsConstructorDescriptionEvaluatorImpl(StackFrameTransformer transformer, boolean color, SecurityManager manager, HttpClient httpClient, Logger logger, Collection<ModuleKeyFactory> factories, Collection<ResourceReader> readers, Map<String, String> environmentVariables, Map<String, String> externalProperties, @Nullable Duration timeout, @Nullable Path moduleCacheDir, @Nullable DeclaredDependencies projectDependencies, @Nullable String outputFormat, TraceMode traceMode) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Releases all resources held by this evaluator.evaluate(ModuleSource moduleSource) Evaluates the module, returning the Java representation of the module object.evaluateExpression(ModuleSource moduleSource, String expression) Evaluates the Pkl expression represented asexpression, returning the Java representation of the result.byte[]evaluateExpressionPklBinary(ModuleSource moduleSource, String expression) Evaluates the Pkl expression represented asexpression, returning a byte array of thepkl-binary-encoded representation of the result.evaluateExpressionString(ModuleSource moduleSource, String expression) Evaluates the Pkl expression, returning the stringified result.byte[]evaluateOutputBytes(ModuleSource moduleSource) Evaluates a module'soutput.bytesproperty.evaluateOutputFiles(ModuleSource moduleSource) Evaluates a module'soutput.filesproperty.evaluateOutputText(ModuleSource moduleSource) Evaluates a module'soutput.textproperty.evaluateOutputValue(ModuleSource moduleSource) Evaluates a module'soutput.valueproperty.<T> TevaluateOutputValueAs(ModuleSource moduleSource, PClassInfo<T> classInfo) Evaluates the module'soutput.valueproperty, and validates that its type matches the provided class info.evaluateSchema(ModuleSource moduleSource) Evaluates the module's schema, which describes the properties, methods, and classes of a module.evaluateTest(ModuleSource moduleSource, boolean overwrite) Runs tests within the module, and returns the test results.
-
Constructor Details
-
EvaluatorImpl
public EvaluatorImpl(StackFrameTransformer transformer, boolean color, SecurityManager manager, HttpClient httpClient, Logger logger, Collection<ModuleKeyFactory> factories, Collection<ResourceReader> readers, Map<String, String> environmentVariables, Map<String, String> externalProperties, @Nullable @Nullable Duration timeout, @Nullable @Nullable Path moduleCacheDir, @Nullable @Nullable DeclaredDependencies projectDependencies, @Nullable @Nullable String outputFormat, TraceMode traceMode)
-
-
Method Details
-
evaluate
Description copied from interface:EvaluatorEvaluates the module, returning the Java representation of the module object. -
evaluateOutputText
Description copied from interface:EvaluatorEvaluates a module'soutput.textproperty.- Specified by:
evaluateOutputTextin interfaceEvaluator
-
evaluateOutputBytes
Description copied from interface:EvaluatorEvaluates a module'soutput.bytesproperty.- Specified by:
evaluateOutputBytesin interfaceEvaluator
-
evaluateOutputValue
Description copied from interface:EvaluatorEvaluates a module'soutput.valueproperty.- Specified by:
evaluateOutputValuein interfaceEvaluator
-
evaluateOutputFiles
Description copied from interface:EvaluatorEvaluates a module'soutput.filesproperty.- Specified by:
evaluateOutputFilesin interfaceEvaluator
-
evaluateExpression
Description copied from interface:EvaluatorEvaluates the Pkl expression represented asexpression, returning the Java representation of the result.The following table describes how Pkl types are represented in Java:
Pkl type Java type Null PNullString StringBoolean BooleanInt LongFloat DoubleTyped, Dynamic PObject(PModuleif the object is a module)Mapping, Map MapListing, List ListSet SetPair PairRegex PatternDataSize DataSizeDuration DurationClass PClassTypeAlias TypeAliasBytes byte[]The following Pkl types have no Java representation, and an error is thrown if an expression computes to a value of these types:
- IntSeq
- Function
- Specified by:
evaluateExpressionin interfaceEvaluator
-
evaluateExpressionPklBinary
Description copied from interface:EvaluatorEvaluates the Pkl expression represented asexpression, returning a byte array of thepkl-binary-encoded representation of the result.- Specified by:
evaluateExpressionPklBinaryin interfaceEvaluator
-
evaluateExpressionString
Description copied from interface:EvaluatorEvaluates the Pkl expression, returning the stringified result.This is equivalent to wrapping the expression with
.toString()- Specified by:
evaluateExpressionStringin interfaceEvaluator
-
evaluateSchema
Description copied from interface:EvaluatorEvaluates the module's schema, which describes the properties, methods, and classes of a module.- Specified by:
evaluateSchemain interfaceEvaluator
-
evaluateTest
Description copied from interface:EvaluatorRuns tests within the module, and returns the test results.This requires that the target module be a test module; it must either amend or extend module
"pkl:test". Otherwise, a type mismatch error is thrown.This method will write possibly
pkl-expected.pcfandpkl-actual.pcffiles as a sibling of the test module. Theoverwriteparameter causes the evaluator to overwritepkl-expected.pklfiles if they currently exist.- Specified by:
evaluateTestin interfaceEvaluator
-
evaluateOutputValueAs
Description copied from interface:EvaluatorEvaluates the module'soutput.valueproperty, and validates that its type matches the provided class info.- Specified by:
evaluateOutputValueAsin interfaceEvaluator
-
close
public void close()Description copied from interface:EvaluatorReleases all resources held by this evaluator. If anevaluatemethod is currently executing, this method blocks until cancellation of that execution has completed.Once an evaluator has been closed, it can no longer be used, and calling
evaluatemethods will throwIllegalStateException. However, objects previously returned byevaluatemethods remain valid.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceEvaluator
-