(ExecutionContext context, Object self, Object... args)
| 28 | } |
| 29 | |
| 30 | @Override |
| 31 | public Object call(ExecutionContext context, Object self, Object... args) { |
| 32 | String includePath = Types.toString(context, args[0]); |
| 33 | File includeFile = new File(includePath); |
| 34 | |
| 35 | try { |
| 36 | ExecutionContext parent = context.getParent(); |
| 37 | while (parent != null) { |
| 38 | context = parent; |
| 39 | parent = context.getParent(); |
| 40 | } |
| 41 | Runner runner = context.getRuntime().newRunner(); |
| 42 | if (includeFile.exists()) { |
| 43 | runner.withContext(context) |
| 44 | .withSource(includeFile) |
| 45 | .execute(); |
| 46 | } else { |
| 47 | InputStream is = context.getClassLoader().getResourceAsStream(includePath); |
| 48 | if (is == null) { |
| 49 | throw new FileNotFoundException(includePath); |
| 50 | } |
| 51 | BufferedReader reader = new BufferedReader(new InputStreamReader(is)); |
| 52 | Object ret = runner.withContext(context).withSource(reader).execute(); |
| 53 | try { |
| 54 | is.close(); |
| 55 | } catch (IOException e) { |
| 56 | // ignore |
| 57 | } |
| 58 | return ret; |
| 59 | } |
| 60 | } catch (IOException e) { |
| 61 | throw new ThrowException(context, context.createError("Error", e.getMessage())); |
| 62 | } |
| 63 | |
| 64 | return Types.UNDEFINED; |
| 65 | } |
| 66 | |
| 67 | @Override |
| 68 | public void setFileName() { |
nothing calls this directly
no test coverage detected