_id stringlengths 2 7 | title stringlengths 3 140 | partition stringclasses 3
values | text stringlengths 73 34.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q154800 | Treap.createTreap | train | public int createTreap(int treap_data) {
int treap = m_treapData.newElement();
setSize_(0, treap);
setTreapData_(treap_data, treap);
return treap;
} | java | {
"resource": ""
} |
q154801 | Treap.addElement | train | public int addElement(int element, int treap) {
int treap_;
if (treap == -1) {
if (m_defaultTreap == nullNode())
m_defaultTreap = createTreap(-1);
treap_ = m_defaultTreap;
} else {
treap_ = treap;
}
return addElement_(element, 0, treap_);
} | java | {
"resource": ""
} |
q154802 | Treap.addUniqueElement | train | public int addUniqueElement(int element, int treap) {
int treap_;
if (treap == -1) {
if (m_defaultTreap == nullNode())
m_defaultTreap = createTreap(-1);
treap_ = m_defaultTreap;
} else {
treap_ = treap;
}
return addElement_(element, 1, treap_);
} | java | {
"resource": ""
} |
q154803 | Treap.addElementAtPosition | train | public int addElementAtPosition(int prevNode, int nextNode, int element,
boolean bUnique, boolean bCallCompare, int treap) {
int treap_ = treap;
if (treap_ == -1) {
if (m_defaultTreap == nullNode())
m_defaultTreap = createTreap(-1);
treap_ = m_defaultTreap;
}
// dbg_check_(m_root);
if (getRoot_(... | java | {
"resource": ""
} |
q154804 | Treap.deleteNode | train | public void deleteNode(int treap_node_index, int treap) {
touch_();
// assert(isValidNode(treap_node_index));
if (m_comparator != null)
m_comparator.onDeleteImpl_(this, treap_node_index);
int treap_;
if (treap == -1)
treap_ = m_defaultTreap;
else
treap_ = treap;
if (!m_b_balancing) {
unbalan... | java | {
"resource": ""
} |
q154805 | Treap.search | train | public int search(int data, int treap) {
int cur = getRoot(treap);
while (cur != nullNode()) {
int res = m_comparator.compare(this, data, cur);
if (res == 0)
return cur;
else if (res < 0)
cur = getLeft(cur);
else
cur = getRight(cur);
}
m_comparator.onEndSearchImpl_(data);
return nullN... | java | {
"resource": ""
} |
q154806 | Treap.setElement | train | public void setElement(int treap_node_index, int newElement) {
if (m_comparator != null)
m_comparator.onSetImpl_(this, treap_node_index);
setElement_(treap_node_index, newElement);
} | java | {
"resource": ""
} |
q154807 | OperatorCentroid2DLocal.computePointsCentroid | train | private static Point2D computePointsCentroid(MultiPoint multiPoint)
{
double xSum = 0;
double ySum = 0;
int pointCount = multiPoint.getPointCount();
Point2D point2D = new Point2D();
for (int i = 0; i < pointCount; i++) {
multiPoint.getXY(i, point2D);
x... | java | {
"resource": ""
} |
q154808 | OperatorCentroid2DLocal.computePolylineCentroid | train | private static Point2D computePolylineCentroid(Polyline polyline)
{
double xSum = 0;
double ySum = 0;
double weightSum = 0;
Point2D startPoint = new Point2D();
Point2D endPoint = new Point2D();
for (int i = 0; i < polyline.getPathCount(); i++) {
polyline.... | java | {
"resource": ""
} |
q154809 | Geometry.mergeVertexDescription | train | public void mergeVertexDescription(VertexDescription src) {
_touch();
if (src == m_description)
return;
// check if we need to do anything (if the src has same attributes)
VertexDescription newdescription = VertexDescriptionDesignerImpl.getMergedVertexDescription(m_description, src);
if (newdescription ==... | java | {
"resource": ""
} |
q154810 | Geometry.addAttribute | train | public void addAttribute(int semantics) {
_touch();
if (m_description.hasAttribute(semantics))
return;
VertexDescription newvd = VertexDescriptionDesignerImpl.getMergedVertexDescription(m_description, semantics);
_assignVertexDescriptionImpl(newvd);
} | java | {
"resource": ""
} |
q154811 | Geometry.dropAttribute | train | public void dropAttribute(int semantics) {
_touch();
if (!m_description.hasAttribute(semantics))
return;
VertexDescription newvd = VertexDescriptionDesignerImpl.removeSemanticsFromVertexDescription(m_description, semantics);
_assignVertexDescriptionImpl(newvd);
} | java | {
"resource": ""
} |
q154812 | IndexMultiList.createList | train | int createList() {
int node = newList_();
if (m_b_allow_navigation_between_lists) {
m_lists.setField(node, 3, m_list_of_lists);
if (m_list_of_lists != nullNode())
m_lists.setField(m_list_of_lists, 2, node);
m_list_of_lists = node;
}
return node;
} | java | {
"resource": ""
} |
q154813 | IndexMultiList.deleteList | train | void deleteList(int list) {
int ptr = getFirst(list);
while (ptr != nullNode()) {
int p = ptr;
ptr = getNext(ptr);
freeNode_(p);
}
if (m_b_allow_navigation_between_lists) {
int prevList = m_lists.getField(list, 2);
int nextList = m_lists.getField(list, 3);
if (prevList != nullNode())
m_li... | java | {
"resource": ""
} |
q154814 | IndexMultiList.deleteElement | train | void deleteElement(int list, int prevNode, int node) {
if (prevNode != nullNode()) {
assert (m_listNodes.getField(prevNode, 1) == node);
m_listNodes.setField(prevNode, 1, m_listNodes.getField(node, 1));
if (m_lists.getField(list, 1) == node)// deleting a tail
{
m_lists.setField(list, 1, prevNode);
... | java | {
"resource": ""
} |
q154815 | IndexMultiList.concatenateLists | train | int concatenateLists(int list1, int list2) {
int tailNode1 = m_lists.getField(list1, 1);
int headNode2 = m_lists.getField(list2, 0);
if (headNode2 != nullNode())// do not concatenate empty lists
{
if (tailNode1 != nullNode()) {
// connect head of list2 to the tail of list1.
m_listNodes.setField(tailN... | java | {
"resource": ""
} |
q154816 | IndexHashTable.addElement | train | public int addElement(int element, int hash) {
int bit_bucket = hash % (m_bit_filter.length << 5);
m_bit_filter[(bit_bucket >> 5)] |= (1 << (bit_bucket & 0x1F));
int bucket = hash % m_hashBuckets.size();
int list = m_hashBuckets.get(bucket);
if (list == -1) {
list = m_lists.createList();
m_hashBuckets.s... | java | {
"resource": ""
} |
q154817 | IndexHashTable.findNode | train | public int findNode(int element) {
int hash = m_hash.getHash(element);
int ptr = getFirstInBucket(hash);
while (ptr != -1) {
int e = m_lists.getElement(ptr);
if (m_hash.equal(e, element)) {
return ptr;
}
ptr = m_lists.getNext(ptr);
}
return -1;
} | java | {
"resource": ""
} |
q154818 | IndexHashTable.findNode | train | public int findNode(Object elementDescriptor) {
int hash = m_hash.getHash(elementDescriptor);
int ptr = getFirstInBucket(hash);;
while (ptr != -1) {
int e = m_lists.getElement(ptr);
if (m_hash.equal(elementDescriptor, e)) {
return ptr;
}
ptr = m_lists.getNext(ptr);
}
return -1;
} | java | {
"resource": ""
} |
q154819 | IndexHashTable.getNextNode | train | public int getNextNode(int elementHandle) {
int element = m_lists.getElement(elementHandle);
int ptr = m_lists.getNext(elementHandle);
while (ptr != -1) {
int e = m_lists.getElement(ptr);
if (m_hash.equal(e, element)) {
return ptr;
}
ptr = m_lists.getNext(ptr);
}
return -1;
} | java | {
"resource": ""
} |
q154820 | IndexHashTable.deleteNode | train | public void deleteNode(int node) {
int element = getElement(node);
int hash = m_hash.getHash(element);
int bucket = hash % m_hashBuckets.size();
int list = m_hashBuckets.get(bucket);
if (list == -1)
throw new IllegalArgumentException();
int ptr = m_lists.getFirst(list);
int prev = -1;
while (ptr != ... | java | {
"resource": ""
} |
q154821 | IndexHashTable.clear | train | public void clear() {
Arrays.fill(m_bit_filter, 0);
m_hashBuckets = new AttributeStreamOfInt32(m_hashBuckets.size(),
nullNode());
m_lists.clear();
} | java | {
"resource": ""
} |
q154822 | ViewPropertyAnimator.animate | train | public static ViewPropertyAnimator animate(View view) {
ViewPropertyAnimator animator = ANIMATORS.get(view);
if (animator == null) {
final int version = Integer.valueOf(Build.VERSION.SDK);
if (version >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
animator = new Vie... | java | {
"resource": ""
} |
q154823 | FlakeView.addFlakes | train | void addFlakes(int quantity) {
for (int i = 0; i < quantity; ++i) {
flakes.add(Flake.createFlake(getWidth(), droid));
}
setNumFlakes(numFlakes + quantity);
} | java | {
"resource": ""
} |
q154824 | FlakeView.subtractFlakes | train | void subtractFlakes(int quantity) {
for (int i = 0; i < quantity; ++i) {
int index = numFlakes - i - 1;
flakes.remove(index);
}
setNumFlakes(numFlakes - quantity);
} | java | {
"resource": ""
} |
q154825 | Flake.createFlake | train | static Flake createFlake(float xRange, Bitmap originalBitmap) {
Flake flake = new Flake();
// Size each flake with a width between 5 and 55 and a proportional height
flake.width = (int)(5 + (float)Math.random() * 50);
float hwRatio = originalBitmap.getHeight() / originalBitmap.getWidth()... | java | {
"resource": ""
} |
q154826 | PropertyValuesHolder.ofObject | train | public static PropertyValuesHolder ofObject(String propertyName, TypeEvaluator evaluator,
Object... values) {
PropertyValuesHolder pvh = new PropertyValuesHolder(propertyName);
pvh.setObjectValues(values);
pvh.setEvaluator(evaluator);
return pvh;
} | java | {
"resource": ""
} |
q154827 | PropertyValuesHolder.ofObject | train | public static <V> PropertyValuesHolder ofObject(Property property,
TypeEvaluator<V> evaluator, V... values) {
PropertyValuesHolder pvh = new PropertyValuesHolder(property);
pvh.setObjectValues(values);
pvh.setEvaluator(evaluator);
return pvh;
} | java | {
"resource": ""
} |
q154828 | PropertyValuesHolder.setKeyframes | train | public void setKeyframes(Keyframe... values) {
int numKeyframes = values.length;
Keyframe keyframes[] = new Keyframe[Math.max(numKeyframes,2)];
mValueType = ((Keyframe)values[0]).getType();
for (int i = 0; i < numKeyframes; ++i) {
keyframes[i] = (Keyframe)values[i];
}... | java | {
"resource": ""
} |
q154829 | PropertyValuesHolder.getPropertyFunction | train | private Method getPropertyFunction(Class targetClass, String prefix, Class valueType) {
// TODO: faster implementation...
Method returnVal = null;
String methodName = getMethodName(prefix, mPropertyName);
Class args[] = null;
if (valueType == null) {
try {
... | java | {
"resource": ""
} |
q154830 | PropertyValuesHolder.setupSetterOrGetter | train | private Method setupSetterOrGetter(Class targetClass,
HashMap<Class, HashMap<String, Method>> propertyMapMap,
String prefix, Class valueType) {
Method setterOrGetter = null;
try {
// Have to lock property map prior to reading it, to guard against
// anothe... | java | {
"resource": ""
} |
q154831 | PropertyValuesHolder.setupEndValue | train | void setupEndValue(Object target) {
setupValue(target, mKeyframeSet.mKeyframes.get(mKeyframeSet.mKeyframes.size() - 1));
} | java | {
"resource": ""
} |
q154832 | PropertyValuesHolder.init | train | void init() {
if (mEvaluator == null) {
// We already handle int and float automatically, but not their Object
// equivalents
mEvaluator = (mValueType == Integer.class) ? sIntEvaluator :
(mValueType == Float.class) ? sFloatEvaluator :
n... | java | {
"resource": ""
} |
q154833 | ViewPropertyAnimatorPreHC.setDuration | train | public ViewPropertyAnimator setDuration(long duration) {
if (duration < 0) {
throw new IllegalArgumentException("Animators cannot have negative duration: " +
duration);
}
mDurationSet = true;
mDuration = duration;
return this;
} | java | {
"resource": ""
} |
q154834 | ViewPropertyAnimatorPreHC.startAnimation | train | private void startAnimation() {
ValueAnimator animator = ValueAnimator.ofFloat(1.0f);
ArrayList<NameValuesHolder> nameValueList =
(ArrayList<NameValuesHolder>) mPendingAnimations.clone();
mPendingAnimations.clear();
int propertyMask = 0;
int propertyCount = nameVa... | java | {
"resource": ""
} |
q154835 | ObjectAnimator.setTarget | train | @Override
public void setTarget(Object target) {
if (mTarget != target) {
final Object oldTarget = mTarget;
mTarget = target;
if (oldTarget != null && target != null && oldTarget.getClass() == target.getClass()) {
return;
}
// New t... | java | {
"resource": ""
} |
q154836 | ValueAnimator.ofPropertyValuesHolder | train | public static ValueAnimator ofPropertyValuesHolder(PropertyValuesHolder... values) {
ValueAnimator anim = new ValueAnimator();
anim.setValues(values);
return anim;
} | java | {
"resource": ""
} |
q154837 | ValueAnimator.addUpdateListener | train | public void addUpdateListener(AnimatorUpdateListener listener) {
if (mUpdateListeners == null) {
mUpdateListeners = new ArrayList<AnimatorUpdateListener>();
}
mUpdateListeners.add(listener);
} | java | {
"resource": ""
} |
q154838 | ValueAnimator.removeUpdateListener | train | public void removeUpdateListener(AnimatorUpdateListener listener) {
if (mUpdateListeners == null) {
return;
}
mUpdateListeners.remove(listener);
if (mUpdateListeners.size() == 0) {
mUpdateListeners = null;
}
} | java | {
"resource": ""
} |
q154839 | ValueAnimator.reverse | train | public void reverse() {
mPlayingBackwards = !mPlayingBackwards;
if (mPlayingState == RUNNING) {
long currentTime = AnimationUtils.currentAnimationTimeMillis();
long currentPlayTime = currentTime - mStartTime;
long timeLeft = mDuration - currentPlayTime;
mS... | java | {
"resource": ""
} |
q154840 | ValueAnimator.endAnimation | train | private void endAnimation() {
sAnimations.get().remove(this);
sPendingAnimations.get().remove(this);
sDelayedAnims.get().remove(this);
mPlayingState = STOPPED;
if (mRunning && mListeners != null) {
ArrayList<AnimatorListener> tmpListeners =
(ArrayL... | java | {
"resource": ""
} |
q154841 | ValueAnimator.startAnimation | train | private void startAnimation() {
initAnimation();
sAnimations.get().add(this);
if (mStartDelay > 0 && mListeners != null) {
// Listeners were already notified in start() if startDelay is 0; this is
// just for delayed animations
ArrayList<AnimatorListener> tmpL... | java | {
"resource": ""
} |
q154842 | ValueAnimator.clearAllAnimations | train | public static void clearAllAnimations() {
sAnimations.get().clear();
sPendingAnimations.get().clear();
sDelayedAnims.get().clear();
} | java | {
"resource": ""
} |
q154843 | AnimatorSet.getChildAnimations | train | public ArrayList<Animator> getChildAnimations() {
ArrayList<Animator> childList = new ArrayList<Animator>();
for (Node node : mNodes) {
childList.add(node.animation);
}
return childList;
} | java | {
"resource": ""
} |
q154844 | AnimatorSet.isRunning | train | @Override
public boolean isRunning() {
for (Node node : mNodes) {
if (node.animation.isRunning()) {
return true;
}
}
return false;
} | java | {
"resource": ""
} |
q154845 | AnimatorSet.setDuration | train | @Override
public AnimatorSet setDuration(long duration) {
if (duration < 0) {
throw new IllegalArgumentException("duration must be a value of zero or greater");
}
for (Node node : mNodes) {
// TODO: don't set the duration of the timing-only nodes created by AnimatorSe... | java | {
"resource": ""
} |
q154846 | DropboxAuth.doStart | train | public void doStart(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
if (!common.checkPost(request, response)) return;
User user = common.requireLoggedInUser(request, response);
if (user == null) return;
// Start the authorizat... | java | {
"resource": ""
} |
q154847 | DropboxAuth.doFinish | train | public void doFinish(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
if (!common.checkGet(request, response)) return;
User user = common.requireLoggedInUser(request, response);
if (user == null) {
common.pageSoftError(resp... | java | {
"resource": ""
} |
q154848 | DbxWebAuth.start | train | @Deprecated
public String start(/*@Nullable*/String urlState) {
if (deprecatedRequest == null) {
throw new IllegalStateException("Must use DbxWebAuth.authorize instead.");
}
return authorizeImpl(
deprecatedRequest.copy()
.withState(urlState)
... | java | {
"resource": ""
} |
q154849 | DbxWebAuth.finishFromRedirect | train | public DbxAuthFinish finishFromRedirect(String redirectUri,
DbxSessionStore sessionStore,
Map<String, String[]> params)
throws DbxException, BadRequestException, BadStateException, CsrfException, NotApprovedException, Provid... | java | {
"resource": ""
} |
q154850 | DbxOfficialAppConnector.addExtrasToIntent | train | protected void addExtrasToIntent(Context context, Intent intent) {
intent.putExtra(EXTRA_DROPBOX_UID, uid);
intent.putExtra(EXTRA_CALLING_PACKAGE, context.getPackageName());
} | java | {
"resource": ""
} |
q154851 | DbxOfficialAppConnector.getLoggedinState | train | private static int getLoggedinState(Context context, String uid) {
Cursor cursor = context.getContentResolver().query(
LOGGED_IN_URI.buildUpon().appendPath(uid).build(), null, // projection
null, // selection clause
null, // selection args
null); // sort order
... | java | {
"resource": ""
} |
q154852 | DbxOfficialAppConnector.getDropboxAppPackage | train | static PackageInfo getDropboxAppPackage(Context context, Intent intent) {
PackageManager manager = context.getPackageManager();
List<ResolveInfo> infos = manager.queryIntentActivities(intent, 0);
if (null == infos || 1 != infos.size()) {
// The official app doesn't exist, or only an... | java | {
"resource": ""
} |
q154853 | DbxRequestConfig.toLanguageTag | train | private static String toLanguageTag(Locale locale) {
if (locale == null) {
return null;
}
StringBuilder tag = new StringBuilder();
tag.append(locale.getLanguage().toLowerCase());
if (!locale.getCountry().isEmpty()) {
tag.append("-");
tag.appe... | java | {
"resource": ""
} |
q154854 | DbxRequestConfig.toLanguageTag | train | private static String toLanguageTag(String locale) {
if (locale == null) {
return null;
}
// assume we are already a language tag
if (!locale.contains("_")) {
return locale;
}
// language can be missing, in which case we don't even bother
... | java | {
"resource": ""
} |
q154855 | DbxClientV1.getMetadata | train | public /*@Nullable*/DbxEntry getMetadata(final String path, boolean includeMediaInfo)
throws DbxException
{
DbxPathV1.checkArg("path", path);
String host = this.host.getApi();
String apiPath = "1/metadata/auto" + path;
/*@Nullable*/String[] params = {
"list", "fa... | java | {
"resource": ""
} |
q154856 | DbxClientV1.getMetadataWithChildren | train | public DbxEntry./*@Nullable*/WithChildren getMetadataWithChildren(String path, boolean includeMediaInfo)
throws DbxException
{
return getMetadataWithChildrenBase(path, includeMediaInfo, DbxEntry.WithChildren.ReaderMaybeDeleted);
} | java | {
"resource": ""
} |
q154857 | DbxClientV1.getAccountInfo | train | public DbxAccountInfo getAccountInfo()
throws DbxException
{
String host = this.host.getApi();
String apiPath = "1/account/info";
return doGet(host, apiPath, null, null, new DbxRequestUtil.ResponseHandler<DbxAccountInfo>() {
@Override
public DbxAccountInfo ha... | java | {
"resource": ""
} |
q154858 | DbxClientV1.startGetSomething | train | private /*@Nullable*/Downloader startGetSomething(final String apiPath,
final /*@Nullable*/String[] params)
throws DbxException
{
final String host = this.host.getContent();
// we don't use doGet() here because doGet() will close our inp... | java | {
"resource": ""
} |
q154859 | DbxClientV1.chunkedUploadCommon | train | private <E extends Throwable> HttpRequestor.Response chunkedUploadCommon(String[] params, long chunkSize, DbxStreamWriter<E> writer)
throws DbxException, E
{
String apiPath = "1/chunked_upload";
ArrayList<HttpRequestor.Header> headers = new ArrayList<HttpRequestor.Header>();
headers... | java | {
"resource": ""
} |
q154860 | DbxClientV1.chunkedUploadAppend | train | public long chunkedUploadAppend(String uploadId, long uploadOffset, byte[] data, int dataOffset, int dataLength)
throws DbxException
{
return chunkedUploadAppend(uploadId, uploadOffset, dataLength, new DbxStreamWriter.ByteArrayCopier(data, dataOffset, dataLength));
} | java | {
"resource": ""
} |
q154861 | DbxClientV1.chunkedUploadAppend | train | public <E extends Throwable> long chunkedUploadAppend(String uploadId, long uploadOffset, long chunkSize, DbxStreamWriter<E> writer)
throws DbxException, E
{
if (uploadId == null) throw new IllegalArgumentException("'uploadId' can't be null");
if (uploadId.length() == 0) throw new IllegalArg... | java | {
"resource": ""
} |
q154862 | DbxClientV1.getThumbnail | train | public DbxEntry./*@Nullable*/File getThumbnail(
DbxThumbnailSize sizeBound, DbxThumbnailFormat format,
String path, /*@Nullable*/String rev, OutputStream target)
throws DbxException, IOException
{
if (target == null) throw new IllegalArgumentException("'target' can't be n... | java | {
"resource": ""
} |
q154863 | DbxClientV1.restoreFile | train | public DbxEntry./*@Nullable*/File restoreFile(String path, String rev)
throws DbxException
{
DbxPathV1.checkArgNonRoot("path", path);
if (rev == null) throw new IllegalArgumentException("'rev' can't be null");
if (rev.length() == 0) throw new IllegalArgumentException("'rev' can't be ... | java | {
"resource": ""
} |
q154864 | DbxClientV1.searchFileAndFolderNames | train | public List<DbxEntry> searchFileAndFolderNames(String basePath, String query)
throws DbxException
{
DbxPathV1.checkArg("basePath", basePath);
if (query == null) throw new IllegalArgumentException("'query' can't be null");
if (query.length() == 0) throw new IllegalArgumentException("'... | java | {
"resource": ""
} |
q154865 | DbxClientV1.createShareableUrl | train | public /*@Nullable*/String createShareableUrl(String path)
throws DbxException
{
DbxPathV1.checkArg("path", path);
String apiPath = "1/shares/auto" + path;
String[] params = {"short_url", "false"};
return doPost(host.getApi(), apiPath, params, null, new DbxRequestUtil.Respo... | java | {
"resource": ""
} |
q154866 | DbxClientV1.createTemporaryDirectUrl | train | public /*@Nullable*/DbxUrlWithExpiration createTemporaryDirectUrl(String path)
throws DbxException
{
DbxPathV1.checkArgNonRoot("path", path);
String apiPath = "1/media/auto" + path;
return doPost(host.getApi(), apiPath, null, null, new DbxRequestUtil.ResponseHandler</*@Nullable*/Db... | java | {
"resource": ""
} |
q154867 | DbxClientV1.createCopyRef | train | public /*@Nullable*/String createCopyRef(String path)
throws DbxException
{
DbxPathV1.checkArgNonRoot("path", path);
String apiPath = "1/copy_ref/auto" + path;
return doPost(host.getApi(), apiPath, null, null, new DbxRequestUtil.ResponseHandler</*@Nullable*/String>()
{
... | java | {
"resource": ""
} |
q154868 | DbxClientV1.createFolder | train | public DbxEntry./*@Nullable*/Folder createFolder(String path)
throws DbxException
{
DbxPathV1.checkArgNonRoot("path", path);
String[] params = {
"root", "auto",
"path", path,
};
return doPost(host.getApi(), "1/fileops/create_folder", params, null, ne... | java | {
"resource": ""
} |
q154869 | DbxClientV1.delete | train | public void delete(String path)
throws DbxException
{
DbxPathV1.checkArgNonRoot("path", path);
String[] params = {
"root", "auto",
"path", path,
};
doPost(host.getApi(), "1/fileops/delete", params, null, new DbxRequestUtil.ResponseHandler<Void>() {
... | java | {
"resource": ""
} |
q154870 | DbxClientV1.doGet | train | private <T> T doGet(String host, String path, /*@Nullable*/String/*@Nullable*/[] params,
/*@Nullable*/ArrayList<HttpRequestor.Header> headers,
DbxRequestUtil.ResponseHandler<T> handler)
throws DbxException
{
return DbxRequestUtil.doGet(requestConfig, a... | java | {
"resource": ""
} |
q154871 | DbxUploader.finish | train | public R finish() throws X, DbxException {
assertOpenAndUnfinished();
HttpRequestor.Response response = null;
try {
response = httpUploader.finish();
try {
if (response.getStatusCode() == 200) {
return responseSerializer.deserialize(r... | java | {
"resource": ""
} |
q154872 | Main.uploadFile | train | private static void uploadFile(DbxClientV2 dbxClient, File localFile, String dropboxPath) {
try (InputStream in = new FileInputStream(localFile)) {
ProgressListener progressListener = l -> printProgress(l, localFile.length());
FileMetadata metadata = dbxClient.files().uploadBuilder(drop... | java | {
"resource": ""
} |
q154873 | DropboxBrowse.doBrowse | train | public void doBrowse(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException
{
if (!common.checkGet(request, response)) return;
User user = common.getLoggedInUser(request);
if (user == null) {
common.pageSoftError(response, "Can'... | java | {
"resource": ""
} |
q154874 | DbxOAuth1Upgrader.createOAuth2AccessToken | train | public String createOAuth2AccessToken(DbxOAuth1AccessToken token)
throws DbxException
{
if (token == null) throw new IllegalArgumentException("'token' can't be null");
return DbxRequestUtil.doPostNoAuth(
requestConfig,
DbxClientV1.USER_AGENT_ID,
appInfo.ge... | java | {
"resource": ""
} |
q154875 | DbxOAuth1Upgrader.disableOAuth1AccessToken | train | public void disableOAuth1AccessToken(DbxOAuth1AccessToken token)
throws DbxException
{
if (token == null) throw new IllegalArgumentException("'token' can't be null");
DbxRequestUtil.doPostNoAuth(
requestConfig,
DbxClientV1.USER_AGENT_ID,
appInfo.getHost().... | java | {
"resource": ""
} |
q154876 | DbxWebAuthNoRedirect.start | train | public String start() {
DbxWebAuth.Request request = DbxWebAuth.newRequestBuilder()
.withNoRedirect()
.build();
return auth.authorize(request);
} | java | {
"resource": ""
} |
q154877 | Main.longpoll | train | public static void longpoll(DbxAuthInfo auth, String path) throws IOException {
long longpollTimeoutSecs = TimeUnit.MINUTES.toSeconds(2);
// need 2 Dropbox clients for making calls:
//
// (1) One for longpoll requests, with its read timeout set longer than our polling timeout
//... | java | {
"resource": ""
} |
q154878 | Main.createClient | train | private static DbxClientV2 createClient(DbxAuthInfo auth, StandardHttpRequestor.Config config) {
String clientUserAgentId = "examples-longpoll";
StandardHttpRequestor requestor = new StandardHttpRequestor(config);
DbxRequestConfig requestConfig = DbxRequestConfig.newBuilder(clientUserAgentId)
... | java | {
"resource": ""
} |
q154879 | Main.printChanges | train | private static String printChanges(DbxClientV2 client, String cursor)
throws DbxApiException, DbxException {
while (true) {
ListFolderResult result = client.files()
.listFolderContinue(cursor);
for (Metadata metadata : result.getEntries()) {
Strin... | java | {
"resource": ""
} |
q154880 | DbxRawClientV2.executeRetriable | train | private static <T> T executeRetriable(int maxRetries, RetriableExecution<T> execution) throws DbxWrappedException, DbxException {
if (maxRetries == 0) {
return execution.execute();
}
int retries = 0;
while (true) {
try {
return execution.execute()... | java | {
"resource": ""
} |
q154881 | Main.doLogin | train | public void doLogin(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
if (!common.checkPost(request, response)) return;
String username = request.getParameter("username");
if (username == null) {
response.sendError(400, "Missing field \... | java | {
"resource": ""
} |
q154882 | Main.checkUsername | train | private static String checkUsername(String username) {
if (username.length() < 3) {
return "too short (minimum: 3 characters)";
} else if (username.length() > 64) {
return "too long (maximum: 64 characters)";
}
for (int i = 0; i < username.length(); i++) {
... | java | {
"resource": ""
} |
q154883 | Main.doLogout | train | public void doLogout(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
if (!common.checkPost(request, response)) return;
request.getSession().removeAttribute("logged-in-username");
response.sendRedirect("/");
} | java | {
"resource": ""
} |
q154884 | DbxRequestUtil.startGet | train | public static HttpRequestor.Response startGet(DbxRequestConfig requestConfig,
String accessToken,
String sdkUserAgentIdentifier,
String host,
... | java | {
"resource": ""
} |
q154885 | DbxRequestUtil.startPostNoAuth | train | public static HttpRequestor.Response startPostNoAuth(DbxRequestConfig requestConfig,
String sdkUserAgentIdentifier,
String host,
String path,
... | java | {
"resource": ""
} |
q154886 | StringUtil.javaQuotedLiteral | train | public static String javaQuotedLiteral(String value)
{
StringBuilder b = new StringBuilder(value.length() * 2);
b.append('"');
for (int i = 0; i < value.length(); i++) {
char c = value.charAt(i);
switch (c) {
case '"': b.append("\\\""); break;
... | java | {
"resource": ""
} |
q154887 | StringUtil.binaryToHex | train | public static String binaryToHex(byte[] data, int offset, int length)
{
assert offset < data.length && offset >= 0 : offset + ", " + data.length;
int end = offset + length;
assert end <= data.length && end >= 0 : offset + ", " + length + ", " + data.length;
char[] chars = new char[l... | java | {
"resource": ""
} |
q154888 | FormProtection.checkAntiCsrfToken | train | public static String checkAntiCsrfToken(HttpServletRequest request) throws IOException, ServletException
{
if (request.getContentType() != null &&
request.getContentType().toLowerCase().indexOf("multipart/form-data") > -1 &&
request.getPart("anti-csrf-token") == null ||
r... | java | {
"resource": ""
} |
q154889 | JsonReader.expectObjectStart | train | public static JsonLocation expectObjectStart(JsonParser parser)
throws IOException, JsonReadException
{
if (parser.getCurrentToken() != JsonToken.START_OBJECT) {
throw new JsonReadException("expecting the start of an object (\"{\")", parser.getTokenLocation());
}
JsonLoca... | java | {
"resource": ""
} |
q154890 | LZ4Factory.main | train | public static void main(String[] args) {
System.out.println("Fastest instance is " + fastestInstance());
System.out.println("Fastest Java instance is " + fastestJavaInstance());
} | java | {
"resource": ""
} |
q154891 | LZ4FrameInputStream.nextFrameInfo | train | private boolean nextFrameInfo() throws IOException {
while (true) {
int size = 0;
do {
final int mySize = in.read(readNumberBuff.array(), size, LZ4FrameOutputStream.INTEGER_BYTES - size);
if (mySize < 0) {
return false;
}
size += mySize;
} while (size < LZ4FrameOutputStream.INTEGER_BYTES);
... | java | {
"resource": ""
} |
q154892 | QueryStringDecoder.decodeHexNibble | train | private static char decodeHexNibble(final char c) {
if ('0' <= c && c <= '9') {
return (char) (c - '0');
} else if ('a' <= c && c <= 'f') {
return (char) (c - 'a' + 10);
} else if ('A' <= c && c <= 'F') {
return (char) (c - 'A' + 10);
} else {
return Character.MAX_VALUE;
}
... | java | {
"resource": ""
} |
q154893 | CalculatorApp.exceptionMiddleware | train | static <T> Middleware<SyncHandler<Response<T>>, SyncHandler<Response<T>>> exceptionMiddleware() {
return handler -> requestContext -> {
try {
return handler.invoke(requestContext);
} catch (RuntimeException e) {
return Response.forStatus(Status.IM_A_TEAPOT);
}
};
} | java | {
"resource": ""
} |
q154894 | MetaDescriptor.loadVersion | train | private static String loadVersion(ClassLoader classLoader) throws IOException {
try {
Enumeration<URL> resources = classLoader.getResources("META-INF/MANIFEST.MF");
while (resources.hasMoreElements()) {
final URL url = resources.nextElement();
final Manifest manifest = new Manifest(url.... | java | {
"resource": ""
} |
q154895 | RuleRouter.of | train | public static <T> RuleRouter<T> of(final Iterable<Rule<T>> rules) {
return new RuleRouter<>(ImmutableList.copyOf(rules));
} | java | {
"resource": ""
} |
q154896 | HtmlSerializerMiddlewares.serialize | train | public static <T> ByteString serialize(final String templateName, T object) {
StringWriter templateResults = new StringWriter();
try {
final Template template = configuration.getTemplate(templateName);
template.process(object, templateResults);
} catch (Exception e) {
throw Throwables.prop... | java | {
"resource": ""
} |
q154897 | HtmlSerializerMiddlewares.htmlSerialize | train | public static <T> Middleware<AsyncHandler<T>, AsyncHandler<Response<ByteString>>> htmlSerialize(
final String templateName) {
return handler ->
requestContext -> handler.invoke(requestContext)
.thenApply(result -> Response
.forPayload(serialize(templateName, result))
... | java | {
"resource": ""
} |
q154898 | HtmlSerializerMiddlewares.htmlSerializeResponse | train | public static <T> Middleware<AsyncHandler<Response<T>>, AsyncHandler<Response<ByteString>>>
htmlSerializeResponse(final String templateName) {
return handler ->
requestContext -> handler.invoke(requestContext)
.thenApply(response -> response
.withPayload(serialize(templateName,... | java | {
"resource": ""
} |
q154899 | HtmlSerializerMiddlewares.htmlSerializeSync | train | public static <T> Middleware<SyncHandler<T>, AsyncHandler<Response<ByteString>>> htmlSerializeSync(
final String templateName) {
Middleware<SyncHandler<T>, AsyncHandler<T>> syncToAsync = Middleware::syncToAsync;
return syncToAsync.and(htmlSerialize(templateName));
} | java | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.