public String getAsString() { return Context.toString(scriptable); }
@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"); } }
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] ) ); } }
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] ) ); } }
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." ); } }
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() ); } }
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()); } }
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 ""; }
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." ); } }
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." ); } }
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." ); } }
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." ); } }
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." ); } }
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." ); } }
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." ); } }
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." ); } }
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." ); } }
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." ); } }
@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; } };
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() ); } }