本文整理了Java中org.mozilla.javascript.Context.reportRuntimeError()
方法的一些代码示例,展示了Context.reportRuntimeError()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Context.reportRuntimeError()
方法的具体详情如下:
包路径:org.mozilla.javascript.Context
类名称:Context
方法名:reportRuntimeError
[英]Report a runtime error using the error reporter for the current thread.
[中]使用当前线程的错误报告器报告运行时错误。
代码示例来源:origin: pentaho/pentaho-kettle
static VariableScope getVariableScope( String codeOfScope ) {
switch ( codeOfScope ) {
case "s":
return VariableScope.SYSTEM;
case "r":
return VariableScope.ROOT;
case "p":
return VariableScope.PARENT;
case "g":
return VariableScope.GRAND_PARENT;
default:
throw Context.reportRuntimeError( "The argument type of function call "
+ "setVariable should either be \"s\", \"r\", \"p\", or \"g\"." );
}
}
代码示例来源:origin: pentaho/pentaho-kettle
public static void setEnvironmentVar( Context actualContext, Scriptable actualObject, Object[] ArgList,
Function FunctionContext ) {
String sArg1 = "";
String sArg2 = "";
if ( ArgList.length == 2 ) {
try {
sArg1 = Context.toString( ArgList[0] );
sArg2 = Context.toString( ArgList[1] );
System.setProperty( sArg1, sArg2 );
} catch ( Exception e ) {
throw Context.reportRuntimeError( e.toString() );
}
} else {
throw Context.reportRuntimeError( "The function call setEnvironmentVar requires 2 arguments." );
}
}
代码示例来源:origin: pentaho/pentaho-kettle
public static void touch( Context actualContext, Scriptable actualObject, Object[] ArgList,
Function FunctionContext ) {
try {
if ( ArgList.length == 1 && !isNull( ArgList[0] ) && !isUndefined( ArgList[0] ) ) {
File file = new File( Context.toString( ArgList[0] ) );
boolean success = file.createNewFile();
if ( !success ) {
file.setLastModified( System.currentTimeMillis() );
}
} else {
throw Context.reportRuntimeError( "The function call touch requires 1 valid argument." );
}
} catch ( Exception e ) {
throw Context.reportRuntimeError( e.toString() );
}
}
代码示例来源:origin: pentaho/pentaho-kettle
public static Object fileExists( Context actualContext, Scriptable actualObject, Object[] ArgList,
Function FunctionContext ) {
try {
if ( ArgList.length == 1 && !isNull( ArgList[0] ) && !isUndefined( ArgList[0] ) ) {
if ( ArgList[0].equals( null ) ) {
return null;
}
File file = new File( Context.toString( ArgList[0] ) );
return Boolean.valueOf( file.isFile() );
} else {
throw Context.reportRuntimeError( "The function call fileExists requires 1 valid argument." );
}
} catch ( Exception e ) {
throw Context.reportRuntimeError( e.toString() );
}
}
代码示例来源:origin: pentaho/pentaho-kettle
public static Object getTransformationName( Context actualContext, Scriptable actualObject, Object[] ArgList,
Function FunctionContext ) {
try {
Object objTranName = Context.toString( actualObject.get( "_TransformationName_", actualObject ) );
return objTranName;
} catch ( Exception e ) {
throw Context.reportRuntimeError( e.toString() );
}
}
代码示例来源:origin: pentaho/pentaho-kettle
public static void appendToFile( Context actualContext, Scriptable actualObject, Object[] ArgList,
Function FunctionContext ) {
if ( !isNull( ArgList ) && !isUndefined( ArgList ) ) {
try {
FileOutputStream file = new FileOutputStream( Context.toString( ArgList[0] ), true );
DataOutputStream out = new DataOutputStream( file );
out.writeBytes( Context.toString( ArgList[1] ) );
out.flush();
out.close();
} catch ( Exception er ) {
throw Context.reportRuntimeError( er.toString() );
}
} else {
throw Context.reportRuntimeError( "The function call appendToFile requires arguments." );
}
}
代码示例来源:origin: pentaho/pentaho-kettle
public static Object[] createRowCopy( Context actualContext, Scriptable actualObject, Object[] ArgList,
Function FunctionContext ) {
if ( ArgList.length == 1 ) {
try {
int newSize = (int) Math.round( Context.toNumber( ArgList[0] ) );
Object scmO = actualObject.get( "row", actualObject );
Object[] row = (Object[]) Context.jsToJava( scmO, ( new Object[] {} ).getClass() );
return RowDataUtil.createResizedCopy( row, newSize );
} catch ( Exception e ) {
throw Context.reportRuntimeError( "Unable to create a row copy: " + Const.CR + e.toString() );
}
} else {
throw Context
.reportRuntimeError( "The function call createRowCopy requires a single arguments : the new size of the row" );
}
}
代码示例来源:origin: pentaho/pentaho-kettle
public static String unEscapeXml( Context actualContext, Scriptable actualObject, Object[] ArgList,
Function FunctionContext ) {
if ( ArgList.length == 1 ) {
return Const.unEscapeXml( Context.toString( ArgList[0] ) );
} else {
throw Context.reportRuntimeError( "The function call unEscapeXml requires 1 argument." );
}
}
代码示例来源:origin: pentaho/pentaho-kettle
public static String escapeSQL( Context actualContext, Scriptable actualObject, Object[] ArgList,
Function FunctionContext ) {
if ( ArgList.length == 1 ) {
return Const.escapeSQL( Context.toString( ArgList[0] ) );
} else {
throw Context.reportRuntimeError( "The function call escapeSQL requires 1 argument." );
}
}
代码示例来源:origin: pentaho/pentaho-kettle
public static String removeDigits( Context actualContext, Scriptable actualObject, Object[] ArgList,
Function FunctionContext ) {
if ( ArgList.length == 1 ) {
return Const.removeDigits( Context.toString( ArgList[0] ) );
} else {
throw Context.reportRuntimeError( "The function call removeDigits requires 1 argument." );
}
}
代码示例来源:origin: pentaho/pentaho-kettle
public static String unEscapeHtml( Context actualContext, Scriptable actualObject, Object[] ArgList,
Function FunctionContext ) {
if ( ArgList.length == 1 ) {
return Const.unEscapeHtml( Context.toString( ArgList[0] ) );
} else {
throw Context.reportRuntimeError( "The function call unEscapeHtml requires 1 argument." );
}
}
代码示例来源:origin: pentaho/pentaho-kettle
public static String protectXMLCDATA( Context actualContext, Scriptable actualObject, Object[] ArgList,
Function FunctionContext ) {
if ( ArgList.length == 1 ) {
return Const.protectXMLCDATA( Context.toString( ArgList[0] ) );
} else {
throw Context.reportRuntimeError( "The function call protectXMLCDATA requires 1 argument." );
}
}
代码示例来源:origin: pentaho/pentaho-kettle
public static String escapeXml( Context actualContext, Scriptable actualObject, Object[] ArgList,
Function FunctionContext ) {
if ( ArgList.length == 1 ) {
return Const.escapeXML( Context.toString( ArgList[0] ) );
} else {
throw Context.reportRuntimeError( "The function call escapeXml requires 1 argument." );
}
}
代码示例来源:origin: pentaho/pentaho-kettle
public static String getDigitsOnly( Context actualContext, Scriptable actualObject, Object[] ArgList,
Function FunctionContext ) {
if ( ArgList.length == 1 ) {
return Const.getDigitsOnly( Context.toString( ArgList[0] ) );
} else {
throw Context.reportRuntimeError( "The function call getDigitsOnly requires 1 argument." );
}
}
代码示例来源:origin: pentaho/pentaho-kettle
public static String escapeHtml( Context actualContext, Scriptable actualObject, Object[] ArgList,
Function FunctionContext ) {
if ( ArgList.length == 1 ) {
return Const.escapeHtml( Context.toString( ArgList[0] ) );
} else {
throw Context.reportRuntimeError( "The function call escapeHtml requires 1 argument." );
}
}
代码示例来源:origin: pentaho/pentaho-kettle
public static String initCap( Context actualContext, Scriptable actualObject, Object[] ArgList,
Function FunctionContext ) {
if ( ArgList.length == 1 ) {
return Const.initCap( Context.toString( ArgList[0] ) );
} else {
throw Context.reportRuntimeError( "The function call initCap requires 1 argument." );
}
}
代码示例来源:origin: pentaho/pentaho-kettle
public static String ltrim( Context actualContext, Scriptable actualObject, Object[] ArgList,
Function FunctionContext ) {
try {
if ( ArgList.length == 1 ) {
if ( isNull( ArgList[0] ) ) {
return null;
} else if ( isUndefined( ArgList[0] ) ) {
return (String) Context.getUndefinedValue();
}
String strValueToTrim = Context.toString( ArgList[0] );
return strValueToTrim.replaceAll( "^\\s+", "" );
} else {
throw Context.reportRuntimeError( "The function call ltrim requires 1 argument." );
}
} catch ( Exception e ) {
throw Context.reportRuntimeError( "The function call ltrim is not valid : " + e.getMessage() );
}
}
代码示例来源:origin: pentaho/pentaho-kettle
public static String rtrim( Context actualContext, Scriptable actualObject, Object[] ArgList,
Function FunctionContext ) {
try {
if ( ArgList.length == 1 ) {
if ( isNull( ArgList[0] ) ) {
return null;
} else if ( isUndefined( ArgList[0] ) ) {
return (String) Context.getUndefinedValue();
}
String strValueToTrim = Context.toString( ArgList[0] );
return strValueToTrim.replaceAll( "\\s+$", "" );
} else {
throw Context.reportRuntimeError( "The function call rtrim requires 1 argument." );
}
} catch ( Exception e ) {
throw Context.reportRuntimeError( "The function call rtrim is not valid : " + e.getMessage() );
}
}
代码示例来源:origin: pentaho/pentaho-kettle
public static Object abs( Context actualContext, Scriptable actualObject, Object[] ArgList,
Function FunctionContext ) {
if ( ArgList.length == 1 ) {
try {
if ( isNull( ArgList[0] ) ) {
return new Double( Double.NaN );
} else if ( isUndefined( ArgList[0] ) ) {
return Context.getUndefinedValue();
} else {
return new Double( Math.abs( Context.toNumber( ArgList[0] ) ) );
}
} catch ( Exception e ) {
return null;
}
} else {
throw Context.reportRuntimeError( "The function call abs requires 1 argument." );
}
}
代码示例来源:origin: pentaho/pentaho-kettle
public static String removeCRLF( Context actualContext, Scriptable actualObject, Object[] ArgList,
Function FunctionContext ) {
if ( ArgList.length == 1 ) {
try {
if ( isNull( ArgList[0] ) ) {
return null;
} else if ( isUndefined( ArgList[0] ) ) {
return (String) Context.getUndefinedValue();
}
return Const.removeCRLF( Context.toString( ArgList[0] ) );
} catch ( Exception e ) {
throw Context.reportRuntimeError( "The function call removeCRLF is not valid" );
}
} else {
throw Context.reportRuntimeError( "The function call removeCRLF is not valid" );
}
}
}
内容来源于网络,如有侵权,请联系作者删除!