idx
int64 0
41.2k
| question
stringlengths 73
5.81k
| target
stringlengths 5
918
|
|---|---|---|
39,500
|
public void loadTemplateClass ( TemplateClass tc ) { if ( ! readEnabled ( ) ) { return ; } InputStream is = null ; try { File f = getCacheFile ( tc ) ; if ( ! f . exists ( ) || ! f . canRead ( ) ) return ; is = new BufferedInputStream ( new FileInputStream ( f ) ) ; int offset = 0 ; int read ; StringBuilder hash = new StringBuilder ( ) ; while ( ( read = is . read ( ) ) != 0 ) { if ( read == - 1 ) { logger . error ( "Failed to read cache file for template class: %s" , tc ) ; return ; } hash . append ( ( char ) read ) ; offset ++ ; } if ( ! conf . loadPrecompiled ( ) ) { String curHash = hash ( tc ) ; if ( ! curHash . equals ( hash . toString ( ) ) ) { if ( logger . isTraceEnabled ( ) ) { logger . trace ( "Bytecode too old (%s != %s)" , hash , curHash ) ; } return ; } } read = - 1 ; StringBuilder source = new StringBuilder ( ) ; while ( ( read = is . read ( ) ) != 0 ) { source . append ( ( char ) read ) ; offset ++ ; } if ( source . length ( ) != 0 ) { String s = source . toString ( ) ; String [ ] sa = s . split ( "__INCLUDED_TAG_TYPES__" ) ; tc . javaSource = sa [ 0 ] ; s = sa [ 1 ] ; sa = s . split ( "__INCULDED_TEMPLATE_CLASS_NAME_LIST__" ) ; tc . deserializeIncludeTagTypes ( sa [ 0 ] ) ; s = sa [ 1 ] ; sa = s . split ( "__IMPORT_PATH_LIST__" ) ; tc . setIncludeTemplateClassNames ( sa [ 0 ] ) ; if ( sa . length > 1 ) { s = sa [ 1 ] ; sa = s . split ( ";" ) ; Set < String > importPaths = new HashSet < String > ( ) ; for ( String path : sa ) { if ( "java.lang" . equals ( path ) ) continue ; importPaths . add ( path ) ; } tc . replaceImportPath ( importPaths ) ; } } byte [ ] byteCode = new byte [ ( int ) f . length ( ) - ( offset + 2 ) ] ; is . read ( byteCode ) ; tc . loadCachedByteCode ( byteCode ) ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } finally { if ( is != null ) try { is . close ( ) ; } catch ( IOException e ) { logger . error ( e . getMessage ( ) , e ) ; } } }
|
Retrieve java source and bytecode if template content has not changed
|
39,501
|
String hash ( TemplateClass tc ) { try { MessageDigest messageDigest = MessageDigest . getInstance ( "MD5" ) ; messageDigest . reset ( ) ; messageDigest . update ( ( engine . version ( ) + tc . getTemplateSource ( true ) ) . getBytes ( "utf-8" ) ) ; byte [ ] digest = messageDigest . digest ( ) ; StringBuilder builder = new StringBuilder ( ) ; for ( int i = 0 ; i < digest . length ; ++ i ) { int value = digest [ i ] ; if ( value < 0 ) { value += 256 ; } builder . append ( Integer . toHexString ( value ) ) ; } return builder . toString ( ) ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } }
|
Build a hash of the source code . To efficiently track source code modifications .
|
39,502
|
File getCacheFile ( TemplateClass tc ) { String id = cacheFileName ( tc , ".rythm" ) ; return getCacheFile ( id ) ; }
|
Retrieve the real file that will be used as cache .
|
39,503
|
public static int compare ( String a , String b ) { int shortestLength = ( a . length ( ) < b . length ( ) ) ? a . length ( ) : b . length ( ) ; for ( int i = 0 ; i < shortestLength ; i ++ ) { if ( a . charAt ( i ) < b . charAt ( i ) ) { return - 1 ; } else if ( a . charAt ( i ) > b . charAt ( i ) ) { return 1 ; } } if ( a . length ( ) > b . length ( ) ) { return 1 ; } else if ( a . length ( ) < b . length ( ) ) { return - 1 ; } return 0 ; }
|
Returns a negative number if the first version is lower than the second zero if they are equal and a positive number if the first version is higher than the second .
|
39,504
|
public void setPort ( int port ) { options . get ( PORT ) . setValue ( PORT . sanitize ( String . valueOf ( port ) ) ) ; }
|
Specifies the port the debugger should connect to .
|
39,505
|
public void setProfile ( OperaProfile profile ) { options . get ( PROFILE ) . setValue ( PROFILE . sanitize ( profile ) ) ; supportsPd = true ; }
|
Sets the profile to use as an Opera profile represented as an object .
|
39,506
|
public void setProduct ( OperaProduct product ) { options . get ( PRODUCT ) . setValue ( product ) ; OperaArguments arguments ; if ( getProduct ( ) . is ( OperaProduct . DESKTOP ) ) { arguments = new OperaDesktopArguments ( ) ; } else { arguments = new OperaCoreArguments ( ) ; } options . get ( ARGUMENTS ) . setValue ( arguments . merge ( arguments ( ) ) ) ; }
|
Sets the product currently used for example desktop or core .
|
39,507
|
public OperaRunner getRunner ( ) { String klassName = ( String ) options . get ( RUNNER ) . getValue ( ) ; if ( klassName == null ) { setRunner ( OperaLauncherRunner . class ) ; return getRunner ( ) ; } Class < ? > klass ; try { klass = Class . forName ( klassName ) ; } catch ( ClassNotFoundException e ) { throw new WebDriverException ( "Unable to find runner class on classpath: " + klassName ) ; } Constructor constructor ; try { constructor = klass . getDeclaredConstructor ( OperaSettings . class ) ; } catch ( NoSuchMethodException e ) { throw new WebDriverException ( "Invalid constructor in runner: " + klass . getName ( ) ) ; } OperaRunner runner ; try { runner = ( OperaRunner ) constructor . newInstance ( this ) ; } catch ( InstantiationException e ) { throw new WebDriverException ( "Unable to create new instance of runner" , e ) ; } catch ( IllegalAccessException e ) { throw new WebDriverException ( "Denied access to runner: " + klass . getName ( ) ) ; } catch ( InvocationTargetException e ) { throw new WebDriverException ( "Runner threw exception on construction" , e ) ; } return runner ; }
|
Get the runner to use for starting and managing the Opera instance .
|
39,508
|
public void setRunner ( Class < ? extends OperaRunner > runner ) { options . get ( RUNNER ) . setValue ( runner . getName ( ) ) ; }
|
Specify which runner to use for starting and managing the Opera instance .
|
39,509
|
public Capabilities toCapabilities ( ) { DesiredCapabilities capabilities = DesiredCapabilities . opera ( ) ; for ( CapabilityInstance option : options . values ( ) ) { if ( option . getValue ( ) == null ) { continue ; } capabilities . setCapability ( option . getCapability ( ) , option . getValue ( ) ) ; } return capabilities . merge ( surplusCapabilities ) ; }
|
Returns this as capabilities . This does not copy the settings . Further changes will be reflected in the capabilities .
|
39,510
|
public void cleanUp ( ) { if ( backupWidgetDat != null ) { try { Files . move ( backupWidgetDat , widgetsDat ) ; } catch ( IOException e ) { throw new WebDriverException ( "Unable to restore widgets.dat" ) ; } } else { widgetsDat . delete ( ) ; } }
|
Remove all custom extensions
|
39,511
|
private void verifyPathIsOEX ( File path ) { checkNotNull ( path ) ; checkArgument ( path . exists ( ) , "%s does not exist" , path . getAbsolutePath ( ) ) ; checkArgument ( ! path . isDirectory ( ) , "%s is a directory" , path . getAbsolutePath ( ) ) ; checkArgument ( path . getName ( ) . endsWith ( ".oex" ) , "%s does not end with .oex" , path . getName ( ) ) ; }
|
Verify that the given path exists and is an OEX file .
|
39,512
|
private void writeOEXtoWidgetsDat ( String wuid , File oexpath ) throws IOException { String oexpathRelative = "{LargePreferences}widgets/" + oexpath . getName ( ) ; String widgetString = Files . toString ( widgetsDat , Charsets . UTF_8 ) ; int beforePreferencesEndTag = widgetString . lastIndexOf ( "</preferences>" ) ; if ( beforePreferencesEndTag == - 1 ) { throw new WebDriverException ( "</preferences> not found in " + widgetsDat . getPath ( ) ) ; } String widgetDatSection = String . format ( WIDGET_DAT_ITEM , wuid , oexpathRelative ) ; widgetString = widgetString . substring ( 0 , beforePreferencesEndTag ) + widgetDatSection + widgetString . substring ( beforePreferencesEndTag ) ; Files . write ( widgetString , widgetsDat , Charsets . UTF_8 ) ; }
|
Install the extension by writing to widgets . dat
|
39,513
|
private void createOEXDirectory ( String wuid ) throws IOException { File oexDirectory = new File ( directory , wuid ) ; if ( ! oexDirectory . exists ( ) && ! oexDirectory . mkdirs ( ) ) { throw new WebDriverException ( "Unable to create directory path: " + directory . getPath ( ) ) ; } File prefsDatPath = new File ( oexDirectory , "prefs.dat" ) ; String prefContent = String . format ( WIDGET_PREFS_DAT_CONTENT , wuid ) ; Files . write ( prefContent , prefsDatPath , Charsets . UTF_8 ) ; }
|
Create the minimal directory structure and prefs . dat for an Opera extension .
|
39,514
|
public void onWindowClosed ( Integer id ) { services . onWindowClosed ( id ) ; services . getWindowManager ( ) . removeWindow ( id ) ; services . getDebugger ( ) . cleanUpRuntimes ( id ) ; }
|
Handles windows that have been closed . Removes it from the list and removes the runtimes that are associated with it .
|
39,515
|
protected String extended ( ) { String defClass = TagBase . class . getName ( ) ; return null == extended ? defClass : extended ; }
|
the cName of the extended template
|
39,516
|
public void clear ( ) { buffer ( ) . ensureCapacity ( 0 ) ; this . engine = null ; this . tmpl = null ; this . cName = null ; this . pName = null ; this . tagName = null ; this . initCode = null ; this . finalCode = null ; this . extended = null ; this . extendedTemplateClass = null ; if ( null != this . extendArgs ) this . extendArgs . pl . clear ( ) ; this . imports . clear ( ) ; this . extendDeclareLineNo = 0 ; this . renderArgs . clear ( ) ; this . builders . clear ( ) ; this . parser = null ; this . templateClass = null ; this . inlineClasses . clear ( ) ; this . inlineTags . clear ( ) ; this . inlineTagBodies . clear ( ) ; this . importLineMap . clear ( ) ; this . logTime = false ; this . macros . clear ( ) ; this . macroStack . clear ( ) ; this . buildBody = null ; this . templateDefLang = null ; this . staticCodes . clear ( ) ; }
|
Reset to the state before construction
|
39,517
|
public void rewind ( ) { renderArgCounter = 0 ; this . initCode = null ; this . finalCode = null ; this . extended = null ; this . extendedTemplateClass = null ; if ( null != this . extendArgs ) this . extendArgs . pl . clear ( ) ; this . imports . clear ( ) ; this . extendDeclareLineNo = 0 ; this . renderArgs . clear ( ) ; this . builders . clear ( ) ; this . inlineClasses . clear ( ) ; this . inlineTags . clear ( ) ; this . inlineTagBodies . clear ( ) ; this . importLineMap . clear ( ) ; this . logTime = false ; this . macros . clear ( ) ; this . macroStack . clear ( ) ; this . buildBody = null ; this . staticCodes . clear ( ) ; }
|
Rewind to the state when construction finished
|
39,518
|
public void addImport ( String imprt , int lineNo ) { imports . add ( imprt ) ; if ( imprt . endsWith ( ".*" ) ) { imprt = imprt . substring ( 0 , imprt . lastIndexOf ( ".*" ) ) ; templateClass . importPaths . add ( imprt ) ; } importLineMap . put ( imprt , lineNo ) ; }
|
add the given import
|
39,519
|
public void removeSpaceToLastLineBreak ( IContext ctx ) { boolean shouldRemoveSpace = true ; List < Token > bl = builders ( ) ; for ( int i = bl . size ( ) - 1 ; i >= 0 ; -- i ) { TextBuilder tb = bl . get ( i ) ; if ( tb == Token . EMPTY_TOKEN || tb instanceof IDirective ) { continue ; } if ( tb . getClass ( ) . equals ( Token . StringToken . class ) ) { String s = tb . toString ( ) ; if ( s . matches ( "[ \\t\\x0B\\f]+" ) ) { continue ; } else if ( s . matches ( "(\\n\\r|\\r\\n|[\\r\\n])" ) ) { } else { shouldRemoveSpace = false ; } } break ; } if ( shouldRemoveSpace ) { for ( int i = bl . size ( ) - 1 ; i >= 0 ; -- i ) { TextBuilder tb = bl . get ( i ) ; if ( tb == Token . EMPTY_TOKEN || tb instanceof IDirective ) { continue ; } if ( tb . getClass ( ) . equals ( Token . StringToken . class ) ) { String s = tb . toString ( ) ; if ( s . matches ( "[ \\t\\x0B\\f]+" ) ) { bl . remove ( i ) ; continue ; } else if ( s . matches ( "(\\n\\r|\\r\\n|[\\r\\n])" ) ) { bl . remove ( i ) ; } } break ; } } }
|
If from the current cursor to last linebreak are all space then remove all those spaces and the last line break
|
39,520
|
public void setPreferences ( OperaPreferences newPreferences ) { if ( ! ( newPreferences instanceof OperaFilePreferences ) ) { OperaFilePreferences convertedPreferences = new OperaFilePreferences ( preferenceFile ) ; convertedPreferences . merge ( newPreferences ) ; preferences = convertedPreferences ; } else { preferences = newPreferences ; } }
|
Replaces the preferences in the profile with the given preferences .
|
39,521
|
public static final ITemplate getTemplate ( String tmpl , Object ... args ) { return engine ( ) . getTemplate ( tmpl , args ) ; }
|
get a template with the given params
|
39,522
|
public void stop ( ) { if ( server == null ) { return ; } logger . fine ( "Shutting down STP connection listener" ) ; monitor . remove ( server ) ; try { server . close ( ) ; } catch ( IOException e ) { } finally { server = null ; } }
|
Shuts down and cleans up the STP connection to Opera .
|
39,523
|
public void start ( ) throws IOException { server = ServerSocketChannel . open ( ) ; server . configureBlocking ( false ) ; server . socket ( ) . setReuseAddress ( true ) ; server . socket ( ) . bind ( new InetSocketAddress ( port ) ) ; monitor . add ( server , this , SelectionKey . OP_ACCEPT ) ; if ( manualConnect ) { System . out . println ( "Ready to accept connections on port " + port ) ; } }
|
Starts the STP connection listener .
|
39,524
|
protected void init ( ) { if ( settings . autostart ( ) ) { runner = settings . getRunner ( ) ; logger . config ( "Using runner " + runner . getClass ( ) . getSimpleName ( ) ) ; } else { settings . setPort ( OperaDefaults . SERVER_DEFAULT_PORT_IDENTIFIER ) ; } createScopeServices ( ) ; if ( runner != null ) { runner . startOpera ( ) ; } services . init ( ) ; debugger = services . getDebugger ( ) ; debugger . setDriver ( this ) ; windowManager = services . getWindowManager ( ) ; exec = services . getExec ( ) ; core = services . getCore ( ) ; cookieManager = services . getCookieManager ( ) ; mouse = new OperaMouse ( this ) ; keyboard = new OperaKeyboard ( this ) ; services . getConsoleLogger ( ) . onConsoleMessage ( new ConsoleMessageConverter ( logs ) ) ; settings . setProduct ( utils ( ) . getProduct ( ) ) ; if ( ! utils ( ) . getUserAgent ( ) . contains ( "Mini" ) ) { preferences = new OperaScopePreferences ( services . getPrefs ( ) ) ; preferences ( ) . set ( "User Prefs" , "Ignore Unrequested Popups" , false ) ; if ( utils ( ) . getProduct ( ) . is ( MOBILE ) ) { preferences ( ) . set ( "User Prefs" , "Allow Autofocus Form Element" , true ) ; } } proxy = new OperaProxy ( this ) ; proxy . parse ( settings . getProxy ( ) ) ; }
|
Initialize required Scope services .
|
39,525
|
@ SuppressWarnings ( "unchecked" ) protected SortedSet < ScopeService > getRequiredServices ( ) { return ImmutableSortedSet . of ( ScopeService . WINDOW_MANAGER , ScopeService . EXEC , ScopeService . CORE , ScopeService . PREFS , ScopeService . SELFTEST , ScopeService . CONSOLE_LOGGER , ScopeService . COOKIE_MANAGER ) ; }
|
A sorted set of required services for this OperaDriver to function . The services listed will be built and initialized in the specified order .
|
39,526
|
private void createScopeServices ( ) { try { services = new ScopeServices ( getRequiredServices ( ) , settings . getPort ( ) , ! settings . autostart ( ) ) ; services . startStpThread ( ) ; } catch ( IOException e ) { throw new CommunicationException ( e ) ; } }
|
Set up the Scope connection and thread .
|
39,527
|
protected WebElement findElement ( String by , String using , OperaWebElement el ) { checkNotNull ( using , "Cannot find elements when the selector is null" ) ; assertConnected ( ) ; using = OperaStrings . escapeJsString ( using ) ; boolean isAvailable ; Integer id ; String script ; if ( el == null ) { script = "return " + OperaAtom . FIND_ELEMENT + "({\"" + by + "\": \"" + using + "\"})" ; } else { script = "return " + OperaAtom . FIND_ELEMENT + "({\"" + by + "\": \"" + using + "\"}, locator)" ; } if ( el == null ) { id = debugger . getObject ( script ) ; } else { id = debugger . executeScriptOnObject ( script , el . getObjectId ( ) ) ; } isAvailable = ( id != null ) ; if ( isAvailable ) { String error = debugger . callFunctionOnObject ( "return (locator instanceof Error) ? locator.message : ''" , id ) ; if ( ! error . isEmpty ( ) ) { throw new InvalidSelectorException ( error ) ; } Boolean isStale = Boolean . valueOf ( debugger . callFunctionOnObject ( "locator.parentNode == undefined" , id ) ) ; if ( isStale ) { throw new StaleElementReferenceException ( "This element is no longer part of DOM" ) ; } return new OperaWebElement ( this , id ) ; } else { throw new NoSuchElementException ( "Cannot find element(s) with " + by ) ; } }
|
Find a single element using the selenium atoms .
|
39,528
|
@ SuppressWarnings ( "unused" ) public void operaAction ( String using , String ... params ) { exec . action ( using , params ) ; }
|
Performs a special action such as setting an Opera preference .
|
39,529
|
protected < X > X implicitlyWaitFor ( Callable < X > condition ) { long end = System . currentTimeMillis ( ) + OperaIntervals . IMPLICIT_WAIT . getMs ( ) ; Exception lastException = null ; do { X toReturn = null ; try { toReturn = condition . call ( ) ; } catch ( Exception e ) { lastException = e ; } if ( toReturn instanceof Boolean && ! ( Boolean ) toReturn ) { continue ; } if ( toReturn != null ) { return toReturn ; } sleep ( OperaIntervals . POLL_INTERVAL . getMs ( ) ) ; } while ( System . currentTimeMillis ( ) < end ) ; if ( lastException != null ) { if ( lastException instanceof RuntimeException ) { throw ( RuntimeException ) lastException ; } throw new WebDriverException ( lastException ) ; } return null ; }
|
Implicitly wait for an element to become visible .
|
39,530
|
private void gc ( ) { if ( ( services != null && services . isConnected ( ) ) && debugger != null ) { debugger . releaseObjects ( ) ; } objectIds . clear ( ) ; }
|
Releases protected ECMAScript objects to make them garbage collectible . Released objects are not necessarily freed immediately . Releasing objects invalidates associated object ID s immediately .
|
39,531
|
public static boolean isEqual ( Object o1 , Object o2 ) { return isEqual ( str ( o1 ) , str ( o2 ) ) ; }
|
Check if two Object is equal after converted into String
|
39,532
|
public static String removeAllLineBreaks ( Object o ) { String s = str ( o ) ; return s . replaceAll ( "[\n\r]+" , " " ) ; }
|
Remove all line breaks from string representation of specified object O
|
39,533
|
private static String _escapeXML ( String value ) { int len = value . length ( ) ; if ( 0 == len ) { return value ; } StringBuilder buf = null ; for ( int i = 0 ; i < len ; i ++ ) { char ch = value . charAt ( i ) ; switch ( ch ) { case '<' : if ( buf == null ) { buf = new StringBuilder ( len * 2 ) ; if ( i > 0 ) { buf . append ( value . substring ( 0 , i ) ) ; } } buf . append ( "<" ) ; break ; case '>' : if ( buf == null ) { buf = new StringBuilder ( len * 2 ) ; if ( i > 0 ) { buf . append ( value . substring ( 0 , i ) ) ; } } buf . append ( ">" ) ; break ; case '\"' : if ( buf == null ) { buf = new StringBuilder ( len * 2 ) ; if ( i > 0 ) { buf . append ( value . substring ( 0 , i ) ) ; } } buf . append ( """ ) ; break ; case '\'' : if ( buf == null ) { buf = new StringBuilder ( len * 2 ) ; if ( i > 0 ) { buf . append ( value . substring ( 0 , i ) ) ; } } buf . append ( "'" ) ; break ; case '&' : if ( buf == null ) { buf = new StringBuilder ( len * 2 ) ; if ( i > 0 ) { buf . append ( value . substring ( 0 , i ) ) ; } } buf . append ( "&" ) ; break ; default : if ( buf != null ) { buf . append ( ch ) ; } break ; } } if ( buf != null ) { return buf . toString ( ) ; } return value ; }
|
we use this method to replace apache StringEscapeUtils which is slower
|
39,534
|
public static RawData escapeRegex ( Object o ) { if ( null == o ) return RawData . NULL ; if ( o instanceof RawData ) return ( RawData ) o ; String s = o . toString ( ) ; return new RawData ( s . replaceAll ( "([\\/\\*\\{\\}\\<\\>\\-\\\\\\!])" , "\\\\$1" ) ) ; }
|
Escape for regular expression
|
39,535
|
public static String stripBraceAndQuotation ( Object o ) { if ( null == o ) return "" ; String s = stripBrace ( o ) ; s = stripQuotation ( s ) ; return s ; }
|
Strip off both brace and quotation
|
39,536
|
public static String shrinkSpace ( Object o ) { if ( null == o ) return "" ; return o . toString ( ) . replaceAll ( "[\r\n]+" , "\n" ) . replaceAll ( "[ \\t\\x0B\\f]+" , " " ) ; }
|
Shrink spaces in an object s string representation by merge multiple spaces tabs into one space and multiple line breaks into one line break
|
39,537
|
public static boolean isDigitsOrAlphabetic ( char c ) { int i = ( int ) c ; return digits . include ( i ) || uppers . include ( i ) || lowers . include ( i ) ; }
|
check the given char to be a digit or alphabetic
|
39,538
|
public static String capitalizeWords ( Object o ) { if ( null == o ) return "" ; String source = o . toString ( ) ; char prevc = ' ' ; StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < source . length ( ) ; i ++ ) { char c = source . charAt ( i ) ; if ( c != ' ' && ! isDigitsOrAlphabetic ( prevc ) ) { sb . append ( Character . toUpperCase ( c ) ) ; } else { sb . append ( c ) ; } prevc = c ; } return sb . toString ( ) ; }
|
Capitalize the first character of every word of the specified object s string representation . Words are separated by space
|
39,539
|
public static String lowerFirst ( Object o ) { if ( null == o ) return "" ; String string = o . toString ( ) ; if ( string . length ( ) == 0 ) { return string ; } return ( "" + string . charAt ( 0 ) ) . toLowerCase ( ) + string . substring ( 1 ) ; }
|
Make the first character be lowercase of the given object s string representation
|
39,540
|
public static String capFirst ( Object o ) { if ( null == o ) return "" ; String string = o . toString ( ) ; if ( string . length ( ) == 0 ) { return string ; } return ( "" + string . charAt ( 0 ) ) . toUpperCase ( ) + string . substring ( 1 ) ; }
|
Make the first character be uppercase of the given object s string representation
|
39,541
|
public static String camelCase ( Object obj ) { if ( null == obj ) return "" ; String string = obj . toString ( ) ; StringBuilder result = new StringBuilder ( string . length ( ) ) ; String [ ] sa = string . split ( " " ) ; int l = sa . length ; for ( int i = 0 ; i < l ; ++ i ) { if ( i > 0 ) result . append ( " " ) ; for ( String s : sa [ i ] . split ( "_" ) ) { result . append ( capFirst ( s ) ) ; } } return result . toString ( ) ; }
|
Turn an object s String representation into Camel Case
|
39,542
|
public static int len ( Object o ) { if ( o instanceof Collection ) { return ( ( Collection ) o ) . size ( ) ; } else if ( o instanceof Map ) { return ( ( Map ) o ) . size ( ) ; } else if ( o . getClass ( ) . isArray ( ) ) { return Array . getLength ( o ) ; } else { return str ( o ) . length ( ) ; } }
|
get length of specified object
|
39,543
|
public static String urlEncode ( Object data ) { if ( null == data ) return "" ; String entity = data . toString ( ) ; try { String encoding = "utf-8" ; return URLEncoder . encode ( entity , encoding ) ; } catch ( UnsupportedEncodingException e ) { Logger . error ( e , entity ) ; } return entity ; }
|
encode using utf - 8
|
39,544
|
public static String format ( ITemplate template , Number number ) { return format ( template , number , null , null ) ; }
|
Format number with specified template
|
39,545
|
@ Transformer ( requireTemplate = true ) public static String format ( Number number , String pattern , Locale locale ) { return format ( null , number , pattern , locale ) ; }
|
Format the number with specified pattern language and locale
|
39,546
|
public static String format ( ITemplate template , Number number , String pattern , Locale locale ) { if ( null == number ) { throw new NullPointerException ( ) ; } if ( null == locale ) { locale = I18N . locale ( template ) ; } NumberFormat nf ; if ( null == pattern ) nf = NumberFormat . getNumberInstance ( locale ) ; else { DecimalFormatSymbols symbols = new DecimalFormatSymbols ( locale ) ; nf = new DecimalFormat ( pattern , symbols ) ; } return nf . format ( number ) ; }
|
Format the number with specified template pattern language and locale
|
39,547
|
@ Transformer ( requireTemplate = true ) public static String format ( Date date ) { return format ( date , null , null , null ) ; }
|
Format a date with engine s default format corresponding to the engine s locale configured
|
39,548
|
public static String format ( ITemplate template , Date date ) { return format ( template , date , null , null , null ) ; }
|
Format a date with specified engine s default format corresponding to the engine s locale configured
|
39,549
|
public static String format ( ITemplate template , Date date , String pattern , Locale locale , String timezone ) { if ( null == date ) throw new NullPointerException ( ) ; RythmEngine engine = null == template ? RythmEngine . get ( ) : template . __engine ( ) ; DateFormat df = ( null == engine ? IDateFormatFactory . DefaultDateFormatFactory . INSTANCE : engine . dateFormatFactory ( ) ) . createDateFormat ( template , pattern , locale , timezone ) ; return df . format ( date ) ; }
|
Format a date with specified pattern lang locale and timezone . The locale comes from the engine instance specified
|
39,550
|
@ Transformer ( requireTemplate = true ) public static String formatCurrency ( Object data ) { return formatCurrency ( null , data , null , null ) ; }
|
Transformer method . Format given data into currency
|
39,551
|
public static String formatCurrency ( ITemplate template , Object data , String currencyCode ) { return formatCurrency ( template , data , currencyCode , null ) ; }
|
Transformer method . Format currency using specified parameters
|
39,552
|
public static String formatCurrency ( ITemplate template , Object data , String currencyCode , Locale locale ) { if ( null == data ) throw new NullPointerException ( ) ; Number number ; if ( data instanceof Number ) { number = ( Number ) data ; } else { number = Double . parseDouble ( data . toString ( ) ) ; } if ( null == locale ) locale = I18N . locale ( template ) ; if ( null == locale . getCountry ( ) || locale . getCountry ( ) . length ( ) != 2 ) { String lan = locale . getLanguage ( ) ; if ( eq ( lan , "en" ) ) { if ( null != currencyCode ) { if ( eq ( "AUD" , currencyCode ) ) { locale = new Locale ( lan , "AU" ) ; } else if ( eq ( "USD" , currencyCode ) ) { locale = Locale . US ; } else if ( eq ( "GBP" , currencyCode ) ) { locale = Locale . UK ; } } } else if ( eq ( lan , "zh" ) ) { locale = Locale . SIMPLIFIED_CHINESE ; } } NumberFormat numberFormat = NumberFormat . getCurrencyInstance ( locale ) ; Currency currency = null ; if ( null == currencyCode ) { String country = locale . getCountry ( ) ; if ( null != country && country . length ( ) == 2 ) { currency = Currency . getInstance ( locale ) ; } if ( null == currency ) currencyCode = "$" ; } if ( null == currency ) { if ( currencyCode . length ( ) != 3 ) { } else { currency = Currency . getInstance ( currencyCode ) ; } } if ( null != currency ) { numberFormat . setCurrency ( currency ) ; numberFormat . setMaximumFractionDigits ( currency . getDefaultFractionDigits ( ) ) ; } else { DecimalFormatSymbols dfs = new DecimalFormatSymbols ( ) ; dfs . setCurrencySymbol ( currencyCode ) ; ( ( DecimalFormat ) numberFormat ) . setDecimalFormatSymbols ( dfs ) ; } String s = numberFormat . format ( number ) ; if ( null != currency ) s = s . replace ( currency . getCurrencyCode ( ) , currency . getSymbol ( locale ) ) ; return s ; }
|
Format give data into currency using locale info from the engine specified
|
39,553
|
@ Transformer ( requireTemplate = true ) public static String i18n ( Object key , Object ... args ) { return i18n ( null , key , args ) ; }
|
Transformer method . Return i18n message of a given key and args .
|
39,554
|
public static String random ( int len ) { final char [ ] chars = { '0' , '1' , '2' , '3' , '4' , '5' , '6' , '7' , '8' , '9' , '$' , '#' , '^' , '&' , '_' , 'a' , 'b' , 'c' , 'd' , 'e' , 'f' , 'g' , 'h' , 'i' , 'j' , 'k' , 'l' , 'm' , 'n' , 'o' , 'p' , 'q' , 'r' , 's' , 't' , 'u' , 'v' , 'w' , 'x' , 'y' , 'z' , 'A' , 'B' , 'C' , 'D' , 'E' , 'F' , 'G' , 'H' , 'I' , 'J' , 'K' , 'L' , 'M' , 'N' , 'O' , 'P' , 'Q' , 'R' , 'S' , 'T' , 'U' , 'V' , 'W' , 'X' , 'Y' , 'Z' , '~' , '!' , '@' } ; final int max = chars . length ; Random r = new Random ( ) ; StringBuilder sb = new StringBuilder ( len ) ; while ( len -- > 0 ) { int i = r . nextInt ( max ) ; sb . append ( chars [ i ] ) ; } return sb . toString ( ) ; }
|
Generate random string .
|
39,555
|
protected RawData __render ( String template ) { if ( null == template ) return new RawData ( "" ) ; return S . raw ( __engine . sandbox ( ) . render ( template , __renderArgs ) ) ; }
|
Render another template from within this template . Using the renderArgs of this template .
|
39,556
|
private void __addLayoutSection ( String name , String section , boolean def ) { Map < String , String > m = def ? layoutSections0 : layoutSections ; if ( m . containsKey ( name ) ) return ; m . put ( name , section ) ; }
|
Add layout section . Should not be used in user application or template
|
39,557
|
protected void __startSection ( String name ) { if ( null == name ) throw new NullPointerException ( "section name cannot be null" ) ; if ( null != tmpOut ) throw new IllegalStateException ( "section cannot be nested" ) ; tmpCaller = __caller ; __caller = null ; tmpOut = __buffer ; __buffer = new StringBuilder ( ) ; section = name ; }
|
Start a layout section . Not to be used in user application or template
|
39,558
|
protected void __endSection ( boolean def ) { if ( null == tmpOut && null == tmpCaller ) throw new IllegalStateException ( "section has not been started" ) ; __addLayoutSection ( section , __buffer . toString ( ) , def ) ; __buffer = tmpOut ; __caller = tmpCaller ; tmpOut = null ; tmpCaller = null ; }
|
End a layout section with a boolean flag mark if it is a default content or not . Not to be used in user application or template
|
39,559
|
protected void __pLayoutSection ( String name ) { String s = layoutSections . get ( name ) ; if ( null == s ) s = layoutSections0 . get ( name ) ; else { String s0 = layoutSections0 . get ( name ) ; if ( s0 == null ) s0 = "" ; s = s . replace ( "\u0000\u0000inherited\u0000\u0000" , s0 ) ; } p ( s ) ; }
|
Print a layout section by name . Not to be used in user application or template
|
39,560
|
public TemplateClass __getTemplateClass ( boolean useCaller ) { TemplateClass tc = __templateClass ; if ( useCaller && null == tc ) { TemplateBase caller = __caller ( ) ; if ( null != caller ) return caller . __getTemplateClass ( true ) ; } return tc ; }
|
Get the template class of this template . Not to be used in user application or template
|
39,561
|
protected void __setOutput ( String path ) { try { w_ = new BufferedWriter ( new FileWriter ( path ) ) ; } catch ( Exception e ) { throw new FastRuntimeException ( e . getMessage ( ) ) ; } }
|
Set output file path
|
39,562
|
protected void __setOutput ( File file ) { try { w_ = new BufferedWriter ( new FileWriter ( file ) ) ; } catch ( Exception e ) { throw new FastRuntimeException ( e . getMessage ( ) ) ; } }
|
Set output file
|
39,563
|
protected final < T > T __getAs ( String name , Class < T > c ) { Object o = __getRenderArg ( name ) ; if ( null == o ) return null ; return ( T ) o ; }
|
Get render arg and do type cast to the class specified
|
39,564
|
protected final < T > T __getRenderPropertyAs ( String name , T def ) { Object o = __getRenderProperty ( name , def ) ; return null == o ? def : ( T ) o ; }
|
Get render property by name and do type cast to the specified default value . If the render property cannot be found by name then return the default value
|
39,565
|
protected final void __handleTemplateExecutionException ( Exception e ) { try { if ( ! RythmEvents . ON_RENDER_EXCEPTION . trigger ( __engine ( ) , F . T2 ( this , e ) ) ) { throw e ; } } catch ( RuntimeException e0 ) { throw e0 ; } catch ( Exception e1 ) { throw new RuntimeException ( e1 ) ; } }
|
Handle template execution exception . Not to be called in user application or template
|
39,566
|
protected byte [ ] getClassDefinition ( final String name0 ) { if ( typeNotFound ( name0 ) ) return null ; byte [ ] ba = null ; String name = name0 . replace ( "." , "/" ) + ".class" ; InputStream is = getResourceAsStream ( name ) ; if ( null != is ) { try { ByteArrayOutputStream os = new ByteArrayOutputStream ( ) ; byte [ ] buffer = new byte [ 8192 ] ; int count ; while ( ( count = is . read ( buffer , 0 , buffer . length ) ) > 0 ) { os . write ( buffer , 0 , count ) ; } ba = os . toByteArray ( ) ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } finally { try { is . close ( ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } } if ( null == ba ) { IByteCodeHelper helper = engine . conf ( ) . byteCodeHelper ( ) ; if ( null != helper ) { ba = helper . findByteCode ( name0 ) ; } } if ( null == ba ) { setTypeNotFound ( name0 ) ; } return ba ; }
|
Search for the byte code of the given class .
|
39,567
|
public void detectChanges ( ) { if ( engine . isProdMode ( ) ) return ; List < TemplateClass > modifieds = new ArrayList < TemplateClass > ( ) ; for ( TemplateClass tc : engine . classes ( ) . all ( ) ) { if ( tc . refresh ( ) ) modifieds . add ( tc ) ; } Set < TemplateClass > modifiedWithDependencies = new HashSet < TemplateClass > ( ) ; modifiedWithDependencies . addAll ( modifieds ) ; List < ClassDefinition > newDefinitions = new ArrayList < ClassDefinition > ( ) ; boolean dirtySig = false ; for ( TemplateClass tc : modifiedWithDependencies ) { if ( tc . compile ( ) == null ) { engine . classes ( ) . remove ( tc ) ; currentState = new TemplateClassloaderState ( ) ; } else { int sigChecksum = tc . sigChecksum ; tc . enhance ( ) ; if ( sigChecksum != tc . sigChecksum ) { dirtySig = true ; } newDefinitions . add ( new ClassDefinition ( tc . javaClass , tc . enhancedByteCode ) ) ; currentState = new TemplateClassloaderState ( ) ; } } if ( ! newDefinitions . isEmpty ( ) ) { throw new ClassReloadException ( "Need Reload" ) ; } if ( dirtySig ) { throw new ClassReloadException ( "Signature change !" ) ; } int hash = computePathHash ( ) ; if ( hash != this . pathHash ) { for ( TemplateClass tc : engine . classes ( ) . all ( ) ) { if ( ! tc . templateResource . isValid ( ) ) { engine . classes ( ) . remove ( tc ) ; currentState = new TemplateClassloaderState ( ) ; } } throw new ClassReloadException ( "Path has changed" ) ; } }
|
Detect Template changes
|
39,568
|
private Point intersection ( int x1 , int y1 , int x2 , int y2 , int x3 , int y3 , int x4 , int y4 ) { double dem = ( x1 - x2 ) * ( y3 - y4 ) - ( y1 - y2 ) * ( x3 - x4 ) ; double xi = ( ( x1 * y2 - y1 * x2 ) * ( x3 - x4 ) - ( x1 - x2 ) * ( x3 * y4 - y3 * x4 ) ) / dem ; double yi = ( ( x1 * y2 - y1 * x2 ) * ( y3 - y4 ) - ( y1 - y2 ) * ( x3 * y4 - y3 * x4 ) ) / dem ; if ( ( x1 - xi ) * ( xi - x2 ) >= 0 && ( x3 - xi ) * ( xi - x4 ) >= 0 && ( y1 - yi ) * ( yi - y2 ) >= 0 && ( y3 - yi ) * ( yi - y4 ) >= 0 ) { return new Point ( ( int ) xi , ( int ) yi ) ; } return null ; }
|
Intersect two lines
|
39,569
|
private Point intersection ( int x1 , int y1 , int x2 , int y2 , DesktopWindowRect rect ) { Point bottom = intersection ( x1 , y1 , x2 , y2 , rect . getX ( ) , rect . getY ( ) , rect . getX ( ) + rect . getHeight ( ) , rect . getY ( ) ) ; if ( bottom != null ) { return bottom ; } Point right = intersection ( x1 , y1 , x2 , y2 , rect . getX ( ) + rect . getWidth ( ) , rect . getY ( ) , rect . getX ( ) + rect . getWidth ( ) , rect . getY ( ) + rect . getHeight ( ) ) ; if ( right != null ) { return right ; } Point top = intersection ( x1 , y1 , x2 , y2 , rect . getX ( ) , rect . getY ( ) + rect . getHeight ( ) , rect . getX ( ) + rect . getWidth ( ) , rect . getY ( ) + rect . getHeight ( ) ) ; if ( top != null ) { return top ; } Point left = intersection ( x1 , y1 , x2 , y2 , rect . getX ( ) , rect . getY ( ) , rect . getX ( ) , rect . getY ( ) + rect . getHeight ( ) ) ; if ( left != null ) { return left ; } return null ; }
|
Intersect a line and a DesktopWindowRect
|
39,570
|
public void dragAndDropOn ( QuickWidget widget , DropPosition dropPos ) { Point currentLocation = getCenterLocation ( ) ; Point dropPoint = getDropPoint ( widget , dropPos ) ; List < ModifierPressed > alist = new ArrayList < ModifierPressed > ( ) ; alist . add ( ModifierPressed . NONE ) ; getSystemInputManager ( ) . mouseDown ( currentLocation , MouseButton . LEFT , alist ) ; getSystemInputManager ( ) . mouseMove ( dropPoint , MouseButton . LEFT , alist ) ; getSystemInputManager ( ) . mouseUp ( dropPoint , MouseButton . LEFT , alist ) ; }
|
Drags this widget onto the specified widget at the given drop position
|
39,571
|
private Point getDropPoint ( QuickWidget element , DropPosition pos ) { Point dropPoint = new Point ( element . getCenterLocation ( ) . x , element . getCenterLocation ( ) . y ) ; if ( pos == DropPosition . CENTER ) { return dropPoint ; } Point dragPoint = new Point ( this . getCenterLocation ( ) . x , this . getCenterLocation ( ) . y ) ; Point dragIntersectPoint = intersection ( dragPoint . x , dragPoint . y , dropPoint . x , dropPoint . y , this . getRect ( ) ) ; if ( dragIntersectPoint != null ) { Point dropIntersectPoint = intersection ( dragPoint . x , dragPoint . y , dropPoint . x , dropPoint . y , element . getRect ( ) ) ; if ( dropIntersectPoint != null ) { if ( pos == DropPosition . EDGE ) { return dropIntersectPoint ; } return new Point ( ( dragIntersectPoint . x + dropIntersectPoint . x ) / 2 , ( dragIntersectPoint . y + dropIntersectPoint . y ) / 2 ) ; } } return null ; }
|
The drop point is on the quick widget passed in
|
39,572
|
public TemplateClass getByClassName ( String name ) { TemplateClass tc = clsNameIdx . get ( name ) ; checkUpdate ( tc ) ; return tc ; }
|
Get a class by name
|
39,573
|
public static Integer getSystemDoubleClickTimeMs ( ) { Integer DEFAULT_INTERVAL_MS = 500 ; Toolkit t = Toolkit . getDefaultToolkit ( ) ; if ( t == null ) { return DEFAULT_INTERVAL_MS ; } Object o = t . getDesktopProperty ( "awt.multiClickInterval" ) ; if ( o == null ) { return DEFAULT_INTERVAL_MS ; } return ( Integer ) o ; }
|
Returns the platform double click timeout that is the time that separates two clicks treated as a double click from two clicks treated as two single clicks .
|
39,574
|
public static boolean textMatchesWithANY ( String haystack , String needle ) { haystack = haystack . trim ( ) ; needle = needle . trim ( ) ; needle = Matcher . quoteReplacement ( needle ) ; String chars_to_be_escaped = ".|*?+(){}[]^" ; for ( char c : chars_to_be_escaped . toCharArray ( ) ) { String regex = "\\" + c ; String replacement = "\\\\" + c ; needle = needle . replaceAll ( regex , replacement ) ; } String pattern = needle . replaceAll ( ANY_MATCHER , "(?:.+)" ) ; logger . finest ( "Looking for pattern '" + pattern + "' in '" + haystack + "'" ) ; return haystack . matches ( pattern ) ; }
|
Compares haystack and needle taking into the account that the needle may contain any number of ANY_MATCHER occurrences that will be matched to any substring in haystack i . e . Show _ANY_ more ... will match anything like Show 1 more ... Show 2 more ... and so on .
|
39,575
|
protected Object parseEvalReply ( EvalResult result ) { String status = result . getStatus ( ) ; if ( ! status . equals ( "completed" ) ) { if ( status . equals ( "unhandled-exception" ) ) { throw new ScopeException ( "Ecmascript exception" ) ; } else if ( status . equals ( "cancelled-by-scheduler" ) ) { return null ; } } String dataType = result . getType ( ) ; if ( dataType . equals ( "object" ) ) { return result . getObjectValue ( ) ; } else { return parseValue ( dataType , result . getValue ( ) ) ; } }
|
Parses a reply and returns the following types String presentation of number boolean or string .
|
39,576
|
public static boolean eval ( String s ) { if ( S . isEmpty ( s ) ) return false ; if ( "false" . equalsIgnoreCase ( s ) ) return false ; if ( "no" . equalsIgnoreCase ( s ) ) return false ; return true ; }
|
Return true if the specified string does not equals ignore case to false or no
|
39,577
|
public static Locale locale ( String language ) { if ( language . contains ( "_" ) ) { String [ ] sa = language . split ( "_" ) ; if ( sa . length > 2 ) { return new Locale ( sa [ 0 ] , sa [ 1 ] , sa [ 2 ] ) ; } else if ( sa . length > 1 ) { return new Locale ( sa [ 0 ] , sa [ 1 ] ) ; } else { return new Locale ( sa [ 0 ] ) ; } } return new Locale ( language ) ; }
|
Eval locale from language string
|
39,578
|
public static Locale locale ( String language , String region , String variant ) { return new Locale ( language , region , variant ) ; }
|
Eval locale from language region and variant
|
39,579
|
public boolean verifyText ( String stringId ) { String text = desktopUtils . getString ( stringId , true ) ; return getText ( ) . equals ( text ) ; }
|
Checks if widget text equals the text specified by the given string id
|
39,580
|
public boolean verifyContainsText ( String stringId ) { String text = desktopUtils . getString ( stringId , true ) ; return getText ( ) . indexOf ( text ) >= 0 ; }
|
Checks if widget text contains the text specified by the given string id
|
39,581
|
public synchronized byte [ ] compile ( ) { long start = System . currentTimeMillis ( ) ; try { if ( null != javaByteCode ) { return javaByteCode ; } if ( null == javaSource ) { throw new IllegalStateException ( "Cannot find java source when compiling " + getKey ( ) ) ; } engine ( ) . classes ( ) . compiler . compile ( new String [ ] { name } ) ; if ( logger . isTraceEnabled ( ) ) { logger . trace ( "%sms to compile template: %s" , System . currentTimeMillis ( ) - start , getKey ( ) ) ; } return javaByteCode ; } catch ( CompileException . CompilerException e ) { String cn = e . className ; TemplateClass tc = S . isEqual ( cn , name ) ? this : engine ( ) . classes ( ) . getByClassName ( cn ) ; if ( null == tc ) { tc = this ; } CompileException ce = new CompileException ( engine ( ) , tc , e . javaLineNumber , e . message ) ; javaSource = null ; logger . warn ( "compile failed for %s at line %d" , tc . tagName , e . javaLineNumber ) ; for ( TemplateClass itc : this . includedTemplateClasses ) { logger . info ( "\tincluded: %s" , itc . tagName ) ; } throw ce ; } catch ( NullPointerException e ) { String clazzName = name ; TemplateClass tc = engine ( ) . classes ( ) . getByClassName ( clazzName ) ; if ( this != tc ) { logger . error ( "tc is not this" ) ; } if ( ! this . equals ( tc ) ) { logger . error ( "tc not match this" ) ; } logger . error ( "NPE encountered when compiling template class:" + name ) ; throw e ; } finally { if ( logger . isTraceEnabled ( ) ) { logger . trace ( "%sms to compile template class %s" , System . currentTimeMillis ( ) - start , getKey ( ) ) ; } } }
|
Compile the class from Java source
|
39,582
|
public void compiled ( byte [ ] code ) { javaByteCode = code ; compiled = true ; RythmEvents . COMPILED . trigger ( engine ( ) , code ) ; enhance ( ) ; }
|
Call back when a class is compiled .
|
39,583
|
private static String toCanonicalName ( String key , String root ) { if ( key . startsWith ( "/" ) || key . startsWith ( "\\" ) ) { key = key . substring ( 1 ) ; } if ( key . startsWith ( root ) ) { key = key . replace ( root , "" ) ; } if ( key . startsWith ( "/" ) || key . startsWith ( "\\" ) ) { key = key . substring ( 1 ) ; } key = key . replace ( '/' , '.' ) . replace ( '\\' , '.' ) ; return key ; }
|
Convert the key to canonical template name
|
39,584
|
public void tripleClick ( Coordinates where ) { Point p = getPoint ( where , "triple click" ) ; exec . mouseAction ( p . x , p . y , 3 , OperaMouseKeys . LEFT ) ; }
|
Triple click is an Opera specific way of selecting a sentence .
|
39,585
|
public void setHttpsProxy ( String host ) { setProxyValue ( HTTPS_SERVER , host ) ; setProxyValue ( USE_HTTPS , host != null ) ; }
|
Specify which proxy to use for HTTPS connections .
|
39,586
|
private void initDesktopDriver ( ) { setServices ( ) ; setPrefsPaths ( ) ; if ( settings . getBinary ( ) == null && ! settings . noRestart ( ) ) { String operaPath = getOperaPath ( ) ; logger . fine ( "OperaBinaryLocation retrieved from Opera: " + operaPath ) ; if ( operaPath . length ( ) > 0 ) { settings . setBinary ( new File ( operaPath ) ) ; runner = new OperaLauncherRunner ( settings ) ; try { getScopeServices ( ) . quit ( runner ) ; } catch ( IOException e ) { throw new WebDriverException ( e ) ; } if ( ! profileUtils . deleteProfile ( ) ) { logger . severe ( "Could not delete profile" ) ; } startOpera ( ) ; } } }
|
Initializes services and starts Opera .
|
39,587
|
public List < QuickWidget > getQuickWidgetList ( String windowName ) { int id = getQuickWindowID ( windowName ) ; if ( id >= 0 || windowName . isEmpty ( ) ) { return getQuickWidgetList ( id ) ; } return Collections . emptyList ( ) ; }
|
Gets a list of all widgets in the window with the given window name .
|
39,588
|
public QuickWidget findWidgetByName ( QuickWidgetType type , int windowId , String widgetName ) { return desktopWindowManager . getQuickWidget ( type , windowId , QuickWidgetSearchType . NAME , widgetName ) ; }
|
Finds widget by name in the window specified by windowId .
|
39,589
|
public QuickWidget findWidgetByText ( QuickWidgetType type , int windowId , String text ) { return desktopWindowManager . getQuickWidget ( type , windowId , QuickWidgetSearchType . TEXT , text ) ; }
|
Finds widget with the text specified in the window with the given window id .
|
39,590
|
public QuickWidget findWidgetByStringId ( QuickWidgetType type , int windowId , String stringId ) { String text = desktopUtils . getString ( stringId , true ) ; return findWidgetByText ( type , windowId , text ) ; }
|
Finds widget with the text specified by string id in the window with the given id .
|
39,591
|
public QuickMenuItem getQuickMenuItemByStringId ( String stringId ) { String text = desktopUtils . getString ( stringId , true ) ; return desktopWindowManager . getQuickMenuItemByText ( text ) ; }
|
Get an item in a language independent way from its stringId .
|
39,592
|
public void keyPress ( String key , List < ModifierPressed > modifiers ) { systemInputManager . keyPress ( key , modifiers ) ; }
|
Press Key with modifiers held down .
|
39,593
|
public void keyUp ( String key , List < ModifierPressed > modifiers ) { systemInputManager . keyUp ( key , modifiers ) ; }
|
Release key .
|
39,594
|
public void keyDown ( String key , List < ModifierPressed > modifiers ) { systemInputManager . keyDown ( key , modifiers ) ; }
|
Press Key .
|
39,595
|
public void operaDesktopAction ( String using , int data , String dataString , String dataStringParam ) { getScopeServices ( ) . getExec ( ) . action ( using , data , dataString , dataStringParam ) ; }
|
Executes an opera action .
|
39,596
|
public int waitForWindowShown ( String windowName ) { if ( getScopeServices ( ) . getConnection ( ) == null ) { throw new CommunicationException ( "waiting for a window failed because Opera is not connected." ) ; } return getScopeServices ( ) . waitForDesktopWindowShown ( windowName , OperaIntervals . WINDOW_EVENT_TIMEOUT . getMs ( ) ) ; }
|
Waits until the window is shown and then returns the window id of the window
|
39,597
|
public int waitForWindowUpdated ( String windowName ) { if ( getScopeServices ( ) . getConnection ( ) == null ) { throw new CommunicationException ( "waiting for a window failed because Opera is not connected." ) ; } return getScopeServices ( ) . waitForDesktopWindowUpdated ( windowName , OperaIntervals . WINDOW_EVENT_TIMEOUT . getMs ( ) ) ; }
|
Waits until the window is updated and then returns the window id of the window .
|
39,598
|
public int waitForWindowActivated ( String windowName ) { if ( getScopeServices ( ) . getConnection ( ) == null ) { throw new CommunicationException ( "waiting for a window failed because Opera is not connected." ) ; } return getScopeServices ( ) . waitForDesktopWindowActivated ( windowName , OperaIntervals . WINDOW_EVENT_TIMEOUT . getMs ( ) ) ; }
|
Waits until the window is activated and then returns the window id of the window .
|
39,599
|
public int waitForWindowClose ( String windowName ) { if ( getScopeServices ( ) . getConnection ( ) == null ) { throw new CommunicationException ( "waiting for a window failed because Opera is not connected." ) ; } return getScopeServices ( ) . waitForDesktopWindowClosed ( windowName , OperaIntervals . WINDOW_EVENT_TIMEOUT . getMs ( ) ) ; }
|
Waits until the window is closed and then returns the window id of the window .
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.