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 ...
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 =...
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...
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 (...
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 We...
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 capa...
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 doe...
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>" ) ;...
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 ( o...
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 ) t...
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 ...
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 ( ) . equal...
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 { prefere...
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 ) {...
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 . ...
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...
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 inst...
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 ...
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...
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 ( " " ) ; ...
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 ) ;...
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 . D...
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 ( nul...
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' , '...
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 ( ) ; se...
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 ( ) ; by...
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 < T...
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 ) ...
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 , ...
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 ( ) . mo...
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 . getCenter...
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 )...
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 ; S...
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 ; ...
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 [ ...
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 ( ...
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 . substrin...
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 (...
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_TIME...
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_...
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_EV...
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_TIM...
Waits until the window is closed and then returns the window id of the window .