当前位置: 首页>>代码示例>>Java>>正文


Java ScriptException.getMessage方法代码示例

本文整理汇总了Java中javax.script.ScriptException.getMessage方法的典型用法代码示例。如果您正苦于以下问题:Java ScriptException.getMessage方法的具体用法?Java ScriptException.getMessage怎么用?Java ScriptException.getMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.script.ScriptException的用法示例。


在下文中一共展示了ScriptException.getMessage方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getValue

import javax.script.ScriptException; //导入方法依赖的package包/类
@Override
public String getValue(String orginData)
{
	String value = null;
	ScriptEngine engine = new ScriptEngineManager().getEngineByName("javascript");
	try
	{
		Object resObj = engine.eval(orginData);
		if(resObj != null)
		{
			value = resObj.toString();
		}
		else
		{
			value = "js not return!";
		}
	}
	catch (ScriptException e)
	{
		value = e.getMessage();
		e.printStackTrace();
	}
	
	return value;
}
 
开发者ID:LinuxSuRen,项目名称:phoenix.webui.framework,代码行数:26,代码来源:JavaScriptDynamicData.java

示例2: addIssues

import javax.script.ScriptException; //导入方法依赖的package包/类
public void addIssues( ScriptException cause )
{
  String message = cause.getMessage();
  for( StringTokenizer tokenizer = new StringTokenizer( message, "\r\n" ); tokenizer.hasMoreTokens(); )
  {
    String line = tokenizer.nextToken();
    if( line.startsWith( "[" ) )
    {
      int lineNum = parseNum( line.substring( 1 ), ':' );
      int column = parseNum( line.substring( line.indexOf( ':' ) + 1 ) + 1, ']' );
      int offset = findOffset( _file, lineNum, column );
      String msg = line.substring( line.indexOf( ']' ) + 1 );
      _issues.add( new JsonIssue( IIssue.Kind.Error, offset, lineNum, column, msg ) );
    }
  }
}
 
开发者ID:manifold-systems,项目名称:manifold,代码行数:17,代码来源:JsonIssueContainer.java

示例3: evalStream

import javax.script.ScriptException; //导入方法依赖的package包/类
/**
 * Evaluates the stream of the script.
 *
 * @param is
 * @return true if eval succeeded
 * @throws ScriptedAgentException
 */
final protected boolean evalStream(Reader reader) throws ScriptedAgentException {
    try {
        engine.eval(reader);
        return true;
    } catch (ScriptException e) {
        getLog().severe("Script error -> " + e.getMessage());
        throw new ScriptedAgentException("Script error -> " + e.getMessage(), e);
    }
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:17,代码来源:StreamScriptLogic.java

示例4: adjustException

import javax.script.ScriptException; //导入方法依赖的package包/类
private static RuntimeException adjustException(ScriptException scriptException, String... scripts) {
	Throwable cause = scriptException.getCause();
	if (!(cause instanceof PyException)) {
		if (scripts.length == 0) {
			return new IllegalStateException(scriptException);
		} else {
			return new IllegalStateException(
					scriptException.getMessage() + "\nscript:" + joinStrings("\n", scripts), scriptException);
		}
	}

	PyException e = (PyException) cause;

	PyObject o = e.value.getDict();
	if (!(o instanceof PyStringMap)) {
		return e;
	}
	PyStringMap m = (PyStringMap) o;

	String message;
	if (e.value instanceof PyBaseException) {
		message = String.valueOf(((PyBaseException) e.value).getMessage());
	} else {
		message = scriptException.getMessage();
	}

	PyObject tlist = m.getMap().get("tlist");
	PyObject trace = m.getMap().get("trace");

	return new UroborosqlFormatterException(message, String.valueOf(tlist), String.valueOf(trace), e);
}
 
开发者ID:future-architect,项目名称:eclipse-uroborosql-formatter,代码行数:32,代码来源:PyEngine.java

示例5: compileScript

import javax.script.ScriptException; //导入方法依赖的package包/类
private static CompiledScript compileScript(String script) {
  ScriptEngine engine = factory.getScriptEngine(new String[] { "--no-java" });
  Compilable compEngine = (Compilable) engine;
  try {
    return compEngine.compile(script);
  } catch (ScriptException e) {
    log.warn("Failed to compile filter script: {}", e.getMessage(), e);
    throw new IllegalArgumentException("Can't compile script: " + e.getMessage());
  }
}
 
开发者ID:osswangxining,项目名称:iotplatform,代码行数:11,代码来源:NashornJsEvaluator.java

示例6: createFromTemplate

import javax.script.ScriptException; //导入方法依赖的package包/类
@Override
public List<FileObject> createFromTemplate(CreateDescriptor desc) throws IOException {
    FileObject template = desc.getTemplate();
    String name = desc.getProposedName();
    Map<String, ?> values = desc.getParameters();
    FileObject f = desc.getTarget();
    
    boolean noExt = desc.hasFreeExtension() && name.indexOf('.') != -1;
    
    String extWithDot;
    if (noExt) {
        extWithDot = null;
    } else {
        extWithDot = '.' + template.getExt();
        if (name.endsWith(extWithDot)) { // Test whether the extension happens to be there already
            // And remove it if yes, it will be appended to the unique name.
            name = name.substring(0, name.length() - extWithDot.length());
        }
    }
    
    String nameUniq = FileUtil.findFreeFileName(f, name, noExt ? null : template.getExt());
    FileObject output = FileUtil.createData(f, noExt ? nameUniq : nameUniq + extWithDot);
    Charset targetEnc = FileEncodingQuery.getEncoding(output);
    Charset sourceEnc = FileEncodingQuery.getEncoding(template);
    
    ScriptEngine eng = engine(template);
    Bindings bind = eng.getContext().getBindings(ScriptContext.ENGINE_SCOPE);
    bind.putAll(values);
    
    if(!values.containsKey(ENCODING_PROPERTY_NAME)) {
        bind.put(ENCODING_PROPERTY_NAME, targetEnc.name());
    }
    
    //Document doc = createDocument(template.getMIMEType());
    FileLock lock = output.lock();
    try (Writer w = new OutputStreamWriter(output.getOutputStream(lock), targetEnc);
         Reader is = new InputStreamReader(template.getInputStream(), sourceEnc);
        /*IndentWriter w2 = new IndentWriter(doc, 0, w, false) */) {
        StringWriter sw = new StringWriter();
        ScriptEngine eng2 = desc.isPreformatted() ? null : indentEngine();
        
        eng.getContext().setWriter(new PrintWriter(eng2 != null ? sw : w));
        //eng.getContext().setBindings(bind, ScriptContext.ENGINE_SCOPE);
        eng.getContext().setAttribute(FileObject.class.getName(), template, ScriptContext.ENGINE_SCOPE);
        eng.getContext().setAttribute(ScriptEngine.FILENAME, template.getNameExt(), ScriptContext.ENGINE_SCOPE);
        eng.eval(is);
        
        if (eng2 != null) {
            eng2.getContext().setAttribute("mimeType", template.getMIMEType(), ScriptContext.ENGINE_SCOPE);
            eng2.getContext().setWriter(w);
            eng2.eval(new StringReader(sw.toString()));
        }
    }catch (ScriptException ex) {
        IOException io = new IOException(ex.getMessage(), ex);
        throw io;
    } finally {
        lock.releaseLock();
    }
    return Collections.singletonList(output);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:61,代码来源:ScriptingCreateFromTemplateHandler.java


注:本文中的javax.script.ScriptException.getMessage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。