idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
151,400
public Response remove ( String id , String rev ) { assertNotEmpty ( id , "id" ) ; assertNotEmpty ( id , "rev" ) ; return db . remove ( ensureDesignPrefix ( id ) , rev ) ; }
Removes a design document using the id and rev from the database .
151,401
public Response remove ( DesignDocument designDocument ) { assertNotEmpty ( designDocument , "DesignDocument" ) ; ensureDesignPrefixObject ( designDocument ) ; return db . remove ( designDocument ) ; }
Removes a design document using DesignDocument object from the database .
151,402
public List < DesignDocument > list ( ) throws IOException { return db . getAllDocsRequestBuilder ( ) . startKey ( "_design/" ) . endKey ( "_design0" ) . inclusiveEnd ( false ) . includeDocs ( true ) . build ( ) . getResponse ( ) . getDocsAs ( DesignDocument . class ) ; }
Performs a query to retrieve all the design documents defined in the database .
151,403
public static List < DesignDocument > fromDirectory ( File directory ) throws FileNotFoundException { List < DesignDocument > designDocuments = new ArrayList < DesignDocument > ( ) ; if ( directory . isDirectory ( ) ) { Collection < File > files = FileUtils . listFiles ( directory , null , true ) ; for ( File designDoc...
Deserialize a directory of javascript design documents to a List of DesignDocument objects .
151,404
public static DesignDocument fromFile ( File file ) throws FileNotFoundException { assertNotEmpty ( file , "Design js file" ) ; DesignDocument designDocument ; Gson gson = new Gson ( ) ; InputStreamReader reader = null ; try { reader = new InputStreamReader ( new FileInputStream ( file ) , "UTF-8" ) ; designDocument = ...
Deserialize a javascript design document file to a DesignDocument object .
151,405
static < K , V > ViewQueryParameters < K , V > forwardPaginationQueryParameters ( ViewQueryParameters < K , V > initialQueryParameters , K startkey , String startkey_docid ) { ViewQueryParameters < K , V > pageParameters = initialQueryParameters . copy ( ) ; pageParameters . setStartKey ( startkey ) ; pageParameters . ...
Generate query parameters for a forward page with the specified start key .
151,406
public static HttpConnection connect ( String requestMethod , URL url , String contentType ) { return new HttpConnection ( requestMethod , url , contentType ) ; }
low level http operations
151,407
public B partialFilterSelector ( Selector selector ) { instance . def . selector = Helpers . getJsonObjectFromSelector ( selector ) ; return returnThis ( ) ; }
Configure a selector to choose documents that should be added to the index .
151,408
protected B fields ( List < F > fields ) { if ( instance . def . fields == null ) { instance . def . fields = new ArrayList < F > ( fields . size ( ) ) ; } instance . def . fields . addAll ( fields ) ; return returnThis ( ) ; }
Add fields to the text index configuration .
151,409
public SchedulerDocsResponse . Doc schedulerDoc ( String docId ) { assertNotEmpty ( docId , "docId" ) ; return this . get ( new DatabaseURIHelper ( getBaseUri ( ) ) . path ( "_scheduler" ) . path ( "docs" ) . path ( "_replicator" ) . path ( docId ) . build ( ) , SchedulerDocsResponse . Doc . class ) ; }
Get replication document state for a given replication document ID .
151,410
public List < String > uuids ( long count ) { final URI uri = new URIBase ( clientUri ) . path ( "_uuids" ) . query ( "count" , count ) . build ( ) ; final JsonObject json = get ( uri , JsonObject . class ) ; return getGson ( ) . fromJson ( json . get ( "uuids" ) . toString ( ) , DeserializationTypes . STRINGS ) ; }
Request a database sends a list of UUIDs .
151,411
public Response executeToResponse ( HttpConnection connection ) { InputStream is = null ; try { is = this . executeToInputStream ( connection ) ; Response response = getResponse ( is , Response . class , getGson ( ) ) ; response . setStatusCode ( connection . getConnection ( ) . getResponseCode ( ) ) ; response . setRe...
Executes a HTTP request and parses the JSON response into a Response instance .
151,412
Response delete ( URI uri ) { HttpConnection connection = Http . DELETE ( uri ) ; return executeToResponse ( connection ) ; }
Performs a HTTP DELETE request .
151,413
public < T > T get ( URI uri , Class < T > classType ) { HttpConnection connection = Http . GET ( uri ) ; InputStream response = executeToInputStream ( connection ) ; try { return getResponse ( response , classType , getGson ( ) ) ; } finally { close ( response ) ; } }
Performs a HTTP GET request .
151,414
Response put ( URI uri , InputStream instream , String contentType ) { HttpConnection connection = Http . PUT ( uri , contentType ) ; connection . setRequestBody ( instream ) ; return executeToResponse ( connection ) ; }
Performs a HTTP PUT request saves an attachment .
151,415
public HttpConnection execute ( HttpConnection connection ) { connection . connectionFactory = factory ; connection . requestProperties . put ( "Accept" , "application/json" ) ; connection . responseInterceptors . addAll ( this . responseInterceptors ) ; connection . requestInterceptors . addAll ( this . requestInterce...
Execute a HTTP request and handle common error cases .
151,416
private static String loadUA ( ClassLoader loader , String filename ) { String ua = "cloudant-http" ; String version = "unknown" ; final InputStream propStream = loader . getResourceAsStream ( filename ) ; final Properties properties = new Properties ( ) ; try { if ( propStream != null ) { try { properties . load ( pro...
Loads the properties file using the classloader provided . Creating a string from the properties user . agent . name and user . agent . version .
151,417
private String getBearerToken ( HttpConnectionInterceptorContext context ) { final AtomicReference < String > iamTokenResponse = new AtomicReference < String > ( ) ; boolean result = super . requestCookie ( context , iamServerUrl , iamTokenRequestBody , "application/x-www-form-urlencoded" , "application/json" , new Sto...
get bearer token returned by IAM in JSON format
151,418
public QueryBuilder useIndex ( String designDocument , String indexName ) { useIndex = new String [ ] { designDocument , indexName } ; return this ; }
Instruct a query to use a specific index .
151,419
private static String quoteSort ( Sort [ ] sort ) { LinkedList < String > sorts = new LinkedList < String > ( ) ; for ( Sort pair : sort ) { sorts . add ( String . format ( "{%s: %s}" , Helpers . quote ( pair . getName ( ) ) , Helpers . quote ( pair . getOrder ( ) . toString ( ) ) ) ) ; } return sorts . toString ( ) ; ...
sorts are a bit more awkward and need a helper ...
151,420
public < K , V > MultipleRequestBuilder < K , V > newMultipleRequest ( Key . Type < K > keyType , Class < V > valueType ) { return new MultipleRequestBuilderImpl < K , V > ( newViewRequestParameters ( keyType . getType ( ) , valueType ) ) ; }
Create a new builder for multiple unpaginated requests on the view .
151,421
public < T > T find ( Class < T > classType , String id , String rev ) { assertNotEmpty ( classType , "Class" ) ; assertNotEmpty ( id , "id" ) ; assertNotEmpty ( id , "rev" ) ; final URI uri = new DatabaseURIHelper ( dbUri ) . documentUri ( id , "rev" , rev ) ; return couchDbClient . get ( uri , classType ) ; }
Finds an Object of the specified type .
151,422
public boolean contains ( String id ) { assertNotEmpty ( id , "id" ) ; InputStream response = null ; try { response = couchDbClient . head ( new DatabaseURIHelper ( dbUri ) . documentUri ( id ) ) ; } catch ( NoDocumentException e ) { return false ; } finally { close ( response ) ; } return true ; }
Checks if a document exist in the database .
151,423
public List < Response > bulk ( List < ? > objects , boolean allOrNothing ) { assertNotEmpty ( objects , "objects" ) ; InputStream responseStream = null ; HttpConnection connection ; try { final JsonObject jsonObject = new JsonObject ( ) ; if ( allOrNothing ) { jsonObject . addProperty ( "all_or_nothing" , true ) ; } f...
Performs a Bulk Documents insert request .
151,424
public < T > List < T > query ( String query , Class < T > classOfT ) { InputStream instream = null ; List < T > result = new ArrayList < T > ( ) ; try { Reader reader = new InputStreamReader ( instream = queryForStream ( query ) , "UTF-8" ) ; JsonObject json = new JsonParser ( ) . parse ( reader ) . getAsJsonObject ( ...
Queries a Search Index and returns ungrouped results . In case the query used grouping an empty list is returned
151,425
public < T > Map < String , List < T > > queryGroups ( String query , Class < T > classOfT ) { InputStream instream = null ; try { Reader reader = new InputStreamReader ( instream = queryForStream ( query ) , "UTF-8" ) ; JsonObject json = new JsonParser ( ) . parse ( reader ) . getAsJsonObject ( ) ; Map < String , List...
Queries a Search Index and returns grouped results in a map where key of the map is the groupName . In case the query didnt use grouping an empty map is returned
151,426
public Search groupField ( String fieldName , boolean isNumber ) { assertNotEmpty ( fieldName , "fieldName" ) ; if ( isNumber ) { databaseHelper . query ( "group_field" , fieldName + "<number>" ) ; } else { databaseHelper . query ( "group_field" , fieldName ) ; } return this ; }
Group results by the specified field .
151,427
public Search counts ( String [ ] countsfields ) { assert ( countsfields . length > 0 ) ; JsonArray countsJsonArray = new JsonArray ( ) ; for ( String countsfield : countsfields ) { JsonPrimitive element = new JsonPrimitive ( countsfield ) ; countsJsonArray . add ( element ) ; } databaseHelper . query ( "counts" , coun...
Array of fieldNames for which counts should be produced
151,428
public List < Index < Field > > allIndexes ( ) { List < Index < Field > > indexesOfAnyType = new ArrayList < Index < Field > > ( ) ; indexesOfAnyType . addAll ( listIndexType ( null , ListableIndex . class ) ) ; return indexesOfAnyType ; }
All the indexes defined in the database . Type widening means that the returned Index objects are limited to the name design document and type of the index and the names of the fields .
151,429
private < T extends Index > List < T > listIndexType ( String type , Class < T > modelType ) { List < T > indexesOfType = new ArrayList < T > ( ) ; Gson g = new Gson ( ) ; for ( JsonElement index : indexes ) { if ( index . isJsonObject ( ) ) { JsonObject indexDefinition = index . getAsJsonObject ( ) ; JsonElement index...
Utility to list indexes of a given type .
151,430
String encodePath ( String in ) { try { String encodedString = HierarchicalUriComponents . encodeUriComponent ( in , "UTF-8" , HierarchicalUriComponents . Type . PATH_SEGMENT ) ; if ( encodedString . startsWith ( _design_prefix_encoded ) || encodedString . startsWith ( _local_prefix_encoded ) ) { return encodedString ....
Encode a path in a manner suitable for a GET request
151,431
public URI build ( ) { try { String uriString = String . format ( "%s%s" , baseUri . toASCIIString ( ) , ( path . isEmpty ( ) ? "" : path ) ) ; if ( qParams != null && qParams . size ( ) > 0 ) { if ( ! completeQuery . isEmpty ( ) ) { uriString = String . format ( "%s?%s&%s" , uriString , getJoinedQuery ( qParams . getP...
Build and return the complete URI containing values such as the document ID attachment ID and query syntax .
151,432
public static ClientBuilder account ( String account ) { logger . config ( "Account: " + account ) ; return ClientBuilder . url ( convertStringToURL ( String . format ( "https://%s.cloudant.com" , account ) ) ) ; }
Constructs a new ClientBuilder for building a CloudantClient instance to connect to the Cloudant server with the specified account .
151,433
public HttpConnection setRequestBody ( final String input ) { try { final byte [ ] inputBytes = input . getBytes ( "UTF-8" ) ; return setRequestBody ( inputBytes ) ; } catch ( UnsupportedEncodingException e ) { throw new RuntimeException ( e ) ; } }
Set the String of request body data to be sent to the server .
151,434
public HttpConnection setRequestBody ( final InputStream input , final long inputLength ) { try { return setRequestBody ( new InputStreamWrappingGenerator ( input , inputLength ) , inputLength ) ; } catch ( IOException e ) { logger . log ( Level . SEVERE , "Error copying input stream for request body" , e ) ; throw new...
Set the InputStream of request body data of known length to be sent to the server .
151,435
private String getLogRequestIdentifier ( ) { if ( logIdentifier == null ) { logIdentifier = String . format ( "%s-%s %s %s" , Integer . toHexString ( hashCode ( ) ) , numberOfRetries , connection . getRequestMethod ( ) , connection . getURL ( ) ) ; } return logIdentifier ; }
Get a prefix for the log message to help identify which request is which and which responses belong to which requests .
151,436
private PGPSecretKey getSecretKey ( InputStream input , String keyId ) throws IOException , PGPException { PGPSecretKeyRingCollection keyrings = new PGPSecretKeyRingCollection ( PGPUtil . getDecoderStream ( input ) , new JcaKeyFingerprintCalculator ( ) ) ; Iterator rIt = keyrings . getKeyRings ( ) ; while ( rIt . hasNe...
Returns the secret key matching the specified identifier .
151,437
private String trim ( String line ) { char [ ] chars = line . toCharArray ( ) ; int len = chars . length ; while ( len > 0 ) { if ( ! Character . isWhitespace ( chars [ len - 1 ] ) ) { break ; } len -- ; } return line . substring ( 0 , len ) ; }
Trim the trailing spaces .
151,438
public void validate ( ) throws PackagingException { if ( control == null || ! control . isDirectory ( ) ) { throw new PackagingException ( "The 'control' attribute doesn't point to a directory. " + control ) ; } if ( changesIn != null ) { if ( changesIn . exists ( ) && ( ! changesIn . isFile ( ) || ! changesIn . canRe...
Validates the input parameters .
151,439
protected String getUserDefinedFieldName ( String field ) { int index = field . indexOf ( '-' ) ; char letter = getUserDefinedFieldLetter ( ) ; for ( int i = 0 ; i < index ; ++ i ) { if ( field . charAt ( i ) == letter ) { return field . substring ( index + 1 ) ; } } return null ; }
Returns the user defined field without its prefix .
151,440
public static String replaceVariables ( final VariableResolver pResolver , final String pExpression , final String pOpen , final String pClose ) { final char [ ] open = pOpen . toCharArray ( ) ; final char [ ] close = pClose . toCharArray ( ) ; final StringBuilder out = new StringBuilder ( ) ; StringBuilder sb = new St...
Substitute the variables in the given expression with the values from the resolver
151,441
public static byte [ ] toUnixLineEndings ( InputStream input ) throws IOException { String encoding = "ISO-8859-1" ; FixCrLfFilter filter = new FixCrLfFilter ( new InputStreamReader ( input , encoding ) ) ; filter . setEol ( FixCrLfFilter . CrLf . newInstance ( "unix" ) ) ; ByteArrayOutputStream filteredFile = new Byte...
Replaces new line delimiters in the input stream with the Unix line feed .
151,442
public static String movePath ( final String file , final String target ) { final String name = new File ( file ) . getName ( ) ; return target . endsWith ( "/" ) ? target + name : target + '/' + name ; }
Construct new path by replacing file directory part . No files are actually modified .
151,443
public static String lookupIfEmpty ( final String value , final Map < String , String > props , final String key ) { return value != null ? value : props . get ( key ) ; }
Extracts value from map if given value is null .
151,444
public static Collection < String > getKnownPGPSecureRingLocations ( ) { final LinkedHashSet < String > locations = new LinkedHashSet < String > ( ) ; final String os = System . getProperty ( "os.name" ) ; final boolean runOnWindows = os == null || os . toLowerCase ( ) . contains ( "win" ) ; if ( runOnWindows ) { final...
Get the known locations where the secure keyring can be located . Looks through known locations of the GNU PG secure keyring .
151,445
public static File guessKeyRingFile ( ) throws FileNotFoundException { final Collection < String > possibleLocations = getKnownPGPSecureRingLocations ( ) ; for ( final String location : possibleLocations ) { final File candidate = new File ( location ) ; if ( candidate . exists ( ) ) { return candidate ; } } final Stri...
Tries to guess location of the user secure keyring using various heuristics .
151,446
public static String defaultString ( final String str , final String fallback ) { return isNullOrEmpty ( str ) ? fallback : str ; }
Return fallback if first string is null or empty
151,447
static TarArchiveEntry defaultFileEntryWithName ( final String fileName ) { TarArchiveEntry entry = new TarArchiveEntry ( fileName , true ) ; entry . setUserId ( ROOT_UID ) ; entry . setUserName ( ROOT_NAME ) ; entry . setGroupId ( ROOT_UID ) ; entry . setGroupName ( ROOT_NAME ) ; entry . setMode ( TarArchiveEntry . DE...
Creates a tar file entry with defaults parameters .
151,448
static TarArchiveEntry defaultDirEntryWithName ( final String dirName ) { TarArchiveEntry entry = new TarArchiveEntry ( dirName , true ) ; entry . setUserId ( ROOT_UID ) ; entry . setUserName ( ROOT_NAME ) ; entry . setGroupId ( ROOT_UID ) ; entry . setGroupName ( ROOT_NAME ) ; entry . setMode ( TarArchiveEntry . DEFAU...
Creates a tar directory entry with defaults parameters .
151,449
static void produceInputStreamWithEntry ( final DataConsumer consumer , final InputStream inputStream , final TarArchiveEntry entry ) throws IOException { try { consumer . onEachFile ( inputStream , entry ) ; } finally { IOUtils . closeQuietly ( inputStream ) ; } }
Feeds input stream to data consumer using metadata from tar entry .
151,450
public String format ( String value ) { StringBuilder s = new StringBuilder ( ) ; if ( value != null && value . trim ( ) . length ( ) > 0 ) { boolean continuationLine = false ; s . append ( getName ( ) ) . append ( ":" ) ; if ( isFirstLineEmpty ( ) ) { s . append ( "\n" ) ; continuationLine = true ; } try { BufferedRea...
Returns the field with the specified value properly formatted . Multiline values are automatically indented and dots are added on the empty lines .
151,451
public void initialize ( BinaryPackageControlFile packageControlFile ) { set ( "Binary" , packageControlFile . get ( "Package" ) ) ; set ( "Source" , Utils . defaultString ( packageControlFile . get ( "Source" ) , packageControlFile . get ( "Package" ) ) ) ; set ( "Architecture" , packageControlFile . get ( "Architectu...
Initializes the fields on the changes file with the values of the specified binary package control file .
151,452
private void initializeSignProperties ( ) { if ( ! signPackage && ! signChanges ) { return ; } if ( key != null && keyring != null && passphrase != null ) { return ; } Map < String , String > properties = readPropertiesFromActiveProfiles ( signCfgPrefix , KEY , KEYRING , PASSPHRASE ) ; key = lookupIfEmpty ( key , prope...
Initializes unspecified sign properties using available defaults and global settings .
151,453
public Map < String , String > readPropertiesFromActiveProfiles ( final String prefix , final String ... properties ) { if ( settings == null ) { console . debug ( "No maven setting injected" ) ; return Collections . emptyMap ( ) ; } final List < String > activeProfilesList = settings . getActiveProfiles ( ) ; if ( act...
Read properties from the active profiles .
151,454
void buildControl ( BinaryPackageControlFile packageControlFile , File [ ] controlFiles , List < String > conffiles , StringBuilder checksums , File output ) throws IOException , ParseException { final File dir = output . getParentFile ( ) ; if ( dir != null && ( ! dir . exists ( ) || ! dir . isDirectory ( ) ) ) { thro...
Build control archive of the deb
151,455
public static String get ( String url , Map < String , String > customHeaders , Map < String , String > params ) throws URISyntaxException , IOException , HTTPException { LOGGER . log ( Level . INFO , "Sending GET request to the url {0}" , url ) ; URIBuilder uriBuilder = new URIBuilder ( url ) ; if ( params != null && ...
Send get request .
151,456
public static String post ( String url , Map < String , String > customHeaders , Map < String , String > params ) throws IOException , HTTPException { LOGGER . log ( Level . INFO , "Sending POST request to the url {0}" , url ) ; HttpPost httpPost = new HttpPost ( url ) ; populateHeaders ( httpPost , customHeaders ) ; i...
Send post request .
151,457
public T reverse ( ) { String id = getId ( ) ; String REVERSE = "_REVERSE" ; if ( id . endsWith ( REVERSE ) ) { setId ( id . substring ( 0 , id . length ( ) - REVERSE . length ( ) ) ) ; } float start = mStart ; float end = mEnd ; mStart = end ; mEnd = start ; mReverse = ! mReverse ; return self ( ) ; }
Reverse how the transition is applied such that the transition previously performed when progress = start of range is only performed when progress = end of range
151,458
public T transitFloat ( int propertyId , float ... vals ) { String property = getPropertyName ( propertyId ) ; mHolders . put ( propertyId , PropertyValuesHolder . ofFloat ( property , vals ) ) ; mShadowHolders . put ( propertyId , ShadowValuesHolder . ofFloat ( property , vals ) ) ; return self ( ) ; }
Transits a float propertyId from the start value to the end value .
151,459
public T transitInt ( int propertyId , int ... vals ) { String property = getPropertyName ( propertyId ) ; mHolders . put ( propertyId , PropertyValuesHolder . ofInt ( property , vals ) ) ; mShadowHolders . put ( propertyId , ShadowValuesHolder . ofInt ( property , vals ) ) ; return self ( ) ; }
Transits a float property from the start value to the end value .
151,460
public boolean isCompatible ( AbstractTransition another ) { if ( getClass ( ) . equals ( another . getClass ( ) ) && mTarget == another . mTarget && mReverse == another . mReverse && ( ( mInterpolator == null && another . mInterpolator == null ) || mInterpolator . getClass ( ) . equals ( another . mInterpolator . getC...
Checks to see if another AbstractTransition s states is isCompatible for merging .
151,461
public boolean merge ( AbstractTransition another ) { if ( ! isCompatible ( another ) ) { return false ; } if ( another . mId != null ) { if ( mId == null ) { mId = another . mId ; } else { StringBuilder sb = new StringBuilder ( mId . length ( ) + another . mId . length ( ) ) ; sb . append ( mId ) ; sb . append ( "_MER...
Merge another AbstractTransition s states into this object such that the other AbstractTransition can be discarded .
151,462
public void removeAllAnimations ( ) { for ( int i = 0 , size = mAnimationList . size ( ) ; i < size ; i ++ ) { mAnimationList . get ( i ) . removeAnimationListener ( mAnimationListener ) ; } mAnimationList . clear ( ) ; }
Stops and clears all transitions
151,463
public void stopTransition ( ) { for ( int i = 0 , size = mListenerList . size ( ) ; i < size ; i ++ ) { mListenerList . get ( i ) . onTransitionEnd ( this ) ; } for ( int i = 0 , size = mTransitionList . size ( ) ; i < size ; i ++ ) { mTransitionList . get ( i ) . stopTransition ( ) ; } }
Stops all transitions .
151,464
public void start ( ) { if ( TransitionConfig . isDebug ( ) ) { getTransitionStateHolder ( ) . start ( ) ; } mLastProgress = Float . MIN_VALUE ; TransitionController transitionController ; for ( int i = 0 , size = mTransitionControls . size ( ) ; i < size ; i ++ ) { transitionController = mTransitionControls . get ( i ...
Starts the transition
151,465
public void end ( ) { if ( TransitionConfig . isPrintDebug ( ) ) { getTransitionStateHolder ( ) . end ( ) ; getTransitionStateHolder ( ) . print ( ) ; } for ( int i = 0 , size = mTransitionControls . size ( ) ; i < size ; i ++ ) { mTransitionControls . get ( i ) . end ( ) ; } }
Ends the transition
151,466
public void reverse ( ) { for ( int i = 0 , size = mTransitionControls . size ( ) ; i < size ; i ++ ) { mTransitionControls . get ( i ) . reverse ( ) ; } }
Reverses all the TransitionControllers managed by this TransitionManager
151,467
private LoginContext getClientLoginContext ( ) throws LoginException { Configuration config = new Configuration ( ) { public AppConfigurationEntry [ ] getAppConfigurationEntry ( String name ) { Map < String , String > options = new HashMap < String , String > ( ) ; options . put ( "multi-threaded" , "true" ) ; options ...
Provides a RunAs client login context
151,468
public static void mainInternal ( String [ ] args ) throws Exception { Options options = new Options ( ) ; CmdLineParser parser = new CmdLineParser ( options ) ; try { parser . parseArgument ( args ) ; } catch ( CmdLineException e ) { helpScreen ( parser ) ; return ; } try { List < String > configs = new ArrayList < > ...
Entry point with no system exit
151,469
public static < T > T assertNull ( T value , String message ) { if ( value != null ) throw new IllegalStateException ( message ) ; return value ; }
Throws an IllegalStateException when the given value is not null .
151,470
public static < T > T assertNotNull ( T value , String message ) { if ( value == null ) throw new IllegalStateException ( message ) ; return value ; }
Throws an IllegalStateException when the given value is null .
151,471
public static Boolean assertTrue ( Boolean value , String message ) { if ( ! Boolean . valueOf ( value ) ) throw new IllegalStateException ( message ) ; return value ; }
Throws an IllegalStateException when the given value is not true .
151,472
public static Boolean assertFalse ( Boolean value , String message ) { if ( Boolean . valueOf ( value ) ) throw new IllegalStateException ( message ) ; return value ; }
Throws an IllegalStateException when the given value is not false .
151,473
public static < T > T assertNotNull ( T value , String name ) { if ( value == null ) throw new IllegalArgumentException ( "Null " + name ) ; return value ; }
Throws an IllegalArgumentException when the given value is null .
151,474
public static Boolean assertTrue ( Boolean value , String message ) { if ( ! Boolean . valueOf ( value ) ) throw new IllegalArgumentException ( message ) ; return value ; }
Throws an IllegalArgumentException when the given value is not true .
151,475
public static Boolean assertFalse ( Boolean value , String message ) { if ( Boolean . valueOf ( value ) ) throw new IllegalArgumentException ( message ) ; return value ; }
Throws an IllegalArgumentException when the given value is not false .
151,476
public void retrieveEngine ( ) throws GeneralSecurityException , IOException { if ( serverEngineFactory == null ) { return ; } engine = serverEngineFactory . retrieveHTTPServerEngine ( nurl . getPort ( ) ) ; if ( engine == null ) { engine = serverEngineFactory . getHTTPServerEngine ( nurl . getHost ( ) , nurl . getPort...
Post - configure retreival of server engine .
151,477
public void finalizeConfig ( ) { assert ! configFinalized ; try { retrieveEngine ( ) ; } catch ( Exception e ) { throw new RuntimeException ( e . getMessage ( ) , e ) ; } configFinalized = true ; }
This method is used to finalize the configuration after the configuration items have been set .
151,478
public File getStylesheetPath ( ) { String path = System . getProperty ( STYLESHEET_KEY ) ; return path == null ? null : new File ( path ) ; }
If a custom CSS file has been specified returns the path . Otherwise returns null .
151,479
private Collection < TestClassResults > flattenResults ( List < ISuite > suites ) { Map < IClass , TestClassResults > flattenedResults = new HashMap < IClass , TestClassResults > ( ) ; for ( ISuite suite : suites ) { for ( ISuiteResult suiteResult : suite . getResults ( ) . values ( ) ) { organiseByClass ( suiteResult ...
Flatten a list of test suite results into a collection of results grouped by test class . This method basically strips away the TestNG way of organising tests and arranges the results by test class .
151,480
private TestClassResults getResultsForClass ( Map < IClass , TestClassResults > flattenedResults , ITestResult testResult ) { TestClassResults resultsForClass = flattenedResults . get ( testResult . getTestClass ( ) ) ; if ( resultsForClass == null ) { resultsForClass = new TestClassResults ( testResult . getTestClass ...
Look - up the results data for a particular test class .
151,481
protected VelocityContext createContext ( ) { VelocityContext context = new VelocityContext ( ) ; context . put ( META_KEY , META ) ; context . put ( UTILS_KEY , UTILS ) ; context . put ( MESSAGES_KEY , MESSAGES ) ; return context ; }
Helper method that creates a Velocity context and initialises it with a reference to the ReportNG utils report metadata and localised messages .
151,482
protected void generateFile ( File file , String templateName , VelocityContext context ) throws Exception { Writer writer = new BufferedWriter ( new FileWriter ( file ) ) ; try { Velocity . mergeTemplate ( classpathPrefix + templateName , ENCODING , context , writer ) ; writer . flush ( ) ; } finally { writer . close ...
Generate the specified output file by merging the specified Velocity template with the supplied context .
151,483
protected void copyClasspathResource ( File outputDirectory , String resourceName , String targetFileName ) throws IOException { String resourcePath = classpathPrefix + resourceName ; InputStream resourceStream = getClass ( ) . getClassLoader ( ) . getResourceAsStream ( resourcePath ) ; copyStream ( outputDirectory , r...
Copy a single named resource from the classpath to the output directory .
151,484
protected void copyFile ( File outputDirectory , File sourceFile , String targetFileName ) throws IOException { InputStream fileStream = new FileInputStream ( sourceFile ) ; try { copyStream ( outputDirectory , fileStream , targetFileName ) ; } finally { fileStream . close ( ) ; } }
Copy a single named file to the output directory .
151,485
protected void copyStream ( File outputDirectory , InputStream stream , String targetFileName ) throws IOException { File resourceFile = new File ( outputDirectory , targetFileName ) ; BufferedReader reader = null ; Writer writer = null ; try { reader = new BufferedReader ( new InputStreamReader ( stream , ENCODING ) )...
Helper method to copy the contents of a stream to a file .
151,486
protected void removeEmptyDirectories ( File outputDirectory ) { if ( outputDirectory . exists ( ) ) { for ( File file : outputDirectory . listFiles ( new EmptyDirectoryFilter ( ) ) ) { file . delete ( ) ; } } }
Deletes any empty directories under the output directory . These directories are created by TestNG for its own reports regardless of whether those reports are generated . If you are using the default TestNG reports as well as ReportNG these directories will not be empty and will be retained . Otherwise they will be rem...
151,487
public void generateReport ( List < XmlSuite > xmlSuites , List < ISuite > suites , String outputDirectoryName ) { removeEmptyDirectories ( new File ( outputDirectoryName ) ) ; boolean useFrames = System . getProperty ( FRAMES_PROPERTY , "true" ) . equals ( "true" ) ; boolean onlyFailures = System . getProperty ( ONLY_...
Generates a set of HTML files that contain data about the outcome of the specified test suites .
151,488
private void createFrameset ( File outputDirectory ) throws Exception { VelocityContext context = createContext ( ) ; generateFile ( new File ( outputDirectory , INDEX_FILE ) , INDEX_FILE + TEMPLATE_EXTENSION , context ) ; }
Create the index file that sets up the frameset .
151,489
private void createSuiteList ( List < ISuite > suites , File outputDirectory , boolean onlyFailures ) throws Exception { VelocityContext context = createContext ( ) ; context . put ( SUITES_KEY , suites ) ; context . put ( ONLY_FAILURES_KEY , onlyFailures ) ; generateFile ( new File ( outputDirectory , SUITES_FILE ) , ...
Create the navigation frame .
151,490
private void createResults ( List < ISuite > suites , File outputDirectory , boolean onlyShowFailures ) throws Exception { int index = 1 ; for ( ISuite suite : suites ) { int index2 = 1 ; for ( ISuiteResult result : suite . getResults ( ) . values ( ) ) { boolean failuresExist = result . getTestContext ( ) . getFailedT...
Generate a results file for each test in each suite .
151,491
private void copyResources ( File outputDirectory ) throws IOException { copyClasspathResource ( outputDirectory , "reportng.css" , "reportng.css" ) ; copyClasspathResource ( outputDirectory , "reportng.js" , "reportng.js" ) ; File customStylesheet = META . getStylesheetPath ( ) ; if ( customStylesheet != null ) { if (...
Reads the CSS and JavaScript files from the JAR file and writes them to the output directory .
151,492
public List < Throwable > getCauses ( Throwable t ) { List < Throwable > causes = new LinkedList < Throwable > ( ) ; Throwable next = t ; while ( next . getCause ( ) != null ) { next = next . getCause ( ) ; causes . add ( next ) ; } return causes ; }
Convert a Throwable into a list containing all of its causes .
151,493
private String commaSeparate ( Collection < String > strings ) { StringBuilder buffer = new StringBuilder ( ) ; Iterator < String > iterator = strings . iterator ( ) ; while ( iterator . hasNext ( ) ) { String string = iterator . next ( ) ; buffer . append ( string ) ; if ( iterator . hasNext ( ) ) { buffer . append ( ...
Takes a list of Strings and combines them into a single comma - separated String .
151,494
public String stripThreadName ( String threadId ) { if ( threadId == null ) { return null ; } else { int index = threadId . lastIndexOf ( '@' ) ; return index >= 0 ? threadId . substring ( 0 , index ) : threadId ; } }
TestNG returns a compound thread ID that includes the thread name and its numeric ID separated by an at sign . We only want to use the thread name as the ID is mostly unimportant and it takes up too much space in the generated report .
151,495
public long getStartTime ( List < IInvokedMethod > methods ) { long startTime = System . currentTimeMillis ( ) ; for ( IInvokedMethod method : methods ) { startTime = Math . min ( startTime , method . getDate ( ) ) ; } return startTime ; }
Find the earliest start time of the specified methods .
151,496
private long getEndTime ( ISuite suite , IInvokedMethod method ) { for ( Map . Entry < String , ISuiteResult > entry : suite . getResults ( ) . entrySet ( ) ) { ITestContext testContext = entry . getValue ( ) . getTestContext ( ) ; for ( ITestNGMethod m : testContext . getAllTestMethods ( ) ) { if ( method == m ) { ret...
Returns the timestamp for the time at which the suite finished executing . This is determined by finding the latest end time for each of the individual tests in the suite .
151,497
public void waitForBuffer ( long timeoutMilli ) { synchronized ( buffer ) { if ( dirtyBuffer ) return ; if ( ! foundEOF ( ) ) { logger . trace ( "Waiting for things to come in, or until timeout" ) ; try { if ( timeoutMilli > 0 ) buffer . wait ( timeoutMilli ) ; else buffer . wait ( ) ; } catch ( InterruptedException ie...
What is something came in between when we last checked and when this method is called
151,498
public static void main ( String args [ ] ) throws Exception { final StringBuffer buffer = new StringBuffer ( "The lazy fox" ) ; Thread t1 = new Thread ( ) { public void run ( ) { synchronized ( buffer ) { buffer . delete ( 0 , 4 ) ; buffer . append ( " in the middle" ) ; System . err . println ( "Middle" ) ; try { Thr...
We have more input since wait started
151,499
protected void notifyBufferChange ( char [ ] newData , int numChars ) { synchronized ( bufferChangeLoggers ) { Iterator < BufferChangeLogger > iterator = bufferChangeLoggers . iterator ( ) ; while ( iterator . hasNext ( ) ) { iterator . next ( ) . bufferChanged ( newData , numChars ) ; } } }
Notifies all registered BufferChangeLogger instances of a change .