org.mozilla.javascript.IdScriptableObject Java Examples
The following examples show how to use
org.mozilla.javascript.IdScriptableObject.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DynamicTextItemExecutor.java From birt with Eclipse Public License 1.0 | 6 votes |
private boolean isSupportedType( Object obValue ) { if ( obValue instanceof Scriptable ) { if ( obValue instanceof IdScriptableObject ) { IdScriptableObject jsObject = ( (IdScriptableObject) obValue ); if ( jsObject.getClassName( ).equals( "Date" ) ) { return true; } return false; } else if ( obValue instanceof NativeJavaObject ) { return true; } return false; } return IOUtil.getTypeIndex( obValue ) != -1; }
Example #2
Source File: ReportDocumentTest.java From birt with Eclipse Public License 1.0 | 5 votes |
/** * @throws BirtException */ private void preBasicDummy( ) throws BirtException { IQueryResults qr = myPreDataEngine.getQueryResults( queryResultID ); assert ( qr.getResultMetaData( ) != null ); IResultIterator ri = qr.getResultIterator( ); assert ( ri.getResultMetaData( ) != null ); Iterator it = this.expectedValue.iterator( ); while ( ri.next( ) ) { String str = ""; Object ob1 = it.next( ); Object ob2 = ri.getValue( dummyRowExprName ); if ( ob1 instanceof IdScriptableObject ) { ob1 = JavascriptEvalUtil.convertJavascriptValue( ob1 ); ob2 = JavascriptEvalUtil.convertJavascriptValue( ob2 ); } assertEquals( ob1, ob2 ); str += " " + ob2.toString( ); this.testOut.println( "row result set: " + str ); } assertTrue( ri.getResultMetaData( ) != null ); ri.close( ); myPreDataEngine.shutdown( ); }
Example #3
Source File: JavascriptEvalUtil.java From birt with Eclipse Public License 1.0 | 4 votes |
/** * Handles a Rhino script evaluation result, converting Javascript object * into equivalent Java objects if necessary. * @param inputObj Object returned by rhino engine. * @return If inputObj is a native Javascript object, its equivalent Java object * is returned; otherwise inputObj is returned */ public static Object convertJavascriptValue(Object inputObj) { if ( inputObj instanceof Undefined ) { return null; } if ( inputObj instanceof IdScriptableObject ) { // Return type is possibly a Javascript native object // Convert to Java object with same value String jsClass = ((Scriptable) inputObj).getClassName(); if ( "Date".equals(jsClass) ) { return Context.toType( inputObj, Date.class ); } else if ( "Boolean".equals(jsClass)) { return Boolean.valueOf( Context.toBoolean( inputObj ) ); } else if ( "Number".equals(jsClass)) { return new Double(Context.toNumber(inputObj)); } else if( "String".equals(jsClass) ) { return inputObj.toString(); } else if ( "Array".equals( jsClass ) ) { Object[] obj = new Object[(int) ( (NativeArray) inputObj ).getLength( )]; for ( int i = 0; i < obj.length; i++ ) { obj[i] = convertJavascriptValue( ( (NativeArray) inputObj ).get( i, null ) ); } return obj; } } else if ( inputObj instanceof Wrapper ) { return ( (Wrapper) inputObj ).unwrap( ); } else if ( inputObj instanceof Scriptable ) { return ((Scriptable) inputObj).getDefaultValue( null ); } return inputObj; }