idx int64 0 41.2k | question stringlengths 74 4.04k | target stringlengths 7 750 |
|---|---|---|
36,400 | public static RequestBody < Collection < ? extends Map . Entry < String , ? > > > form ( Collection < ? extends Map . Entry < String , ? > > value ) { return new FormRequestBody ( requireNonNull ( value ) ) ; } | Create request body send x - www - form - encoded data |
36,401 | public static RequestBody < Collection < ? extends Part > > multiPart ( Collection < ? extends Part > parts ) { return new MultiPartRequestBody ( requireNonNull ( parts ) ) ; } | Create multi - part post request body |
36,402 | public List < String > getHeaders ( String name ) { requireNonNull ( name ) ; List < String > values = lazyMap . get ( ) . get ( name . toLowerCase ( ) ) ; if ( values == null ) { return Lists . of ( ) ; } return Collections . unmodifiableList ( values ) ; } | Get headers by name . If not exists return empty list |
36,403 | public long getLongHeader ( String name , long defaultValue ) { String firstHeader = getHeader ( name ) ; if ( firstHeader == null ) { return defaultValue ; } try { return Long . parseLong ( firstHeader . trim ( ) ) ; } catch ( NumberFormatException e ) { return defaultValue ; } } | Get header value as long . If not exists return defaultValue |
36,404 | public Charset getCharset ( Charset defaultCharset ) { String contentType = getHeader ( HttpHeaders . NAME_CONTENT_TYPE ) ; if ( contentType == null ) { return defaultCharset ; } String [ ] items = contentType . split ( ";" ) ; for ( String item : items ) { item = item . trim ( ) ; if ( item . isEmpty ( ) ) { continue ... | Get charset set in content type header . |
36,405 | static boolean isText ( String contentType ) { return contentType . contains ( "text" ) || contentType . contains ( "json" ) || contentType . contains ( "xml" ) || contentType . contains ( "html" ) ; } | If content type looks like a text content . |
36,406 | public RawResponse charset ( Charset charset ) { return new RawResponse ( method , url , statusCode , statusLine , cookies , headers , body , charset , decompress ) ; } | Set response read charset . If not set would get charset from response headers . If not found would use UTF - 8 . |
36,407 | public RawResponse decompress ( boolean decompress ) { return new RawResponse ( method , url , statusCode , statusLine , cookies , headers , body , charset , decompress ) ; } | If decompress http response body . Default is true . |
36,408 | public String readToText ( ) { Charset charset = getCharset ( ) ; try ( InputStream in = body ( ) ; Reader reader = new InputStreamReader ( in , charset ) ) { return Readers . readAll ( reader ) ; } catch ( IOException e ) { throw new RequestsException ( e ) ; } finally { close ( ) ; } } | Read response body to string . return empty string if response has no body |
36,409 | public byte [ ] readToBytes ( ) { try { try ( InputStream in = body ( ) ) { return InputStreams . readAll ( in ) ; } } catch ( IOException e ) { throw new RequestsException ( e ) ; } finally { close ( ) ; } } | Read response body to byte array . return empty byte array if response has no body |
36,410 | public < T > Response < T > toResponse ( ResponseHandler < T > handler ) { ResponseInfo responseInfo = new ResponseInfo ( this . url , this . statusCode , this . headers , body ( ) ) ; try { T result = handler . handle ( responseInfo ) ; return new Response < > ( this . url , this . statusCode , this . cookies , this .... | Handle response body with handler return a new response with content as handler result . The response is closed whether this call succeed or failed with exception . |
36,411 | public < T > T readToJson ( Type type ) { try { return JsonLookup . getInstance ( ) . lookup ( ) . unmarshal ( body ( ) , getCharset ( ) , type ) ; } catch ( IOException e ) { throw new RequestsException ( e ) ; } finally { close ( ) ; } } | Deserialize response content as json |
36,412 | public Response < File > toFileResponse ( Path path ) { File file = path . toFile ( ) ; this . writeToFile ( file ) ; return new Response < > ( this . url , this . statusCode , this . cookies , this . headers , file ) ; } | Write response body to file and return response contains the file . |
36,413 | public void writeTo ( OutputStream out ) { try { InputStreams . transferTo ( body ( ) , out ) ; } catch ( IOException e ) { throw new RequestsException ( e ) ; } finally { close ( ) ; } } | Write response body to OutputStream . OutputStream will not be closed . |
36,414 | public void discardBody ( ) { try ( InputStream in = body ) { InputStreams . discardAll ( in ) ; } catch ( IOException e ) { throw new RequestsException ( e ) ; } finally { close ( ) ; } } | Consume and discard this response body . |
36,415 | private InputStream decompressBody ( ) { if ( ! decompress ) { return body ; } if ( method . equals ( Methods . HEAD ) || ( statusCode >= 100 && statusCode < 200 ) || statusCode == NOT_MODIFIED || statusCode == NO_CONTENT ) { return body ; } String contentEncoding = headers . getHeader ( NAME_CONTENT_ENCODING ) ; if ( ... | Wrap response input stream if it is compressed return input its self if not use compress |
36,416 | public static Result list ( int page , String sortBy , String order , String filter ) { return ok ( list . render ( Computer . page ( page , 10 , sortBy , order , filter ) , sortBy , order , filter ) ) ; } | Display the paginated list of computers . |
36,417 | public static Result edit ( Long id ) { Form < Computer > computerForm = form ( Computer . class ) . fill ( Computer . find . byId ( id ) ) ; return ok ( editForm . render ( id , computerForm ) ) ; } | Display the edit form of a existing Computer . |
36,418 | public static Result update ( Long id ) { Form < Computer > computerForm = form ( Computer . class ) . bindFromRequest ( ) ; if ( computerForm . hasErrors ( ) ) { return badRequest ( editForm . render ( id , computerForm ) ) ; } computerForm . get ( ) . update ( id ) ; flash ( "success" , "Computer " + computerForm . g... | Handle the edit form submission |
36,419 | public static Result create ( ) { Form < Computer > computerForm = form ( Computer . class ) ; return ok ( createForm . render ( computerForm ) ) ; } | Display the new computer form . |
36,420 | public static Result save ( ) { Form < Computer > computerForm = form ( Computer . class ) . bindFromRequest ( ) ; if ( computerForm . hasErrors ( ) ) { return badRequest ( createForm . render ( computerForm ) ) ; } computerForm . get ( ) . save ( ) ; flash ( "success" , "Computer " + computerForm . get ( ) . name + " ... | Handle the new computer form submission |
36,421 | public static Result delete ( Long id ) { Computer . find . ref ( id ) . delete ( ) ; flash ( "success" , "Computer has been deleted" ) ; return GO_HOME ; } | Handle computer deletion |
36,422 | public static Page < Computer > page ( int page , int pageSize , String sortBy , String order , String filter ) { return find . where ( ) . ilike ( "name" , "%" + filter + "%" ) . orderBy ( sortBy + " " + order ) . fetch ( "company" ) . findPagingList ( pageSize ) . getPage ( page ) ; } | Return a page of computer |
36,423 | public void parse ( ) throws ParserException { try { jsonParser . nextToken ( ) ; contentHandler . startDocument ( ) ; if ( shouldAddArtificialRoot ( ) ) { startElement ( artificialRootName ) ; parseElement ( artificialRootName , false ) ; endElement ( artificialRootName ) ; } else if ( START_OBJECT . equals ( jsonPars... | Method parses JSON and emits SAX events . |
36,424 | private int parseObject ( ) throws Exception { int elementsWritten = 0 ; while ( jsonParser . nextToken ( ) != null && jsonParser . getCurrentToken ( ) != END_OBJECT ) { if ( FIELD_NAME . equals ( jsonParser . getCurrentToken ( ) ) ) { String elementName = convertName ( jsonParser . getCurrentName ( ) ) ; jsonParser . ... | Parses generic object . |
36,425 | private void parseElement ( final String elementName , final boolean inArray ) throws Exception { JsonToken currentToken = jsonParser . getCurrentToken ( ) ; if ( inArray ) { startElement ( elementName ) ; } if ( START_OBJECT . equals ( currentToken ) ) { parseObject ( ) ; } else if ( START_ARRAY . equals ( currentToke... | Pares JSON element . |
36,426 | public static Node convertToDom ( final String json , final String namespace , final boolean addTypeAttributes , final String artificialRootName ) throws TransformerConfigurationException , TransformerException { Transformer transformer = TransformerFactory . newInstance ( ) . newTransformer ( ) ; InputSource source = ... | Helper method to convert JSON string to XML DOM |
36,427 | private static void convertElement ( JsonGenerator generator , Element element , boolean isArrayItem , ElementNameConverter converter ) throws IOException { TYPE type = toTYPE ( element . getAttribute ( "type" ) ) ; String name = element . getTagName ( ) ; if ( ! isArrayItem ) { generator . writeFieldName ( converter .... | Convert a DOM element to Json with special handling for arrays since arrays don t exist in XML . |
36,428 | private static void convertChildren ( JsonGenerator generator , Element element , boolean isArray , ElementNameConverter converter ) throws IOException { NodeList list = element . getChildNodes ( ) ; int len = list . getLength ( ) ; for ( int i = 0 ; i < len ; i ++ ) { Node node = list . item ( i ) ; if ( node . getNod... | Method to recurse within children elements and convert them to JSON too . |
36,429 | protected void postExecute ( List < String > filesProcessed , int nonComplyingFiles ) throws MojoFailureException { if ( nonComplyingFiles > 0 ) { String message = "Found " + nonComplyingFiles + " non-complying files, failing build" ; getLog ( ) . error ( message ) ; getLog ( ) . error ( "To fix formatting errors, run ... | Post Execute action . It is called at the end of the execute method . Subclasses can add extra checks . |
36,430 | public int lengthOf ( String value ) { int length = 0 ; if ( value != null ) { length = value . length ( ) ; } return length ; } | Determines length of string . |
36,431 | public boolean textContains ( String value , String expectedSubstring ) { boolean result = false ; if ( value != null ) { result = value . contains ( expectedSubstring ) ; } return result ; } | Checks whether values contains a specific sub string . |
36,432 | public String convertToUpperCase ( String value ) { String result = null ; if ( value != null ) { result = value . toUpperCase ( ) ; } return result ; } | Converts the value to upper case . |
36,433 | public String convertToLowerCase ( String value ) { String result = null ; if ( value != null ) { result = value . toLowerCase ( ) ; } return result ; } | Converts the value to lower case . |
36,434 | public String replaceAllInWith ( String regEx , String value , String replace ) { String result = null ; if ( value != null ) { if ( replace == null ) { replace = "" ; } result = getMatcher ( regEx , value ) . replaceAll ( replace ) ; } return result ; } | Replaces all occurrences of the regular expression in the value with the replacement value . |
36,435 | public Integer extractIntFromUsingGroup ( String value , String regEx , int groupIndex ) { Integer result = null ; if ( value != null ) { Matcher matcher = getMatcher ( regEx , value ) ; if ( matcher . matches ( ) ) { String intStr = matcher . group ( groupIndex ) ; result = convertToInt ( intStr ) ; } } return result ... | Extracts a whole number for a string using a regular expression . |
36,436 | public String getRawXPath ( String xPathExpr , Object ... params ) { return getRawXPath ( getResponse ( ) , xPathExpr , params ) ; } | Gets XPath value without checking whether response is valid . |
36,437 | public XPathCheckResult checkXPaths ( Map < String , Object > values , Map < String , String > expressionsToCheck ) { XPathCheckResult result ; String content = getResponse ( ) ; if ( content == null ) { result = new XPathCheckResult ( ) ; result . setMismatchDetail ( "NOK: no response available." ) ; } else { validRes... | Checks whether input values are present at correct locations in the response . |
36,438 | private String fillPattern ( String pattern , String [ ] parameters ) { boolean containsSingleQuote = false ; boolean containsDoubleQuote = false ; Object [ ] escapedParams = new Object [ parameters . length ] ; for ( int i = 0 ; i < parameters . length ; i ++ ) { String param = parameters [ i ] ; containsSingleQuote =... | Fills in placeholders in pattern using the supplied parameters . |
36,439 | public void registerPrefixForNamespace ( String prefix , String namespace ) { getEnvironment ( ) . registerNamespace ( prefix , getUrl ( namespace ) ) ; } | Register a prefix to use in XPath expressions . |
36,440 | public boolean validateAgainstXsdFile ( String xsdFileName ) { String xsdContent = new FileFixture ( ) . textIn ( xsdFileName ) ; return new XMLValidator ( ) . validateAgainst ( content , xsdContent ) ; } | Validate the loaded xml against a schema in file xsdFileName |
36,441 | public boolean validateAgainstXsd ( String xsdSchema ) { String xsdContent = cleanupValue ( xsdSchema ) ; return new XMLValidator ( ) . validateAgainst ( content , xsdContent ) ; } | Validate the loaded xml against a schema provided from the wiki |
36,442 | public XMLGregorianCalendar addDays ( final XMLGregorianCalendar cal , final int amount ) { XMLGregorianCalendar to = buildXMLGregorianCalendarDate ( cal ) ; to . add ( addDays ( amount ) ) ; return to ; } | Add Days to a Gregorian Calendar . |
36,443 | public XMLGregorianCalendar addMonths ( final XMLGregorianCalendar cal , final int amount ) { XMLGregorianCalendar to = buildXMLGregorianCalendarDate ( cal ) ; to . add ( addMonths ( amount ) ) ; return to ; } | Add Months to a Gregorian Calendar . |
36,444 | public XMLGregorianCalendar addYears ( final XMLGregorianCalendar cal , final int amount ) { XMLGregorianCalendar to = buildXMLGregorianCalendarDate ( cal ) ; to . add ( addYears ( amount ) ) ; return to ; } | Add Years to a Gregorian Calendar . |
36,445 | public int getDurationInYears ( XMLGregorianCalendar startDate , XMLGregorianCalendar endDate ) { int startYear = startDate . getYear ( ) ; final int dec = 12 ; if ( startDate . getMonth ( ) == dec ) { startYear ++ ; } int endYear = endDate . getYear ( ) ; return endYear - startYear ; } | Determines number of years between two dates so that premium duration can be established . |
36,446 | Duration addDays ( final int amount ) { Duration duration ; if ( amount < 0 ) { duration = getDatatypeFactory ( ) . newDuration ( false , 0 , 0 , Math . abs ( amount ) , 0 , 0 , 0 ) ; } else { duration = getDatatypeFactory ( ) . newDuration ( true , 0 , 0 , amount , 0 , 0 , 0 ) ; } return duration ; } | Create a Duration of x days . |
36,447 | public String format ( String json ) { String result = null ; if ( json != null ) { if ( json . startsWith ( "{" ) ) { result = new JSONObject ( json ) . toString ( 4 ) ; } else if ( json . startsWith ( "[" ) ) { JSONObject jsonObject = new JSONObject ( "{'a': " + json + "}" ) ; org . json . JSONArray array = ( org . j... | Creates formatted version of the supplied JSON . |
36,448 | public Map < String , Object > jsonStringToMap ( String jsonString ) { if ( StringUtils . isEmpty ( jsonString ) ) { return null ; } JSONObject jsonObject ; try { jsonObject = new JSONObject ( jsonString ) ; return jsonObjectToMap ( jsonObject ) ; } catch ( JSONException e ) { throw new RuntimeException ( "Unable to co... | Interprets supplied String as Json and converts it into a Map . |
36,449 | public String sort ( String json , String arrayExpr , String nestedPathExpr ) { JsonPathHelper pathHelper = getPathHelper ( ) ; Object topLevel = pathHelper . getJsonPath ( json , arrayExpr ) ; if ( topLevel instanceof JSONArray ) { JSONArray a = ( JSONArray ) topLevel ; JSONArray aSorted = sort ( pathHelper , a , nest... | Sorts an array in a json object . |
36,450 | public void setWebDriver ( WebDriver aWebDriver , int defaultTimeout ) { if ( webDriver != null && ! webDriver . equals ( aWebDriver ) ) { webDriver . quit ( ) ; } webDriver = aWebDriver ; if ( webDriver == null ) { webDriverWait = null ; } else { webDriverWait = new WebDriverWait ( webDriver , defaultTimeout ) ; } } | Sets up webDriver to be used . |
36,451 | public T getElementToCheckVisibility ( String place ) { return findByTechnicalSelectorOr ( place , ( ) -> { T result = findElement ( TextBy . partial ( place ) ) ; if ( ! IsDisplayedFilter . mayPass ( result ) ) { result = findElement ( ToClickBy . heuristic ( place ) ) ; } return result ; } ) ; } | Finds element to determine whether it is on screen by searching in multiple locations . |
36,452 | public Integer getNumberFor ( WebElement element ) { Integer number = null ; if ( "li" . equalsIgnoreCase ( element . getTagName ( ) ) && element . isDisplayed ( ) ) { int num ; String ownVal = element . getAttribute ( "value" ) ; if ( ownVal != null && ! "0" . equals ( ownVal ) ) { num = toInt ( ownVal , 0 ) ; } else ... | Determines number displayed for item in ordered list . |
36,453 | public ArrayList < String > getAvailableOptions ( WebElement element ) { ArrayList < String > result = null ; if ( isInteractable ( element ) && "select" . equalsIgnoreCase ( element . getTagName ( ) ) ) { result = new ArrayList < String > ( ) ; List < WebElement > options = element . findElements ( By . tagName ( "opt... | Returns the texts of all available options for the supplied select element . |
36,454 | public String getText ( WebElement element ) { String text = element . getText ( ) ; if ( text != null ) { text = text . replace ( NON_BREAKING_SPACE , ' ' ) ; text = text . trim ( ) ; } return text ; } | Gets element s text content . |
36,455 | public boolean setHiddenInputValue ( String idOrName , String value ) { T element = findElement ( By . id ( idOrName ) ) ; if ( element == null ) { element = findElement ( By . name ( idOrName ) ) ; if ( element != null ) { executeJavascript ( "document.getElementsByName('%s')[0].value='%s'" , idOrName , value ) ; } } ... | Sets value of hidden input field . |
36,456 | public Object executeJavascript ( String statementPattern , Object ... parameters ) { Object result ; String script = String . format ( statementPattern , parameters ) ; if ( statementPattern . contains ( "arguments" ) ) { result = executeScript ( script , parameters ) ; } else { result = executeScript ( script ) ; } r... | Executes Javascript in browser . If statementPattern contains the magic variable arguments the parameters will also be passed to the statement . In the latter case the parameters must be a number a boolean a String WebElement or a List of any combination of the above . |
36,457 | public void setImplicitlyWait ( int implicitWait ) { try { driver ( ) . manage ( ) . timeouts ( ) . implicitlyWait ( implicitWait , TimeUnit . MILLISECONDS ) ; } catch ( Exception e ) { System . err . println ( "Unable to set implicit timeout (known issue for Safari): " + e . getMessage ( ) ) ; } } | Sets how long to wait before deciding an element does not exists . |
36,458 | public void setScriptWait ( int scriptTimeout ) { try { driver ( ) . manage ( ) . timeouts ( ) . setScriptTimeout ( scriptTimeout , TimeUnit . MILLISECONDS ) ; } catch ( Exception e ) { System . err . println ( "Unable to set script timeout (known issue for Safari): " + e . getMessage ( ) ) ; } } | Sets how long to wait when executing asynchronous script calls . |
36,459 | public void setPageLoadWait ( int pageLoadWait ) { try { driver ( ) . manage ( ) . timeouts ( ) . pageLoadTimeout ( pageLoadWait , TimeUnit . MILLISECONDS ) ; } catch ( Exception e ) { System . err . println ( "Unable to set page load timeout (known issue for Safari): " + e . getMessage ( ) ) ; } } | Sets how long to wait on opening a page . |
36,460 | public void clickWithKeyDown ( WebElement element , CharSequence key ) { getActions ( ) . keyDown ( key ) . click ( element ) . keyUp ( key ) . perform ( ) ; } | Simulates clicking with the supplied key pressed on the supplied element . Key will be released after click . |
36,461 | public void dragAndDrop ( WebElement source , WebElement target ) { getActions ( ) . dragAndDrop ( source , target ) . perform ( ) ; } | Simulates a drag from source element and drop to target element |
36,462 | public T findByXPath ( String pattern , String ... parameters ) { By by = byXpath ( pattern , parameters ) ; return findElement ( by ) ; } | Finds element using xPath supporting placeholder replacement . |
36,463 | public T findElement ( By by , int index ) { T element = null ; List < T > elements = findElements ( by ) ; if ( elements . size ( ) > index ) { element = elements . get ( index ) ; } return element ; } | Finds the nth element matching the By supplied . |
36,464 | public < T > T waitUntil ( int maxSecondsToWait , ExpectedCondition < T > condition ) { ExpectedCondition < T > cHandlingStale = getConditionIgnoringStaleElement ( condition ) ; FluentWait < WebDriver > wait = waitDriver ( ) . withTimeout ( Duration . ofSeconds ( maxSecondsToWait ) ) ; return wait . until ( cHandlingSt... | Executes condition until it returns a value other than null or false . It does not forward StaleElementReferenceExceptions but keeps waiting . |
36,465 | public boolean isStaleElementException ( WebDriverException e ) { boolean result = false ; if ( e instanceof StaleElementReferenceException ) { result = true ; } else { String msg = e . getMessage ( ) ; if ( msg != null ) { result = msg . contains ( "Element does not exist in cache" ) || msg . contains ( "unknown error... | Check whether exception indicates a stale element not all drivers throw the exception one would expect ... |
36,466 | public byte [ ] findScreenshot ( Throwable t ) { byte [ ] result = null ; if ( t != null ) { if ( t instanceof ScreenshotException ) { String encodedScreenshot = ( ( ScreenshotException ) t ) . getBase64EncodedScreenshot ( ) ; result = Base64 . getDecoder ( ) . decode ( encodedScreenshot ) ; } else { result = findScree... | Finds screenshot embedded in throwable if any . |
36,467 | public void switchToFrame ( T iframe ) { getTargetLocator ( ) . frame ( iframe ) ; setCurrentContext ( null ) ; currentIFramePath . add ( iframe ) ; } | Activates specified child frame of current iframe . |
36,468 | public void copySeleniumCookies ( Set < Cookie > browserCookies , CookieStore cookieStore ) { for ( Cookie browserCookie : browserCookies ) { ClientCookie cookie = convertCookie ( browserCookie ) ; cookieStore . addCookie ( cookie ) ; } } | Converts Selenium cookies to Apache http client ones . |
36,469 | protected ClientCookie convertCookie ( Cookie browserCookie ) { BasicClientCookie cookie = new BasicClientCookie ( browserCookie . getName ( ) , browserCookie . getValue ( ) ) ; String domain = browserCookie . getDomain ( ) ; if ( domain != null && domain . startsWith ( "." ) ) { domain = domain . substring ( 1 ) ; } c... | Converts Selenium cookie to Apache http client . |
36,470 | public T waitForRequest ( long maxWait ) { long start = System . currentTimeMillis ( ) ; try { while ( requestsReceived . get ( ) < 1 && ( System . currentTimeMillis ( ) - start ) < maxWait ) { try { Thread . sleep ( 50 ) ; } catch ( InterruptedException ex ) { throw new RuntimeException ( ex ) ; } } } finally { stopSe... | Waits until at least one request is received and then stops the server . |
36,471 | public static com . sun . net . httpserver . HttpServer bind ( InetAddress address , int startPort , int maxPort ) { com . sun . net . httpserver . HttpServer aServer = createServer ( ) ; int port = - 1 ; for ( int possiblePort = startPort ; port == - 1 && possiblePort <= maxPort ; possiblePort ++ ) { try { InetSocketA... | Finds free port number and binds a server to it . |
36,472 | public static JavascriptExecutor getJavascriptExecutor ( SearchContext searchContext ) { JavascriptExecutor executor = null ; if ( searchContext instanceof JavascriptExecutor ) { executor = ( JavascriptExecutor ) searchContext ; } else { if ( searchContext instanceof WrapsDriver ) { WrapsDriver wraps = ( WrapsDriver ) ... | Obtains executor based on Selenium context . |
36,473 | public static Object executeScript ( JavascriptExecutor jse , String script , Object ... parameters ) { Object result ; try { result = jse . executeScript ( script , parameters ) ; } catch ( WebDriverException e ) { String msg = e . getMessage ( ) ; if ( msg != null && msg . contains ( "Detected a page unload event; sc... | Executes Javascript in browser . If script contains the magic variable arguments the parameters will also be passed to the statement . In the latter case the parameters must be a number a boolean a String WebElement or a List of any combination of the above . |
36,474 | public CheckResponse getRawCheckResponse ( ) { if ( ! checkCalled ) { setupMaxTries ( ) ; setupWaitTime ( ) ; addResultsToValuesForCheck ( getCurrentRowValues ( ) ) ; long startTime = currentTimeMillis ( ) ; try { executeCheckWithRetry ( ) ; } finally { checkTime = currentTimeMillis ( ) - startTime ; } } return checkRe... | Trigger to actually call check . |
36,475 | public void setJsonPathTo ( String path , Object value ) { Object cleanValue = cleanupValue ( value ) ; String jsonPath = getPathExpr ( path ) ; String newContent = getPathHelper ( ) . updateJsonPathWithValue ( content , jsonPath , cleanValue ) ; content = newContent ; } | Update a value in a the content by supplied jsonPath |
36,476 | public String savePageSource ( String fileName ) { List < WebElement > framesWithFakeSources = new ArrayList < > ( 2 ) ; Map < String , String > sourceReplacements = new HashMap < > ( ) ; List < WebElement > frames = getFrames ( ) ; for ( WebElement frame : frames ) { String newLocation = saveFrameSource ( frame ) ; if... | Saves current page s source as new file . |
36,477 | public String randomLowerMaxLength ( int minLength , int maxLength ) { int range = maxLength - minLength ; int randomLength = 0 ; if ( range > 0 ) { randomLength = random ( range ) ; } return randomLower ( minLength + randomLength ) ; } | Creates a random string consisting of lowercase letters . |
36,478 | public String randomString ( String permitted , int length ) { StringBuilder result = new StringBuilder ( length ) ; int maxIndex = permitted . length ( ) ; for ( int i = 0 ; i < length ; i ++ ) { int index = random ( maxIndex ) ; char value = permitted . charAt ( index ) ; result . append ( value ) ; } return result .... | Creates a random string consisting only of supplied characters . |
36,479 | private Object getSymbolArrayValue ( Object arraySymbol , int index ) { Object result = null ; if ( index > - 1 && index < ( ( Object [ ] ) arraySymbol ) . length ) { result = ( ( Object [ ] ) arraySymbol ) [ index ] ; } return result ; } | Fetch the value from arraySymbol on specified index . |
36,480 | protected boolean configureSeleniumIfNeeded ( ) { setSeleniumDefaultTimeOut ( ) ; try { DriverFactory factory = null ; SeleniumDriverFactoryFactory factoryFactory = getSeleniumDriverFactoryFactory ( ) ; if ( factoryFactory != null ) { factory = factoryFactory . getDriverFactory ( ) ; if ( factory != null ) { SeleniumDr... | Determines whether system properties should override Selenium configuration in wiki . If so Selenium will be configured according to property values and locked so that wiki pages no longer control Selenium setup . |
36,481 | public void execute ( ProgramResponse response , int timeout ) { ProcessBuilder builder = createProcessBuilder ( response ) ; invokeProgram ( builder , response , timeout ) ; } | Calls a program and returns any output generated . |
36,482 | public String format ( String xml ) { try { boolean keepDeclaration = DECL_PATTERN . matcher ( xml ) . find ( ) ; if ( trimElements ) { xml = trimElements ( xml ) ; } Source xmlInput = new StreamSource ( new StringReader ( xml ) ) ; StreamResult xmlOutput = new StreamResult ( new StringWriter ( ) ) ; TransformerFactory... | Creates formatted version of the supplied XML . |
36,483 | public static String trim ( String xml ) { String content = removeDeclaration ( xml ) ; return trimElements ( content ) ; } | Removes both XML declaration and trims all elements . |
36,484 | public < T > Supplier < T > getConstructor ( Class < ? extends T > clazz ) { return getConstructorAs ( Supplier . class , "get" , clazz ) ; } | Gets no - arg constructor as Supplier . |
36,485 | public < T , A > Function < A , T > getConstructor ( Class < ? extends T > clazz , Class < A > arg ) { return getConstructorAs ( Function . class , "apply" , clazz , arg ) ; } | Gets single arg constructor as Function . |
36,486 | public < A1 , A2 , T > BiFunction < A1 , A2 , T > getConstructor ( Class < ? extends T > clazz , Class < A1 > arg1 , Class < A2 > arg2 ) { return getConstructorAs ( BiFunction . class , "apply" , clazz , new Class < ? > [ ] { arg1 , arg2 } ) ; } | Gets two arg constructor as BiFunction . |
36,487 | public static String loadFile ( String filename ) { ClassLoader classLoader = Thread . currentThread ( ) . getContextClassLoader ( ) ; InputStream is = classLoader . getResourceAsStream ( filename ) ; if ( is == null ) { throw new IllegalArgumentException ( "Unable to locate: " + filename ) ; } return streamToString ( ... | Reads content of UTF - 8 file on classpath to String . |
36,488 | public static File copyFile ( String source , String target ) throws IOException { FileChannel inputChannel = null ; FileChannel outputChannel = null ; try { inputChannel = new FileInputStream ( source ) . getChannel ( ) ; outputChannel = new FileOutputStream ( target ) . getChannel ( ) ; outputChannel . transferFrom (... | Copies source file to target . |
36,489 | public static File writeFile ( String filename , String content ) { PrintWriter pw = null ; try { pw = new PrintWriter ( filename , FILE_ENCODING ) ; pw . write ( content ) ; pw . flush ( ) ; } catch ( FileNotFoundException e ) { throw new IllegalArgumentException ( "Unable to write to: " + filename , e ) ; } catch ( U... | Writes content to file in UTF - 8 encoding . |
36,490 | public static File appendToFile ( String filename , String extraContent , boolean onNewLine ) { PrintWriter pw = null ; try { pw = new PrintWriter ( new BufferedWriter ( new OutputStreamWriter ( new FileOutputStream ( filename , true ) , FILE_ENCODING ) ) ) ; if ( onNewLine ) { pw . println ( ) ; } pw . print ( extraCo... | Appends the extra content to the file in UTF - 8 encoding . |
36,491 | public String createContainingBase64Value ( String basename , String key ) { String file ; Object value = value ( key ) ; if ( value == null ) { throw new SlimFixtureException ( false , "No value for key: " + key ) ; } else if ( value instanceof String ) { file = createFileFromBase64 ( basename , ( String ) value ) ; }... | Saves content of a key s value as file in the files section . |
36,492 | public void addTo ( Object value , List aList ) { Object cleanValue = cleanupValue ( value ) ; aList . add ( cleanValue ) ; } | Adds new element to end of list . |
36,493 | public void copyValuesFromTo ( Collection < Object > source , List < Object > target ) { target . addAll ( source ) ; } | Adds values to list . |
36,494 | private XmlHttpResponse getReportXml ( String reportXmlFilename ) { String url = LalCallColumnFixture . getLalUrl ( ) + "/xmlrr/archive/Report/" + reportXmlFilename ; return env . doHttpGetXml ( url ) ; } | Gets content of reportXmlFile |
36,495 | public void setValueFor ( Object value , String name ) { getMapHelper ( ) . setValueForIn ( value , name , getCurrentValues ( ) ) ; } | Stores value . |
36,496 | public boolean clearValue ( String name ) { String cleanName = cleanupValue ( name ) ; boolean result = getCurrentValues ( ) . containsKey ( cleanName ) ; getCurrentValues ( ) . remove ( cleanName ) ; return result ; } | Clears a values previously set . |
36,497 | public String getRequiredSymbol ( String key ) { String result = null ; Object symbol = getSymbol ( key ) ; if ( symbol == null ) { throw new FitFailureException ( "No Symbol defined with key: " + key ) ; } else { result = symbol . toString ( ) ; } return result ; } | Gets symbol value or throws exception if no symbol by that key exists . |
36,498 | public void doHttpPost ( String url , String templateName , Object model , HttpResponse result , Map < String , Object > headers , String contentType ) { String request = processTemplate ( templateName , model ) ; result . setRequest ( request ) ; doHttpPost ( url , result , headers , contentType ) ; } | Performs POST to supplied url of result of applying template with model . |
36,499 | public void doHttpPost ( String url , HttpResponse result , Map < String , Object > headers , String contentType ) { httpClient . post ( url , result , headers , contentType ) ; } | Performs POST to supplied url of result s request . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.