Package org.openhab.core.scriptengine

Examples of org.openhab.core.scriptengine.ScriptParsingException


  private XExpression parseScriptIntoXTextEObject(String scriptAsString) throws ScriptParsingException {
    Resource resource = resourceSet.createResource(computeUnusedUri(resourceSet)); // IS-A XtextResource
    try {
      resource.load(new StringInputStream(scriptAsString), resourceSet.getLoadOptions());
    } catch (IOException e) {
      throw new ScriptParsingException("Unexpected IOException; from close() of a String-based ByteArrayInputStream, no real I/O; how is that possible???", scriptAsString, e);
    }
   
    List<Diagnostic> errors = resource.getErrors();
    if (errors.size() != 0) {
      throw new ScriptParsingException("Failed to parse expression (due to managed SyntaxError/s)", scriptAsString).addDiagnosticErrors(errors);
    }
   
    EList<EObject> contents = resource.getContents();

    if (!contents.isEmpty()) {
      Iterable<Issue> validationErrors = getValidationErrors(contents.get(0));
      if(!validationErrors.iterator().hasNext()) {
        return (XExpression) contents.get(0);
      } else {
        throw new ScriptParsingException("Failed to parse expression (due to managed ValidationError/s)", scriptAsString).addValidationIssues(validationErrors);
      }
    } else {
      return null;
    }
  }
View Full Code Here

TOP

Related Classes of org.openhab.core.scriptengine.ScriptParsingException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.