code
stringlengths
73
34.1k
label
stringclasses
1 value
private void findReferencesBean( Object base, Class<?> declaredClass, Map<Object, Integer> objects, SerIterator parentIterator) { if (base == null) { return; } // has this object been seen before, if so no need to check it again ...
java
private void findReferencesIterable(SerIterator itemIterator, Map<Object, Integer> objects) { if (itemIterator.category() == SerCategory.MAP) { while (itemIterator.hasNext()) { itemIterator.next(); findReferencesBean(itemIterator.key(), itemIterator.keyType(), objects...
java
private void addClassInfoAndIncrementCount(Class<?> type, ClassInfo classInfo) { classes.putIfAbsent(type, classInfo); classSerializationCount.compute(type, BeanReferences::incrementOrOne); }
java
private ClassInfo classInfoFromMetaBean(MetaBean metaBean, Class<?> aClass) { MetaProperty<?>[] metaProperties = StreamSupport.stream(metaBean.metaPropertyIterable().spliterator(), false) .filter(metaProp -> settings.isSerialized(metaProp)) .toArray(MetaProperty<?>[]::new); // P...
java
ClassInfo getClassInfo(Class<?> effectiveType) { ClassInfo classInfo = classes.get(effectiveType); if (classInfo == null) { throw new IllegalStateException( "Tried to serialise class that wasn't present in bean on first pass: " + effectiveType.getName()); } ...
java
private void writeObject(Class<?> declaredType, Object obj, SerIterator parentIterator) throws IOException { if (obj == null) { output.writeNull(); } else if (settings.getConverter().isConvertible(obj.getClass())) { writeSimple(declaredType, obj); } else if (obj instanceo...
java
private <T> T parseVersion(DataInputStream input, Class<T> declaredType) throws Exception { // root array int arrayByte = input.readByte(); int versionByte = input.readByte(); switch (versionByte) { case 1: if (arrayByte != MIN_FIX_ARRAY + 2) { ...
java
public static CacheFrame[] get(Throwable throwable) { if (throwable == null) { return null; } Map<Throwable, CacheFrame[]> weakMap = cache.get(); return weakMap.get(throwable); }
java
public void setPersonData(final String id, final String username, final String email) { this.rollbar.configure(new ConfigProvider() { @Override public Config provide(ConfigBuilder builder) { return builder .person(new PersonProvider(id, username, email)) .build(); }...
java
public void clearPersonData() { this.rollbar.configure(new ConfigProvider() { @Override public Config provide(ConfigBuilder builder) { return builder .person(null) .build(); } }); }
java
public void setIncludeLogcat(final boolean includeLogcat) { final int versionCode = this.versionCode; final String versionName = this.versionName; this.rollbar.configure(new ConfigProvider() { @Override public Config provide(ConfigBuilder builder) { ClientProvider clientProvider = new Cl...
java
public void critical(Throwable error, Map<String, Object> custom) { critical(error, custom, null); }
java
public void critical(Throwable error, Map<String, Object> custom, String description) { log(error, custom, description, Level.CRITICAL); }
java
public void warning(Throwable error, Map<String, Object> custom) { warning(error, custom, null); }
java
public void warning(Throwable error, Map<String, Object> custom, String description) { log(error, custom, description, Level.WARNING); }
java
public void info(Throwable error, Map<String, Object> custom) { info(error, custom, null); }
java
public void info(Throwable error, Map<String, Object> custom, String description) { log(error, custom, description, Level.INFO); }
java
public void debug(Throwable error, Map<String, Object> custom) { debug(error, custom, null); }
java
public void debug(Throwable error, Map<String, Object> custom, String description) { log(error, custom, description, Level.DEBUG); }
java
public void log(Throwable error, Level level) { log(error, null, null, level); }
java
public void log(Throwable error, String description, Level level) { log(error, null, description, level); }
java
public void log(String message, Level level) { log(null, null, message, level); }
java
public void log(String message, Map<String, Object> custom, Level level) { log(null, custom, message, level); }
java
@Deprecated public static void reportException(final Throwable throwable, final String level) { reportException(throwable, level, null, null); }
java
@Deprecated public static void reportException(final Throwable throwable, final String level, final String description, final Map<String, String> params) { ensureInit(new Runnable() { @Override public void run() { notifier.log(throwable, params != null ? Collections.<String, Object>unmodifiabl...
java
@Deprecated public static void reportMessage(final String message, final String level) { reportMessage(message, level, null); }
java
@Deprecated public static void reportMessage(final String message, final String level, final Map<String, String> params) { ensureInit(new Runnable() { @Override public void run() { notifier.log(message, params != null ? Collections.<String, Object>unmodifiableMap(params) : null, Level.lookupBy...
java
public String greeting() { int current = counter.getAndAdd(1); if (current % 2 != 0) { return format("Hello Rollbar number %d", current); } throw new RuntimeException("Fatal error at greeting number: " + current); }
java
public static ConfigProvider getConfigProvider(String configProviderClassName) { ConfigProvider configProvider = null; if (configProviderClassName != null && !"".equals(configProviderClassName)) { Class userConfigProviderClass = null; try { userConfigProviderClass = Class.forName(configProv...
java
public void critical(Throwable error, String description) { log(error, null, description, Level.CRITICAL); }
java
public void error(Throwable error, String description) { log(error, null, description, Level.ERROR); }
java
public void warning(Throwable error, String description) { log(error, null, description, Level.WARNING); }
java
public void info(Throwable error, String description) { log(error, null, description, Level.INFO); }
java
public void debug(Throwable error, String description) { log(error, null, description, Level.DEBUG); }
java
public void log(Throwable error, Map<String, Object> custom, String description, Level level, boolean isUncaught) { this.rollbar.log(error, custom, description, level, isUncaught); }
java
@Deprecated public Body from(Throwable throwable, String description) { if (throwable == null) { return new Body.Builder().bodyContent(message(description)).build(); } return from(new RollbarThrowableWrapper(throwable), description); }
java
public static Rollbar init(Config config) { if (notifier == null) { synchronized (Rollbar.class) { if (notifier == null) { notifier = new Rollbar(config); LOGGER.debug("Rollbar managed notifier created."); } } } return notifier; }
java
public void configure(Config config) { LOGGER.debug("Reloading configuration."); this.configWriteLock.lock(); try { this.config = config; processAppPackages(config); } finally { this.configWriteLock.unlock(); } }
java
public void sendJsonPayload(String json) { try { this.configReadLock.lock(); Config config = this.config; this.configReadLock.unlock(); sendPayload(config, new Payload(json)); } catch (Exception e) { LOGGER.error("Error while sending payload to Rollbar: {}", e); } }
java
public static <T> T requireNonNull(T object, String errorMessage) { if (object == null) { throw new NullPointerException(errorMessage); } else { return object; } }
java
@PluginFactory public static RollbarAppender createAppender( @PluginAttribute("accessToken") @Required final String accessToken, @PluginAttribute("endpoint") final String endpoint, @PluginAttribute("environment") final String environment, @PluginAttribute("language") final String language, ...
java
public static Intent newEmailIntent(String address, String subject, String body) { return newEmailIntent(address, subject, body, null); }
java
public static Intent newEmailIntent(String address, String subject, String body, Uri attachment) { return newEmailIntent(address == null ? null : new String[]{address}, subject, body, attachment); }
java
public static Intent newEmailIntent(String[] addresses, String subject, String body, Uri attachment) { Intent intent = new Intent(Intent.ACTION_SEND); if (addresses != null) intent.putExtra(Intent.EXTRA_EMAIL, addresses); if (body != null) intent.putExtra(Intent.EXTRA_TEXT, body); if (su...
java
public static Intent newPlayYouTubeVideoIntent(String videoId) { try { return new Intent(Intent.ACTION_VIEW, Uri.parse("vnd.youtube:" + videoId)); } catch (ActivityNotFoundException ex) { return new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.youtube.com/watch?v=" + videoId)...
java
public static Intent newPlayMediaIntent(Uri uri, String type) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(uri, type); return intent; }
java
public static Intent newTakePictureIntent(File tempFile) { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(tempFile)); return intent; }
java
public static Intent newSelectPictureIntent() { Intent intent = new Intent(Intent.ACTION_PICK); intent.setType("image/*"); return intent; }
java
public static Intent newShareTextIntent(String subject, String message, String chooserDialogTitle) { Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.putExtra(Intent.EXTRA_TEXT, message); shareIntent.putExtra(Intent.EXTRA_SUBJECT, subject); shareIntent.setType(MIME_TYPE_T...
java
public static Intent newSmsIntent(Context context, String body, String[] phoneNumbers) { Uri smsUri; if (phoneNumbers == null || phoneNumbers.length==0) { smsUri = Uri.parse("smsto:"); } else { smsUri = Uri.parse("smsto:" + Uri.encode(TextUtils.join(",", phoneNumbers))); ...
java
public static Intent newMarketForAppIntent(Context context) { String packageName = context.getApplicationContext().getPackageName(); return newMarketForAppIntent(context, packageName); }
java
public static Intent newMarketForAppIntent(Context context, String packageName) { Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + packageName)); if (!IntentUtils.isIntentAvailable(context, intent)) { intent = new Intent(Intent.ACTION_VIEW, Uri.parse("amzn:/...
java
public static Intent newGooglePlayIntent(Context context, String packageName) { Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + packageName)); if (!IntentUtils.isIntentAvailable(context, intent)) { intent = MediaIntents.newOpenWebBrowserIntent("https://play...
java
private String getSymbolExceptions() { if (TextUtils.isEmpty(filteredMask)) return ""; StringBuilder maskSymbolException = new StringBuilder(); for (char c : filteredMask.toCharArray()) { if (!Character.isDigit(c) && maskSymbolException.indexOf(String.valueOf(c)) == -1) { ...
java
public E remove (int index) { E e = data[index]; // make copy of element to remove so it can be returned data[index] = data[--size]; // overwrite item to remove with last element data[size] = null; // null last element, so gc can do its work return e; }
java
public E removeLast () { if (size > 0) { E e = data[--size]; data[size] = null; return e; } return null; }
java
public boolean remove (E e) { for (int i = 0; i < size; i++) { E e2 = data[i]; if (e == e2) { data[i] = data[--size]; // overwrite item to remove with last element data[size] = null; // null last element, so gc can do its work return true; } } return false; }
java
public boolean contains (E e) { for (int i = 0; size > i; i++) { if (e == data[i]) { return true; } } return false; }
java
public void add (E e) { // is size greater than capacity increase capacity if (size == data.length) { grow(); } data[size++] = e; }
java
public void set (int index, E e) { if (index >= data.length) { grow(index * 2); } size = index + 1; data[index] = e; }
java
public void addEntity(Entity entity){ boolean delayed = updating || familyManager.notifying(); entityManager.addEntity(entity, delayed); }
java
public void removeEntity(Entity entity){ boolean delayed = updating || familyManager.notifying(); entityManager.removeEntity(entity, delayed); }
java
public void update(float deltaTime){ if (updating) { throw new IllegalStateException("Cannot call update() on an Engine that is already updating."); } updating = true; ImmutableArray<EntitySystem> systems = systemManager.getSystems(); try { for (int i = 0; i < systems.size(); ++i) { EntitySystem ...
java
@SuppressWarnings("unchecked") <T extends Component> T getComponent (ComponentType componentType) { int componentTypeIndex = componentType.getIndex(); if (componentTypeIndex < components.getCapacity()) { return (T)components.get(componentType.getIndex()); } else { return null; } }
java
public void dispatch (T object) { final Object[] items = listeners.begin(); for (int i = 0, n = listeners.size; i < n; i++) { Listener<T> listener = (Listener<T>)items[i]; listener.receive(this, object); } listeners.end(); }
java
private static void warmup(Argon2 argon2, char[] password) { for (int i = 0; i < WARMUP_RUNS; i++) { argon2.hash(MIN_ITERATIONS, MIN_MEMORY, MIN_PARALLELISM, password); } }
java
private byte[] toByteArray(char[] chars, Charset charset) { assert chars != null; CharBuffer charBuffer = CharBuffer.wrap(chars); ByteBuffer byteBuffer = charset.encode(charBuffer); byte[] bytes = Arrays.copyOfRange(byteBuffer.array(), byteBuffer.position(), byteBuffer.l...
java
public <T> T makeRequest(String call, String method, boolean authenticate, ApiRequestWriter writer, ApiResponseReader<T> reader) { HttpURLConnection connection = null; try { connection = sendRequest(call, method, authenticate, writer); handleResponseCode(connection); if(reader != null) return ...
java
public ChangesetInfo get(long id) { SingleElementHandler<ChangesetInfo> handler = new SingleElementHandler<>(); String query = CHANGESET + "/" + id + "?include_discussion=true"; try { osm.makeAuthenticatedRequest(query, null, new ChangesetParser(handler)); } catch(OsmNotFoundException e) { ...
java
public void find(Handler<ChangesetInfo> handler, QueryChangesetsFilters filters) { String query = filters != null ? "?" + filters.toParamString() : ""; try { osm.makeAuthenticatedRequest(CHANGESET + "s" + query, null, new ChangesetParser(handler)); } catch(OsmNotFoundException e) { // ok, we...
java
public ChangesetInfo comment(long id, String text) { if(text.isEmpty()) { throw new IllegalArgumentException("Text must not be empty"); } SingleElementHandler<ChangesetInfo> handler = new SingleElementHandler<>(); String apiCall = CHANGESET + "/" + id + "/comment?text=" + urlEncodeText(text); ...
java
public ChangesetInfo subscribe(long id) { SingleElementHandler<ChangesetInfo> handler = new SingleElementHandler<>(); ChangesetInfo result; try { String apiCall = CHANGESET + "/" + id + "/subscribe"; osm.makeAuthenticatedRequest(apiCall, "POST", new ChangesetParser(handler)); result = handler....
java
public ChangesetInfo unsubscribe(long id) { SingleElementHandler<ChangesetInfo> handler = new SingleElementHandler<>(); ChangesetInfo result; try { String apiCall = CHANGESET + "/" + id + "/unsubscribe"; osm.makeAuthenticatedRequest(apiCall, "POST", new ChangesetParser(handler)); result = ha...
java
public void getData(long id, MapDataChangesHandler handler, MapDataFactory factory) { osm.makeAuthenticatedRequest(CHANGESET + "/" + id + "/download", null, new MapDataChangesParser(handler, factory)); }
java
public long create( final String name, final GpsTraceDetails.Visibility visibility, final String description, final List<String> tags, final Iterable<GpsTrackpoint> trackpoints) { checkFieldLength("Name", name); checkFieldLength("Description", description); checkTagsLength(tags); /* * ...
java
public long create(String name, GpsTraceDetails.Visibility visibility, String description, final Iterable<GpsTrackpoint> trackpoints) { return create(name, visibility, description, null, trackpoints); }
java
public void update( long id, GpsTraceDetails.Visibility visibility, String description, List<String> tags) { checkFieldLength("Description", description); checkTagsLength(tags); GpsTraceWriter writer = new GpsTraceWriter(id, visibility, description, tags); osm.makeAuthenticatedRequest(GPX + "/...
java
public GpsTraceDetails get(long id) { SingleElementHandler<GpsTraceDetails> handler = new SingleElementHandler<>(); try { osm.makeAuthenticatedRequest(GPX + "/" + id, "GET", new GpsTracesParser(handler) ); } catch(OsmNotFoundException e) { return null; } return handler.get(); }
java
public void getData(long id, Handler<GpsTrackpoint> handler) { osm.makeAuthenticatedRequest(GPX + "/" + id + "/data", "GET", new GpxTrackParser(handler)); }
java
public Note create(LatLon pos, String text) { if(text.isEmpty()) { throw new IllegalArgumentException("Text may not be empty"); } String data = "lat=" + numberFormat.format(pos.getLatitude()) + "&lon=" + numberFormat.format(pos.getLongitude()) + "&text=" + urlEncode(text); String call = NOTES...
java
public Note reopen(long id, String reason) { SingleElementHandler<Note> noteHandler = new SingleElementHandler<>(); makeSingleNoteRequest(id, "reopen", reason, new NotesParser(noteHandler)); return noteHandler.get(); }
java
public void getAll(BoundingBox bounds, Handler<Note> handler, int limit, int hideClosedNoteAfter) { getAll(bounds, null, handler, limit, hideClosedNoteAfter); }
java
public void getAll(BoundingBox bounds, String search, Handler<Note> handler, int limit, int hideClosedNoteAfter) { if(limit <= 0 || limit > 10000) { throw new IllegalArgumentException("limit must be within 1 and 10000"); } if(bounds.crosses180thMeridian()) { throw new IllegalArgumentException("...
java
public void find(Handler<Note> handler, QueryNotesFilters filters) { String query = filters != null ? "?" + filters.toParamString() : ""; osm.makeAuthenticatedRequest(NOTES+"/search"+query, null, new NotesParser(handler)); }
java
public long updateMap(Map<String, String> tags, Iterable<Element> elements, Handler<DiffElement> handler) { tags.put("created_by", osm.getUserAgent()); long changesetId = openChangeset(tags); /* the try-finally is not really necessary because the server closes an open changeset after 24 hours autom...
java
public void uploadChanges(long changesetId, Iterable<Element> elements, Handler<DiffElement> handler) { MapDataDiffParser parser = null; if(handler != null) { parser = new MapDataDiffParser(handler); } osm.makeAuthenticatedRequest( "changeset/" + changesetId + "/upload", "POST", new MapDataChange...
java
public void setAll(Map<String, String> preferences) { // check it before sending it to the server in order to be able to raise a precise exception for(Map.Entry<String,String> preference : preferences.entrySet()) { checkPreferenceKeyLength(preference.getKey()); checkPreferenceValueLength(preference.getValu...
java
public void set(String key, String value) { String urlKey = urlEncode(key); checkPreferenceKeyLength(urlKey); checkPreferenceValueLength(value); osm.makeAuthenticatedRequest(USERPREFS + urlKey, "PUT", new PlainTextWriter(value)); }
java
public void delete(String key) { String urlKey = urlEncode(key); checkPreferenceKeyLength(urlKey); osm.makeAuthenticatedRequest(USERPREFS + urlKey, "DELETE"); }
java
public QueryChangesetsFilters byOpenSomeTimeBetween(Date createdBefore, Date closedAfter) { params.put("time", dateFormat.format(closedAfter) + "," + dateFormat.format(createdBefore)); return this; }
java
public R call() throws BackendException { while (hasNext) { pagesProcessed++; next(); } delegate.updatePagesHistogram(apiName, tableName, pagesProcessed); return getMergedPages(); }
java
private ScanContext grab() throws ExecutionException, InterruptedException { final Future<ScanContext> ret = exec.take(); final ScanRequest originalRequest = ret.get().getScanRequest(); final int segment = originalRequest.getSegment(); final ScanSegmentWorker sw = workers[segment]; ...
java
public boolean contains(final AbstractDynamoDbStore store, final StaticBuffer key, final StaticBuffer column) { return expectedValues.containsKey(store) && expectedValues.get(store).containsKey(key) && expectedValues.get(store).get(key).containsKey(column); }
java
public StaticBuffer get(final AbstractDynamoDbStore store, final StaticBuffer key, final StaticBuffer column) { // This method assumes the caller has called contains(..) and received a positive response return expectedValues.get(store).get(key).get(column); }
java
public void putKeyColumnOnlyIfItIsNotYetChangedInTx(final AbstractDynamoDbStore store, final StaticBuffer key, final StaticBuffer column, final StaticBuffer expectedValue) { expectedValues.computeIfAbsent(store, s -> new HashMap<>()); expectedValues.get(store).computeIfAbsent(key, k -> new HashM...
java
public CreateTableRequest getTableSchema() { return new CreateTableRequest() .withTableName(tableName) .withProvisionedThroughput(new ProvisionedThroughput(client.readCapacity(tableName), client.writeCapacity(tableName))); }
java
private int calculateExpressionBasedUpdateSize(final UpdateItemRequest request) { if (request == null || request.getUpdateExpression() == null) { throw new IllegalArgumentException("request did not use update expression"); } int size = calculateItemSizeInBytes(request.getKey()); ...
java
public static Map<String, AttributeValue> cloneItem(final Map<String, AttributeValue> item) { if (item == null) { return null; } final Map<String, AttributeValue> clonedItem = Maps.newHashMap(); final IdentityHashMap<AttributeValue, AttributeValue> sourceDestinationMap = new ...
java
private static int calculateAttributeSizeInBytes(final AttributeValue value) { int attrValSize = 0; if (value == null) { return attrValSize; } if (value.getB() != null) { final ByteBuffer b = value.getB(); attrValSize += b.remaining(); } else ...
java
private void readObject(ObjectInputStream ois) { try { ois.defaultReadObject(); pauseLock = new ReentrantLock(); pauseLock.newCondition(); } catch (Exception e) { e.printStackTrace(); } }
java