Skip to content

compileScript 支持传入 InputStream #659

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions src/main/java/com/googlecode/aviator/AviatorEvaluatorInstance.java
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,41 @@ public Expression compileScript(final String path) throws IOException {
return this.compileScript(path, this.cachedExpressionByDefault);
}

/**
* Compile a script into expression.
*
* @param cacheKey caching key when cached is true.
* @param in the script file's InputStream
* @param name source file name
* @return the compiled expression instance.
* @throws IOException
* @since 5.0.0
*/
public Expression compileScript(final String cacheKey, final InputStream in,
final String name)
throws IOException {
return this.compileScript(cacheKey, in, name, this.cachedExpressionByDefault);
}

/**
* Compile a script into expression.
*
* @param cacheKey caching key when cached is true.
* @param in the script file's InputStream
* @param name source file name
* @param cached whether to cache the expression instance by cacheKey.
* @return the compiled expression instance.
* @throws IOException
* @since 5.0.0
*/
public Expression compileScript(final String cacheKey, final InputStream in,
final String name, final boolean cached)
throws IOException {
Reader reader = new InputStreamReader(in, Charset.forName("utf-8"));
return compile(cacheKey, Utils.readFully(reader), name, cached);
}


/**
* Returns the function missing handler, null if not set.
*
Expand Down