idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
148,300
private void countPropertyMain ( UsageStatistics usageStatistics , PropertyIdValue property , int count ) { addPropertyCounters ( usageStatistics , property ) ; usageStatistics . propertyCountsMain . put ( property , usageStatistics . propertyCountsMain . get ( property ) + count ) ; }
Counts additional occurrences of a property as the main property of statements .
148,301
private void addPropertyCounters ( UsageStatistics usageStatistics , PropertyIdValue property ) { if ( ! usageStatistics . propertyCountsMain . containsKey ( property ) ) { usageStatistics . propertyCountsMain . put ( property , 0 ) ; usageStatistics . propertyCountsQualifier . put ( property , 0 ) ; usageStatistics . ...
Initializes the counters for a property to zero if not done yet .
148,302
private void countKey ( Map < String , Integer > map , String key , int count ) { if ( map . containsKey ( key ) ) { map . put ( key , map . get ( key ) + count ) ; } else { map . put ( key , count ) ; } }
Helper method that stores in a hash map how often a certain key occurs . If the key has not been encountered yet a new entry is created for it in the map . Otherwise the existing value for the key is incremented .
148,303
public void addSite ( String siteKey ) { ValueMap gv = new ValueMap ( siteKey ) ; if ( ! this . valueMaps . contains ( gv ) ) { this . valueMaps . add ( gv ) ; } }
Registers a new site for specific data collection . If null is used as a site key then all data is collected .
148,304
private void countCoordinateStatement ( Statement statement , ItemDocument itemDocument ) { Value value = statement . getValue ( ) ; if ( ! ( value instanceof GlobeCoordinatesValue ) ) { return ; } GlobeCoordinatesValue coordsValue = ( GlobeCoordinatesValue ) value ; if ( ! this . globe . equals ( ( coordsValue . getGl...
Counts the coordinates stored in a single statement for the relevant property if they are actually given and valid .
148,305
private void countCoordinates ( int xCoord , int yCoord , ItemDocument itemDocument ) { for ( String siteKey : itemDocument . getSiteLinks ( ) . keySet ( ) ) { Integer count = this . siteCounts . get ( siteKey ) ; if ( count == null ) { this . siteCounts . put ( siteKey , 1 ) ; } else { this . siteCounts . put ( siteKe...
Counts a single pair of coordinates in all datasets .
148,306
private void writeImages ( ) { for ( ValueMap gv : this . valueMaps ) { gv . writeImage ( ) ; } try ( PrintStream out = new PrintStream ( ExampleHelpers . openExampleFileOuputStream ( "map-site-count.csv" ) ) ) { out . println ( "Site key,Number of geo items" ) ; out . println ( "wikidata total," + this . count ) ; for...
Writes image files for all data that was collected and the statistics file for all sites .
148,307
private int getColor ( int value ) { if ( value == 0 ) { return 0 ; } double scale = Math . log10 ( value ) / Math . log10 ( this . topValue ) ; double lengthScale = Math . min ( 1.0 , scale ) * ( colors . length - 1 ) ; int index = 1 + ( int ) lengthScale ; if ( index == colors . length ) { index -- ; } double partSca...
Returns a color for a given absolute number that is to be shown on the map .
148,308
public ReferenceBuilder withPropertyValue ( PropertyIdValue propertyIdValue , Value value ) { getSnakList ( propertyIdValue ) . add ( factory . getValueSnak ( propertyIdValue , value ) ) ; return getThis ( ) ; }
Adds the given property and value to the constructed reference .
148,309
private static void close ( Closeable closeable ) { if ( closeable != null ) { try { closeable . close ( ) ; } catch ( IOException ignored ) { logger . error ( "Failed to close output stream: " + ignored . getMessage ( ) ) ; } } }
Closes a Closeable and swallows any exceptions that might occur in the process .
148,310
public static void configureLogging ( ) { ConsoleAppender consoleAppender = new ConsoleAppender ( ) ; String pattern = "%d{yyyy-MM-dd HH:mm:ss} %-5p - %m%n" ; consoleAppender . setLayout ( new PatternLayout ( pattern ) ) ; consoleAppender . setThreshold ( Level . INFO ) ; consoleAppender . activateOptions ( ) ; Logger ...
Defines how messages should be logged . This method can be modified to restrict the logging messages that are shown on the console or to change their formatting . See the documentation of Log4J for details on how to do this .
148,311
public static void processEntitiesFromWikidataDump ( EntityDocumentProcessor entityDocumentProcessor ) { DumpProcessingController dumpProcessingController = new DumpProcessingController ( "wikidatawiki" ) ; dumpProcessingController . setOfflineMode ( OFFLINE_MODE ) ; boolean onlyCurrentRevisions ; switch ( DUMP_FILE_MO...
Processes all entities in a Wikidata dump using the given entity processor . By default the most recent JSON dump will be used . In offline mode only the most recent previously downloaded file is considered .
148,312
void addValue ( V value , Resource resource ) { this . valueQueue . add ( value ) ; this . valueSubjectQueue . add ( resource ) ; }
Adds the given value to the list of values that should still be serialized . The given RDF resource will be used as a subject .
148,313
protected void processAliases ( List < MonolingualTextValue > addAliases , List < MonolingualTextValue > deleteAliases ) { for ( MonolingualTextValue val : addAliases ) { addAlias ( val ) ; } for ( MonolingualTextValue val : deleteAliases ) { deleteAlias ( val ) ; } }
Processes changes on aliases updating the planned state of the item .
148,314
protected void deleteAlias ( MonolingualTextValue alias ) { String lang = alias . getLanguageCode ( ) ; AliasesWithUpdate currentAliases = newAliases . get ( lang ) ; if ( currentAliases != null ) { currentAliases . aliases . remove ( alias ) ; currentAliases . deleted . add ( alias ) ; currentAliases . write = true ; ...
Deletes an individual alias
148,315
protected void addAlias ( MonolingualTextValue alias ) { String lang = alias . getLanguageCode ( ) ; AliasesWithUpdate currentAliasesUpdate = newAliases . get ( lang ) ; NameWithUpdate currentLabel = newLabels . get ( lang ) ; if ( currentLabel == null ) { newLabels . put ( lang , new NameWithUpdate ( alias , true ) ) ...
Adds an individual alias . It will be merged with the current list of aliases or added as a label if there is no label for this item in this language yet .
148,316
protected void processDescriptions ( List < MonolingualTextValue > descriptions ) { for ( MonolingualTextValue description : descriptions ) { NameWithUpdate currentValue = newDescriptions . get ( description . getLanguageCode ( ) ) ; if ( currentValue == null || ! currentValue . value . equals ( description ) ) { newDe...
Adds descriptions to the item .
148,317
protected void processLabels ( List < MonolingualTextValue > labels ) { for ( MonolingualTextValue label : labels ) { String lang = label . getLanguageCode ( ) ; NameWithUpdate currentValue = newLabels . get ( lang ) ; if ( currentValue == null || ! currentValue . value . equals ( label ) ) { newLabels . put ( lang , n...
Adds labels to the item
148,318
@ JsonProperty ( "labels" ) @ JsonInclude ( Include . NON_EMPTY ) public Map < String , TermImpl > getLabelUpdates ( ) { return getMonolingualUpdatedValues ( newLabels ) ; }
Label accessor provided for JSON serialization only .
148,319
@ JsonProperty ( "descriptions" ) @ JsonInclude ( Include . NON_EMPTY ) public Map < String , TermImpl > getDescriptionUpdates ( ) { return getMonolingualUpdatedValues ( newDescriptions ) ; }
Description accessor provided for JSON serialization only .
148,320
@ JsonProperty ( "aliases" ) @ JsonInclude ( Include . NON_EMPTY ) public Map < String , List < TermImpl > > getAliasUpdates ( ) { Map < String , List < TermImpl > > updatedValues = new HashMap < > ( ) ; for ( Map . Entry < String , AliasesWithUpdate > entry : newAliases . entrySet ( ) ) { AliasesWithUpdate update = en...
Alias accessor provided for JSON serialization only
148,321
protected Map < String , TermImpl > getMonolingualUpdatedValues ( Map < String , NameWithUpdate > updates ) { Map < String , TermImpl > updatedValues = new HashMap < > ( ) ; for ( NameWithUpdate update : updates . values ( ) ) { if ( ! update . write ) { continue ; } updatedValues . put ( update . value . getLanguageCo...
Helper to format term updates as expected by the Wikibase API
148,322
protected RdfSerializer createRdfSerializer ( ) throws IOException { String outputDestinationFinal ; if ( this . outputDestination != null ) { outputDestinationFinal = this . outputDestination ; } else { outputDestinationFinal = "{PROJECT}" + this . taskName + "{DATE}" + ".nt" ; } OutputStream exportOutputStream = getO...
Creates a new RDF serializer based on the current configuration of this object .
148,323
private void setTasks ( String tasks ) { for ( String task : tasks . split ( "," ) ) { if ( KNOWN_TASKS . containsKey ( task ) ) { this . tasks |= KNOWN_TASKS . get ( task ) ; this . taskName += ( this . taskName . isEmpty ( ) ? "" : "-" ) + task ; } else { logger . warn ( "Unsupported RDF serialization task \"" + task...
Sets the RDF serialization tasks based on the given string value .
148,324
void resizeArray ( int newArraySize ) { long [ ] newArray = new long [ newArraySize ] ; System . arraycopy ( this . arrayOfBits , 0 , newArray , 0 , Math . min ( this . arrayOfBits . length , newArraySize ) ) ; this . arrayOfBits = newArray ; }
Resizes the array that represents this bit vector .
148,325
public ItemDocument updateStatements ( ItemIdValue itemIdValue , List < Statement > addStatements , List < Statement > deleteStatements , String summary ) throws MediaWikiApiErrorException , IOException { ItemDocument currentDocument = ( ItemDocument ) this . wikibaseDataFetcher . getEntityDocument ( itemIdValue . getI...
Updates the statements of the item document identified by the given item id . The updates are computed with respect to the current data found online making sure that no redundant deletions or duplicate insertions happen . The references of duplicate statements will be merged .
148,326
public ItemDocument updateTermsStatements ( ItemIdValue itemIdValue , List < MonolingualTextValue > addLabels , List < MonolingualTextValue > addDescriptions , List < MonolingualTextValue > addAliases , List < MonolingualTextValue > deleteAliases , List < Statement > addStatements , List < Statement > deleteStatements ...
Updates the terms and statements of the item document identified by the given item id . The updates are computed with respect to the current data found online making sure that no redundant deletions or duplicate insertions happen . The references of duplicate statements will be merged . The labels and aliases in a give...
148,327
@ SuppressWarnings ( "unchecked" ) public < T extends TermedStatementDocument > T updateTermsStatements ( T currentDocument , List < MonolingualTextValue > addLabels , List < MonolingualTextValue > addDescriptions , List < MonolingualTextValue > addAliases , List < MonolingualTextValue > deleteAliases , List < Statemen...
Updates the terms and statements of the current document . The updates are computed with respect to the current data in the document making sure that no redundant deletions or duplicate insertions happen . The references of duplicate statements will be merged . The labels and aliases in a given language are kept distin...
148,328
public < T extends StatementDocument > void nullEdit ( ItemIdValue itemId ) throws IOException , MediaWikiApiErrorException { ItemDocument currentDocument = ( ItemDocument ) this . wikibaseDataFetcher . getEntityDocument ( itemId . getId ( ) ) ; nullEdit ( currentDocument ) ; }
Performs a null edit on an item . This has some effects on Wikibase such as refreshing the labels of the referred items in the UI .
148,329
public < T extends StatementDocument > void nullEdit ( PropertyIdValue propertyId ) throws IOException , MediaWikiApiErrorException { PropertyDocument currentDocument = ( PropertyDocument ) this . wikibaseDataFetcher . getEntityDocument ( propertyId . getId ( ) ) ; nullEdit ( currentDocument ) ; }
Performs a null edit on a property . This has some effects on Wikibase such as refreshing the labels of the referred items in the UI .
148,330
@ SuppressWarnings ( "unchecked" ) public < T extends StatementDocument > T nullEdit ( T currentDocument ) throws IOException , MediaWikiApiErrorException { StatementUpdate statementUpdate = new StatementUpdate ( currentDocument , Collections . < Statement > emptyList ( ) , Collections . < Statement > emptyList ( ) ) ;...
Performs a null edit on an entity . This has some effects on Wikibase such as refreshing the labels of the referred items in the UI .
148,331
public static void main ( String [ ] args ) throws IOException { ExampleHelpers . configureLogging ( ) ; JsonSerializationProcessor . printDocumentation ( ) ; JsonSerializationProcessor jsonSerializationProcessor = new JsonSerializationProcessor ( ) ; ExampleHelpers . processEntitiesFromWikidataDump ( jsonSerialization...
Runs the example program .
148,332
public void close ( ) throws IOException { System . out . println ( "Serialized " + this . jsonSerializer . getEntityDocumentCount ( ) + " item documents to JSON file " + OUTPUT_FILE_NAME + "." ) ; this . jsonSerializer . close ( ) ; }
Closes the output . Should be called after the JSON serialization was finished .
148,333
private boolean includeDocument ( ItemDocument itemDocument ) { for ( StatementGroup sg : itemDocument . getStatementGroups ( ) ) { if ( ! "P19" . equals ( sg . getProperty ( ) . getId ( ) ) ) { continue ; } for ( Statement s : sg ) { if ( s . getMainSnak ( ) instanceof ValueSnak ) { Value v = s . getValue ( ) ; if ( v...
Returns true if the given document should be included in the serialization .
148,334
public static String insertDumpInformation ( String pattern , String dateStamp , String project ) { if ( pattern == null ) { return null ; } else { return pattern . replace ( "{DATE}" , dateStamp ) . replace ( "{PROJECT}" , project ) ; } }
Inserts the information about the dateStamp of a dump and the project name into a pattern .
148,335
private List < DumpProcessingAction > handleArguments ( String [ ] args ) { CommandLine cmd ; CommandLineParser parser = new GnuParser ( ) ; try { cmd = parser . parse ( options , args ) ; } catch ( ParseException e ) { logger . error ( "Failed to parse arguments: " + e . getMessage ( ) ) ; return Collections . emptyLi...
This function interprets the arguments of the main function . By doing this it will set flags for the dump generation . See in the help text for more specific information about the options .
148,336
private void handleGlobalArguments ( CommandLine cmd ) { if ( cmd . hasOption ( CMD_OPTION_DUMP_LOCATION ) ) { this . dumpDirectoryLocation = cmd . getOptionValue ( CMD_OPTION_DUMP_LOCATION ) ; } if ( cmd . hasOption ( CMD_OPTION_OFFLINE_MODE ) ) { this . offlineMode = true ; } if ( cmd . hasOption ( CMD_OPTION_QUIET )...
Analyses the command - line arguments which are relevant for the serialization process in general . It fills out the class arguments with this data .
148,337
private void handleGlobalArguments ( Section section ) { for ( String key : section . keySet ( ) ) { switch ( key ) { case OPTION_OFFLINE_MODE : if ( section . get ( key ) . toLowerCase ( ) . equals ( "true" ) ) { this . offlineMode = true ; } break ; case OPTION_QUIET : if ( section . get ( key ) . toLowerCase ( ) . e...
Analyses the content of the general section of an ini configuration file and fills out the class arguments with this data .
148,338
private void checkDuplicateStdOutOutput ( DumpProcessingAction newAction ) { if ( newAction . useStdOut ( ) ) { if ( this . quiet ) { logger . warn ( "Multiple actions are using stdout as output destination." ) ; } this . quiet = true ; } }
Checks if a newly created action wants to write output to stdout and logs a warning if other actions are doing the same .
148,339
private void setLanguageFilters ( String filters ) { this . filterLanguages = new HashSet < > ( ) ; if ( ! "-" . equals ( filters ) ) { Collections . addAll ( this . filterLanguages , filters . split ( "," ) ) ; } }
Sets the set of language filters based on the given string .
148,340
private void setSiteFilters ( String filters ) { this . filterSites = new HashSet < > ( ) ; if ( ! "-" . equals ( filters ) ) { Collections . addAll ( this . filterSites , filters . split ( "," ) ) ; } }
Sets the set of site filters based on the given string .
148,341
private void setPropertyFilters ( String filters ) { this . filterProperties = new HashSet < > ( ) ; if ( ! "-" . equals ( filters ) ) { for ( String pid : filters . split ( "," ) ) { this . filterProperties . add ( Datamodel . makeWikidataPropertyIdValue ( pid ) ) ; } } }
Sets the set of property filters based on the given string .
148,342
public void writeFinalResults ( ) { printStatus ( ) ; try ( PrintStream out = new PrintStream ( ExampleHelpers . openExampleFileOuputStream ( "gender-ratios.csv" ) ) ) { out . print ( "Site key,pages total,pages on humans,pages on humans with gender" ) ; for ( EntityIdValue gender : this . genderNamesList ) { out . pri...
Writes the results of the processing to a CSV file .
148,343
public static void printDocumentation ( ) { System . out . println ( "********************************************************************" ) ; System . out . println ( "*** Wikidata Toolkit: GenderRatioProcessor" ) ; System . out . println ( "*** " ) ; System . out . println ( "*** This program will download and proce...
Prints some basic documentation about this program .
148,344
private boolean containsValue ( StatementGroup statementGroup , Value value ) { for ( Statement s : statementGroup ) { if ( value . equals ( s . getValue ( ) ) ) { return true ; } } return false ; }
Checks if the given group of statements contains the given value as the value of a main snak of some statement .
148,345
private void addNewGenderName ( EntityIdValue entityIdValue , String name ) { this . genderNames . put ( entityIdValue , name ) ; this . genderNamesList . add ( entityIdValue ) ; }
Adds a new gender item and an initial name .
148,346
private SiteRecord getSiteRecord ( String siteKey ) { SiteRecord siteRecord = this . siteRecords . get ( siteKey ) ; if ( siteRecord == null ) { siteRecord = new SiteRecord ( siteKey ) ; this . siteRecords . put ( siteKey , siteRecord ) ; } return siteRecord ; }
Returns a site record for the site of the given name creating a new one if it does not exist yet .
148,347
private void countGender ( EntityIdValue gender , SiteRecord siteRecord ) { Integer curValue = siteRecord . genderCounts . get ( gender ) ; if ( curValue == null ) { siteRecord . genderCounts . put ( gender , 1 ) ; } else { siteRecord . genderCounts . put ( gender , curValue + 1 ) ; } }
Counts a single page of the specified gender . If this is the first page of that gender on this site a suitable key is added to the list of the site s genders .
148,348
public List < WbSearchEntitiesResult > wbSearchEntities ( String search , String language , Boolean strictLanguage , String type , Long limit , Long offset ) throws MediaWikiApiErrorException { Map < String , String > parameters = new HashMap < String , String > ( ) ; parameters . put ( ApiConnection . PARAM_ACTION , "...
Executes the API action wbsearchentity for the given parameters . Searches for entities using labels and aliases . Returns a label and description for the entity in the user language if possible . Returns details of the matched term . The matched term text is also present in the aliases key if different from the displa...
148,349
public ItemDocumentBuilder withSiteLink ( String title , String siteKey , ItemIdValue ... badges ) { withSiteLink ( factory . getSiteLink ( title , siteKey , Arrays . asList ( badges ) ) ) ; return this ; }
Adds an additional site link to the constructed document .
148,350
public Resource addReference ( Reference reference ) { Resource resource = this . rdfWriter . getUri ( Vocabulary . getReferenceUri ( reference ) ) ; this . referenceQueue . add ( reference ) ; this . referenceSubjectQueue . add ( resource ) ; return resource ; }
Adds the given reference to the list of references that should still be serialized and returns the RDF resource that will be used as a subject .
148,351
public void writeReferences ( ) throws RDFHandlerException { Iterator < Reference > referenceIterator = this . referenceQueue . iterator ( ) ; for ( Resource resource : this . referenceSubjectQueue ) { final Reference reference = referenceIterator . next ( ) ; if ( this . declaredReferences . add ( resource ) ) { write...
Writes references that have been added recently . Auxiliary triples that are generated for serializing snaks in references will be written right afterwards . This will also trigger any other auxiliary triples to be written that the snak converter object may have buffered .
148,352
public Sites getSitesInformation ( ) throws IOException { MwDumpFile sitesTableDump = getMostRecentDump ( DumpContentType . SITES ) ; if ( sitesTableDump == null ) { return null ; } MwSitesDumpFileProcessor sitesDumpFileProcessor = new MwSitesDumpFileProcessor ( ) ; sitesDumpFileProcessor . processDumpFileContents ( si...
Processes the most recent dump of the sites table to extract information about registered sites .
148,353
public void processMostRecentDump ( DumpContentType dumpContentType , MwDumpFileProcessor dumpFileProcessor ) { MwDumpFile dumpFile = getMostRecentDump ( dumpContentType ) ; if ( dumpFile != null ) { processDumpFile ( dumpFile , dumpFileProcessor ) ; } }
Processes the most recent dump of the given type using the given dump processor .
148,354
void processDumpFile ( MwDumpFile dumpFile , MwDumpFileProcessor dumpFileProcessor ) { try ( InputStream inputStream = dumpFile . getDumpFileStream ( ) ) { dumpFileProcessor . processDumpFileContents ( inputStream , dumpFile ) ; } catch ( FileAlreadyExistsException e ) { logger . error ( "Dump file " + dumpFile . toStr...
Processes one dump file with the given dump file processor handling exceptions appropriately .
148,355
public MwDumpFile findMostRecentDump ( DumpContentType dumpContentType ) { List < MwDumpFile > dumps = findAllDumps ( dumpContentType ) ; for ( MwDumpFile dump : dumps ) { if ( dump . isAvailable ( ) ) { return dump ; } } return null ; }
Finds the most recent dump of the given type that is actually available .
148,356
List < MwDumpFile > mergeDumpLists ( List < MwDumpFile > localDumps , List < MwDumpFile > onlineDumps ) { List < MwDumpFile > result = new ArrayList < > ( localDumps ) ; HashSet < String > localDateStamps = new HashSet < > ( ) ; for ( MwDumpFile dumpFile : localDumps ) { localDateStamps . add ( dumpFile . getDateStamp ...
Merges a list of local and online dumps . For dumps available both online and locally only the local version is included . The list is order with most recent dump date first .
148,357
List < MwDumpFile > findDumpsLocally ( DumpContentType dumpContentType ) { String directoryPattern = WmfDumpFile . getDumpFileDirectoryName ( dumpContentType , "*" ) ; List < String > dumpFileDirectories ; try { dumpFileDirectories = this . dumpfileDirectoryManager . getSubdirectories ( directoryPattern ) ; } catch ( I...
Finds out which dump files of the given type have been downloaded already . The result is a list of objects that describe the available dump files in descending order by their date . Not all of the dumps included might be actually available .
148,358
List < MwDumpFile > findDumpsOnline ( DumpContentType dumpContentType ) { List < String > dumpFileDates = findDumpDatesOnline ( dumpContentType ) ; List < MwDumpFile > result = new ArrayList < > ( ) ; for ( String dateStamp : dumpFileDates ) { if ( dumpContentType == DumpContentType . DAILY ) { result . add ( new WmfOn...
Finds out which dump files of the given type are available for download . The result is a list of objects that describe the available dump files in descending order by their date . Not all of the dumps included might be actually available .
148,359
public void processItemDocument ( ItemDocument itemDocument ) { this . countItems ++ ; if ( this . countItems < 10 ) { System . out . println ( itemDocument ) ; } else if ( this . countItems == 10 ) { System . out . println ( "*** I won't print any further items.\n" + "*** We will never finish if we print all the items...
Processes one item document . This is often the main workhorse that gathers the data you are interested in . You can modify this code as you wish .
148,360
static EntityIdValue fromId ( String id , String siteIri ) { switch ( guessEntityTypeFromId ( id ) ) { case EntityIdValueImpl . JSON_ENTITY_TYPE_ITEM : return new ItemIdValueImpl ( id , siteIri ) ; case EntityIdValueImpl . JSON_ENTITY_TYPE_PROPERTY : return new PropertyIdValueImpl ( id , siteIri ) ; case EntityIdValueI...
Parses an item id
148,361
static String guessEntityTypeFromId ( String id ) { if ( id . isEmpty ( ) ) { throw new IllegalArgumentException ( "Entity ids should not be empty." ) ; } switch ( id . charAt ( 0 ) ) { case 'L' : if ( id . contains ( "-F" ) ) { return JSON_ENTITY_TYPE_FORM ; } else if ( id . contains ( "-S" ) ) { return JSON_ENTITY_TY...
RReturns the entity type of the id like item or property
148,362
public void close ( ) { logger . info ( "Finished processing." ) ; this . timer . stop ( ) ; this . lastSeconds = ( int ) ( timer . getTotalWallTime ( ) / 1000000000 ) ; printStatus ( ) ; }
Stops the processing and prints the final time .
148,363
private void countEntity ( ) { if ( ! this . timer . isRunning ( ) ) { startTimer ( ) ; } this . entityCount ++ ; if ( this . entityCount % 100 == 0 ) { timer . stop ( ) ; int seconds = ( int ) ( timer . getTotalWallTime ( ) / 1000000000 ) ; if ( seconds >= this . lastSeconds + this . reportInterval ) { this . lastSeco...
Counts one entity . Every once in a while the current time is checked so as to print an intermediate report roughly every ten seconds .
148,364
public static String implodeObjects ( Iterable < ? > objects ) { StringBuilder builder = new StringBuilder ( ) ; boolean first = true ; for ( Object o : objects ) { if ( first ) { first = false ; } else { builder . append ( "|" ) ; } builder . append ( o . toString ( ) ) ; } return builder . toString ( ) ; }
Builds a string that serializes a list of objects separated by the pipe character . The toString methods are used to turn objects into strings . This operation is commonly used to build parameter lists for API requests .
148,365
public void logout ( ) throws IOException { if ( this . loggedIn ) { Map < String , String > params = new HashMap < > ( ) ; params . put ( "action" , "logout" ) ; params . put ( "format" , "json" ) ; try { sendJsonRequest ( "POST" , params ) ; } catch ( MediaWikiApiErrorException e ) { throw new IOException ( e . getMe...
Logs the current user out .
148,366
String fetchToken ( String tokenType ) throws IOException , MediaWikiApiErrorException { Map < String , String > params = new HashMap < > ( ) ; params . put ( ApiConnection . PARAM_ACTION , "query" ) ; params . put ( "meta" , "tokens" ) ; params . put ( "type" , tokenType ) ; try { JsonNode root = this . sendJsonReques...
Executes a API query action to get a new token . The method only executes the action without doing any checks first . If errors occur they are logged and null is returned .
148,367
public InputStream sendRequest ( String requestMethod , Map < String , String > parameters ) throws IOException { String queryString = getQueryString ( parameters ) ; URL url = new URL ( this . apiBaseUrl ) ; HttpURLConnection connection = ( HttpURLConnection ) WebResourceFetcherImpl . getUrlConnection ( url ) ; setupC...
Sends a request to the API with the given parameters and the given request method and returns the result string . It automatically fills the cookie map with cookies in the result header after the request .
148,368
List < String > getWarnings ( JsonNode root ) { ArrayList < String > warnings = new ArrayList < > ( ) ; if ( root . has ( "warnings" ) ) { JsonNode warningNode = root . path ( "warnings" ) ; Iterator < Map . Entry < String , JsonNode > > moduleIterator = warningNode . fields ( ) ; while ( moduleIterator . hasNext ( ) )...
Extracts warnings that are returned in an API response .
148,369
String getQueryString ( Map < String , String > params ) { StringBuilder builder = new StringBuilder ( ) ; try { boolean first = true ; for ( Map . Entry < String , String > entry : params . entrySet ( ) ) { if ( first ) { first = false ; } else { builder . append ( "&" ) ; } builder . append ( URLEncoder . encode ( en...
Returns the query string of a URL from a parameter list .
148,370
public static < T > T load ( String resourcePath , BeanSpec spec ) { return load ( resourcePath , spec , false ) ; }
Load resource content from given path into variable with type specified by spec .
148,371
protected void printCenter ( String format , Object ... args ) { String text = S . fmt ( format , args ) ; info ( S . center ( text , 80 ) ) ; }
Print formatted string in the center of 80 chars line left and right padded .
148,372
protected void printCenterWithLead ( String lead , String format , Object ... args ) { String text = S . fmt ( format , args ) ; int len = 80 - lead . length ( ) ; info ( S . concat ( lead , S . center ( text , len ) ) ) ; }
Print the lead string followed by centered formatted string . The whole length of the line is 80 chars .
148,373
public String convert ( BufferedImage image , boolean favicon ) { statsArray = new int [ 12 ] ; dStart = System . nanoTime ( ) ; image = scale ( image , favicon ) ; StringBuilder sb = new StringBuilder ( ( image . getWidth ( ) + 1 ) * image . getHeight ( ) ) ; for ( int y = 0 ; y < image . getHeight ( ) ; y ++ ) { if (...
The main conversion method .
148,374
private static BufferedImage scale ( BufferedImage imageToScale , int dWidth , int dHeight , double fWidth , double fHeight ) { BufferedImage dbi = null ; int imageType = imageToScale . getType ( ) ; if ( imageToScale != null ) { dbi = new BufferedImage ( dWidth , dHeight , imageType ) ; Graphics2D g = dbi . createGrap...
Image scale method
148,375
public EventBus emit ( Enum < ? > event , Object ... args ) { return _emitWithOnceBus ( eventContext ( event , args ) ) ; }
Emit an enum event with parameters supplied .
148,376
public EventBus emit ( String event , Object ... args ) { return _emitWithOnceBus ( eventContext ( event , args ) ) ; }
Emit a string event with parameters .
148,377
public EventBus emit ( EventObject event , Object ... args ) { return _emitWithOnceBus ( eventContext ( event , args ) ) ; }
Emit an event object with parameters .
148,378
public EventBus emitAsync ( Enum < ? > event , Object ... args ) { return _emitWithOnceBus ( eventContextAsync ( event , args ) ) ; }
Emit an enum event with parameters and force all listeners to be called asynchronously .
148,379
public EventBus emitAsync ( String event , Object ... args ) { return _emitWithOnceBus ( eventContextAsync ( event , args ) ) ; }
Emit a string event with parameters and force all listeners to be called asynchronously .
148,380
public EventBus emitAsync ( EventObject event , Object ... args ) { return _emitWithOnceBus ( eventContextAsync ( event , args ) ) ; }
Emit a event object with parameters and force all listeners to be called asynchronously .
148,381
public EventBus emitSync ( Enum < ? > event , Object ... args ) { return _emitWithOnceBus ( eventContextSync ( event , args ) ) ; }
Emit an enum event with parameters and force all listener to be called synchronously .
148,382
public EventBus emitSync ( String event , Object ... args ) { return _emitWithOnceBus ( eventContextSync ( event , args ) ) ; }
Emit a string event with parameters and force all listener to be called synchronously .
148,383
public EventBus emitSync ( EventObject event , Object ... args ) { return _emitWithOnceBus ( eventContextSync ( event , args ) ) ; }
Emit a event object with parameters and force all listeners to be called synchronously .
148,384
public static String common ( ) { String common = SysProps . get ( KEY_COMMON_CONF_TAG ) ; if ( S . blank ( common ) ) { common = "common" ; } return common ; }
Return the common configuration set name . By default it is common
148,385
public static String confSetName ( ) { String profile = SysProps . get ( AppConfigKey . PROFILE . key ( ) ) ; if ( S . blank ( profile ) ) { profile = Act . mode ( ) . name ( ) . toLowerCase ( ) ; } return profile ; }
Return the name of the current conf set
148,386
private static Map < String , Object > processConf ( Map < String , ? > conf ) { Map < String , Object > m = new HashMap < String , Object > ( conf . size ( ) ) ; for ( String s : conf . keySet ( ) ) { Object o = conf . get ( s ) ; if ( s . startsWith ( "act." ) ) s = s . substring ( 4 ) ; m . put ( s , o ) ; m . put (...
trim act . from conf keys
148,387
public File curDir ( ) { File file = session ( ) . attribute ( ATTR_PWD ) ; if ( null == file ) { file = new File ( System . getProperty ( "user.dir" ) ) ; session ( ) . attribute ( ATTR_PWD , file ) ; } return file ; }
Return the current working directory
148,388
private String getRowLineBuf ( int colCount , List < Integer > colMaxLenList , String [ ] [ ] data ) { S . Buffer rowBuilder = S . buffer ( ) ; int colWidth ; for ( int i = 0 ; i < colCount ; i ++ ) { colWidth = colMaxLenList . get ( i ) + 3 ; for ( int j = 0 ; j < colWidth ; j ++ ) { if ( j == 0 ) { rowBuilder . appen...
Each string item rendering requires the border and a space on both sides .
148,389
public byte [ ] toByteArray ( ) { try { ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ; ObjectOutputStream oos = new ObjectOutputStream ( baos ) ; oos . writeObject ( this ) ; return baos . toByteArray ( ) ; } catch ( IOException e ) { throw E . ioException ( e ) ; } }
Serialize this AppDescriptor and output byte array
148,390
public static AppDescriptor of ( String appName , Class < ? > entryClass ) { System . setProperty ( "osgl.version.suppress-var-found-warning" , "true" ) ; return of ( appName , entryClass , Version . of ( entryClass ) ) ; }
Create an AppDescriptor with appName and entry class specified .
148,391
public static AppDescriptor of ( String appName , String packageName ) { String [ ] packages = packageName . split ( S . COMMON_SEP ) ; return of ( appName , packageName , Version . ofPackage ( packages [ 0 ] ) ) ; }
Create an AppDescriptor with appName and package name specified
148,392
public static AppDescriptor deserializeFrom ( byte [ ] bytes ) { try { ByteArrayInputStream bais = new ByteArrayInputStream ( bytes ) ; ObjectInputStream ois = new ObjectInputStream ( bais ) ; return ( AppDescriptor ) ois . readObject ( ) ; } catch ( IOException e ) { throw E . ioException ( e ) ; } catch ( ClassNotFou...
Deserialize an AppDescriptor from byte array
148,393
static String from ( Class < ? > entryClass ) { List < String > tokens = tokenOf ( entryClass ) ; return fromTokens ( tokens ) ; }
Infer app name from entry class
148,394
static String fromPackageName ( String packageName ) { List < String > tokens = tokenOf ( packageName ) ; return fromTokens ( tokens ) ; }
Infer app name from scan package
148,395
public static String nextWord ( String string ) { int index = 0 ; while ( index < string . length ( ) && ! Character . isWhitespace ( string . charAt ( index ) ) ) { index ++ ; } return string . substring ( 0 , index ) ; }
Return the next word of the string in other words it stops when a space is encountered .
148,396
private final String getHeader ( Map headers , String name ) { return ( String ) headers . get ( name . toLowerCase ( ) ) ; }
Returns the header with the specified name from the supplied map . The header lookup is case - insensitive .
148,397
public ProgressBar stop ( ) { target . kill ( ) ; try { thread . join ( ) ; target . consoleStream . print ( "\n" ) ; target . consoleStream . flush ( ) ; } catch ( InterruptedException ex ) { } return this ; }
Stops this progress bar .
148,398
public synchronized List < String > propertyListOf ( Class < ? > c ) { String cn = c . getName ( ) ; List < String > ls = repo . get ( cn ) ; if ( ls != null ) { return ls ; } Set < Class < ? > > circularReferenceDetector = new HashSet < > ( ) ; ls = propertyListOf ( c , circularReferenceDetector , null ) ; repo . put ...
Returns the complete property list of a class
148,399
public ClassNode parent ( String name ) { this . parent = infoBase . node ( name ) ; this . parent . addChild ( this ) ; for ( ClassNode intf : parent . interfaces . values ( ) ) { addInterface ( intf ) ; } return this ; }
Specify the class represented by this ClassNode extends a class with the name specified