_id stringlengths 2 7 | title stringlengths 3 140 | partition stringclasses 3
values | text stringlengths 73 34.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q4900 | TermStatementUpdate.addAlias | train | protected void addAlias(MonolingualTextValue alias) {
String lang = alias.getLanguageCode();
AliasesWithUpdate currentAliasesUpdate = newAliases.get(lang);
NameWithUpdate currentLabel = newLabels.get(lang);
// If there isn't any label for that language, put the alias there
if (currentLabel == null) {
newLabels.put(lang, new NameWithUpdate(alias, true));
// If the new alias is equal to the current label, skip it
} else if (!currentLabel.value.equals(alias)) {
if (currentAliasesUpdate == null) {
currentAliasesUpdate = new AliasesWithUpdate(new ArrayList<MonolingualTextValue>(), true);
}
List<MonolingualTextValue> currentAliases = currentAliasesUpdate.aliases;
if(!currentAliases.contains(alias)) {
currentAliases.add(alias);
currentAliasesUpdate.added.add(alias);
currentAliasesUpdate.write = true;
}
newAliases.put(lang, currentAliasesUpdate);
}
} | java | {
"resource": ""
} |
q4901 | TermStatementUpdate.processDescriptions | train | protected void processDescriptions(List<MonolingualTextValue> descriptions) {
for(MonolingualTextValue description : descriptions) {
NameWithUpdate currentValue = newDescriptions.get(description.getLanguageCode());
// only mark the description as added if the value we are writing is different from the current one
if (currentValue == null || !currentValue.value.equals(description)) {
newDescriptions.put(description.getLanguageCode(),
new NameWithUpdate(description, true));
}
}
} | java | {
"resource": ""
} |
q4902 | TermStatementUpdate.processLabels | train | 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,
new NameWithUpdate(label, true));
// Delete any alias that matches the new label
AliasesWithUpdate currentAliases = newAliases.get(lang);
if (currentAliases != null && currentAliases.aliases.contains(label)) {
deleteAlias(label);
}
}
}
} | java | {
"resource": ""
} |
q4903 | TermStatementUpdate.getLabelUpdates | train | @JsonProperty("labels")
@JsonInclude(Include.NON_EMPTY)
public Map<String, TermImpl> getLabelUpdates() {
return getMonolingualUpdatedValues(newLabels);
} | java | {
"resource": ""
} |
q4904 | TermStatementUpdate.getDescriptionUpdates | train | @JsonProperty("descriptions")
@JsonInclude(Include.NON_EMPTY)
public Map<String, TermImpl> getDescriptionUpdates() {
return getMonolingualUpdatedValues(newDescriptions);
} | java | {
"resource": ""
} |
q4905 | TermStatementUpdate.getAliasUpdates | train | @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 = entry.getValue();
if (!update.write) {
continue;
}
List<TermImpl> convertedAliases = new ArrayList<>();
for(MonolingualTextValue alias : update.aliases) {
convertedAliases.add(monolingualToJackson(alias));
}
updatedValues.put(entry.getKey(), convertedAliases);
}
return updatedValues;
} | java | {
"resource": ""
} |
q4906 | TermStatementUpdate.getMonolingualUpdatedValues | train | 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.getLanguageCode(), monolingualToJackson(update.value));
}
return updatedValues;
} | java | {
"resource": ""
} |
q4907 | RdfSerializationAction.createRdfSerializer | train | protected RdfSerializer createRdfSerializer() throws IOException {
String outputDestinationFinal;
if (this.outputDestination != null) {
outputDestinationFinal = this.outputDestination;
} else {
outputDestinationFinal = "{PROJECT}" + this.taskName + "{DATE}"
+ ".nt";
}
OutputStream exportOutputStream = getOutputStream(this.useStdOut,
insertDumpInformation(outputDestinationFinal),
this.compressionType);
RdfSerializer serializer = new RdfSerializer(RDFFormat.NTRIPLES,
exportOutputStream, this.sites,
PropertyRegister.getWikidataPropertyRegister());
serializer.setTasks(this.tasks);
return serializer;
} | java | {
"resource": ""
} |
q4908 | RdfSerializationAction.setTasks | train | 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
+ "\". Run without specifying any tasks for help.");
}
}
} | java | {
"resource": ""
} |
q4909 | BitVectorImpl.resizeArray | train | 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;
} | java | {
"resource": ""
} |
q4910 | WikibaseDataEditor.updateStatements | train | public ItemDocument updateStatements(ItemIdValue itemIdValue,
List<Statement> addStatements, List<Statement> deleteStatements,
String summary) throws MediaWikiApiErrorException, IOException {
ItemDocument currentDocument = (ItemDocument) this.wikibaseDataFetcher
.getEntityDocument(itemIdValue.getId());
return updateStatements(currentDocument, addStatements,
deleteStatements, summary);
} | java | {
"resource": ""
} |
q4911 | WikibaseDataEditor.updateTermsStatements | train | public ItemDocument updateTermsStatements(ItemIdValue itemIdValue,
List<MonolingualTextValue> addLabels,
List<MonolingualTextValue> addDescriptions,
List<MonolingualTextValue> addAliases,
List<MonolingualTextValue> deleteAliases,
List<Statement> addStatements,
List<Statement> deleteStatements,
String summary) throws MediaWikiApiErrorException, IOException {
ItemDocument currentDocument = (ItemDocument) this.wikibaseDataFetcher
.getEntityDocument(itemIdValue.getId());
return updateTermsStatements(currentDocument, addLabels,
addDescriptions, addAliases, deleteAliases,
addStatements, deleteStatements, summary);
} | java | {
"resource": ""
} |
q4912 | WikibaseDataEditor.updateTermsStatements | train | @SuppressWarnings("unchecked")
public <T extends TermedStatementDocument> T updateTermsStatements(T currentDocument,
List<MonolingualTextValue> addLabels,
List<MonolingualTextValue> addDescriptions,
List<MonolingualTextValue> addAliases,
List<MonolingualTextValue> deleteAliases,
List<Statement> addStatements, List<Statement> deleteStatements,
String summary) throws MediaWikiApiErrorException, IOException {
TermStatementUpdate termStatementUpdate = new TermStatementUpdate(
currentDocument,
addStatements, deleteStatements,
addLabels, addDescriptions, addAliases, deleteAliases);
termStatementUpdate.setGuidGenerator(guidGenerator);
return (T) termStatementUpdate.performEdit(wbEditingAction, editAsBot, summary);
} | java | {
"resource": ""
} |
q4913 | WikibaseDataEditor.nullEdit | train | public <T extends StatementDocument> void nullEdit(ItemIdValue itemId)
throws IOException, MediaWikiApiErrorException {
ItemDocument currentDocument = (ItemDocument) this.wikibaseDataFetcher
.getEntityDocument(itemId.getId());
nullEdit(currentDocument);
} | java | {
"resource": ""
} |
q4914 | WikibaseDataEditor.nullEdit | train | public <T extends StatementDocument> void nullEdit(PropertyIdValue propertyId)
throws IOException, MediaWikiApiErrorException {
PropertyDocument currentDocument = (PropertyDocument) this.wikibaseDataFetcher
.getEntityDocument(propertyId.getId());
nullEdit(currentDocument);
} | java | {
"resource": ""
} |
q4915 | WikibaseDataEditor.nullEdit | train | @SuppressWarnings("unchecked")
public <T extends StatementDocument> T nullEdit(T currentDocument)
throws IOException, MediaWikiApiErrorException {
StatementUpdate statementUpdate = new StatementUpdate(currentDocument,
Collections.<Statement>emptyList(), Collections.<Statement>emptyList());
statementUpdate.setGuidGenerator(guidGenerator);
return (T) this.wbEditingAction.wbEditEntity(currentDocument
.getEntityId().getId(), null, null, null, statementUpdate
.getJsonUpdateString(), false, this.editAsBot, currentDocument
.getRevisionId(), null);
} | java | {
"resource": ""
} |
q4916 | JsonSerializationProcessor.main | train | public static void main(String[] args) throws IOException {
ExampleHelpers.configureLogging();
JsonSerializationProcessor.printDocumentation();
JsonSerializationProcessor jsonSerializationProcessor = new JsonSerializationProcessor();
ExampleHelpers.processEntitiesFromWikidataDump(jsonSerializationProcessor);
jsonSerializationProcessor.close();
} | java | {
"resource": ""
} |
q4917 | JsonSerializationProcessor.close | train | public void close() throws IOException {
System.out.println("Serialized "
+ this.jsonSerializer.getEntityDocumentCount()
+ " item documents to JSON file " + OUTPUT_FILE_NAME + ".");
this.jsonSerializer.close();
} | java | {
"resource": ""
} |
q4918 | JsonSerializationProcessor.includeDocument | train | private boolean includeDocument(ItemDocument itemDocument) {
for (StatementGroup sg : itemDocument.getStatementGroups()) {
// "P19" is "place of birth" on Wikidata
if (!"P19".equals(sg.getProperty().getId())) {
continue;
}
for (Statement s : sg) {
if (s.getMainSnak() instanceof ValueSnak) {
Value v = s.getValue();
// "Q1731" is "Dresden" on Wikidata
if (v instanceof ItemIdValue
&& "Q1731".equals(((ItemIdValue) v).getId())) {
return true;
}
}
}
}
return false;
} | java | {
"resource": ""
} |
q4919 | ClientConfiguration.insertDumpInformation | train | public static String insertDumpInformation(String pattern,
String dateStamp, String project) {
if (pattern == null) {
return null;
} else {
return pattern.replace("{DATE}", dateStamp).replace("{PROJECT}",
project);
}
} | java | {
"resource": ""
} |
q4920 | ClientConfiguration.handleArguments | train | 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.emptyList();
}
// Stop processing if a help text is to be printed:
if ((cmd.hasOption(CMD_OPTION_HELP)) || (args.length == 0)) {
return Collections.emptyList();
}
List<DumpProcessingAction> configuration = new ArrayList<>();
handleGlobalArguments(cmd);
if (cmd.hasOption(CMD_OPTION_ACTION)) {
DumpProcessingAction action = handleActionArguments(cmd);
if (action != null) {
configuration.add(action);
}
}
if (cmd.hasOption(CMD_OPTION_CONFIG_FILE)) {
try {
List<DumpProcessingAction> configFile = readConfigFile(cmd
.getOptionValue(CMD_OPTION_CONFIG_FILE));
configuration.addAll(configFile);
} catch (IOException e) {
logger.error("Failed to read configuration file \""
+ cmd.getOptionValue(CMD_OPTION_CONFIG_FILE) + "\": "
+ e.toString());
}
}
return configuration;
} | java | {
"resource": ""
} |
q4921 | ClientConfiguration.handleGlobalArguments | train | 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)) {
this.quiet = true;
}
if (cmd.hasOption(CMD_OPTION_CREATE_REPORT)) {
this.reportFilename = cmd.getOptionValue(CMD_OPTION_CREATE_REPORT);
}
if (cmd.hasOption(OPTION_FILTER_LANGUAGES)) {
setLanguageFilters(cmd.getOptionValue(OPTION_FILTER_LANGUAGES));
}
if (cmd.hasOption(OPTION_FILTER_SITES)) {
setSiteFilters(cmd.getOptionValue(OPTION_FILTER_SITES));
}
if (cmd.hasOption(OPTION_FILTER_PROPERTIES)) {
setPropertyFilters(cmd.getOptionValue(OPTION_FILTER_PROPERTIES));
}
if (cmd.hasOption(CMD_OPTION_LOCAL_DUMPFILE)) {
this.inputDumpLocation = cmd.getOptionValue(OPTION_LOCAL_DUMPFILE);
}
} | java | {
"resource": ""
} |
q4922 | ClientConfiguration.handleGlobalArguments | train | 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().equals("true")) {
this.quiet = true;
}
break;
case OPTION_CREATE_REPORT:
this.reportFilename = section.get(key);
break;
case OPTION_DUMP_LOCATION:
this.dumpDirectoryLocation = section.get(key);
break;
case OPTION_FILTER_LANGUAGES:
setLanguageFilters(section.get(key));
break;
case OPTION_FILTER_SITES:
setSiteFilters(section.get(key));
break;
case OPTION_FILTER_PROPERTIES:
setPropertyFilters(section.get(key));
break;
case OPTION_LOCAL_DUMPFILE:
this.inputDumpLocation = section.get(key);
break;
default:
logger.warn("Unrecognized option: " + key);
}
}
} | java | {
"resource": ""
} |
q4923 | ClientConfiguration.checkDuplicateStdOutOutput | train | private void checkDuplicateStdOutOutput(DumpProcessingAction newAction) {
if (newAction.useStdOut()) {
if (this.quiet) {
logger.warn("Multiple actions are using stdout as output destination.");
}
this.quiet = true;
}
} | java | {
"resource": ""
} |
q4924 | ClientConfiguration.setLanguageFilters | train | private void setLanguageFilters(String filters) {
this.filterLanguages = new HashSet<>();
if (!"-".equals(filters)) {
Collections.addAll(this.filterLanguages, filters.split(","));
}
} | java | {
"resource": ""
} |
q4925 | ClientConfiguration.setSiteFilters | train | private void setSiteFilters(String filters) {
this.filterSites = new HashSet<>();
if (!"-".equals(filters)) {
Collections.addAll(this.filterSites, filters.split(","));
}
} | java | {
"resource": ""
} |
q4926 | ClientConfiguration.setPropertyFilters | train | private void setPropertyFilters(String filters) {
this.filterProperties = new HashSet<>();
if (!"-".equals(filters)) {
for (String pid : filters.split(",")) {
this.filterProperties.add(Datamodel
.makeWikidataPropertyIdValue(pid));
}
}
} | java | {
"resource": ""
} |
q4927 | GenderRatioProcessor.writeFinalResults | train | 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.print("," + this.genderNames.get(gender) + " ("
+ gender.getId() + ")");
}
out.println();
List<SiteRecord> siteRecords = new ArrayList<>(
this.siteRecords.values());
Collections.sort(siteRecords, new SiteRecordComparator());
for (SiteRecord siteRecord : siteRecords) {
out.print(siteRecord.siteKey + "," + siteRecord.pageCount + ","
+ siteRecord.humanPageCount + ","
+ siteRecord.humanGenderPageCount);
for (EntityIdValue gender : this.genderNamesList) {
if (siteRecord.genderCounts.containsKey(gender)) {
out.print("," + siteRecord.genderCounts.get(gender));
} else {
out.print(",0");
}
}
out.println();
}
} catch (IOException e) {
e.printStackTrace();
}
} | java | {
"resource": ""
} |
q4928 | GenderRatioProcessor.printDocumentation | train | public static void printDocumentation() {
System.out
.println("********************************************************************");
System.out.println("*** Wikidata Toolkit: GenderRatioProcessor");
System.out.println("*** ");
System.out
.println("*** This program will download and process dumps from Wikidata.");
System.out
.println("*** It will compute the numbers of articles about humans across");
System.out
.println("*** Wikimedia projects, and in particular it will count the articles");
System.out
.println("*** for each sex/gender. Results will be stored in a CSV file.");
System.out.println("*** See source code for further details.");
System.out
.println("********************************************************************");
} | java | {
"resource": ""
} |
q4929 | GenderRatioProcessor.containsValue | train | private boolean containsValue(StatementGroup statementGroup, Value value) {
for (Statement s : statementGroup) {
if (value.equals(s.getValue())) {
return true;
}
}
return false;
} | java | {
"resource": ""
} |
q4930 | GenderRatioProcessor.addNewGenderName | train | private void addNewGenderName(EntityIdValue entityIdValue, String name) {
this.genderNames.put(entityIdValue, name);
this.genderNamesList.add(entityIdValue);
} | java | {
"resource": ""
} |
q4931 | GenderRatioProcessor.getSiteRecord | train | 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;
} | java | {
"resource": ""
} |
q4932 | GenderRatioProcessor.countGender | train | 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);
}
} | java | {
"resource": ""
} |
q4933 | WbSearchEntitiesAction.wbSearchEntities | train | 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, "wbsearchentities");
if (search != null) {
parameters.put("search", search);
} else {
throw new IllegalArgumentException(
"Search parameter must be specified for this action.");
}
if (language != null) {
parameters.put("language", language);
} else {
throw new IllegalArgumentException(
"Language parameter must be specified for this action.");
}
if (strictLanguage != null) {
parameters.put("strictlanguage", Boolean.toString(strictLanguage));
}
if (type != null) {
parameters.put("type", type);
}
if (limit != null) {
parameters.put("limit", Long.toString(limit));
}
if (offset != null) {
parameters.put("continue", Long.toString(offset));
}
List<WbSearchEntitiesResult> results = new ArrayList<>();
try {
JsonNode root = this.connection.sendJsonRequest("POST", parameters);
JsonNode entities = root.path("search");
for (JsonNode entityNode : entities) {
try {
JacksonWbSearchEntitiesResult ed = mapper.treeToValue(entityNode,
JacksonWbSearchEntitiesResult.class);
results.add(ed);
} catch (JsonProcessingException e) {
LOGGER.error("Error when reading JSON for entity "
+ entityNode.path("id").asText("UNKNOWN") + ": "
+ e.toString());
}
}
} catch (IOException e) {
LOGGER.error("Could not retrive data: " + e.toString());
}
return results;
} | java | {
"resource": ""
} |
q4934 | ItemDocumentBuilder.withSiteLink | train | public ItemDocumentBuilder withSiteLink(String title, String siteKey,
ItemIdValue... badges) {
withSiteLink(factory.getSiteLink(title, siteKey, Arrays.asList(badges)));
return this;
} | java | {
"resource": ""
} |
q4935 | ReferenceRdfConverter.addReference | train | public Resource addReference(Reference reference) {
Resource resource = this.rdfWriter.getUri(Vocabulary.getReferenceUri(reference));
this.referenceQueue.add(reference);
this.referenceSubjectQueue.add(resource);
return resource;
} | java | {
"resource": ""
} |
q4936 | ReferenceRdfConverter.writeReferences | train | 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)) {
writeReference(reference, resource);
}
}
this.referenceSubjectQueue.clear();
this.referenceQueue.clear();
this.snakRdfConverter.writeAuxiliaryTriples();
} | java | {
"resource": ""
} |
q4937 | DumpProcessingController.getSitesInformation | train | public Sites getSitesInformation() throws IOException {
MwDumpFile sitesTableDump = getMostRecentDump(DumpContentType.SITES);
if (sitesTableDump == null) {
return null;
}
// Create a suitable processor for such dumps and process the file:
MwSitesDumpFileProcessor sitesDumpFileProcessor = new MwSitesDumpFileProcessor();
sitesDumpFileProcessor.processDumpFileContents(
sitesTableDump.getDumpFileStream(), sitesTableDump);
return sitesDumpFileProcessor.getSites();
} | java | {
"resource": ""
} |
q4938 | DumpProcessingController.processMostRecentDump | train | @Deprecated
public void processMostRecentDump(DumpContentType dumpContentType,
MwDumpFileProcessor dumpFileProcessor) {
MwDumpFile dumpFile = getMostRecentDump(dumpContentType);
if (dumpFile != null) {
processDumpFile(dumpFile, dumpFileProcessor);
}
} | java | {
"resource": ""
} |
q4939 | DumpProcessingController.processDumpFile | train | void processDumpFile(MwDumpFile dumpFile,
MwDumpFileProcessor dumpFileProcessor) {
try (InputStream inputStream = dumpFile.getDumpFileStream()) {
dumpFileProcessor.processDumpFileContents(inputStream, dumpFile);
} catch (FileAlreadyExistsException e) {
logger.error("Dump file "
+ dumpFile.toString()
+ " could not be processed since file "
+ e.getFile()
+ " already exists. Try deleting the file or dumpfile directory to attempt a new download.");
} catch (IOException e) {
logger.error("Dump file " + dumpFile.toString()
+ " could not be processed: " + e.toString());
}
} | java | {
"resource": ""
} |
q4940 | WmfDumpFileManager.findMostRecentDump | train | public MwDumpFile findMostRecentDump(DumpContentType dumpContentType) {
List<MwDumpFile> dumps = findAllDumps(dumpContentType);
for (MwDumpFile dump : dumps) {
if (dump.isAvailable()) {
return dump;
}
}
return null;
} | java | {
"resource": ""
} |
q4941 | WmfDumpFileManager.mergeDumpLists | train | 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());
}
for (MwDumpFile dumpFile : onlineDumps) {
if (!localDateStamps.contains(dumpFile.getDateStamp())) {
result.add(dumpFile);
}
}
result.sort(Collections.reverseOrder(new MwDumpFile.DateComparator()));
return result;
} | java | {
"resource": ""
} |
q4942 | WmfDumpFileManager.findDumpsLocally | train | List<MwDumpFile> findDumpsLocally(DumpContentType dumpContentType) {
String directoryPattern = WmfDumpFile.getDumpFileDirectoryName(
dumpContentType, "*");
List<String> dumpFileDirectories;
try {
dumpFileDirectories = this.dumpfileDirectoryManager
.getSubdirectories(directoryPattern);
} catch (IOException e) {
logger.error("Unable to access dump directory: " + e.toString());
return Collections.emptyList();
}
List<MwDumpFile> result = new ArrayList<>();
for (String directory : dumpFileDirectories) {
String dateStamp = WmfDumpFile
.getDateStampFromDumpFileDirectoryName(dumpContentType,
directory);
if (dateStamp.matches(WmfDumpFileManager.DATE_STAMP_PATTERN)) {
WmfLocalDumpFile dumpFile = new WmfLocalDumpFile(dateStamp,
this.projectName, dumpfileDirectoryManager,
dumpContentType);
if (dumpFile.isAvailable()) {
result.add(dumpFile);
} else {
logger.error("Incomplete local dump file data. Maybe delete "
+ dumpFile.getDumpfileDirectory()
+ " to attempt fresh download.");
}
} // else: silently ignore directories that don't match
}
result.sort(Collections.reverseOrder(new MwDumpFile.DateComparator()));
logger.info("Found " + result.size() + " local dumps of type "
+ dumpContentType + ": " + result);
return result;
} | java | {
"resource": ""
} |
q4943 | WmfDumpFileManager.findDumpsOnline | train | 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 WmfOnlineDailyDumpFile(dateStamp,
this.projectName, this.webResourceFetcher,
this.dumpfileDirectoryManager));
} else if (dumpContentType == DumpContentType.JSON) {
result.add(new JsonOnlineDumpFile(dateStamp, this.projectName,
this.webResourceFetcher, this.dumpfileDirectoryManager));
} else {
result.add(new WmfOnlineStandardDumpFile(dateStamp,
this.projectName, this.webResourceFetcher,
this.dumpfileDirectoryManager, dumpContentType));
}
}
logger.info("Found " + result.size() + " online dumps of type "
+ dumpContentType + ": " + result);
return result;
} | java | {
"resource": ""
} |
q4944 | TutorialDocumentProcessor.processItemDocument | train | @Override
public void processItemDocument(ItemDocument itemDocument) {
this.countItems++;
// Do some printing for demonstration/debugging.
// Only print at most 50 items (or it would get too slow).
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.\n"
+ "*** Maybe remove this debug output altogether.");
}
} | java | {
"resource": ""
} |
q4945 | EntityIdValueImpl.fromId | train | 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 EntityIdValueImpl.JSON_ENTITY_TYPE_LEXEME:
return new LexemeIdValueImpl(id, siteIri);
case EntityIdValueImpl.JSON_ENTITY_TYPE_FORM:
return new FormIdValueImpl(id, siteIri);
case EntityIdValueImpl.JSON_ENTITY_TYPE_SENSE:
return new SenseIdValueImpl(id, siteIri);
default:
throw new IllegalArgumentException("Entity id \"" + id + "\" is not supported.");
}
} | java | {
"resource": ""
} |
q4946 | EntityIdValueImpl.guessEntityTypeFromId | train | 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_TYPE_SENSE;
} else {
return JSON_ENTITY_TYPE_LEXEME;
}
case 'P':
return JSON_ENTITY_TYPE_PROPERTY;
case 'Q':
return JSON_ENTITY_TYPE_ITEM;
default:
throw new IllegalArgumentException("Entity id \"" + id + "\" is not supported.");
}
} | java | {
"resource": ""
} |
q4947 | EntityTimerProcessor.close | train | @Override
public void close() {
logger.info("Finished processing.");
this.timer.stop();
this.lastSeconds = (int) (timer.getTotalWallTime() / 1000000000);
printStatus();
} | java | {
"resource": ""
} |
q4948 | EntityTimerProcessor.countEntity | train | 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.lastSeconds = seconds;
printStatus();
if (this.timeout > 0 && seconds > this.timeout) {
logger.info("Timeout. Aborting processing.");
throw new TimeoutException();
}
}
timer.start();
}
} | java | {
"resource": ""
} |
q4949 | ApiConnection.implodeObjects | train | 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();
} | java | {
"resource": ""
} |
q4950 | ApiConnection.logout | train | public void logout() throws IOException {
if (this.loggedIn) {
Map<String, String> params = new HashMap<>();
params.put("action", "logout");
params.put("format", "json"); // reduce the output
try {
sendJsonRequest("POST", params);
} catch (MediaWikiApiErrorException e) {
throw new IOException(e.getMessage(), e); //TODO: we should throw a better exception
}
this.loggedIn = false;
this.username = "";
this.password = "";
}
} | java | {
"resource": ""
} |
q4951 | ApiConnection.fetchToken | train | 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.sendJsonRequest("POST", params);
return root.path("query").path("tokens").path(tokenType + "token").textValue();
} catch (IOException | MediaWikiApiErrorException e) {
logger.error("Error when trying to fetch token: " + e.toString());
}
return null;
} | java | {
"resource": ""
} |
q4952 | ApiConnection.sendRequest | train | 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);
setupConnection(requestMethod, queryString, connection);
OutputStreamWriter writer = new OutputStreamWriter(
connection.getOutputStream());
writer.write(queryString);
writer.flush();
writer.close();
int rc = connection.getResponseCode();
if (rc != 200) {
logger.warn("Error: API request returned response code " + rc);
}
InputStream iStream = connection.getInputStream();
fillCookies(connection.getHeaderFields());
return iStream;
} | java | {
"resource": ""
} |
q4953 | ApiConnection.getWarnings | train | 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()) {
Map.Entry<String, JsonNode> moduleNode = moduleIterator.next();
Iterator<JsonNode> moduleOutputIterator = moduleNode.getValue()
.elements();
while (moduleOutputIterator.hasNext()) {
JsonNode moduleOutputNode = moduleOutputIterator.next();
if (moduleOutputNode.isTextual()) {
warnings.add("[" + moduleNode.getKey() + "]: "
+ moduleOutputNode.textValue());
} else if (moduleOutputNode.isArray()) {
Iterator<JsonNode> messageIterator = moduleOutputNode
.elements();
while (messageIterator.hasNext()) {
JsonNode messageNode = messageIterator.next();
warnings.add("["
+ moduleNode.getKey()
+ "]: "
+ messageNode.path("html").path("*")
.asText(messageNode.toString()));
}
} else {
warnings.add("["
+ moduleNode.getKey()
+ "]: "
+ "Warning was not understood. Please report this to Wikidata Toolkit. JSON source: "
+ moduleOutputNode.toString());
}
}
}
}
return warnings;
} | java | {
"resource": ""
} |
q4954 | ApiConnection.getQueryString | train | 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(entry.getKey(), "UTF-8"));
builder.append("=");
builder.append(URLEncoder.encode(entry.getValue(), "UTF-8"));
}
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(
"Your Java version does not support UTF-8 encoding.");
}
return builder.toString();
} | java | {
"resource": ""
} |
q4955 | ResourceLoader.load | train | public static <T> T load(String resourcePath, BeanSpec spec) {
return load(resourcePath, spec, false);
} | java | {
"resource": ""
} |
q4956 | LogSupport.printCenter | train | protected void printCenter(String format, Object... args) {
String text = S.fmt(format, args);
info(S.center(text, 80));
} | java | {
"resource": ""
} |
q4957 | LogSupport.printCenterWithLead | train | 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)));
} | java | {
"resource": ""
} |
q4958 | Image2ascii.convert | train | public String convert(BufferedImage image, boolean favicon) {
// Reset statistics before anything
statsArray = new int[12];
// Begin the timer
dStart = System.nanoTime();
// Scale the image
image = scale(image, favicon);
// The +1 is for the newline characters
StringBuilder sb = new StringBuilder((image.getWidth() + 1) * image.getHeight());
for (int y = 0; y < image.getHeight(); y++) {
// At the end of each line, add a newline character
if (sb.length() != 0) sb.append("\n");
for (int x = 0; x < image.getWidth(); x++) {
//
Color pixelColor = new Color(image.getRGB(x, y), true);
int alpha = pixelColor.getAlpha();
boolean isTransient = alpha < 0.1;
double gValue = isTransient ? 250 : ((double) pixelColor.getRed() * 0.2989 + (double) pixelColor.getBlue() * 0.5870 + (double) pixelColor.getGreen() * 0.1140) / ((double)alpha / (double)250);
final char s = gValue < 130 ? darkGrayScaleMap(gValue) : lightGrayScaleMap(gValue);
sb.append(s);
}
}
imgArray = sb.toString().toCharArray();
dEnd = System.nanoTime();
return sb.toString();
} | java | {
"resource": ""
} |
q4959 | Image2ascii.scale | train | private static BufferedImage scale(BufferedImage imageToScale, int dWidth, int dHeight, double fWidth, double fHeight) {
BufferedImage dbi = null;
// Needed to create a new BufferedImage object
int imageType = imageToScale.getType();
if (imageToScale != null) {
dbi = new BufferedImage(dWidth, dHeight, imageType);
Graphics2D g = dbi.createGraphics();
AffineTransform at = AffineTransform.getScaleInstance(fWidth, fHeight);
g.drawRenderedImage(imageToScale, at);
}
return dbi;
} | java | {
"resource": ""
} |
q4960 | EventBus.emit | train | public EventBus emit(Enum<?> event, Object... args) {
return _emitWithOnceBus(eventContext(event, args));
} | java | {
"resource": ""
} |
q4961 | EventBus.emit | train | public EventBus emit(String event, Object... args) {
return _emitWithOnceBus(eventContext(event, args));
} | java | {
"resource": ""
} |
q4962 | EventBus.emit | train | public EventBus emit(EventObject event, Object... args) {
return _emitWithOnceBus(eventContext(event, args));
} | java | {
"resource": ""
} |
q4963 | EventBus.emitAsync | train | public EventBus emitAsync(Enum<?> event, Object... args) {
return _emitWithOnceBus(eventContextAsync(event, args));
} | java | {
"resource": ""
} |
q4964 | EventBus.emitAsync | train | public EventBus emitAsync(String event, Object... args) {
return _emitWithOnceBus(eventContextAsync(event, args));
} | java | {
"resource": ""
} |
q4965 | EventBus.emitAsync | train | public EventBus emitAsync(EventObject event, Object... args) {
return _emitWithOnceBus(eventContextAsync(event, args));
} | java | {
"resource": ""
} |
q4966 | EventBus.emitSync | train | public EventBus emitSync(Enum<?> event, Object... args) {
return _emitWithOnceBus(eventContextSync(event, args));
} | java | {
"resource": ""
} |
q4967 | EventBus.emitSync | train | public EventBus emitSync(String event, Object... args) {
return _emitWithOnceBus(eventContextSync(event, args));
} | java | {
"resource": ""
} |
q4968 | EventBus.emitSync | train | public EventBus emitSync(EventObject event, Object... args) {
return _emitWithOnceBus(eventContextSync(event, args));
} | java | {
"resource": ""
} |
q4969 | ConfLoader.common | train | public static String common() {
String common = SysProps.get(KEY_COMMON_CONF_TAG);
if (S.blank(common)) {
common = "common";
}
return common;
} | java | {
"resource": ""
} |
q4970 | ConfLoader.confSetName | train | public static String confSetName() {
String profile = SysProps.get(AppConfigKey.PROFILE.key());
if (S.blank(profile)) {
profile = Act.mode().name().toLowerCase();
}
return profile;
} | java | {
"resource": ""
} |
q4971 | ConfLoader.processConf | train | 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(Config.canonical(s), o);
}
return m;
} | java | {
"resource": ""
} |
q4972 | CliContext.curDir | train | 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;
} | java | {
"resource": ""
} |
q4973 | SimpleASCIITableImpl.getRowLineBuf | train | 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.append("+");
} else if ((i+1 == colCount && j+1 == colWidth)) {//for last column close the border
rowBuilder.append("-+");
} else {
rowBuilder.append("-");
}
}
}
return rowBuilder.append("\n").toString();
} | java | {
"resource": ""
} |
q4974 | AppDescriptor.toByteArray | train | 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);
}
} | java | {
"resource": ""
} |
q4975 | AppDescriptor.of | train | public static AppDescriptor of(String appName, Class<?> entryClass) {
System.setProperty("osgl.version.suppress-var-found-warning", "true");
return of(appName, entryClass, Version.of(entryClass));
} | java | {
"resource": ""
} |
q4976 | AppDescriptor.of | train | public static AppDescriptor of(String appName, String packageName) {
String[] packages = packageName.split(S.COMMON_SEP);
return of(appName, packageName, Version.ofPackage(packages[0]));
} | java | {
"resource": ""
} |
q4977 | AppDescriptor.deserializeFrom | train | 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 (ClassNotFoundException e) {
throw E.unexpected(e);
}
} | java | {
"resource": ""
} |
q4978 | AppNameInferer.from | train | static String from(Class<?> entryClass) {
List<String> tokens = tokenOf(entryClass);
return fromTokens(tokens);
} | java | {
"resource": ""
} |
q4979 | AppNameInferer.fromPackageName | train | static String fromPackageName(String packageName) {
List<String> tokens = tokenOf(packageName);
return fromTokens(tokens);
} | java | {
"resource": ""
} |
q4980 | Utils.nextWord | train | public static String nextWord(String string) {
int index = 0;
while (index < string.length() && !Character.isWhitespace(string.charAt(index))) {
index++;
}
return string.substring(0, index);
} | java | {
"resource": ""
} |
q4981 | ApacheMultipartParser.getHeader | train | private final String getHeader(Map /* String, String */ headers, String name) {
return (String) headers.get(name.toLowerCase());
} | java | {
"resource": ""
} |
q4982 | ProgressBar.stop | train | public ProgressBar stop() {
target.kill();
try {
thread.join();
target.consoleStream.print("\n");
target.consoleStream.flush();
}
catch (InterruptedException ex) { }
return this;
} | java | {
"resource": ""
} |
q4983 | DataPropertyRepository.propertyListOf | train | 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(c.getName(), ls);
return ls;
} | java | {
"resource": ""
} |
q4984 | ClassNode.parent | train | public ClassNode parent(String name) {
this.parent = infoBase.node(name);
this.parent.addChild(this);
for (ClassNode intf : parent.interfaces.values()) {
addInterface(intf);
}
return this;
} | java | {
"resource": ""
} |
q4985 | ClassNode.addInterface | train | public ClassNode addInterface(String name) {
ClassNode intf = infoBase.node(name);
addInterface(intf);
return this;
} | java | {
"resource": ""
} |
q4986 | ClassNode.annotatedWith | train | public ClassNode annotatedWith(String name) {
ClassNode anno = infoBase.node(name);
this.annotations.add(anno);
anno.annotated.add(this);
return this;
} | java | {
"resource": ""
} |
q4987 | TimeZoneResolver.timezoneOffset | train | public static int timezoneOffset(H.Session session) {
String s = null != session ? session.get(SESSION_KEY) : null;
return S.notBlank(s) ? Integer.parseInt(s) : serverTimezoneOffset();
} | java | {
"resource": ""
} |
q4988 | WebSocketConnectionManager.sendJsonToUrl | train | public void sendJsonToUrl(Object data, String url) {
sendToUrl(JSON.toJSONString(data), url);
} | java | {
"resource": ""
} |
q4989 | WebSocketConnectionManager.sendToTagged | train | public void sendToTagged(String message, String ... labels) {
for (String label : labels) {
sendToTagged(message, label);
}
} | java | {
"resource": ""
} |
q4990 | WebSocketConnectionManager.sendJsonToTagged | train | public void sendJsonToTagged(Object data, String label) {
sendToTagged(JSON.toJSONString(data), label);
} | java | {
"resource": ""
} |
q4991 | WebSocketConnectionManager.sendJsonToTagged | train | public void sendJsonToTagged(Object data, String ... labels) {
for (String label : labels) {
sendJsonToTagged(data, label);
}
} | java | {
"resource": ""
} |
q4992 | WebSocketConnectionManager.sendJsonToUser | train | public void sendJsonToUser(Object data, String username) {
sendToUser(JSON.toJSONString(data), username);
} | java | {
"resource": ""
} |
q4993 | SysUtilAdmin.isBinary | train | private static boolean isBinary(InputStream in) {
try {
int size = in.available();
if (size > 1024) size = 1024;
byte[] data = new byte[size];
in.read(data);
in.close();
int ascii = 0;
int other = 0;
for (int i = 0; i < data.length; i++) {
byte b = data[i];
if (b < 0x09) return true;
if (b == 0x09 || b == 0x0A || b == 0x0C || b == 0x0D) ascii++;
else if (b >= 0x20 && b <= 0x7E) ascii++;
else other++;
}
return other != 0 && 100 * other / (ascii + other) > 95;
} catch (IOException e) {
throw E.ioException(e);
}
} | java | {
"resource": ""
} |
q4994 | Javadoc.toText | train | public String toText() {
StringBuilder sb = new StringBuilder();
if (!description.isEmpty()) {
sb.append(description.toText());
sb.append(EOL);
}
if (!blockTags.isEmpty()) {
sb.append(EOL);
}
for (JavadocBlockTag tag : blockTags) {
sb.append(tag.toText()).append(EOL);
}
return sb.toString();
} | java | {
"resource": ""
} |
q4995 | Javadoc.toComment | train | public JavadocComment toComment(String indentation) {
for (char c : indentation.toCharArray()) {
if (!Character.isWhitespace(c)) {
throw new IllegalArgumentException("The indentation string should be composed only by whitespace characters");
}
}
StringBuilder sb = new StringBuilder();
sb.append(EOL);
final String text = toText();
if (!text.isEmpty()) {
for (String line : text.split(EOL)) {
sb.append(indentation);
sb.append(" * ");
sb.append(line);
sb.append(EOL);
}
}
sb.append(indentation);
sb.append(" ");
return new JavadocComment(sb.toString());
} | java | {
"resource": ""
} |
q4996 | ViewManager.isTemplatePath | train | public static boolean isTemplatePath(String string) {
int sz = string.length();
if (sz == 0) {
return true;
}
for (int i = 0; i < sz; ++i) {
char c = string.charAt(i);
switch (c) {
case ' ':
case '\t':
case '\b':
case '<':
case '>':
case '(':
case ')':
case '[':
case ']':
case '{':
case '}':
case '!':
case '@':
case '#':
case '*':
case '?':
case '%':
case '|':
case ',':
case ':':
case ';':
case '^':
case '&':
return false;
}
}
return true;
} | java | {
"resource": ""
} |
q4997 | PasswordSpec.parse | train | public static PasswordSpec parse(String spec) {
char[] ca = spec.toCharArray();
int len = ca.length;
illegalIf(0 == len, spec);
Builder builder = new Builder();
StringBuilder minBuf = new StringBuilder();
StringBuilder maxBuf = new StringBuilder();
boolean lenSpecStart = false;
boolean minPart = false;
for (int i = 0; i < len; ++i) {
char c = ca[i];
switch (c) {
case SPEC_LOWERCASE:
illegalIf(lenSpecStart, spec);
builder.requireLowercase();
break;
case SPEC_UPPERCASE:
illegalIf(lenSpecStart, spec);
builder.requireUppercase();
break;
case SPEC_SPECIAL_CHAR:
illegalIf(lenSpecStart, spec);
builder.requireSpecialChar();
break;
case SPEC_LENSPEC_START:
lenSpecStart = true;
minPart = true;
break;
case SPEC_LENSPEC_CLOSE:
illegalIf(minPart, spec);
lenSpecStart = false;
break;
case SPEC_LENSPEC_SEP:
minPart = false;
break;
case SPEC_DIGIT:
if (!lenSpecStart) {
builder.requireDigit();
} else {
if (minPart) {
minBuf.append(c);
} else {
maxBuf.append(c);
}
}
break;
default:
illegalIf(!lenSpecStart || !isDigit(c), spec);
if (minPart) {
minBuf.append(c);
} else {
maxBuf.append(c);
}
}
}
illegalIf(lenSpecStart, spec);
if (minBuf.length() != 0) {
builder.minLength(Integer.parseInt(minBuf.toString()));
}
if (maxBuf.length() != 0) {
builder.maxLength(Integer.parseInt(maxBuf.toString()));
}
return builder;
} | java | {
"resource": ""
} |
q4998 | WebSocketConnectionHandler._onConnect | train | protected final void _onConnect(WebSocketContext context) {
if (null != connectionListener) {
connectionListener.onConnect(context);
}
connectionListenerManager.notifyFreeListeners(context, false);
Act.eventBus().emit(new WebSocketConnectEvent(context));
} | java | {
"resource": ""
} |
q4999 | IdGenerator.genId | train | public String genId() {
S.Buffer sb = S.newBuffer();
sb.a(longEncoder.longToStr(nodeIdProvider.nodeId()))
.a(longEncoder.longToStr(startIdProvider.startId()))
.a(longEncoder.longToStr(sequenceProvider.seqId()));
return sb.toString();
} | java | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.