idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
2,800
public void addInt16 ( final int key , final short s ) { PebbleTuple t = PebbleTuple . create ( key , PebbleTuple . TupleType . INT , PebbleTuple . Width . SHORT , s ) ; addTuple ( t ) ; }
Associate the specified signed short with the provided key in the dictionary . If another key - value pair with the same key is already present in the dictionary it will be replaced .
2,801
public void addUint16 ( final int key , final short s ) { PebbleTuple t = PebbleTuple . create ( key , PebbleTuple . TupleType . UINT , PebbleTuple . Width . SHORT , s ) ; addTuple ( t ) ; }
Associate the specified unsigned short with the provided key in the dictionary . If another key - value pair with the same key is already present in the dictionary it will be replaced .
2,802
public void addInt32 ( final int key , final int i ) { PebbleTuple t = PebbleTuple . create ( key , PebbleTuple . TupleType . INT , PebbleTuple . Width . WORD , i ) ; addTuple ( t ) ; }
Associate the specified signed int with the provided key in the dictionary . If another key - value pair with the same key is already present in the dictionary it will be replaced .
2,803
public void addUint32 ( final int key , final int i ) { PebbleTuple t = PebbleTuple . create ( key , PebbleTuple . TupleType . UINT , PebbleTuple . Width . WORD , i ) ; addTuple ( t ) ; }
Associate the specified unsigned int with the provided key in the dictionary . If another key - value pair with the same key is already present in the dictionary it will be replaced .
2,804
public Long getInteger ( int key ) { PebbleTuple tuple = getTuple ( key , PebbleTuple . TupleType . INT ) ; if ( tuple == null ) { return null ; } return ( Long ) tuple . value ; }
Returns the signed integer to which the specified key is mapped or null if the key does not exist in this dictionary .
2,805
public Long getUnsignedIntegerAsLong ( int key ) { PebbleTuple tuple = getTuple ( key , PebbleTuple . TupleType . UINT ) ; if ( tuple == null ) { return null ; } return ( Long ) tuple . value ; }
Returns the unsigned integer as a long to which the specified key is mapped or null if the key does not exist in this dictionary . We are using the Long type here so that we can remove the guava dependency . This is done so that we dont have incompatibility issues with the UnsignedInteger class from the Holo applicatio...
2,806
public byte [ ] getBytes ( int key ) { PebbleTuple tuple = getTuple ( key , PebbleTuple . TupleType . BYTES ) ; if ( tuple == null ) { return null ; } return ( byte [ ] ) tuple . value ; }
Returns the byte array to which the specified key is mapped or null if the key does not exist in this dictionary .
2,807
public String getString ( int key ) { PebbleTuple tuple = getTuple ( key , PebbleTuple . TupleType . STRING ) ; if ( tuple == null ) { return null ; } return ( String ) tuple . value ; }
Returns the string to which the specified key is mapped or null if the key does not exist in this dictionary .
2,808
public String toJsonString ( ) { try { JSONArray array = new JSONArray ( ) ; for ( PebbleTuple t : tuples . values ( ) ) { array . put ( serializeTuple ( t ) ) ; } return array . toString ( ) ; } catch ( JSONException je ) { je . printStackTrace ( ) ; } return null ; }
Returns a JSON representation of this dictionary .
2,809
public static PebbleDictionary fromJson ( String jsonString ) throws JSONException { PebbleDictionary d = new PebbleDictionary ( ) ; JSONArray elements = new JSONArray ( jsonString ) ; for ( int idx = 0 ; idx < elements . length ( ) ; ++ idx ) { JSONObject o = elements . getJSONObject ( idx ) ; final int key = o . getI...
Deserializes a JSON representation of a PebbleDictionary .
2,810
protected void processInput ( String input ) { String command = input . trim ( ) ; if ( ! command . isEmpty ( ) ) { runCommand ( command ) ; } }
Process an input line entered through the console .
2,811
public void start ( ) { try { final Terminal terminal = TerminalConsoleAppender . getTerminal ( ) ; if ( terminal != null ) { readCommands ( terminal ) ; } else { readCommands ( System . in ) ; } } catch ( IOException e ) { LogManager . getLogger ( "TerminalConsole" ) . error ( "Failed to read console input" , e ) ; } ...
Start reading commands from the console .
2,812
public void setPaceInSec ( int paceInSec ) { this . speed = null ; this . paceInSec = Math . max ( 0 , Math . min ( paceInSec , 3599 ) ) ; }
Set the current pace in seconds per kilometer or seconds per mile .
2,813
public void setSpeed ( float speed ) { this . paceInSec = null ; this . speed = Math . max ( 0 , Math . min ( speed , 99.9 ) ) ; }
Set the current speed in kilometers per hour or miles per hour .
2,814
public void synchronize ( final Context context ) { SportsState previousState = this . previousState ; boolean firstMessage = false ; if ( previousState == null ) { previousState = this . previousState = new SportsState ( ) ; firstMessage = true ; } PebbleDictionary message = new PebbleDictionary ( ) ; if ( getTimeInSe...
Synchronizes the current state of the Sports App to the connected watch .
2,815
public BaseAttacher start ( ) { if ( mAdapterView == null ) { throw new IllegalStateException ( "Adapter View cannot be null" ) ; } if ( mMugenCallbacks == null ) { throw new IllegalStateException ( "MugenCallbacks cannot be null" ) ; } if ( mLoadMoreOffset <= 0 ) { throw new IllegalStateException ( "Trigger Offset mus...
Begin load more on the attached Adapter View
2,816
public static < T > MatcherDecoratorsBuilder < T > should ( final Matcher < ? super T > matcher ) { return MatcherDecoratorsBuilder . should ( matcher ) ; }
Factory method for decorating matcher with action condition or waiter .
2,817
private boolean nextWithoutLimit ( ) throws SQLException { if ( maxRows > 0 && rowsFetched >= maxRows ) { System . out . println ( "Reach max rows " + maxRows ) ; return false ; } if ( ( recordItr == null || ! recordItr . hasNext ( ) ) && ! emptyResultSet ) { TSFetchResultsReq req = new TSFetchResultsReq ( sql , fetchS...
the next record rule without considering the LIMIT&SLIMIT constraints
2,818
public QueryAtomGroupImpl pop ( ) { QueryAtomGroupImpl group = new QueryAtomGroupImpl ( ) ; boolean first = true ; for ( QueryAtom atom : atoms ) { if ( first ) { first = false ; } else { group . addAtom ( atom ) ; } } return group ; }
A convenience method to clone the atom group instance and pop the first atom . Only the instance itself will be cloned not the atoms .
2,819
public QueryAtomGroupImpl bind ( QueryBinding binding ) { QueryAtomGroupImpl group = new QueryAtomGroupImpl ( ) ; for ( QueryAtom atom : atoms ) { group . addAtom ( atom . bind ( binding ) ) ; } return group ; }
A convenience method to clone the atom group instance while inserting a new binding to all atoms of the group . The instance and the atoms will be cloned .
2,820
public void addResultVar ( QueryArgument arg ) { if ( arg . getType ( ) == QueryArgumentType . VAR ) { resultVars . add ( arg ) ; } }
Add a result variable to the query .
2,821
public boolean isCommandInstalled ( String command , String failureMessage ) { List < String > output = getProcessManager ( ) . executeAndJoinOutput ( command ) ; return output . size ( ) > 0 && ! output . get ( 0 ) . contains ( failureMessage ) ; }
True if the given command is installed in the shell false otherwise .
2,822
public boolean confirmInstalled ( String packageName , List < String > output ) { if ( output != null ) { return output . stream ( ) . anyMatch ( s -> s != null && s . contains ( getInstallSuccess ( ) ) ) ; } else { return true ; } }
Checks the output to confirm the package is installed .
2,823
protected boolean isPermissionDenied ( List < String > output ) { return output . stream ( ) . anyMatch ( s -> s != null && s . contains ( PERMISSION_DENIED_MESSAGE ) ) ; }
Returns true if permission was denied .
2,824
public static void premain ( String agentArgs , Instrumentation inst ) throws YamlConvertException , IllegalTestScriptException , IOException , ClassNotFoundException , InstantiationException , IllegalAccessException { String configFilePath ; String propValue = System . getProperty ( "sahagin.configPath" ) ; if ( ! Str...
agentArgs is configuration YAML file path
2,825
public static int getUInt16 ( byte [ ] src , int offset ) { final int v0 = src [ offset + 0 ] & 0xFF ; final int v1 = src [ offset + 1 ] & 0xFF ; return ( ( v1 << 8 ) | v0 ) ; }
Gets a 16 - bit unsigned integer from the given byte array at the given offset .
2,826
public static void setInt16 ( byte [ ] dst , int offset , int value ) { assert ( value & 0xffff ) == value : "value out of range" ; dst [ offset + 0 ] = ( byte ) ( value & 0xFF ) ; dst [ offset + 1 ] = ( byte ) ( ( value >>> 8 ) & 0xFF ) ; }
Sets a 16 - bit integer in the given byte array at the given offset .
2,827
public static void setInt32 ( byte [ ] dst , int offset , long value ) throws IllegalArgumentException { assert value <= Integer . MAX_VALUE : "value out of range" ; dst [ offset + 0 ] = ( byte ) ( value & 0xFF ) ; dst [ offset + 1 ] = ( byte ) ( ( value >>> 8 ) & 0xFF ) ; dst [ offset + 2 ] = ( byte ) ( ( value >>> 16...
Sets a 32 - bit integer in the given byte array at the given offset .
2,828
public FatFileSystem format ( ) throws IOException { final int sectorSize = device . getSectorSize ( ) ; final int totalSectors = ( int ) ( device . getSize ( ) / sectorSize ) ; final FsInfoSector fsi ; final BootSector bs ; if ( sectorsPerCluster == 0 ) throw new AssertionError ( ) ; if ( fatType == FatType . FAT32 ) ...
Initializes the boot sector and file system for the device . The file system created by this method will always be in read - write mode .
2,829
public boolean matchesStackLines ( List < StackLine > targetStackLines ) { if ( targetStackLines . size ( ) != getStackLines ( ) . size ( ) ) { return false ; } for ( int i = 0 ; i < targetStackLines . size ( ) ; i ++ ) { StackLine targetLine = targetStackLines . get ( i ) ; StackLine line = getStackLines ( ) . get ( i...
check if stack line for this instance matches targetStackLines
2,830
public Webcam getWebcam ( String name , Dimension dimension ) { if ( name == null ) { return getWebcam ( dimension ) ; } Webcam webcam = webcams . get ( name ) ; openWebcam ( webcam , dimension ) ; return webcam ; }
Returns the webcam by name null if not found .
2,831
public Webcam getWebcam ( Dimension dimension ) { if ( webcams . size ( ) == 0 ) { throw new IllegalStateException ( "No webcams found" ) ; } Webcam webcam = webcams . values ( ) . iterator ( ) . next ( ) ; openWebcam ( webcam , dimension ) ; return webcam ; }
Returns the first webcam .
2,832
public void beforeMethodHook ( String hookedClassQualifiedName , String hookedMethodSimpleName , String actualHookedMethodSimpleName ) { if ( currentRunResult != null ) { return ; } List < TestMethod > rootMethods = srcTree . getRootMethodTable ( ) . getByName ( hookedClassQualifiedName , hookedMethodSimpleName ) ; if ...
initialize runResult information if the method for the arguments is root method
2,833
public void methodErrorHook ( String hookedClassQualifiedName , String hookedMethodSimpleName , Throwable e ) { if ( currentRunResult == null ) { return ; } TestMethod rootMethod = currentRunResult . getRootMethod ( ) ; if ( ! rootMethod . getTestClassKey ( ) . equals ( hookedClassQualifiedName ) || ! rootMethod . getS...
This method must be called before afterMethodHook is called
2,834
public void afterMethodHook ( String hookedClassQualifiedName , String hookedMethodSimpleName ) { if ( currentRunResult == null ) { return ; } TestMethod rootMethod = currentRunResult . getRootMethod ( ) ; if ( ! rootMethod . getTestClassKey ( ) . equals ( hookedClassQualifiedName ) || ! rootMethod . getSimpleName ( ) ...
write runResult to YAML file if the method for the arguments is root method
2,835
private List < StackLine > getCodeLineHookedStackLines ( final String hookedMethodSimpleName , final String actualHookedMethodSimpleName , final int hookedLine , final int actualHookedLine ) { LineReplacer replacer = new LineReplacer ( ) { public void replace ( String classQualifiedName , String methodSimpleName , int ...
get the stackLines for the hook method code line .
2,836
private String getCodeLineKey ( final String hookedClassQualifiedName , final String hookedMethodSimpleName , String hookedArgClassesStr , final int hookedLine ) { return String . format ( "%s_%s_%s_%d_%d" , hookedClassQualifiedName , hookedMethodSimpleName , hookedArgClassesStr , hookedLine , Thread . currentThread ( ...
Calculate unique key for each code line hook
2,837
private File captureScreen ( TestMethod rootMethod ) { byte [ ] screenData = AdapterContainer . globalInstance ( ) . captureScreen ( ) ; if ( screenData == null ) { return null ; } File captureFile = new File ( String . format ( "%s/%s/%s/%03d.png" , captureRootDir , CommonUtils . encodeToSafeAsciiFileNameString ( root...
returns null if not executed
2,838
private File captureScreenForStackLines ( TestMethod rootMethod , List < List < StackLine > > stackLinesList , List < Integer > executionTimes ) { if ( stackLinesList == null ) { throw new NullPointerException ( ) ; } if ( stackLinesList . size ( ) == 0 ) { throw new IllegalArgumentException ( "empty list" ) ; } if ( s...
- returns null if fails to capture
2,839
private boolean canStepInCaptureTo ( List < StackLine > stackLines ) { for ( int i = 0 ; i < stackLines . size ( ) - 1 ; i ++ ) { StackLine stackLine = stackLines . get ( i ) ; CaptureStyle style = stackLine . getMethod ( ) . getCaptureStyle ( ) ; if ( style != CaptureStyle . STEP_IN && style != CaptureStyle . STEP_IN_...
if method is called from not stepInCapture line then returns false .
2,840
public String getAPIAccessMode ( ) { String apiAccessMode = ( String ) getScenarioGlobals ( ) . getAttribute ( API_ACCESS_MODE_KEY ) ; return apiAccessMode == null ? HTTP_API_ACCESS_MODE : apiAccessMode ; }
When the api is accessed though the browser selenium is used though straight HTTP calls we can choose to POST or GET the api
2,841
private void setRequestHeaders ( HttpURLConnection ucon , GenericUser authenticationUser , String [ ] requestHedaers ) { if ( authenticationUser != null ) { String authenticationString = authenticationUser . getUserName ( ) + ":" + authenticationUser . getPassword ( ) ; byte [ ] encodedAuthentication = Base64 . encodeB...
Add the request headers to the request
2,842
private static Map < Locale , String > getAllPageDocs ( IAnnotationBinding [ ] annotations ) { List < IAnnotationBinding > allPageAnnotations = new ArrayList < > ( 2 ) ; List < Class < ? > > singlePageAnnotationClasses = new ArrayList < > ( 2 ) ; singlePageAnnotationClasses . add ( PageDoc . class ) ; singlePageAnnotat...
return empty list if no Page is found
2,843
private static String getPageDoc ( IAnnotationBinding [ ] annotations , AcceptableLocales locales ) { Map < Locale , String > allPages = getAllPageDocs ( annotations ) ; if ( allPages . isEmpty ( ) ) { return null ; } for ( Locale locale : locales . getLocales ( ) ) { String value = allPages . get ( locale ) ; if ( val...
return null if no Page found
2,844
private void read ( ) throws IOException { final byte [ ] data = new byte [ sectorCount * sectorSize ] ; device . read ( offset , ByteBuffer . wrap ( data ) ) ; for ( int i = 0 ; i < entries . length ; i ++ ) entries [ i ] = fatType . readEntry ( data , i ) ; }
Read the contents of this FAT from the given device at the given offset .
2,845
public void writeCopy ( long offset ) throws IOException { final byte [ ] data = new byte [ sectorCount * sectorSize ] ; for ( int index = 0 ; index < entries . length ; index ++ ) { fatType . writeEntry ( data , index , entries [ index ] ) ; } device . write ( offset , ByteBuffer . wrap ( data ) ) ; }
Write the contents of this FAT to the given device at the given offset .
2,846
public long getNextCluster ( long cluster ) { testCluster ( cluster ) ; long entry = entries [ ( int ) cluster ] ; if ( isEofCluster ( entry ) ) { return - 1 ; } else { return entry ; } }
Gets the cluster after the given cluster
2,847
public long allocNew ( ) throws IOException { int i ; int entryIndex = - 1 ; for ( i = lastAllocatedCluster ; i < lastClusterIndex ; i ++ ) { if ( isFreeCluster ( i ) ) { entryIndex = i ; break ; } } if ( entryIndex < 0 ) { for ( i = FIRST_CLUSTER ; i < lastAllocatedCluster ; i ++ ) { if ( isFreeCluster ( i ) ) { entry...
Allocate a cluster for a new file
2,848
public long [ ] allocNew ( int nrClusters ) throws IOException { final long rc [ ] = new long [ nrClusters ] ; rc [ 0 ] = allocNew ( ) ; for ( int i = 1 ; i < nrClusters ; i ++ ) { rc [ i ] = allocAppend ( rc [ i - 1 ] ) ; } return rc ; }
Allocate a series of clusters for a new file .
2,849
public long allocAppend ( long cluster ) throws IOException { testCluster ( cluster ) ; while ( ! isEofCluster ( entries [ ( int ) cluster ] ) ) { cluster = entries [ ( int ) cluster ] ; } long newCluster = allocNew ( ) ; entries [ ( int ) cluster ] = newCluster ; return newCluster ; }
Allocate a cluster to append to a new file
2,850
public static void consumeTPVObject ( TPVObject tpv , Processor processor , GpsdEndpoint endpoint , ExceptionHandler exceptionHandler ) { LOG . debug ( "About to consume TPV object {},{} from {}" , tpv . getLatitude ( ) , tpv . getLongitude ( ) , endpoint ) ; Validate . notNull ( tpv ) ; Validate . notNull ( processor ...
Process the TPVObject all params required .
2,851
public String namespaceString ( String plainString ) throws RuntimeException { if ( plainString . startsWith ( NAME_SPACE_PREFIX ) ) { return ( plainString . replace ( NAME_SPACE_PREFIX , nameSpaceThreadLocale . get ( ) ) ) ; } if ( plainString . startsWith ( SCENARIO_NAME_SPACE_PREFIX ) ) { if ( cucumberManager . getC...
Extends the name space prefix with the actual name space All tests that need to ensure privacy i . e . no other test shall mess up their data shall use name spacing . Data that can be messed up by other tests and there fore needs to be unique shall contain the name space prefix that will be replaced at run time .
2,852
public WebElement findExpectedElement ( By by , boolean includeHiddenElements ) { log . debug ( "findExpectedElement() called with: " + by ) ; waitForLoaders ( ) ; try { WebElement foundElement = new WebDriverWait ( getWebDriver ( ) , getSeleniumManager ( ) . getTimeout ( ) ) . until ( ExpectedConditions . presenceOfEl...
Find an element that is expected to be on the page
2,853
public List < WebElement > findExpectedElements ( By by ) { waitForLoaders ( ) ; try { return new WebDriverWait ( getWebDriver ( ) , getSeleniumManager ( ) . getTimeout ( ) ) . until ( ExpectedConditions . presenceOfAllElementsLocatedBy ( by ) ) ; } catch ( WebDriverException wde ) { log . error ( "Expected elements no...
Find all elements expected on the page
2,854
public boolean getElementExists ( By locator ) { waitForLoaders ( ) ; List < WebElement > foundElements = getWebDriver ( ) . findElements ( locator ) ; return ( foundElements . size ( ) > 0 ) ; }
Tells whether the passed element exists
2,855
public void viewShouldNotShowElement ( String viewName , String elementName ) throws IllegalAccessException , InterruptedException { boolean pass = false ; long startOfLookup = System . currentTimeMillis ( ) ; int timeoutInMillies = getSeleniumManager ( ) . getTimeout ( ) * 1000 ; while ( ! pass ) { WebElement found = ...
The referenced view should not show the element identified by elementName
2,856
public static double convertDdmCoordinatesToDecimal ( String ddmCoordinate ) { checkArgument ( isNotBlank ( ddmCoordinate ) , "Coordinate to convert can't be null nor blank." ) ; int dotIndex = ddmCoordinate . indexOf ( '.' ) ; double degrees = parseDouble ( ddmCoordinate . substring ( 0 , dotIndex - 2 ) ) ; double min...
Converts Degrees Decimal Minutes GPS coordinate string into the decimal value .
2,857
public static Map < String , Object > getYamlObjectValue ( Map < String , Object > yamlObject , String key , boolean allowsEmpty ) throws YamlConvertException { Object obj = getObjectValue ( yamlObject , key , allowsEmpty ) ; @ SuppressWarnings ( "unchecked" ) Map < String , Object > result = ( Map < String , Object > ...
returns null for empty
2,858
public static Map < String , Object > getYamlObjectValue ( Map < String , Object > yamlObject , String key ) throws YamlConvertException { return getYamlObjectValue ( yamlObject , key , false ) ; }
for null or not found returns null
2,859
public static List < String > getStrListValue ( Map < String , Object > yamlObject , String key , boolean allowsEmpty ) throws YamlConvertException { Object obj = getObjectValue ( yamlObject , key , allowsEmpty ) ; @ SuppressWarnings ( "unchecked" ) List < String > result = ( List < String > ) obj ; if ( result == null...
for null or not found key returns empty list
2,860
public static Map < String , Object > load ( InputStream input ) { Yaml yaml = new Yaml ( ) ; Object rawYamlObj = yaml . load ( input ) ; @ SuppressWarnings ( "unchecked" ) Map < String , Object > yamlObj = ( Map < String , Object > ) rawYamlObj ; return yamlObj ; }
this method does not close the stream
2,861
public static Query create ( String query ) throws QueryParserException { QueryTokenizer tokenizer = new QueryTokenizerImpl ( ) ; QueryParser parser = new QueryParserImpl ( ) ; return parser . parse ( tokenizer . tokenize ( query ) ) ; }
A factory method to create a query from string .
2,862
public String getVolumeLabel ( ) { final StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < MAX_VOLUME_LABEL_LENGTH ; i ++ ) { final char c = ( char ) get8 ( VOLUME_LABEL_OFFSET + i ) ; if ( c != 0 ) { sb . append ( c ) ; } else { break ; } } return sb . toString ( ) ; }
Returns the volume label that is stored in this boot sector .
2,863
public void setVolumeLabel ( String label ) throws IllegalArgumentException { if ( label . length ( ) > MAX_VOLUME_LABEL_LENGTH ) throw new IllegalArgumentException ( "volume label too long" ) ; for ( int i = 0 ; i < MAX_VOLUME_LABEL_LENGTH ; i ++ ) { set8 ( VOLUME_LABEL_OFFSET + i , i < label . length ( ) ? label . ch...
Sets the volume label that is stored in this boot sector .
2,864
public void setRootDirEntryCount ( int v ) throws IllegalArgumentException { if ( v < 0 ) throw new IllegalArgumentException ( ) ; if ( v == getRootDirEntryCount ( ) ) return ; set16 ( ROOT_DIR_ENTRIES_OFFSET , v ) ; }
Sets the number of entries in the root directory
2,865
public void setEntries ( List < FatDirectoryEntry > newEntries ) { if ( newEntries . size ( ) > capacity ) throw new IllegalArgumentException ( "too many entries" ) ; this . entries . clear ( ) ; this . entries . addAll ( newEntries ) ; }
Replaces all entries in this directory .
2,866
public void flush ( ) throws IOException { final ByteBuffer data = ByteBuffer . allocate ( getCapacity ( ) * FatDirectoryEntry . SIZE + ( volumeLabel != null ? FatDirectoryEntry . SIZE : 0 ) ) ; for ( FatDirectoryEntry entry : this . entries ) { if ( entry != null ) { entry . write ( data ) ; } } if ( this . volumeLabe...
Flush the contents of this directory to the persistent storage
2,867
public void setLabel ( String label ) throws IllegalArgumentException , UnsupportedOperationException , IOException { checkRoot ( ) ; if ( label != null && label . length ( ) > MAX_LABEL_LENGTH ) throw new IllegalArgumentException ( "label too long" ) ; if ( this . volumeLabel != null ) { if ( label == null ) { changeS...
Sets the volume label that is stored in this directory . Setting the volume label is supported on the root directory only .
2,868
public String getFileSystemTypeLabel ( ) { final StringBuilder sb = new StringBuilder ( FILE_SYSTEM_TYPE_LENGTH ) ; for ( int i = 0 ; i < FILE_SYSTEM_TYPE_LENGTH ; i ++ ) { sb . append ( ( char ) get8 ( getFileSystemTypeLabelOffset ( ) + i ) ) ; } return sb . toString ( ) ; }
Returns the file system type label string .
2,869
public String getOemName ( ) { StringBuilder b = new StringBuilder ( 8 ) ; for ( int i = 0 ; i < 8 ; i ++ ) { int v = get8 ( 0x3 + i ) ; if ( v == 0 ) break ; b . append ( ( char ) v ) ; } return b . toString ( ) ; }
Gets the OEM name
2,870
public void setOemName ( String name ) { if ( name . length ( ) > 8 ) throw new IllegalArgumentException ( "only 8 characters are allowed" ) ; for ( int i = 0 ; i < 8 ; i ++ ) { char ch ; if ( i < name . length ( ) ) { ch = name . charAt ( i ) ; } else { ch = ( char ) 0 ; } set8 ( 0x3 + i , ch ) ; } }
Sets the OEM name must be at most 8 characters long .
2,871
public static int compare ( String left , String right ) { if ( left == null ) { if ( right == null ) { return 0 ; } else { return 1 ; } } else if ( right == null ) { return - 1 ; } return left . compareTo ( right ) ; }
0 if equals
2,872
public static String encodeToSafeAsciiFileNameString ( String str , Charset strCharset ) { if ( str == null ) { return str ; } if ( ! SAFE_ASCII_PATTERN . matcher ( str ) . matches ( ) ) { return calcSHA1Digest ( str , strCharset ) ; } if ( SHA1_DIGEST_PATTERN . matcher ( str ) . matches ( ) ) { return calcSHA1Digest (...
- character which will be encoded by URL encoding
2,873
public static Manifest readManifestFromExternalJar ( File jarFile ) { if ( ! jarFile . getName ( ) . endsWith ( ".jar" ) ) { throw new IllegalArgumentException ( "not jar file : " + jarFile ) ; } InputStream in = null ; String urlStr = "jar:file:" + jarFile . getAbsolutePath ( ) + "!/META-INF/MANIFEST.MF" ; try { URL i...
returns null if no manifest found
2,874
public void afterScenario ( Scenario scenario ) throws InterruptedException { log . debug ( "Scenarion finished" ) ; ScenarioGlobals scenarioGlobals = getCucumberManager ( ) . getCurrentScenarioGlobals ( ) ; TestEnvironment testNev = getSeleniumManager ( ) . getAssociatedTestEnvironment ( ) ; if ( testNev != null && sc...
Capture a selenium screenshot when a test fails and add it to the Cucumber generated report if the scenario has accessed selenium in its lifetime
2,875
private Dimension getDefaultResolution ( ) { if ( getResolution ( ) != null ) { WebcamResolution res = WebcamResolution . valueOf ( getResolution ( ) ) ; return res . getSize ( ) ; } else { return new Dimension ( getWidth ( ) , getHeight ( ) ) ; } }
Returns the default resolution by name if provided eg HD720 otherwise the width and height .
2,876
static Exchange createOutOnlyExchangeWithBodyAndHeaders ( WebcamEndpoint endpoint , BufferedImage image ) throws IOException { Exchange exchange = endpoint . createExchange ( ExchangePattern . OutOnly ) ; Message message = exchange . getIn ( ) ; try ( ByteArrayOutputStream output = new ByteArrayOutputStream ( ) ) { Ima...
Creates an OutOnly exchange with the BufferedImage .
2,877
public static void consumeBufferedImage ( BufferedImage image , Processor processor , WebcamEndpoint endpoint , ExceptionHandler exceptionHandler ) { Validate . notNull ( image ) ; Validate . notNull ( processor ) ; Validate . notNull ( endpoint ) ; try { Exchange exchange = createOutOnlyExchangeWithBodyAndHeaders ( en...
Consume the java . awt . BufferedImage from the webcam all params required .
2,878
public static void consumeWebcamMotionEvent ( WebcamMotionEvent motionEvent , Processor processor , WebcamEndpoint endpoint , ExceptionHandler exceptionHandler ) { Validate . notNull ( motionEvent ) ; Validate . notNull ( processor ) ; Validate . notNull ( endpoint ) ; try { Exchange exchange = createOutOnlyExchangeWit...
Consume the motion event from the webcam all params required . The event is stored in the header while the latest image is available as the body .
2,879
public static boolean isWebcamPresent ( ) { try { Webcam . getDefault ( WebcamConstants . DEFAULT_WEBCAM_LOOKUP_TIMEOUT ) ; return true ; } catch ( Throwable exception ) { LOG . debug ( "Problem occurred when detecting the webcam. Returning false." , exception ) ; return false ; } }
Returns true if there s a webcam available false otherwise .
2,880
public ShortName generateShortName ( String longFullName ) throws IllegalStateException { longFullName = stripLeadingPeriods ( longFullName ) . toUpperCase ( Locale . ROOT ) ; final String longName ; final String longExt ; final int dotIdx = longFullName . lastIndexOf ( '.' ) ; final boolean forceSuffix ; if ( dotIdx =...
Generates a new unique 8 . 3 file name that is not already contained in the set specified to the constructor .
2,881
public ScenarioGlobals stopNewScenario ( ) { if ( scenarioCreationHook != null ) { scenarioCreationHook . scenarionShutdown ( getCurrentScenarioGlobals ( ) ) ; } return scenarioGlobalsMap . remove ( Thread . currentThread ( ) ) ; }
Called at the end of an scenario?
2,882
public Iterator < QueryBinding > iterator ( ) { List < QueryBinding > iBindings = new ArrayList < QueryBinding > ( ) ; for ( QueryBindingImpl b : bindings ) { iBindings . add ( b ) ; } return iBindings . iterator ( ) ; }
An iterator over the result set .
2,883
public static QueryEngine create ( OWLOntologyManager manager , OWLReasoner reasoner , boolean strict ) { return new QueryEngineImpl ( manager , reasoner , strict ) ; }
Factory method to create a QueryEngine instance .
2,884
public static void initialize ( String configFilePath ) { if ( manager != null ) { return ; } logger . info ( "initialize" ) ; final Config config ; try { config = JavaConfig . generateFromYamlConfig ( new File ( configFilePath ) ) ; } catch ( YamlConvertException e ) { throw new RuntimeException ( e ) ; } final File s...
if called multiple times just ignored
2,885
public static String readDeviceMetric ( String deviceId , String metric ) { return format ( "%s.%s.%s" , CHANNEL_DEVICE_METRICS_READ , deviceId , metric ) ; }
Device metrics channel helpers
2,886
public void clickElementWithAttributeValue ( String attributeName , String attributeValue ) { By xpath = By . xpath ( "//*[@" + attributeName + "='" + attributeValue + "']" ) ; WebElement element = seleniumElementService . findExpectedElement ( xpath ) ; assertTrue ( "The element you are trying to click (" + xpath . to...
Find a Element that has a attribute with a certain value and click it
2,887
public boolean isInitialPageRequested ( ) { String currentUrl = getWebDriver ( ) . getCurrentUrl ( ) ; if ( StringUtils . isBlank ( currentUrl ) || ( ! currentUrl . toLowerCase ( ) . startsWith ( "http" ) && ! currentUrl . toLowerCase ( ) . startsWith ( "file" ) ) ) { return false ; } else { return true ; } }
Has a page been requested for this selenium session . This method is available to prevent scripts for waiting for a cetrain condition if no url has been requested yet . If true you know you can just proceed and not check for any state as none exists
2,888
public void mouseHoverOverElement ( By locator ) { SynchronisationService synchronisationService = new SynchronisationService ( ) ; synchronisationService . waitAndAssertForExpectedCondition ( ExpectedConditions . visibilityOfElementLocated ( locator ) ) ; WebElement element = getWebDriver ( ) . findElement ( locator )...
Hovers the mouse over the given element
2,889
public void resolveKeyReference ( ) throws IllegalDataStructureException { for ( TestClass testClass : rootClassTable . getTestClasses ( ) ) { resolveTestMethod ( testClass ) ; resolveTestField ( testClass ) ; resolveDelegateToTestClass ( testClass ) ; } for ( TestClass testClass : subClassTable . getTestClasses ( ) ) ...
assume all keys have been set
2,890
private void addLineScreenCaptureForErrorEachStackLine ( List < LineScreenCapture > lineScreenCaptures , RunFailure runFailure ) { if ( runFailure == null ) { return ; } List < StackLine > failureLines = runFailure . getStackLines ( ) ; int failureCaptureIndex = matchedLineScreenCaptureIndex ( lineScreenCaptures , fail...
The same capture is used for the all StackLines .
2,891
private List < ReportScreenCapture > generateReportScreenCaptures ( List < LineScreenCapture > lineScreenCaptures , File inputCaptureRootDir , File reportOutputDir , File methodReportParentDir ) { List < ReportScreenCapture > reportCaptures = new ArrayList < > ( lineScreenCaptures . size ( ) ) ; String noImageFilePath ...
generate ResportScreenCapture list from lineScreenCaptures and
2,892
private RunFailure getRunFailure ( RootMethodRunResult runResult ) { if ( runResult == null || runResult . getRunFailures ( ) . size ( ) == 0 ) { return null ; } return runResult . getRunFailures ( ) . get ( 0 ) ; }
returns null if no failure
2,893
private List < RunResults > generateRunResultList ( List < File > reportInputDataDirs , SrcTree srcTree ) throws IllegalDataStructureException { List < RunResults > resultsList = new ArrayList < > ( reportInputDataDirs . size ( ) ) ; for ( File reportInputDataDir : reportInputDataDirs ) { RunResults results = new RunRe...
returns RunResults list for reportInputDataDirs
2,894
public Vertx getVertx ( ) { if ( vertx != null ) { return vertx ; } if ( getComponent ( ) . getVertx ( ) != null ) { vertx = getComponent ( ) . getVertx ( ) ; } else { vertx = Vertx . vertx ( ) ; } return vertx ; }
Getters & setters
2,895
private void configureMessagesExceptionArgumentResolvers ( ) { this . handlerExceptionResolver = this . applicationContext . getBean ( "handlerExceptionResolver" , HandlerExceptionResolver . class ) ; for ( final HandlerExceptionResolver resolver : ( ( HandlerExceptionResolverComposite ) this . handlerExceptionResolver...
adds a FlashMessagesMethodArgumentResolver to handlerExceptionResolver s argument resolvers
2,896
public void setVolumeLabel ( String label ) { for ( int i = 0 ; i < 11 ; i ++ ) { final byte c = ( label == null ) ? 0 : ( label . length ( ) > i ) ? ( byte ) label . charAt ( i ) : 0x20 ; set8 ( 0x47 + i , c ) ; } }
Sets the 11 - byte volume label stored at offset 0x47 .
2,897
public void writeCopy ( BlockDevice device ) throws IOException { if ( getBootSectorCopySector ( ) > 0 ) { final long offset = ( long ) getBootSectorCopySector ( ) * SIZE ; buffer . rewind ( ) ; buffer . limit ( buffer . capacity ( ) ) ; device . write ( offset , buffer ) ; } }
Writes a copy of this boot sector to the specified device if a copy is requested .
2,898
public QueryBindingImpl cloneAndFilter ( Set < QueryArgument > args ) { QueryBindingImpl binding = new QueryBindingImpl ( ) ; for ( QueryArgument arg : getBoundArgs ( ) ) { if ( args . contains ( arg ) ) { binding . set ( arg , bindingMap . get ( arg ) ) ; } } return binding ; }
Clone this instance of QueryBinding and filter the binding map given by args . Only query arguments within the set of args will be available in the result . Only the QueryBinding class itself will be cloned but not the query arguments .
2,899
private boolean isLineLastStament ( TestMethod method , int codeLineIndex ) { CodeLine codeLine = method . getCodeBody ( ) . get ( codeLineIndex ) ; if ( codeLineIndex == method . getCodeBody ( ) . size ( ) - 1 ) { return true ; } CodeLine nextCodeLine = method . getCodeBody ( ) . get ( codeLineIndex + 1 ) ; assert cod...
This may return false since multiple statement can be found in a line .