_id stringlengths 2 7 | title stringlengths 3 140 | partition stringclasses 3
values | text stringlengths 73 34.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q158900 | KTypeVTypeHashMap.from | train | public static <KType, VType> KTypeVTypeHashMap<KType, VType> from(KType[] keys, VType[] values) {
if (keys.length != values.length) {
throw new IllegalArgumentException("Arrays of keys and values must have an identical length.");
}
KTypeVTypeHashMap<KType, VType> map = new KTypeVTypeHashMap<>(keys.le... | java | {
"resource": ""
} |
q158901 | SignatureProcessor.processComment | train | private String processComment(String text, TemplateOptions options) {
if (options.hasKType()) {
text = text.replaceAll("(KType)(?=\\p{Lu})", options.getKType().getBoxedType());
text = text.replace("KType", options.getKType().getType());
}
if (options.hasVType()) {
text = text.replace... | java | {
"resource": ""
} |
q158902 | KTypeHashSet.addAll | train | public int addAll(Iterable<? extends KTypeCursor<? extends KType>> iterable) {
int count = 0;
for (KTypeCursor<? extends KType> cursor : iterable) {
if (add(cursor.value)) {
count++;
}
}
return count;
} | java | {
"resource": ""
} |
q158903 | KTypeHashSet.indexGet | train | public KType indexGet(int index) {
assert index >= 0 : "The index must point at an existing key.";
assert index <= mask ||
(index == mask + 1 && hasEmptyKey);
return Intrinsics.<KType> cast(keys[index]);
} | java | {
"resource": ""
} |
q158904 | KTypeHashSet.indexReplace | train | public KType indexReplace(int index, KType equivalentKey) {
assert index >= 0 : "The index must point at an existing key.";
assert index <= mask ||
(index == mask + 1 && hasEmptyKey);
assert Intrinsics.equals(this, keys[index], equivalentKey);
KType previousValue = Intrinsics.<KType> cast(ke... | java | {
"resource": ""
} |
q158905 | KTypeHashSet.indexInsert | train | public void indexInsert(int index, KType key) {
assert index < 0 : "The index must not point at an existing key.";
index = ~index;
if (Intrinsics.isEmpty(key)) {
assert index == mask + 1;
assert Intrinsics.isEmpty(keys[index]);
hasEmptyKey = true;
} else {
assert Intrinsics.isEm... | java | {
"resource": ""
} |
q158906 | IndirectSort.topDownMergeSort | train | private static void topDownMergeSort(int[] src, int[] dst, int fromIndex, int toIndex, IndirectComparator comp) {
if (toIndex - fromIndex <= MIN_LENGTH_FOR_INSERTION_SORT) {
insertionSort(fromIndex, toIndex - fromIndex, dst, comp);
return;
}
final int mid = (fromIndex + toIndex) >>> 1;
topD... | java | {
"resource": ""
} |
q158907 | IndirectSort.createOrderArray | train | private static int[] createOrderArray(final int start, final int length) {
final int[] order = new int[length];
for (int i = 0; i < length; i++) {
order[i] = start + i;
}
return order;
} | java | {
"resource": ""
} |
q158908 | KTypeArrayList.add | train | public void add(KType[] elements, int start, int length) {
assert length >= 0 : "Length must be >= 0";
ensureBufferSpace(length);
System.arraycopy(elements, start, buffer, elementsCount, length);
elementsCount += length;
} | java | {
"resource": ""
} |
q158909 | KTypeArrayList.addAll | train | public int addAll(KTypeContainer<? extends KType> container) {
final int size = container.size();
ensureBufferSpace(size);
for (KTypeCursor<? extends KType> cursor : container) {
add(cursor.value);
}
return size;
} | java | {
"resource": ""
} |
q158910 | KTypeArrayList.addAll | train | public int addAll(Iterable<? extends KTypeCursor<? extends KType>> iterable) {
int size = 0;
for (KTypeCursor<? extends KType> cursor : iterable) {
add(cursor.value);
size++;
}
return size;
} | java | {
"resource": ""
} |
q158911 | KTypeArrayDeque.addFirst | train | public int addFirst(Iterable<? extends KTypeCursor<? extends KType>> iterable) {
int size = 0;
for (KTypeCursor<? extends KType> cursor : iterable) {
addFirst(cursor.value);
size++;
}
return size;
} | java | {
"resource": ""
} |
q158912 | KTypeArrayDeque.addLast | train | public int addLast(KTypeContainer<? extends KType> container) {
int size = container.size();
ensureBufferSpace(size);
for (KTypeCursor<? extends KType> cursor : container) {
addLast(cursor.value);
}
return size;
} | java | {
"resource": ""
} |
q158913 | KTypeArrayDeque.addLast | train | public int addLast(Iterable<? extends KTypeCursor<? extends KType>> iterable) {
int size = 0;
for (KTypeCursor<? extends KType> cursor : iterable) {
addLast(cursor.value);
size++;
}
return size;
} | java | {
"resource": ""
} |
q158914 | BitUtil.pop_array | train | public static long pop_array(long[] arr, int wordOffset, int numWords) {
long popCount = 0;
for (int i = wordOffset, end = wordOffset + numWords; i < end; ++i) {
popCount += Long.bitCount(arr[i]);
}
return popCount;
} | java | {
"resource": ""
} |
q158915 | BitUtil.pop_intersect | train | public static long pop_intersect(long[] arr1, long[] arr2, int wordOffset, int numWords) {
long popCount = 0;
for (int i = wordOffset, end = wordOffset + numWords; i < end; ++i) {
popCount += Long.bitCount(arr1[i] & arr2[i]);
}
return popCount;
} | java | {
"resource": ""
} |
q158916 | BitMixer.mix32 | train | public static int mix32(int k) {
k = (k ^ (k >>> 16)) * 0x85ebca6b;
k = (k ^ (k >>> 13)) * 0xc2b2ae35;
return k ^ (k >>> 16);
} | java | {
"resource": ""
} |
q158917 | TemplateProcessorMojo.generate | train | private void generate(TemplateFile input, List<OutputFile> outputs, TemplateOptions templateOptions) throws IOException {
final String targetFileName = targetFileName(templatesPath.relativize(input.path).toString(), templateOptions);
final OutputFile output = new OutputFile(outputPath.resolve(targetFileName).... | java | {
"resource": ""
} |
q158918 | TemplateProcessorMojo.filterVelocity | train | private String filterVelocity(TemplateFile f, String template, TemplateOptions options) {
final VelocityContext ctx = new VelocityContext();
ctx.put("TemplateOptions", options);
ctx.put("true", true);
ctx.put("templateOnly", false);
ctx.put("false", false);
StringWriter sw = new StringWr... | java | {
"resource": ""
} |
q158919 | TemplateProcessorMojo.collectTemplateFiles | train | private List<TemplateFile> collectTemplateFiles(Path dir) throws IOException {
final List<TemplateFile> paths = new ArrayList<>();
for (Path path : scanFilesMatching(dir, "glob:**.java")) {
paths.add(new TemplateFile(path));
}
return paths;
} | java | {
"resource": ""
} |
q158920 | ToastCompat.makeText | train | public static ToastCompat makeText(Context context, CharSequence text, int duration) {
// We cannot pass the SafeToastContext to Toast.makeText() because
// the View will unwrap the base context and we are in vain.
@SuppressLint("ShowToast")
Toast toast = Toast.makeText(context, text, duration);
set... | java | {
"resource": ""
} |
q158921 | AdaptiveTableManager.switchTwoColumns | train | void switchTwoColumns(int columnIndex, int columnToIndex) {
checkForInit();
int cellData = mColumnWidths[columnToIndex];
mColumnWidths[columnToIndex] = mColumnWidths[columnIndex];
mColumnWidths[columnIndex] = cellData;
} | java | {
"resource": ""
} |
q158922 | AdaptiveTableManager.switchTwoRows | train | void switchTwoRows(int rowIndex, int rowToIndex) {
checkForInit();
int cellData = mRowHeights[rowToIndex];
mRowHeights[rowToIndex] = mRowHeights[rowIndex];
mRowHeights[rowIndex] = cellData;
} | java | {
"resource": ""
} |
q158923 | SparseMatrix.remove | train | void remove(int row, int column) {
SparseArrayCompat<TObj> array = mData.get(row);
if (array != null) {
array.remove(column);
}
} | java | {
"resource": ""
} |
q158924 | AdaptiveTableLayout.refreshViewHolders | train | private void refreshViewHolders() {
if (mAdapter != null) {
for (ViewHolder holder : mViewHolders.getAll()) {
if (holder != null) {
// cell item
refreshItemViewHolder(holder, mState.isRowDragging(), mState.isColumnDragging());
... | java | {
"resource": ""
} |
q158925 | AdaptiveTableLayout.refreshHeaderColumnViewHolder | train | private void refreshHeaderColumnViewHolder(ViewHolder holder) {
int left = getEmptySpace() + mManager.getColumnsWidth(0, Math.max(0, holder.getColumnIndex()));
if (!isRTL()) {
left += mManager.getHeaderRowWidth();
}
int top = mSettings.isHeaderFixed() ? 0 : -mState.getScrollY... | java | {
"resource": ""
} |
q158926 | AdaptiveTableLayout.recycleViewHolders | train | private void recycleViewHolders(boolean isRecycleAll) {
if (mAdapter == null) {
return;
}
final List<Integer> headerKeysToRemove = new ArrayList<>();
// item view holders
for (ViewHolder holder : mViewHolders.getAll()) {
if (holder != null && !holder.is... | java | {
"resource": ""
} |
q158927 | AdaptiveTableLayout.removeKeys | train | private void removeKeys(List<Integer> keysToRemove, SparseArrayCompat<ViewHolder> headers) {
for (Integer key : keysToRemove) {
headers.remove(key);
}
} | java | {
"resource": ""
} |
q158928 | AdaptiveTableLayout.recycleViewHolder | train | private void recycleViewHolder(ViewHolder holder) {
mRecycler.pushRecycledView(holder);
removeView(holder.getItemView());
mAdapter.onViewHolderRecycled(holder);
} | java | {
"resource": ""
} |
q158929 | AdaptiveTableLayout.addViewHolders | train | private void addViewHolders(Rect filledArea) {
//search indexes for columns and rows which NEED TO BE showed in this area
int leftColumn = mManager.getColumnByXWithShift(filledArea.left, mSettings.getCellMargin());
int rightColumn = mManager.getColumnByXWithShift(filledArea.right, mSettings.getC... | java | {
"resource": ""
} |
q158930 | AdaptiveTableLayout.createViewHolder | train | @Nullable
private ViewHolder createViewHolder(int itemType) {
if (itemType == ViewHolderType.ITEM) {
return mAdapter.onCreateItemViewHolder(AdaptiveTableLayout.this);
} else if (itemType == ViewHolderType.ROW_HEADER) {
return mAdapter.onCreateRowHeaderViewHolder(AdaptiveTable... | java | {
"resource": ""
} |
q158931 | AdaptiveTableLayout.shiftColumnsViews | train | private void shiftColumnsViews(final int fromColumn, final int toColumn) {
if (mAdapter != null) {
// change data
mAdapter.changeColumns(getBindColumn(fromColumn), getBindColumn(toColumn));
// change view holders
switchHeaders(mHeaderColumnViewHolders, fromColum... | java | {
"resource": ""
} |
q158932 | AdaptiveTableLayout.shiftRowsViews | train | private void shiftRowsViews(final int fromRow, final int toRow) {
if (mAdapter != null) {
// change data
mAdapter.changeRows(fromRow, toRow, mSettings.isSolidRowHeader());
// change view holders
switchHeaders(mHeaderRowViewHolders, fromRow, toRow, ViewHolderType.... | java | {
"resource": ""
} |
q158933 | AdaptiveTableLayout.setDraggingToColumn | train | @SuppressWarnings("unused")
private void setDraggingToColumn(int column, boolean isDragging) {
Collection<ViewHolder> holders = mViewHolders.getColumnItems(column);
for (ViewHolder holder : holders) {
holder.setIsDragging(isDragging);
}
ViewHolder holder = mHeaderColumnV... | java | {
"resource": ""
} |
q158934 | AdaptiveTableLayout.setDraggingToRow | train | @SuppressWarnings("unused")
private void setDraggingToRow(int row, boolean isDragging) {
Collection<ViewHolder> holders = mViewHolders.getRowItems(row);
for (ViewHolder holder : holders) {
holder.setIsDragging(isDragging);
}
ViewHolder holder = mHeaderRowViewHolders.get(... | java | {
"resource": ""
} |
q158935 | BaseDataAdaptiveTableLayoutAdapter.switchTwoColumns | train | void switchTwoColumns(int columnIndex, int columnToIndex) {
for (int i = 0; i < getRowCount() - 1; i++) {
Object cellData = getItems()[i][columnToIndex];
getItems()[i][columnToIndex] = getItems()[i][columnIndex];
getItems()[i][columnIndex] = cellData;
}
} | java | {
"resource": ""
} |
q158936 | BaseDataAdaptiveTableLayoutAdapter.switchTwoColumnHeaders | train | void switchTwoColumnHeaders(int columnIndex, int columnToIndex) {
Object cellData = getColumnHeaders()[columnToIndex];
getColumnHeaders()[columnToIndex] = getColumnHeaders()[columnIndex];
getColumnHeaders()[columnIndex] = cellData;
} | java | {
"resource": ""
} |
q158937 | BaseDataAdaptiveTableLayoutAdapter.switchTwoRows | train | void switchTwoRows(int rowIndex, int rowToIndex) {
for (int i = 0; i < getItems().length; i++) {
Object cellData = getItems()[rowToIndex][i];
getItems()[rowToIndex][i] = getItems()[rowIndex][i];
getItems()[rowIndex][i] = cellData;
}
} | java | {
"resource": ""
} |
q158938 | BaseDataAdaptiveTableLayoutAdapter.switchTwoRowHeaders | train | void switchTwoRowHeaders(int rowIndex, int rowToIndex) {
Object cellData = getRowHeaders()[rowToIndex];
getRowHeaders()[rowToIndex] = getRowHeaders()[rowIndex];
getRowHeaders()[rowIndex] = cellData;
} | java | {
"resource": ""
} |
q158939 | DB.newEmbeddedDB | train | public static DB newEmbeddedDB(DBConfiguration config) throws ManagedProcessException {
DB db = new DB(config);
db.prepareDirectories();
db.unpackEmbeddedDb();
db.install();
return db;
} | java | {
"resource": ""
} |
q158940 | DB.newEmbeddedDB | train | public static DB newEmbeddedDB(int port) throws ManagedProcessException {
DBConfigurationBuilder config = new DBConfigurationBuilder();
config.setPort(port);
return newEmbeddedDB(config.build());
} | java | {
"resource": ""
} |
q158941 | DB.install | train | synchronized protected void install() throws ManagedProcessException {
try {
ManagedProcess mysqlInstallProcess = installPreparation();
mysqlInstallProcess.start();
mysqlInstallProcess.waitForExit();
} catch (Exception e) {
throw new ManagedProcessExceptio... | java | {
"resource": ""
} |
q158942 | DB.start | train | public synchronized void start() throws ManagedProcessException {
logger.info("Starting up the database...");
boolean ready = false;
try {
mysqldProcess = startPreparation();
ready = mysqldProcess.startAndWaitForConsoleMessageMaxMs(getReadyForConnectionsTag(), dbStartMaxW... | java | {
"resource": ""
} |
q158943 | DB.source | train | public void source(String resource, String username, String password, String dbName) throws ManagedProcessException {
InputStream from = getClass().getClassLoader().getResourceAsStream(resource);
if (from == null)
throw new IllegalArgumentException("Could not find script file on the classpat... | java | {
"resource": ""
} |
q158944 | DB.stop | train | public synchronized void stop() throws ManagedProcessException {
if (mysqldProcess.isAlive()) {
logger.debug("Stopping the database...");
mysqldProcess.destroy();
logger.info("Database stopped.");
} else {
logger.debug("Database was already stopped.");
... | java | {
"resource": ""
} |
q158945 | DB.unpackEmbeddedDb | train | protected void unpackEmbeddedDb() {
if (configuration.getBinariesClassPathLocation() == null) {
logger.info("Not unpacking any embedded database (as BinariesClassPathLocation configuration is null)");
return;
}
try {
Util.extractFromClasspathToFile(configurat... | java | {
"resource": ""
} |
q158946 | DB.prepareDirectories | train | protected void prepareDirectories() throws ManagedProcessException {
baseDir = Util.getDirectory(configuration.getBaseDir());
libDir = Util.getDirectory(configuration.getLibDir());
try {
String dataDirPath = configuration.getDataDir();
if (Util.isTemporaryDirectory(dataDi... | java | {
"resource": ""
} |
q158947 | DB.cleanupOnExit | train | protected void cleanupOnExit() {
String threadName = "Shutdown Hook Deletion Thread for Temporary DB " + dataDir.toString();
final DB db = this;
Runtime.getRuntime().addShutdownHook(new Thread(threadName) {
@Override
public void run() {
// ManagedProcess ... | java | {
"resource": ""
} |
q158948 | DB.dumpXML | train | public ManagedProcess dumpXML(File outputFile, String dbName, String user, String password)
throws IOException, ManagedProcessException {
return dump(outputFile, Arrays.asList(dbName), true, true, true, user, password);
} | java | {
"resource": ""
} |
q158949 | Util.extractFromClasspathToFile | train | public static int extractFromClasspathToFile(String packagePath, File toDir) throws IOException {
String locationPattern = "classpath*:" + packagePath + "/**";
ResourcePatternResolver resourcePatternResolver = new PathMatchingResourcePatternResolver();
Resource[] resources = resourcePatternResol... | java | {
"resource": ""
} |
q158950 | GitHubLoginFunction.connector | train | private OkHttpConnector connector(GitHubServerConfig config) {
OkHttpClient client = new OkHttpClient().setProxy(getProxy(defaultIfBlank(config.getApiUrl(), GITHUB_URL)));
if (config.getClientCacheSize() > 0) {
Cache cache = toCacheDir().apply(config);
client.setCache(cache);
... | java | {
"resource": ""
} |
q158951 | JobInfoHelpers.isBuildable | train | public static <ITEM extends Item> Predicate<ITEM> isBuildable() {
return new Predicate<ITEM>() {
public boolean apply(ITEM item) {
return item instanceof Job ? ((Job<?, ?>) item).isBuildable() : item instanceof BuildableItem;
}
};
} | java | {
"resource": ""
} |
q158952 | JobInfoHelpers.isAlive | train | public static <ITEM extends Item> Predicate<ITEM> isAlive() {
return new Predicate<ITEM>() {
@Override
public boolean apply(ITEM item) {
return !from(GHEventsSubscriber.all()).filter(isApplicableFor(item)).toList().isEmpty();
}
};
} | java | {
"resource": ""
} |
q158953 | XSSApi.asValidHref | train | public static String asValidHref(String urlString) {
try {
return new URL(urlString).toExternalForm();
} catch (MalformedURLException e) {
LOG.debug("Malformed url - {}, empty string will be returned", urlString);
return "";
}
} | java | {
"resource": ""
} |
q158954 | GitHubHookRegisterProblemMonitor.doAct | train | @RequirePOST
@RequireAdminRights
public HttpResponse doAct(StaplerRequest req) throws IOException {
if (req.hasParameter("no")) {
disable(true);
return HttpResponses.redirectViaContextPath("/manage");
} else {
return new HttpRedirect(".");
}
} | java | {
"resource": ""
} |
q158955 | WebhookManager.unregisterFor | train | public void unregisterFor(GitHubRepositoryName name, List<GitHubRepositoryName> aliveRepos) {
try {
GHRepository repo = checkNotNull(
from(name.resolve(allowedToManageHooks())).firstMatch(withAdminAccess()).orNull(),
"There are no credentials with admin access... | java | {
"resource": ""
} |
q158956 | BetterThanOrEqualBuildResult.betterThanOrEqualTo | train | public static BetterThanOrEqualBuildResult betterThanOrEqualTo(Result result, GHCommitState state, String msg) {
BetterThanOrEqualBuildResult conditional = new BetterThanOrEqualBuildResult();
conditional.setResult(result.toString());
conditional.setState(state.name());
conditional.setMes... | java | {
"resource": ""
} |
q158957 | BuildDataHelper.calculateBuildData | train | public static BuildData calculateBuildData(
String parentName, String parentFullName, List<BuildData> buildDataList
) {
if (buildDataList == null) {
return null;
}
if (buildDataList.size() == 1) {
return buildDataList.get(0);
}
String projec... | java | {
"resource": ""
} |
q158958 | GitHubPluginConfig.findGithubConfig | train | public Iterable<GitHub> findGithubConfig(Predicate<GitHubServerConfig> match) {
Function<GitHubServerConfig, GitHub> loginFunction = loginToGithub();
if (Objects.isNull(loginFunction)) {
return Collections.emptyList();
}
// try all the credentials since we don't know which o... | java | {
"resource": ""
} |
q158959 | GithubUrl.commitId | train | public String commitId(final String id) {
return new StringBuilder().append(baseUrl).append("commit/").append(id).toString();
} | java | {
"resource": ""
} |
q158960 | ExpandableMessage.expandAll | train | public String expandAll(Run<?, ?> run, TaskListener listener) throws IOException, InterruptedException {
if (run instanceof AbstractBuild) {
try {
return TokenMacro.expandAll(
(AbstractBuild) run,
listener,
conte... | java | {
"resource": ""
} |
q158961 | BuildRefBackrefSource.get | train | @SuppressWarnings("deprecation")
@Override
public String get(Run<?, ?> run, TaskListener listener) {
return DisplayURLProvider.get().getRunURL(run);
} | java | {
"resource": ""
} |
q158962 | PingGHEventSubscriber.onEvent | train | @Override
protected void onEvent(GHEvent event, String payload) {
GHEventPayload.Ping ping;
try {
ping = GitHub.offline().parseEventPayload(new StringReader(payload), GHEventPayload.Ping.class);
} catch (IOException e) {
LOGGER.warn("Received malformed PingEvent: " + ... | java | {
"resource": ""
} |
q158963 | GitHubClientCacheOps.notInCaches | train | public static DirectoryStream.Filter<Path> notInCaches(Set<String> caches) {
checkNotNull(caches, "set of active caches can't be null");
return new NotInCachesFilter(caches);
} | java | {
"resource": ""
} |
q158964 | GitHubClientCacheOps.clearRedundantCaches | train | public static void clearRedundantCaches(List<GitHubServerConfig> configs) {
Path baseCacheDir = getBaseCacheDir();
if (notExists(baseCacheDir)) {
return;
}
final Set<String> actualNames = from(configs).filter(withEnabledCache()).transform(toCacheDir())
.tran... | java | {
"resource": ""
} |
q158965 | GitHubClientCacheOps.deleteEveryIn | train | private static void deleteEveryIn(DirectoryStream<Path> caches) {
for (Path notActualCache : caches) {
LOGGER.debug("Deleting redundant cache dir {}", notActualCache);
try {
FileUtils.deleteDirectory(notActualCache.toFile());
} catch (IOException e) {
... | java | {
"resource": ""
} |
q158966 | GitHubPlugin.runMigrator | train | @Initializer(after = InitMilestone.EXTENSIONS_AUGMENTED, before = InitMilestone.JOB_LOADED)
public static void runMigrator() throws Exception {
new Migrator().migrate();
} | java | {
"resource": ""
} |
q158967 | Migrator.toGHServerConfig | train | @VisibleForTesting
protected Function<Credential, GitHubServerConfig> toGHServerConfig() {
return new Function<Credential, GitHubServerConfig>() {
@Override
public GitHubServerConfig apply(Credential input) {
LOGGER.info("Migrate GitHub Plugin creds for {} {}", input.... | java | {
"resource": ""
} |
q158968 | PinEntryEditText.focus | train | public void focus() {
requestFocus();
// Show keyboard
InputMethodManager inputMethodManager = (InputMethodManager) getContext()
.getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.showSoftInput(this, 0);
} | java | {
"resource": ""
} |
q158969 | PermissionFragmentHelper.openSettingsScreen | train | public void openSettingsScreen() {
Intent intent = new Intent();
intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
Uri uri = Uri.parse("package:" + context.getContext().getPackageName());
intent.setData(uri);
context.startActivity(intent);
} | java | {
"resource": ""
} |
q158970 | BasePermissionActivity.requestPermission | train | protected void requestPermission(final PermissionModel model) {
new AlertDialog.Builder(this)
.setTitle(model.getTitle())
.setMessage(model.getExplanationMessage())
.setPositiveButton("Request", new DialogInterface.OnClickListener() {
@Override... | java | {
"resource": ""
} |
q158971 | SegmentIntegration.performFlush | train | void performFlush() {
// Conditions could have changed between enqueuing the task and when it is run.
if (!shouldFlush()) {
return;
}
logger.verbose("Uploading payloads in queue to Segment.");
int payloadsUploaded = 0;
Client.Connection connection = null;
try {
// Open a connect... | java | {
"resource": ""
} |
q158972 | BasePayload.timestamp | train | @Nullable
public Date timestamp() {
// It's unclear if this will ever be null. So we're being safe.
String timestamp = getString(TIMESTAMP_KEY);
if (isNullOrEmpty(timestamp)) {
return null;
}
return parseISO8601Date(timestamp);
} | java | {
"resource": ""
} |
q158973 | Traits.create | train | static Traits create() {
Traits traits = new Traits(new NullableConcurrentHashMap<String, Object>());
traits.putAnonymousId(UUID.randomUUID().toString());
return traits;
} | java | {
"resource": ""
} |
q158974 | ValueMap.putValue | train | public ValueMap putValue(String key, Object value) {
delegate.put(key, value);
return this;
} | java | {
"resource": ""
} |
q158975 | ScreenPayload.event | train | @NonNull
public String event() {
String name = name();
if (!isNullOrEmpty(name)) {
return name;
}
return category();
} | java | {
"resource": ""
} |
q158976 | Options.setIntegration | train | public Options setIntegration(String integrationKey, boolean enabled) {
if (SegmentIntegration.SEGMENT_KEY.equals(integrationKey)) {
throw new IllegalArgumentException("Segment integration cannot be enabled or disabled.");
}
integrations.put(integrationKey, enabled);
return this;
} | java | {
"resource": ""
} |
q158977 | Options.setIntegrationOptions | train | public Options setIntegrationOptions(String integrationKey, Map<String, Object> options) {
integrations.put(integrationKey, options);
return this;
} | java | {
"resource": ""
} |
q158978 | Utils.newSet | train | public static <T> Set<T> newSet(T... values) {
Set<T> set = new HashSet<>(values.length);
Collections.addAll(set, values);
return set;
} | java | {
"resource": ""
} |
q158979 | Utils.getDeviceId | train | @SuppressLint("HardwareIds")
public static String getDeviceId(Context context) {
String androidId = getString(context.getContentResolver(), ANDROID_ID);
if (!isNullOrEmpty(androidId)
&& !"9774d56d682e549c".equals(androidId)
&& !"unknown".equals(androidId)
&& !"000000000000000".equals(a... | java | {
"resource": ""
} |
q158980 | Utils.getSegmentSharedPreferences | train | public static SharedPreferences getSegmentSharedPreferences(Context context, String tag) {
return context.getSharedPreferences("analytics-android-" + tag, MODE_PRIVATE);
} | java | {
"resource": ""
} |
q158981 | Utils.getResourceString | train | public static String getResourceString(Context context, String key) {
int id = getIdentifier(context, "string", key);
if (id != 0) {
return context.getResources().getString(id);
} else {
return null;
}
} | java | {
"resource": ""
} |
q158982 | Utils.getIdentifier | train | private static int getIdentifier(Context context, String type, String key) {
return context.getResources().getIdentifier(key, type, context.getPackageName());
} | java | {
"resource": ""
} |
q158983 | Utils.createDirectory | train | public static void createDirectory(File location) throws IOException {
if (!(location.exists() || location.mkdirs() || location.isDirectory())) {
throw new IOException("Could not create directory at " + location);
}
} | java | {
"resource": ""
} |
q158984 | WearAnalytics.screen | train | public void screen(String category, String name, Properties properties) {
if (isNullOrEmpty(category) && isNullOrEmpty(name)) {
throw new IllegalArgumentException("either category or name must be provided.");
}
if (properties == null) {
properties = new Properties();
}
dispatcher.dispa... | java | {
"resource": ""
} |
q158985 | Cartographer.listToWriter | train | private static void listToWriter(List<?> list, JsonWriter writer) throws IOException {
writer.beginArray();
for (Object value : list) {
writeValue(value, writer);
}
writer.endArray();
} | java | {
"resource": ""
} |
q158986 | Logger.verbose | train | public void verbose(String format, Object... extra) {
if (shouldLog(VERBOSE)) {
Log.v(tag, String.format(format, extra));
}
} | java | {
"resource": ""
} |
q158987 | Logger.info | train | public void info(String format, Object... extra) {
if (shouldLog(INFO)) {
Log.i(tag, String.format(format, extra));
}
} | java | {
"resource": ""
} |
q158988 | Logger.debug | train | public void debug(String format, Object... extra) {
if (shouldLog(DEBUG)) {
Log.d(tag, String.format(format, extra));
}
} | java | {
"resource": ""
} |
q158989 | AnalyticsContext.unmodifiableCopy | train | public AnalyticsContext unmodifiableCopy() {
LinkedHashMap<String, Object> map = new LinkedHashMap<>(this);
return new AnalyticsContext(unmodifiableMap(map));
} | java | {
"resource": ""
} |
q158990 | AnalyticsContext.putLibrary | train | void putLibrary() {
Map<String, Object> library = createMap();
library.put(LIBRARY_NAME_KEY, "analytics-android");
library.put(LIBRARY_VERSION_KEY, BuildConfig.VERSION_NAME);
put(LIBRARY_KEY, library);
} | java | {
"resource": ""
} |
q158991 | AnalyticsContext.putOs | train | void putOs() {
Map<String, Object> os = createMap();
os.put(OS_NAME_KEY, "Android");
os.put(OS_VERSION_KEY, Build.VERSION.RELEASE);
put(OS_KEY, os);
} | java | {
"resource": ""
} |
q158992 | QueueFile.add | train | public synchronized void add(byte[] data, int offset, int count) throws IOException {
if (data == null) {
throw new NullPointerException("data == null");
}
if ((offset | count) < 0 || count > data.length - offset) {
throw new IndexOutOfBoundsException();
}
expandIfNecessary(count);
... | java | {
"resource": ""
} |
q158993 | Analytics.group | train | public void group(
@NonNull final String groupId,
@Nullable final Traits groupTraits,
@Nullable final Options options) {
assertNotShutdown();
if (isNullOrEmpty(groupId)) {
throw new IllegalArgumentException("groupId must not be null or empty.");
}
analyticsExecutor.submit(
... | java | {
"resource": ""
} |
q158994 | Analytics.screen | train | public void screen(
@Nullable final String category,
@Nullable final String name,
@Nullable final Properties properties,
@Nullable final Options options) {
assertNotShutdown();
if (isNullOrEmpty(category) && isNullOrEmpty(name)) {
throw new IllegalArgumentException("either category... | java | {
"resource": ""
} |
q158995 | Analytics.alias | train | public void alias(final @NonNull String newId, final @Nullable Options options) {
assertNotShutdown();
if (isNullOrEmpty(newId)) {
throw new IllegalArgumentException("newId must not be null or empty.");
}
analyticsExecutor.submit(
new Runnable() {
@Override
public void... | java | {
"resource": ""
} |
q158996 | Analytics.reset | train | public void reset() {
Utils.getSegmentSharedPreferences(application, tag).edit().clear().apply();
traitsCache.delete();
traitsCache.set(Traits.create());
analyticsContext.setTraits(traitsCache.get());
runOnMainThread(IntegrationOperation.RESET);
} | java | {
"resource": ""
} |
q158997 | Analytics.onIntegrationReady | train | public <T> void onIntegrationReady(final String key, final Callback<T> callback) {
if (isNullOrEmpty(key)) {
throw new IllegalArgumentException("key cannot be null or empty.");
}
analyticsExecutor.submit(
new Runnable() {
@Override
public void run() {
HANDLER.p... | java | {
"resource": ""
} |
q158998 | Analytics.performRun | train | void performRun(IntegrationOperation operation) {
for (Map.Entry<String, Integration<?>> entry : integrations.entrySet()) {
String key = entry.getKey();
long startTime = System.nanoTime();
operation.run(key, entry.getValue(), projectSettings);
long endTime = System.nanoTime();
long dur... | java | {
"resource": ""
} |
q158999 | Properties.putProducts | train | public Properties putProducts(Product... products) {
if (isNullOrEmpty(products)) {
throw new IllegalArgumentException("products cannot be null or empty.");
}
List<Product> productList = new ArrayList<>(products.length);
Collections.addAll(productList, products);
return putValue(PRODUCTS_KEY, ... | java | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.