本文整理了Java中org.mozilla.javascript.Context.toString()
方法的一些代码示例,展示了Context.toString()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Context.toString()
方法的具体详情如下:
包路径:org.mozilla.javascript.Context
类名称:Context
方法名:toString
[英]Convert the value to a JavaScript String value.
See ECMA 9.8.
[中]将该值转换为JavaScript字符串值。
见ECMA 9.8。
代码示例来源:origin: org.freemarker/freemarker
public String getAsString() {
return Context.toString(scriptable);
}
代码示例来源:origin: stackoverflow.com
@Override
public void onAttach(Context context) {
super.onAttach(context);
// Verify that the host activity implements the callback interface
try {
// Instantiate the EditNameDialogListener so we can send events to the host
listener = (EditNameDialogListener) context;
} catch (ClassCastException e) {
// The activity doesn't implement the interface, throw exception
throw new ClassCastException(context.toString()
+ " must implement EditNameDialogListener");
}
}
代码示例来源:origin: pentaho/pentaho-kettle
public static void print( Context actualContext, Scriptable actualObject, Object[] ArgList,
Function FunctionContext ) {
for ( int i = 0; i < ArgList.length; i++ ) { // don't worry about "undefined" arguments
java.lang.System.out.print( Context.toString( ArgList[i] ) );
}
}
代码示例来源:origin: pentaho/pentaho-kettle
public static void LoadScriptFile( Context actualContext, Scriptable actualObject, Object[] ArgList,
Function FunctionContext ) {
for ( int i = 0; i < ArgList.length; i++ ) { // don't worry about "undefined" arguments
checkAndLoadJSFile( actualContext, actualObject, Context.toString( ArgList[i] ) );
}
}
代码示例来源: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 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 LoadScriptFromTab( Context actualContext, Scriptable actualObject, Object[] ArgList,
Function FunctionContext ) {
try {
for ( int i = 0; i < ArgList.length; i++ ) { // don't worry about "undefined" arguments
String strToLoad = Context.toString( ArgList[i] );
String strScript = actualObject.get( strToLoad, actualObject ).toString();
actualContext.evaluateString( actualObject, strScript, "_" + strToLoad + "_", 0, null );
}
} catch ( Exception e ) {
// System.out.println(e.toString());
}
}
代码示例来源:origin: pentaho/pentaho-kettle
public static String Alert( Context actualContext, Scriptable actualObject, Object[] ArgList,
Function FunctionContext ) {
SpoonInterface spoon = SpoonFactory.getInstance();
if ( ArgList.length == 1 && spoon != null ) {
String strMessage = Context.toString( ArgList[0] );
boolean ok = spoon.messageBox( strMessage, "Alert", true, Const.INFO );
if ( !ok ) {
throw new RuntimeException( "Alert dialog cancelled by user." );
}
}
return "";
}
代码示例来源: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 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 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 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: apache/incubator-druid
@Override
public String apply(Object input)
{
// ideally we need a close() function to discard the context once it is not used anymore
Context cx = Context.getCurrentContext();
if (cx == null) {
cx = contextFactory.enterContext();
}
final Object res = fn.call(cx, scope, scope, new Object[]{input});
return res != null ? Context.toString(res) : null;
}
};
代码示例来源: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() );
}
}
内容来源于网络,如有侵权,请联系作者删除!