idx int64 0 165k | question stringlengths 73 4.15k | target stringlengths 5 918 | len_question int64 21 890 | len_target int64 3 255 |
|---|---|---|---|---|
36,300 | public ChunkedUploadResponse updateChunkedUpload ( String accountId , String chunkedUploadId ) throws ApiException { return updateChunkedUpload ( accountId , chunkedUploadId , null ) ; } | Integrity - Check and Commit a ChunkedUpload readying it for use elsewhere . | 46 | 18 |
36,301 | public byte [ ] getCommentsTranscript ( String accountId , String envelopeId ) throws ApiException { return getCommentsTranscript ( accountId , envelopeId , null ) ; } | Gets comment transcript for envelope and user | 38 | 8 |
36,302 | public void registerAccessTokenListener ( AccessTokenListener accessTokenListener ) { for ( Authentication auth : authentications . values ( ) ) { if ( auth instanceof OAuth ) { OAuth oauth = ( OAuth ) auth ; oauth . registerAccessTokenListener ( accessTokenListener ) ; return ; } } } | Configures a listener which is notified when a new access token is received . | 66 | 15 |
36,303 | private String getXWWWFormUrlencodedParams ( Map < String , Object > formParams ) { StringBuilder formParamBuilder = new StringBuilder ( ) ; for ( Entry < String , Object > param : formParams . entrySet ( ) ) { String valueStr = parameterToString ( param . getValue ( ) ) ; try { formParamBuilder . append ( URLEncoder .... | Encode the given form parameters as request body . | 221 | 10 |
36,304 | private < T > String serializeToCsv ( T obj ) { if ( obj == null ) { return "" ; } for ( Method method : obj . getClass ( ) . getMethods ( ) ) { if ( "java.util.List" . equals ( method . getReturnType ( ) . getName ( ) ) ) { try { @ SuppressWarnings ( "rawtypes" ) java . util . List itemList = ( java . util . List ) me... | Encode the given request object in CSV format . | 420 | 10 |
36,305 | public Recipients createRecipients ( String accountId , String templateId , TemplateRecipients templateRecipients ) throws ApiException { return createRecipients ( accountId , templateId , templateRecipients , null ) ; } | Adds tabs for a recipient . Adds one or more recipients to a template . | 52 | 15 |
36,306 | public EnvelopeTemplate get ( String accountId , String templateId ) throws ApiException { return get ( accountId , templateId , null ) ; } | Gets a list of templates for a specified account . Retrieves the definition of the specified template . | 33 | 21 |
36,307 | public byte [ ] getDocumentPageImage ( String accountId , String templateId , String documentId , String pageNumber ) throws ApiException { return getDocumentPageImage ( accountId , templateId , documentId , pageNumber , null ) ; } | Gets a page image from a template for display . Retrieves a page image for display from the specified template . | 52 | 24 |
36,308 | public Recipients listRecipients ( String accountId , String templateId ) throws ApiException { return listRecipients ( accountId , templateId , null ) ; } | Gets recipient information from a template . Retrieves the information for all recipients in the specified template . | 38 | 21 |
36,309 | public Tabs listTabs ( String accountId , String templateId , String recipientId ) throws ApiException { return listTabs ( accountId , templateId , recipientId , null ) ; } | Gets the tabs information for a signer or sign - in - person recipient in a template . Gets the tabs information for a signer or sign - in - person recipient in a template . | 42 | 39 |
36,310 | public EnvelopeDocument updateDocument ( String accountId , String templateId , String documentId , EnvelopeDefinition envelopeDefinition ) throws ApiException { return updateDocument ( accountId , templateId , documentId , envelopeDefinition , null ) ; } | Adds a document to a template document . Adds the specified document to an existing template document . | 52 | 18 |
36,311 | public TemplateDocumentsResult updateDocuments ( String accountId , String templateId , EnvelopeDefinition envelopeDefinition ) throws ApiException { return updateDocuments ( accountId , templateId , envelopeDefinition , null ) ; } | Adds documents to a template document . Adds one or more documents to an existing template document . | 44 | 18 |
36,312 | public NotaryJournalList listNotaryJournals ( NotaryApi . ListNotaryJournalsOptions options ) throws ApiException { Object localVarPostBody = "{}" ; // create path and map variables String localVarPath = "/v2/current_user/notary/journals" . replaceAll ( "\\{format\\}" , "json" ) ; // query params java . util . List < P... | Get notary jurisdictions for a user | 452 | 7 |
36,313 | public static String calculatePath ( String uri ) { if ( ! uri . startsWith ( "/" ) ) { return "/" ; } int idx = uri . lastIndexOf ( ' ' ) ; return uri . substring ( 0 , idx + 1 ) ; } | Get cookie default path from url path | 61 | 7 |
36,314 | public static boolean isDomainSuffix ( String domain , String domainSuffix ) { if ( domain . length ( ) < domainSuffix . length ( ) ) { return false ; } if ( domain . length ( ) == domainSuffix . length ( ) ) { return domain . equals ( domainSuffix ) ; } return domain . endsWith ( domainSuffix ) && domain . charAt ( do... | If domainSuffix is suffix of domain | 110 | 9 |
36,315 | public static boolean match ( Cookie cookie , String protocol , String host , String path ) { if ( cookie . secure ( ) && ! protocol . equalsIgnoreCase ( "https" ) ) { return false ; } // check domain if ( isIP ( host ) || cookie . hostOnly ( ) ) { if ( ! host . equals ( cookie . domain ( ) ) ) { return false ; } } els... | If cookie match the given scheme host and path . | 233 | 10 |
36,316 | @ Nullable public static Cookie parseCookie ( String cookieStr , String host , String defaultPath ) { String [ ] items = cookieStr . split ( ";" ) ; Parameter < String > param = parseCookieNameValue ( items [ 0 ] ) ; if ( param == null ) { return null ; } String domain = "" ; String path = "" ; long expiry = 0 ; boolea... | Parse one cookie header value return the cookie . | 494 | 10 |
36,317 | private static String normalizeDomain ( String value ) { if ( value . startsWith ( "." ) ) { return value . substring ( 1 ) ; } return value . toLowerCase ( ) ; } | Parse cookie domain . In RFC 6265 the leading dot will be ignored and cookie always available in sub domains . | 43 | 23 |
36,318 | public static Proxy httpProxy ( String host , int port ) { return new Proxy ( Proxy . Type . HTTP , new InetSocketAddress ( Objects . requireNonNull ( host ) , port ) ) ; } | Create http proxy | 43 | 3 |
36,319 | public static Proxy socksProxy ( String host , int port ) { return new Proxy ( Proxy . Type . SOCKS , new InetSocketAddress ( Objects . requireNonNull ( host ) , port ) ) ; } | Create socks5 proxy | 45 | 4 |
36,320 | public static RequestBuilder newRequest ( String method , String url ) { return new RequestBuilder ( ) . method ( method ) . url ( url ) ; } | Create new request with method and url | 32 | 7 |
36,321 | @ SafeVarargs public final RequestBuilder headers ( Map . Entry < String , ? > ... headers ) { headers ( Lists . of ( headers ) ) ; return this ; } | Set request headers . | 36 | 4 |
36,322 | @ SafeVarargs public final RequestBuilder cookies ( Map . Entry < String , ? > ... cookies ) { cookies ( Lists . of ( cookies ) ) ; return this ; } | Set request cookies . | 36 | 4 |
36,323 | @ SafeVarargs public final RequestBuilder params ( Map . Entry < String , ? > ... params ) { this . params = Lists . of ( params ) ; return this ; } | Set url query params . | 37 | 5 |
36,324 | public RawResponse send ( ) { Request request = build ( ) ; RequestExecutorFactory factory = RequestExecutorFactory . getInstance ( ) ; HttpExecutor executor = factory . getHttpExecutor ( ) ; return new InterceptorChain ( interceptors , executor ) . proceed ( request ) ; } | build http request and send out | 65 | 6 |
36,325 | public Part < T > contentType ( String contentType ) { requireNonNull ( contentType ) ; return new Part <> ( name , fileName , body , contentType , charset , partWriter ) ; } | Set content type for this part . | 45 | 7 |
36,326 | public Part < T > charset ( Charset charset ) { requireNonNull ( charset ) ; return new Part <> ( name , fileName , body , contentType , charset , partWriter ) ; } | The charset of this part s content . Each part of MultiPart body can has it s own charset set . Default not set . | 47 | 28 |
36,327 | public static String encodeForm ( Parameter < String > query , Charset charset ) { try { return URLEncoder . encode ( query . name ( ) , charset . name ( ) ) + "=" + URLEncoder . encode ( query . value ( ) , charset . name ( ) ) ; } catch ( UnsupportedEncodingException e ) { // should not happen throw new RequestsExcep... | Encode key - value form parameter | 94 | 7 |
36,328 | public static String encodeForms ( Collection < ? extends Parameter < String > > queries , Charset charset ) { StringBuilder sb = new StringBuilder ( ) ; try { for ( Parameter < String > query : queries ) { sb . append ( URLEncoder . encode ( query . name ( ) , charset . name ( ) ) ) ; sb . append ( ' ' ) ; sb . append... | Encode multi form parameters | 189 | 5 |
36,329 | public static Parameter < String > decodeForm ( String s , Charset charset ) { int idx = s . indexOf ( "=" ) ; try { if ( idx < 0 ) { return Parameter . of ( "" , URLDecoder . decode ( s , charset . name ( ) ) ) ; } return Parameter . of ( URLDecoder . decode ( s . substring ( 0 , idx ) , charset . name ( ) ) , URLDeco... | Decode key - value query parameter | 152 | 7 |
36,330 | public static List < Parameter < String > > decodeForms ( String queryStr , Charset charset ) { String [ ] queries = queryStr . split ( "&" ) ; List < Parameter < String > > list = new ArrayList <> ( queries . length ) ; for ( String query : queries ) { list . add ( decodeForm ( query , charset ) ) ; } return list ; } | Parse query params | 88 | 4 |
36,331 | @ Nullable public Cookie getCookie ( String name ) { for ( Cookie cookie : cookies ) { if ( cookie . name ( ) . equals ( name ) ) { return cookie ; } } return null ; } | Get first cookie match the name returned by this response return null if not found | 44 | 15 |
36,332 | private static void registerAllTypeFactories ( GsonBuilder gsonBuilder ) { ServiceLoader < TypeAdapterFactory > loader = ServiceLoader . load ( TypeAdapterFactory . class ) ; for ( TypeAdapterFactory typeFactory : loader ) { if ( logger . isLoggable ( Level . FINE ) ) { logger . fine ( "Add gson type factory: " + typeF... | Find and register all gson type factory using spi | 108 | 11 |
36,333 | public static KeyStore load ( String path , char [ ] password ) { try { return load ( new FileInputStream ( path ) , password ) ; } catch ( FileNotFoundException e ) { throw new TrustManagerLoadFailedException ( e ) ; } } | Load keystore from file . | 55 | 6 |
36,334 | public static KeyStore load ( InputStream in , char [ ] password ) { try { KeyStore myTrustStore = KeyStore . getInstance ( KeyStore . getDefaultType ( ) ) ; myTrustStore . load ( in , password ) ; return myTrustStore ; } catch ( CertificateException | NoSuchAlgorithmException | KeyStoreException | IOException e ) { th... | Load keystore from InputStream close the stream after load succeed or failed . | 105 | 15 |
36,335 | private RawResponse getResponse ( URL url , HttpURLConnection conn , CookieJar cookieJar , String method ) throws IOException { // read result int status = conn . getResponseCode ( ) ; String host = url . getHost ( ) . toLowerCase ( ) ; String statusLine = null ; // headers and cookies List < Header > headerList = new ... | Wrap response deal with headers and cookies | 354 | 8 |
36,336 | @ NonNull public JsonProcessor lookup ( ) { JsonProcessor registeredJsonProcessor = this . registeredJsonProcessor ; if ( registeredJsonProcessor != null ) { return registeredJsonProcessor ; } if ( ! init ) { synchronized ( this ) { if ( ! init ) { lookedJsonProcessor = lookupInClasspath ( ) ; init = true ; } } } if ( ... | Find one json provider . | 125 | 5 |
36,337 | 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 | 52 | 12 |
36,338 | public static RequestBody < Collection < ? extends Part > > multiPart ( Collection < ? extends Part > parts ) { return new MultiPartRequestBody ( requireNonNull ( parts ) ) ; } | Create multi - part post request body | 40 | 7 |
36,339 | 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 | 71 | 11 |
36,340 | 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 | 68 | 12 |
36,341 | 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 . | 216 | 9 |
36,342 | 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 . | 52 | 9 |
36,343 | 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 . | 42 | 26 |
36,344 | 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 . | 40 | 11 |
36,345 | 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 | 81 | 14 |
36,346 | 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 | 61 | 16 |
36,347 | 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 . | 111 | 28 |
36,348 | 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 | 75 | 7 |
36,349 | 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 . | 59 | 12 |
36,350 | 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 . | 52 | 14 |
36,351 | 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 . | 52 | 8 |
36,352 | private InputStream decompressBody ( ) { if ( ! decompress ) { return body ; } // if has no body, some server still set content-encoding header, // GZIPInputStream wrap empty input stream will cause exception. we should check this if ( method . equals ( Methods . HEAD ) || ( statusCode >= 100 && statusCode < 200 ) || s... | Wrap response input stream if it is compressed return input its self if not use compress | 287 | 17 |
36,353 | 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 . | 52 | 8 |
36,354 | 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 . | 52 | 9 |
36,355 | 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 | 102 | 5 |
36,356 | public static Result create ( ) { Form < Computer > computerForm = form ( Computer . class ) ; return ok ( createForm . render ( computerForm ) ) ; } | Display the new computer form . | 35 | 6 |
36,357 | 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 | 97 | 6 |
36,358 | public static Result delete ( Long id ) { Computer . find . ref ( id ) . delete ( ) ; flash ( "success" , "Computer has been deleted" ) ; return GO_HOME ; } | Handle computer deletion | 42 | 3 |
36,359 | 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 | 84 | 5 |
36,360 | 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 . | 215 | 10 |
36,361 | 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 ( ) ) ; //jump to ele... | Parses generic object . | 157 | 6 |
36,362 | 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 . | 126 | 5 |
36,363 | 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 | 124 | 9 |
36,364 | 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 . | 250 | 21 |
36,365 | 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 . | 116 | 14 |
36,366 | @ Override 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 e... | Post Execute action . It is called at the end of the execute method . Subclasses can add extra checks . | 249 | 23 |
36,367 | public int lengthOf ( String value ) { int length = 0 ; if ( value != null ) { length = value . length ( ) ; } return length ; } | Determines length of string . | 34 | 7 |
36,368 | 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 . | 43 | 10 |
36,369 | public String convertToUpperCase ( String value ) { String result = null ; if ( value != null ) { result = value . toUpperCase ( ) ; } return result ; } | Converts the value to upper case . | 40 | 8 |
36,370 | public String convertToLowerCase ( String value ) { String result = null ; if ( value != null ) { result = value . toLowerCase ( ) ; } return result ; } | Converts the value to lower case . | 38 | 8 |
36,371 | public String replaceAllInWith ( String regEx , String value , String replace ) { String result = null ; if ( value != null ) { if ( replace == null ) { // empty cell in table is sent as null replace = "" ; } result = getMatcher ( regEx , value ) . replaceAll ( replace ) ; } return result ; } | Replaces all occurrences of the regular expression in the value with the replacement value . | 74 | 16 |
36,372 | 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 . | 86 | 14 |
36,373 | public String getRawXPath ( String xPathExpr , Object ... params ) { return getRawXPath ( getResponse ( ) , xPathExpr , params ) ; } | Gets XPath value without checking whether response is valid . | 38 | 12 |
36,374 | 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 . | 109 | 14 |
36,375 | 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 . | 206 | 12 |
36,376 | public void registerPrefixForNamespace ( String prefix , String namespace ) { getEnvironment ( ) . registerNamespace ( prefix , getUrl ( namespace ) ) ; } | Register a prefix to use in XPath expressions . | 35 | 10 |
36,377 | 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 | 55 | 14 |
36,378 | 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 | 47 | 12 |
36,379 | public XMLGregorianCalendar addDays ( final XMLGregorianCalendar cal , final int amount ) { XMLGregorianCalendar to = buildXMLGregorianCalendarDate ( cal ) ; // Add amount of months to . add ( addDays ( amount ) ) ; return to ; } | Add Days to a Gregorian Calendar . | 61 | 8 |
36,380 | public XMLGregorianCalendar addMonths ( final XMLGregorianCalendar cal , final int amount ) { XMLGregorianCalendar to = buildXMLGregorianCalendarDate ( cal ) ; // Add amount of months to . add ( addMonths ( amount ) ) ; return to ; } | Add Months to a Gregorian Calendar . | 63 | 8 |
36,381 | public XMLGregorianCalendar addYears ( final XMLGregorianCalendar cal , final int amount ) { XMLGregorianCalendar to = buildXMLGregorianCalendarDate ( cal ) ; // Add amount of months to . add ( addYears ( amount ) ) ; return to ; } | Add Years to a Gregorian Calendar . | 61 | 8 |
36,382 | public int getDurationInYears ( XMLGregorianCalendar startDate , XMLGregorianCalendar endDate ) { int startYear = startDate . getYear ( ) ; final int dec = 12 ; if ( startDate . getMonth ( ) == dec ) { // started in December, increase year with one startYear ++ ; } int endYear = endDate . getYear ( ) ; return endYear -... | Determines number of years between two dates so that premium duration can be established . | 89 | 17 |
36,383 | 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 . | 88 | 7 |
36,384 | 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 . | 124 | 9 |
36,385 | 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 . | 95 | 15 |
36,386 | 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 . | 140 | 9 |
36,387 | 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 . | 86 | 9 |
36,388 | 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 . | 81 | 16 |
36,389 | 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 . | 273 | 11 |
36,390 | 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 . | 125 | 13 |
36,391 | public String getText ( WebElement element ) { String text = element . getText ( ) ; if ( text != null ) { // Safari driver does not return as normal spacce, while others do text = text . replace ( NON_BREAKING_SPACE , ' ' ) ; // Safari driver does not return trim, while others do text = text . trim ( ) ; } retu... | Gets element s text content . | 87 | 7 |
36,392 | 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 . | 131 | 8 |
36,393 | 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 . | 71 | 50 |
36,394 | public void setImplicitlyWait ( int implicitWait ) { try { driver ( ) . manage ( ) . timeouts ( ) . implicitlyWait ( implicitWait , TimeUnit . MILLISECONDS ) ; } catch ( Exception e ) { // https://code.google.com/p/selenium/issues/detail?id=6015 System . err . println ( "Unable to set implicit timeout (known issue for ... | Sets how long to wait before deciding an element does not exists . | 104 | 14 |
36,395 | public void setScriptWait ( int scriptTimeout ) { try { driver ( ) . manage ( ) . timeouts ( ) . setScriptTimeout ( scriptTimeout , TimeUnit . MILLISECONDS ) ; } catch ( Exception e ) { // https://code.google.com/p/selenium/issues/detail?id=6015 System . err . println ( "Unable to set script timeout (known issue for Sa... | Sets how long to wait when executing asynchronous script calls . | 103 | 12 |
36,396 | public void setPageLoadWait ( int pageLoadWait ) { try { driver ( ) . manage ( ) . timeouts ( ) . pageLoadTimeout ( pageLoadWait , TimeUnit . MILLISECONDS ) ; } catch ( Exception e ) { // https://code.google.com/p/selenium/issues/detail?id=6015 System . err . println ( "Unable to set page load timeout (known issue for ... | Sets how long to wait on opening a page . | 107 | 11 |
36,397 | 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 . | 45 | 20 |
36,398 | public void dragAndDrop ( WebElement source , WebElement target ) { getActions ( ) . dragAndDrop ( source , target ) . perform ( ) ; } | Simulates a drag from source element and drop to target element | 35 | 12 |
36,399 | public T findByXPath ( String pattern , String ... parameters ) { By by = byXpath ( pattern , parameters ) ; return findElement ( by ) ; } | Finds element using xPath supporting placeholder replacement . | 35 | 10 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.