code stringlengths 73 34.1k | label stringclasses 1
value |
|---|---|
protected final void openSessionForRead(String applicationId, List<String> permissions,
SessionLoginBehavior behavior, int activityCode) {
openSession(applicationId, permissions, behavior, activityCode, SessionAuthorizationType.READ);
} | java |
public static void fetchDeferredAppLinkData(
Context context,
String applicationId,
final CompletionHandler completionHandler) {
Validate.notNull(context, "context");
Validate.notNull(completionHandler, "completionHandler");
if (applicationId == null) {
... | java |
public static AppLinkData createFromActivity(Activity activity) {
Validate.notNull(activity, "activity");
Intent intent = activity.getIntent();
if (intent == null) {
return null;
}
AppLinkData appLinkData = createFromAlApplinkData(intent);
if (appLinkData == ... | java |
public void setPattern(Pattern regex)
{
this.re = regex;
int memregCount, counterCount, lookaheadCount;
if ((memregCount = regex.memregs) > 0) {
MemReg[] memregs = new MemReg[memregCount];
for (int i = 0; i < memregCount; i++) {
memregs[i] = new MemRe... | java |
public void skip() {
int we = wEnd;
if (wOffset == we) { //requires special handling
//if no variants at 'wOutside',advance pointer and clear
if (top == null) {
wOffset++;
flush();
}
//otherwise, if there exist a variant,
... | java |
public void flush() {
top = null;
defaultEntry.reset(0);
first.reset(minQueueLength);
for (int i = memregs.length - 1; i > 0; i--) {
MemReg mr = memregs[i];
mr.in = mr.out = -1;
}
/*
for (int i = memregs.length - 1; i > 0; i--) {
... | java |
@Override
public int start(String name) {
Integer id = re.groupId(name);
if (id == null) throw new IllegalArgumentException("<" + name + "> isn't defined");
return start(id);
} | java |
private static int repeat(char[] data, int off, int out, Term term) {
switch (term.type) {
case Term.CHAR: {
char c = term.c;
int i = off;
while (i < out) {
if (data[i] != c) break;
i++;
}
... | java |
private static int find(char[] data, int off, int out, Term term) {
if (off >= out) return -1;
switch (term.type) {
case Term.CHAR: {
char c = term.c;
int i = off;
while (i < out) {
if (data[i] == c) break;
... | java |
public PendingCall present() {
logDialogActivity(activity, fragment, getEventName(appCall.getRequestIntent()),
AnalyticsEvents.PARAMETER_DIALOG_OUTCOME_VALUE_COMPLETED);
if (onPresentCallback != null) {
try {
onPresentCallback.onPresent(activity);
... | java |
public static boolean handleActivityResult(Context context, PendingCall appCall, int requestCode, Intent data,
Callback callback) {
if (requestCode != appCall.getRequestCode()) {
return false;
}
if (attachmentStore != null) {
attachmentStore.cleanupAttachment... | java |
public static boolean canPresentShareDialog(Context context, ShareDialogFeature... features) {
return handleCanPresent(context, EnumSet.of(ShareDialogFeature.SHARE_DIALOG, features));
} | java |
public static boolean canPresentMessageDialog(Context context, MessageDialogFeature... features) {
return handleCanPresent(context, EnumSet.of(MessageDialogFeature.MESSAGE_DIALOG, features));
} | java |
public static boolean canPresentOpenGraphActionDialog(Context context, OpenGraphActionDialogFeature... features) {
return handleCanPresent(context, EnumSet.of(OpenGraphActionDialogFeature.OG_ACTION_DIALOG, features));
} | java |
public static boolean canPresentOpenGraphMessageDialog(Context context, OpenGraphMessageDialogFeature... features) {
return handleCanPresent(context, EnumSet.of(OpenGraphMessageDialogFeature.OG_MESSAGE_DIALOG, features));
} | java |
private static String reduceVariant(final String variant){
if (isEmpty(variant))
throw new AssertionError("Shouldn't happen, can't reduce non existent variant");
int indexOfUnderscore = variant.lastIndexOf('_');
if (indexOfUnderscore==-1)
return "";
return variant.substring(0, indexOfUnderscore);
} | java |
@SuppressWarnings({ "unchecked" })
public static <V> V associate(Associator associator, Serializable id,
V value) {
associator.setAssociated(
new TypedIdKey<V>((Class<V>) value.getClass(), id), value);
return value;
} | java |
@SuppressWarnings({ "unchecked" })
public static <V> V put(Map<? super TypedIdKey<V>, ? super V> map,
Serializable id, V value) {
map.put(new TypedIdKey<V>((Class<V>) value.getClass(), id), value);
return value;
} | java |
public static <V> Optional<V> associated(Associator associator,
Class<V> type, Serializable id) {
return associator.associated(new TypedIdKey<>(type, id), type);
} | java |
@SuppressWarnings({ "unchecked" })
public static <V> Optional<V> get(Map<?, ?> map, Class<V> type,
Serializable id) {
return Optional
.ofNullable((V) map.get(new TypedIdKey<>(type, id)));
} | java |
public static BaseFolder with(String first, String... more) {
return new BaseFolder(Paths.get(first, more));
} | java |
@SuppressWarnings({ "PMD.GuardLogStatement", "PMD.AvoidDuplicateLiterals" })
public void add(Object obj) {
synchronized (this) {
running += 1;
if (generators != null) {
generators.put(obj, null);
generatorTracking.finest(() -> "Added generator " + obj
... | java |
@SuppressWarnings("PMD.GuardLogStatement")
public void remove(Object obj) {
synchronized (this) {
running -= 1;
if (generators != null) {
generators.remove(obj);
generatorTracking.finest(() -> "Removed generator " + obj
+ ", " + gen... | java |
@SuppressWarnings({ "PMD.CollapsibleIfStatements",
"PMD.GuardLogStatement" })
public void awaitExhaustion() throws InterruptedException {
synchronized (this) {
if (generators != null) {
if (running != generators.size()) {
generatorTracking
... | java |
@SuppressWarnings({ "PMD.CollapsibleIfStatements",
"PMD.GuardLogStatement" })
public boolean awaitExhaustion(long timeout)
throws InterruptedException {
synchronized (this) {
if (generators != null) {
if (running != generators.size()) {
gen... | java |
public boolean matchesLocale(String loc) {
return getLocale()==null || (getLocale().isPresent() && getLocale().get().startsWith(loc));
} | java |
public static Request newPostRequest(Session session, String graphPath, GraphObject graphObject, Callback callback) {
Request request = new Request(session, graphPath, null, HttpMethod.POST , callback);
request.setGraphObject(graphObject);
return request;
} | java |
public static Request newMeRequest(Session session, final GraphUserCallback callback) {
Callback wrapper = new Callback() {
@Override
public void onCompleted(Response response) {
if (callback != null) {
callback.onCompleted(response.getGraphObjectAs(Gr... | java |
public static Request newMyFriendsRequest(Session session, final GraphUserListCallback callback) {
Callback wrapper = new Callback() {
@Override
public void onCompleted(Response response) {
if (callback != null) {
callback.onCompleted(typedListFromResp... | java |
public static Request newUploadPhotoRequest(Session session, Bitmap image, Callback callback) {
Bundle parameters = new Bundle(1);
parameters.putParcelable(PICTURE_PARAM, image);
return new Request(session, MY_PHOTOS, parameters, HttpMethod.POST, callback);
} | java |
public static Request newUploadPhotoRequest(Session session, File file,
Callback callback) throws FileNotFoundException {
ParcelFileDescriptor descriptor = ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY);
Bundle parameters = new Bundle(1);
parameters.putParcelabl... | java |
public static Request newUploadVideoRequest(Session session, File file,
Callback callback) throws FileNotFoundException {
ParcelFileDescriptor descriptor = ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY);
Bundle parameters = new Bundle(1);
parameters.putParcelabl... | java |
public static Request newGraphPathRequest(Session session, String graphPath, Callback callback) {
return new Request(session, graphPath, null, null, callback);
} | java |
public static Request newPlacesSearchRequest(Session session, Location location, int radiusInMeters,
int resultsLimit, String searchText, final GraphPlaceListCallback callback) {
if (location == null && Utility.isNullOrEmpty(searchText)) {
throw new FacebookException("Either location or ... | java |
public static Request newPostOpenGraphActionRequest(Session session, OpenGraphAction openGraphAction,
Callback callback) {
if (openGraphAction == null) {
throw new FacebookException("openGraphAction cannot be null");
}
if (Utility.isNullOrEmpty(openGraphAction.getType()))... | java |
public static Request newDeleteObjectRequest(Session session, String id, Callback callback) {
return new Request(session, id, null, HttpMethod.DELETE, callback);
} | java |
public static final ConfigurationSourceKey propertyFile(final String name){
return new ConfigurationSourceKey(Type.FILE, Format.PROPERTIES, name);
} | java |
public static final ConfigurationSourceKey xmlFile(final String name){
return new ConfigurationSourceKey(Type.FILE, Format.XML, name);
} | java |
public static final ConfigurationSourceKey jsonFile(final String name){
return new ConfigurationSourceKey(Type.FILE, Format.JSON, name);
} | java |
public static <T> boolean isSubset(Collection<T> subset, Collection<T> superset) {
if ((superset == null) || (superset.size() == 0)) {
return ((subset == null) || (subset.size() == 0));
}
HashSet<T> hash = new HashSet<T>(superset);
for (T t : subset) {
if (!hash.... | java |
static InputStream getCachedImageStream(URI url, Context context) {
InputStream imageStream = null;
if (url != null) {
if (isCDNURL(url)) {
try {
FileLruCache cache = getCache(context);
imageStream = cache.get(url.toString());
... | java |
public void reduceThis(){
if (elements==null || elements.isEmpty())
throw new AssertionError("Can't reduce this environment");
elements.remove(elements.size()-1);
} | java |
public static Environment parse(final String s){
if (s==null || s.isEmpty() || s.trim().isEmpty())
return GlobalEnvironment.INSTANCE;
final String[] tokens = StringUtils.tokenize(s, '_');
final DynamicEnvironment env = new DynamicEnvironment();
for (final String t : tokens) {
env.add(t);
... | java |
public static void downloadAsync(ImageRequest request) {
if (request == null) {
return;
}
// NOTE: This is the ONLY place where the original request's Url is read. From here on,
// we will keep track of the Url separately. This is because we might be dealing with a
/... | java |
public static AppEventsLogger newLogger(Context context, String applicationId) {
return new AppEventsLogger(context, applicationId, null);
} | java |
public void logEvent(String eventName, Bundle parameters) {
logEvent(eventName, null, parameters, false);
} | java |
public void logEvent(String eventName, double valueToSum, Bundle parameters) {
logEvent(eventName, valueToSum, parameters, false);
} | java |
public void logPurchase(BigDecimal purchaseAmount, Currency currency, Bundle parameters) {
if (purchaseAmount == null) {
notifyDeveloperError("purchaseAmount cannot be null");
return;
} else if (currency == null) {
notifyDeveloperError("currency cannot be null");
... | java |
public void logSdkEvent(String eventName, Double valueToSum, Bundle parameters) {
logEvent(eventName, valueToSum, parameters, true);
} | java |
private static SessionEventsState getSessionEventsState(Context context, AccessTokenAppIdPair accessTokenAppId) {
// Do this work outside of the lock to prevent deadlocks in implementation of
// AdvertisingIdClient.getAdvertisingIdInfo, because that implementation blocks waiting on the main thread,
... | java |
private static void setSourceApplication(Activity activity) {
ComponentName callingApplication = activity.getCallingActivity();
if (callingApplication != null) {
String callingApplicationPackage = callingApplication.getPackageName();
if (callingApplicationPackage.equals(activity... | java |
private Pair<List<BooleanExpression>, Optional<BooleanExpression>> extractWhereConditions(SelectQueryAware selectQueryAware) {
List<BooleanExpression> whereConditions = new ArrayList<>();
Optional<BooleanExpression> whereExpressionCandidate = selectQueryAware.getWhereExpression();
if (w... | java |
private Pair<DataSource, Optional<BooleanExpression>> optimizeDataSource(
DataSource originalDataSource,
List<BooleanExpression> originalWhereConditions,
Map<String, Object> selectionMap,
Map<String, String> tableAliases
) {
OptimizationContext optimizationCo... | java |
public static ReplyObject success(final String name, final Object result) {
final ReplyObject ret = new ReplyObject(name, result);
ret.success = true;
return ret;
} | java |
public final void close() {
synchronized (this.lock) {
final SessionState oldState = this.state;
switch (this.state) {
case CREATED:
case OPENING:
this.state = SessionState.CLOSED_LOGIN_FAILED;
postStateChange(oldSt... | java |
public final void closeAndClearTokenInformation() {
if (this.tokenCachingStrategy != null) {
this.tokenCachingStrategy.clear();
}
Utility.clearFacebookCookies(staticContext);
Utility.clearCaches(staticContext);
close();
} | java |
public final void addCallback(StatusCallback callback) {
synchronized (callbacks) {
if (callback != null && !callbacks.contains(callback)) {
callbacks.add(callback);
}
}
} | java |
public static final void saveSession(Session session, Bundle bundle) {
if (bundle != null && session != null && !bundle.containsKey(SESSION_BUNDLE_SAVE_KEY)) {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
try {
new ObjectOutputStream(outputStream).wri... | java |
public static final Session restoreSession(
Context context, TokenCachingStrategy cachingStrategy, StatusCallback callback, Bundle bundle) {
if (bundle == null) {
return null;
}
byte[] data = bundle.getByteArray(SESSION_BUNDLE_SAVE_KEY);
if (data != null) {
... | java |
public Node getConfigurationOption (String optionName) {
NodeList children = configuration.getChildNodes ();
Node configurationOption = null;
for (int childIndex = 0; childIndex < children.getLength (); childIndex++) {
if (children.item (childIndex).getNodeName ().equals (optionName)) {
configurationOption... | java |
public String getConfigurationOptionValue (String optionName, String defaultValue) {
String optionValue;
Node configurationOption = this.getConfigurationOption (optionName);
if (configurationOption != null) {
optionValue = configurationOption.getTextContent ();
} else {
optionValue = defaultValue;
}
r... | java |
public InputStream interceptAndPut(String key, InputStream input) throws IOException {
OutputStream output = openPutStream(key);
return new CopyingInputStream(input, output);
} | java |
public void configure() {
ServletContext servletContext = ServletActionContext.getServletContext();
ServletContextTemplateResolver templateResolver = new ServletContextTemplateResolver(servletContext);
templateResolver.setTemplateMode(templateMode);
templateResolver.setCharacterEncoding(characterEncoding)... | java |
public void setContainer(Container container) {
this.container = container;
Map<String, TemplateEngine> map = new HashMap<String, TemplateEngine>();
// loading TemplateEngine class from DI Container.
Set<String> prefixes = container.getInstanceNames(TemplateEngine.class);
for (String prefix : prefixe... | java |
public static boolean hasTokenInformation(Bundle bundle) {
if (bundle == null) {
return false;
}
String token = bundle.getString(TOKEN_KEY);
if ((token == null) || (token.length() == 0)) {
return false;
}
long expiresMilliseconds = bundle.getLong... | java |
public static String getToken(Bundle bundle) {
Validate.notNull(bundle, "bundle");
return bundle.getString(TOKEN_KEY);
} | java |
public static void putToken(Bundle bundle, String value) {
Validate.notNull(bundle, "bundle");
Validate.notNull(value, "value");
bundle.putString(TOKEN_KEY, value);
} | java |
public static Date getExpirationDate(Bundle bundle) {
Validate.notNull(bundle, "bundle");
return getDate(bundle, EXPIRATION_DATE_KEY);
} | java |
public static List<String> getPermissions(Bundle bundle) {
Validate.notNull(bundle, "bundle");
return bundle.getStringArrayList(PERMISSIONS_KEY);
} | java |
public static void putPermissions(Bundle bundle, List<String> value) {
Validate.notNull(bundle, "bundle");
Validate.notNull(value, "value");
ArrayList<String> arrayList;
if (value instanceof ArrayList<?>) {
arrayList = (ArrayList<String>) value;
} else {
... | java |
public static void putDeclinedPermissions(Bundle bundle, List<String> value) {
Validate.notNull(bundle, "bundle");
Validate.notNull(value, "value");
ArrayList<String> arrayList;
if (value instanceof ArrayList<?>) {
arrayList = (ArrayList<String>) value;
} else {
... | java |
public static AccessTokenSource getSource(Bundle bundle) {
Validate.notNull(bundle, "bundle");
if (bundle.containsKey(TokenCachingStrategy.TOKEN_SOURCE_KEY)) {
return (AccessTokenSource) bundle.getSerializable(TokenCachingStrategy.TOKEN_SOURCE_KEY);
} else {
boolean isSSO... | java |
public static void putSource(Bundle bundle, AccessTokenSource value) {
Validate.notNull(bundle, "bundle");
bundle.putSerializable(TOKEN_SOURCE_KEY, value);
} | java |
public static Date getLastRefreshDate(Bundle bundle) {
Validate.notNull(bundle, "bundle");
return getDate(bundle, LAST_REFRESH_DATE_KEY);
} | java |
public Builder newCopyBuilder() {
return new Builder(getInputFormat(), getOutputFormat(), getActivity()).locale(getLocale()).setRequiredOptions(keys);
} | java |
public static Builder newConvertBuilder(String input, String output) {
return new Builder(input, output, TaskGroupActivity.CONVERT);
} | java |
@SuppressWarnings({ "PMD.DataflowAnomalyAnalysis",
"PMD.AvoidCatchingGenericException",
"PMD.UseStringBufferForStringAppends", "PMD.SystemPrintln" })
public void printError(Error event) {
String msg = "Unhandled " + event;
System.err.println(msg);
if (event.throwable() == nul... | java |
protected List<Segment> segment() {
List<Segment> segments = new ArrayList<>();
List<Recipe> recipeStack = new ArrayList<>();
recipeStack.add(this);
_segment(new Recipe(), recipeStack, null, segments);
return segments;
} | java |
@RequestHandler(patterns = "/ws/echo", priority = 100)
public void onGet(Request.In.Get event, IOSubchannel channel)
throws InterruptedException {
final HttpRequest request = event.httpRequest();
if (!request.findField(
HttpField.UPGRADE, Converters.STRING_LIST)
.... | java |
@Handler
public void onUpgraded(Upgraded event, IOSubchannel channel) {
if (!openChannels.contains(channel)) {
return;
}
channel.respond(Output.from("/Greetings!", true));
} | java |
@Handler
public void onOutput(Output<ByteBuffer> event,
PlainChannel plainChannel)
throws InterruptedException, SSLException, ExecutionException {
if (plainChannel.hub() != this) {
return;
}
plainChannel.sendUpstream(event);
} | java |
@Handler
public void onClose(Close event, PlainChannel plainChannel)
throws InterruptedException, SSLException {
if (plainChannel.hub() != this) {
return;
}
plainChannel.close(event);
} | java |
@Handler
public void onInput(Input<ByteBuffer> event, Channel channel) {
Writer writer = inputWriters.get(channel);
if (writer != null) {
writer.write(event.buffer());
}
} | java |
@Handler
public void onClose(Close event, Channel channel)
throws InterruptedException {
Writer writer = inputWriters.get(channel);
if (writer != null) {
writer.close(event);
}
writer = outputWriters.get(channel);
if (writer != null) {
writ... | java |
@Handler(priority = -1000)
public void onStop(Stop event) throws InterruptedException {
while (!inputWriters.isEmpty()) {
Writer handler = inputWriters.entrySet().iterator().next()
.getValue();
handler.close(event);
}
while (!outputWriters.isEmpty()) {... | java |
private String data() {
if (datasets.isEmpty()) {
return "";
} else {
final StringBuilder ret = new StringBuilder();
int biggestSize = 0;
for (final Dataset dataset : datasets) {
biggestSize = Math.max(biggestSize, dataset.numPoints());
}
for (int row = 0; row < bigge... | java |
private String valueOrBlank(Dataset dataset, int idx) {
if (idx < dataset.numPoints()) {
return Double.toString(dataset.get(idx));
} else {
return "";
}
} | java |
public static void main(String[] argv) throws IOException {
final File outputDir = new File(argv[0]);
final Random rand = new Random();
final double mean1 = 5.0;
final double mean2 = 7.0;
final double dev1 = 2.0;
final double dev2 = 4.0;
final double[] data1 = new double[100];
final do... | java |
@Override
public void setFirstAxis(double x, double y, double z, double extent, CoordinateSystem3D system) {
this.axis1.set(x, y, z);
assert(this.axis1.isUnitVector());
if (system.isLeftHanded()) {
this.axis3.set(this.axis1.crossLeftHand(this.axis2));
} else {
this.axis3.set(this.axis3.crossRightHand(thi... | java |
public ObjectProperty<PathWindingRule> windingRuleProperty() {
if (this.windingRule == null) {
this.windingRule = new SimpleObjectProperty<>(this, MathFXAttributeNames.WINDING_RULE, DEFAULT_WINDING_RULE);
}
return this.windingRule;
} | java |
public BooleanProperty isPolylineProperty() {
if (this.isPolyline == null) {
this.isPolyline = new ReadOnlyBooleanWrapper(this, MathFXAttributeNames.IS_POLYLINE, false);
this.isPolyline.bind(Bindings.createBooleanBinding(() -> {
boolean first = true;
boolean hasOneLine = false;
for (final PathElemen... | java |
public BooleanProperty isCurvedProperty() {
if (this.isCurved == null) {
this.isCurved = new ReadOnlyBooleanWrapper(this, MathFXAttributeNames.IS_CURVED, false);
this.isCurved.bind(Bindings.createBooleanBinding(() -> {
for (final PathElementType type : innerTypesProperty()) {
if (type == PathElementTy... | java |
public BooleanProperty isPolygonProperty() {
if (this.isPolygon == null) {
this.isPolygon = new ReadOnlyBooleanWrapper(this, MathFXAttributeNames.IS_POLYGON, false);
this.isPolygon.bind(Bindings.createBooleanBinding(() -> {
boolean first = true;
boolean lastIsClose = false;
for (final PathElementTyp... | java |
protected ReadOnlyListWrapper<PathElementType> innerTypesProperty() {
if (this.types == null) {
this.types = new ReadOnlyListWrapper<>(this, MathFXAttributeNames.TYPES,
FXCollections.observableList(new ArrayList<>()));
}
return this.types;
} | java |
protected void setMapLayerAt(int index, L layer) {
this.subLayers.set(index, layer);
layer.setContainer(this);
resetBoundingBox();
} | java |
protected void fireLayerAddedEvent(MapLayer layer, int index) {
fireLayerHierarchyChangedEvent(new MapLayerHierarchyEvent(this, layer, Type.ADD_CHILD, index, layer.isTemporaryLayer()));
} | java |
protected void fireLayerRemovedEvent(MapLayer layer, int oldChildIndex) {
fireLayerHierarchyChangedEvent(new MapLayerHierarchyEvent(
this, layer, Type.REMOVE_CHILD, oldChildIndex, layer.isTemporaryLayer()));
} | java |
protected void fireLayerMovedUpEvent(MapLayer layer, int newIndex) {
fireLayerHierarchyChangedEvent(new MapLayerHierarchyEvent(this, layer,
Type.MOVE_CHILD_UP, newIndex, layer.isTemporaryLayer()));
} | java |
protected void fireLayerMovedDownEvent(MapLayer layer, int newIndex) {
fireLayerHierarchyChangedEvent(new MapLayerHierarchyEvent(this, layer,
Type.MOVE_CHILD_DOWN, newIndex, layer.isTemporaryLayer()));
} | java |
protected void fireLayerRemoveAllEvent(List<? extends L> removedObjects) {
fireLayerHierarchyChangedEvent(
new MapLayerHierarchyEvent(
this,
removedObjects,
Type.REMOVE_ALL_CHILDREN,
-1,
isTemporaryLayer()));
} | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.