_id
stringlengths
2
7
title
stringlengths
3
140
partition
stringclasses
3 values
text
stringlengths
73
34.1k
language
stringclasses
1 value
meta_information
dict
q155300
Converters.toDBObject
train
public void toDBObject(final Object containingObject, final MappedField mf, final DBObject dbObj, final MapperOptions opts) { final Object fieldValue = mf.getFieldValue(containingObject); final TypeConverter enc = getEncoder(fieldValue, mf); final Object encoded = enc.encode(fieldValue, mf); ...
java
{ "resource": "" }
q155301
MappedField.getFieldValue
train
public Object getFieldValue(final Object instance) { try { return field.get(instance); } catch (IllegalAccessException e) { throw new RuntimeException(e); } }
java
{ "resource": "" }
q155302
MappedField.getFirstFieldName
train
public String getFirstFieldName(final DBObject dbObj) { String fieldName = getNameToStore(); boolean foundField = false; for (final String n : getLoadNames()) { if (dbObj.containsField(n)) { if (!foundField) { foundField = true; ...
java
{ "resource": "" }
q155303
MappedField.setFieldValue
train
public void setFieldValue(final Object instance, final Object value) { try { field.set(instance, value); } catch (IllegalAccessException e) { throw new RuntimeException(e); } }
java
{ "resource": "" }
q155304
ReferenceMap.verify
train
private static void verify(final String name, final int type) { if ((type < HARD) || (type > WEAK)) { throw new IllegalArgumentException(name + " must be HARD, SOFT, WEAK."); } }
java
{ "resource": "" }
q155305
ReferenceMap.clear
train
@Override public void clear() { Arrays.fill(table, null); size = 0; //noinspection StatementWithEmptyBody while (queue.poll() != null) { // drain the queue } }
java
{ "resource": "" }
q155306
ReferenceMap.keySet
train
@Override public Set keySet() { if (keySet != null) { return keySet; } keySet = new AbstractSet() { @Override public Iterator iterator() { return new KeyIterator(); } @Override public int size() ...
java
{ "resource": "" }
q155307
ReferenceMap.entrySet
train
@Override public Set entrySet() { if (entrySet != null) { return entrySet; } entrySet = new AbstractSet() { @Override public int size() { return ReferenceMap.this.size(); } @Override public...
java
{ "resource": "" }
q155308
ReferenceMap.readObject
train
private void readObject(final ObjectInputStream inp) throws IOException, ClassNotFoundException { inp.defaultReadObject(); table = new Entry[inp.readInt()]; threshold = (int) (table.length * loadFactor); queue = new ReferenceQueue(); Object key = inp.readObject(); w...
java
{ "resource": "" }
q155309
ReferenceMap.resize
train
private void resize() { final Entry[] old = table; table = new Entry[old.length * 2]; for (int i = 0; i < old.length; i++) { Entry next = old[i]; while (next != null) { final Entry entry = next; next = next.next; f...
java
{ "resource": "" }
q155310
DeleteOptions.copy
train
public DeleteOptions copy() { DeleteOptions deleteOptions = new DeleteOptions() .writeConcern(getWriteConcern()); if (getCollation() != null) { deleteOptions.collation(Collation.builder(getCollation()).build()); } return deleteOptions; }
java
{ "resource": "" }
q155311
QueryImpl.parseFieldsString
train
@Deprecated public static BasicDBObject parseFieldsString(final String str, final Class clazz, final Mapper mapper, final boolean validate) { BasicDBObject ret = new BasicDBObject(); final String[] parts = str.split(","); for (String s : parts) { s = s.trim(); int dir...
java
{ "resource": "" }
q155312
Projection.projection
train
public static Projection projection(final String field, final Projection projection, final Projection... subsequent) { return new Projection(field, projection, subsequent); }
java
{ "resource": "" }
q155313
MapreduceResults.iterator
train
@Override public Iterator<T> iterator() { return outputType == OutputType.INLINE ? getInlineResults() : createQuery().fetch().iterator(); }
java
{ "resource": "" }
q155314
MapreduceResults.setInlineRequiredOptions
train
public void setInlineRequiredOptions(final Datastore datastore, final Class<T> clazz, final Mapper mapper, final EntityCache cache) { this.mapper = mapper; this.datastore = datastore; this.clazz = clazz; this.cache = cache; }
java
{ "resource": "" }
q155315
SingleReference.decode
train
public static MorphiaReference<?> decode(final Datastore datastore, final Mapper mapper, final MappedField mappedField, final Class paramType, final DBObject dbObject) { final M...
java
{ "resource": "" }
q155316
ChunkedInputStream.readLine
train
private static String readLine(InputStream is) throws IOException { StringBuilder builder = new StringBuilder(); while (true) { int ch = is.read(); if (ch == '\r') { ch = is.read(); if (ch == '\n') { break; } els...
java
{ "resource": "" }
q155317
S3ProxyHandler.mapXmlAclsToCannedPolicy
train
private static String mapXmlAclsToCannedPolicy( AccessControlPolicy policy) throws S3Exception { if (!policy.owner.id.equals(FAKE_OWNER_ID)) { throw new S3Exception(S3ErrorCode.NOT_IMPLEMENTED); } boolean ownerFullControl = false; boolean allUsersRead = false; ...
java
{ "resource": "" }
q155318
S3ProxyHandler.parseIso8601
train
private static long parseIso8601(String date) { SimpleDateFormat formatter = new SimpleDateFormat( "yyyyMMdd'T'HHmmss'Z'"); formatter.setTimeZone(TimeZone.getTimeZone("UTC")); logger.debug("8601date {}", date); try { return formatter.parse(date).getTime() / 10...
java
{ "resource": "" }
q155319
S3ProxyHandler.formatDate
train
private static String formatDate(Date date) { SimpleDateFormat formatter = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss'Z'"); formatter.setTimeZone(TimeZone.getTimeZone("GMT")); return formatter.format(date); }
java
{ "resource": "" }
q155320
S3ProxyHandler.encodeBlob
train
private static String encodeBlob(String encodingType, String blobName) { if (encodingType != null && encodingType.equals("url")) { return urlEscaper.escape(blobName); } else { return blobName; } }
java
{ "resource": "" }
q155321
Buffers.readAsciiString
train
public static String readAsciiString(ByteBuffer buffer, int strLen) { byte[] bytes = new byte[strLen]; buffer.get(bytes); return new String(bytes); }
java
{ "resource": "" }
q155322
Buffers.readString
train
public static String readString(ByteBuffer buffer, int strLen) { StringBuilder sb = new StringBuilder(strLen); for (int i = 0; i < strLen; i++) { sb.append(buffer.getChar()); } return sb.toString(); }
java
{ "resource": "" }
q155323
Buffers.readZeroTerminatedString
train
public static String readZeroTerminatedString(ByteBuffer buffer, int strLen) { StringBuilder sb = new StringBuilder(strLen); for (int i = 0; i < strLen; i++) { char c = buffer.getChar(); if (c == '\0') { skip(buffer, (strLen - i - 1) * 2); break; ...
java
{ "resource": "" }
q155324
Buffers.sliceAndSkip
train
public static ByteBuffer sliceAndSkip(ByteBuffer buffer, int size) { ByteBuffer buf = buffer.slice().order(ByteOrder.LITTLE_ENDIAN); ByteBuffer slice = (ByteBuffer) ((Buffer) buf).limit(buf.position() + size); skip(buffer, size); return slice; }
java
{ "resource": "" }
q155325
ResourceTable.getResourcesById
train
@Nonnull public List<Resource> getResourcesById(long resourceId) { // An Android Resource id is a 32-bit integer. It comprises // an 8-bit Package id [bits 24-31] // an 8-bit Type id [bits 16-23] // a 16-bit Entry index [bits 0-15] short packageId = (short) (resourceId >> 2...
java
{ "resource": "" }
q155326
ResourceTableParser.parse
train
public void parse() { // read resource file header. ResourceTableHeader resourceTableHeader = (ResourceTableHeader) readChunkHeader(); // read string pool chunk stringPool = ParseUtils.readStringPool(buffer, (StringPoolHeader) readChunkHeader()); resourceTable = new ResourceTab...
java
{ "resource": "" }
q155327
ResourceLoader.loadSystemAttrIds
train
public static Map<Integer, String> loadSystemAttrIds() { try (BufferedReader reader = toReader("/r_values.ini")) { Map<Integer, String> map = new HashMap<>(); String line; while ((line = reader.readLine()) != null) { String[] items = line.trim().split("="); ...
java
{ "resource": "" }
q155328
ParseUtils.readString
train
public static String readString(ByteBuffer buffer, boolean utf8) { if (utf8) { // The lengths are encoded in the same way as for the 16-bit format // but using 8-bit rather than 16-bit integers. int strLen = readLen(buffer); int bytesLen = readLen(buffer); ...
java
{ "resource": "" }
q155329
ParseUtils.readStringUTF16
train
public static String readStringUTF16(ByteBuffer buffer, int strLen) { String str = Buffers.readString(buffer, strLen); for (int i = 0; i < str.length(); i++) { char c = str.charAt(i); if (c == 0) { return str.substring(0, i); } } return...
java
{ "resource": "" }
q155330
ParseUtils.readLen
train
private static int readLen(ByteBuffer buffer) { int len = 0; int i = Buffers.readUByte(buffer); if ((i & 0x80) != 0) { //read one more byte. len |= (i & 0x7f) << 8; len += Buffers.readUByte(buffer); } else { len = i; } retur...
java
{ "resource": "" }
q155331
ParseUtils.readLen16
train
private static int readLen16(ByteBuffer buffer) { int len = 0; int i = Buffers.readUShort(buffer); if ((i & 0x8000) != 0) { len |= (i & 0x7fff) << 16; len += Buffers.readUShort(buffer); } else { len = i; } return len; }
java
{ "resource": "" }
q155332
ParseUtils.readStringPool
train
public static StringPool readStringPool(ByteBuffer buffer, StringPoolHeader stringPoolHeader) { long beginPos = buffer.position(); int[] offsets = new int[stringPoolHeader.getStringCount()]; // read strings offset if (stringPoolHeader.getStringCount() > 0) { for (int idx = 0...
java
{ "resource": "" }
q155333
ParseUtils.readResValue
train
@Nullable public static ResourceValue readResValue(ByteBuffer buffer, StringPool stringPool) { // ResValue resValue = new ResValue(); int size = Buffers.readUShort(buffer); short res0 = Buffers.readUByte(buffer); short dataType = Buffers.readUByte(buffer); switch (dataType) {...
java
{ "resource": "" }
q155334
BCCertificateParser.parse
train
@SuppressWarnings("unchecked") public List<CertificateMeta> parse() throws CertificateException { CMSSignedData cmsSignedData; try { cmsSignedData = new CMSSignedData(data); } catch (CMSException e) { throw new CertificateException(e); } Store<X509Cert...
java
{ "resource": "" }
q155335
Locales.match
train
public static int match(Locale locale, Locale targetLocale) { if (locale == null) { return -1; } if (locale.getLanguage().equals(targetLocale.getLanguage())) { if (locale.getCountry().equals(targetLocale.getCountry())) { return 3; } else if (ta...
java
{ "resource": "" }
q155336
ResourceMapEntry.toStringValue
train
public String toStringValue(ResourceTable resourceTable, Locale locale) { if (resourceTableMaps.length > 0) { return resourceTableMaps[0].toString(); } else { return null; } }
java
{ "resource": "" }
q155337
CharSequenceTranslator.with
train
public final CharSequenceTranslator with(final CharSequenceTranslator... translators) { final CharSequenceTranslator[] newArray = new CharSequenceTranslator[translators.length + 1]; newArray[0] = this; System.arraycopy(translators, 0, newArray, 1, translators.length); return new Aggregat...
java
{ "resource": "" }
q155338
DexParser.readClass
train
private DexClassStruct[] readClass(long classDefsOff, int classDefsSize) { Buffers.position(buffer, classDefsOff); DexClassStruct[] dexClassStructs = new DexClassStruct[classDefsSize]; for (int i = 0; i < classDefsSize; i++) { DexClassStruct dexClassStruct = new DexClassStruct(); ...
java
{ "resource": "" }
q155339
DexParser.readTypes
train
private int[] readTypes(long typeIdsOff, int typeIdsSize) { Buffers.position(buffer, typeIdsOff); int[] typeIds = new int[typeIdsSize]; for (int i = 0; i < typeIdsSize; i++) { typeIds[i] = (int) Buffers.readUInt(buffer); } return typeIds; }
java
{ "resource": "" }
q155340
DexParser.readStrings
train
private StringPool readStrings(long[] offsets) { // read strings. // buffer some apk, the strings' offsets may not well ordered. we sort it first StringPoolEntry[] entries = new StringPoolEntry[offsets.length]; for (int i = 0; i < offsets.length; i++) { entries[i] = new Stri...
java
{ "resource": "" }
q155341
DexParser.readString
train
private String readString(int strLen) { char[] chars = new char[strLen]; for (int i = 0; i < strLen; i++) { short a = Buffers.readUByte(buffer); if ((a & 0x80) == 0) { // ascii char chars[i] = (char) a; } else if ((a & 0xe0) == 0xc0) {...
java
{ "resource": "" }
q155342
DexParser.readVarInts
train
private int readVarInts() { int i = 0; int count = 0; short s; do { if (count > 4) { throw new ParserException("read varints error."); } s = Buffers.readUByte(buffer); i |= (s & 0x7f) << (count * 7); count++; ...
java
{ "resource": "" }
q155343
AbstractApkFile.getCertificateMetaList
train
@Deprecated public List<CertificateMeta> getCertificateMetaList() throws IOException, CertificateException { if (apkSigners == null) { parseCertificates(); } if (apkSigners.isEmpty()) { throw new ParserException("ApkFile certificate not found"); } retu...
java
{ "resource": "" }
q155344
AbstractApkFile.getAllCertificateMetas
train
@Deprecated public Map<String, List<CertificateMeta>> getAllCertificateMetas() throws IOException, CertificateException { List<ApkSigner> apkSigners = getApkSingers(); Map<String, List<CertificateMeta>> map = new LinkedHashMap<>(); for (ApkSigner apkSigner : apkSigners) { map.put...
java
{ "resource": "" }
q155345
AbstractApkFile.transBinaryXml
train
public String transBinaryXml(String path) throws IOException { byte[] data = getFileData(path); if (data == null) { return null; } parseResourceTable(); XmlTranslator xmlTranslator = new XmlTranslator(); transBinaryXml(data, xmlTranslator); return xml...
java
{ "resource": "" }
q155346
AbstractApkFile.getAllIcons
train
public List<IconFace> getAllIcons() throws IOException { List<IconPath> iconPaths = getIconPaths(); if (iconPaths.isEmpty()) { return Collections.emptyList(); } List<IconFace> iconFaces = new ArrayList<>(iconPaths.size()); for (IconPath iconPath : iconPaths) { ...
java
{ "resource": "" }
q155347
AbstractApkFile.getIconFile
train
@Deprecated public Icon getIconFile() throws IOException { ApkMeta apkMeta = getApkMeta(); String iconPath = apkMeta.getIcon(); if (iconPath == null) { return null; } return new Icon(iconPath, Densities.DEFAULT, getFileData(iconPath)); }
java
{ "resource": "" }
q155348
AbstractApkFile.getIconFiles
train
@Deprecated public List<Icon> getIconFiles() throws IOException { List<IconPath> iconPaths = getIconPaths(); List<Icon> icons = new ArrayList<>(iconPaths.size()); for (IconPath iconPath : iconPaths) { Icon icon = newFileIcon(iconPath.getPath(), iconPath.getDensity()); ...
java
{ "resource": "" }
q155349
AbstractApkFile.parseResourceTable
train
private void parseResourceTable() throws IOException { if (resourceTableParsed) { return; } resourceTableParsed = true; byte[] data = getFileData(AndroidConstants.RESOURCE_FILE); if (data == null) { // if no resource entry has been found, we assume it is n...
java
{ "resource": "" }
q155350
AbstractApkFile.findApkSignBlock
train
protected ByteBuffer findApkSignBlock() throws IOException { ByteBuffer buffer = fileData().order(ByteOrder.LITTLE_ENDIAN); int len = buffer.limit(); // first find zip end of central directory entry if (len < 22) { // should not happen throw new RuntimeException(...
java
{ "resource": "" }
q155351
BinaryXmlParser.parse
train
public void parse() { ChunkHeader firstChunkHeader = readChunkHeader(); if (firstChunkHeader == null) { return; } switch (firstChunkHeader.getChunkType()) { case ChunkType.XML: case ChunkType.NULL: break; case ChunkType.STR...
java
{ "resource": "" }
q155352
BinaryXmlParser.getFinalValueAsString
train
private String getFinalValueAsString(String attributeName, String str) { int value = Integer.parseInt(str); switch (attributeName) { case "screenOrientation": return AttributeValues.getScreenOrientation(value); case "configChanges": return Attribut...
java
{ "resource": "" }
q155353
Asn1BerParser.parse
train
public static <T> T parse(ByteBuffer encoded, Class<T> containerClass) throws Asn1DecodingException { BerDataValue containerDataValue; try { containerDataValue = new ByteBufferBerDataValueReader(encoded).readDataValue(); } catch (BerDataValueFormatException e) { ...
java
{ "resource": "" }
q155354
Attributes.getString
train
@Nullable public String getString(String name) { Attribute attribute = get(name); if (attribute == null) { return null; } return attribute.getValue(); }
java
{ "resource": "" }
q155355
ApkParsers.getMetaInfo
train
public static ApkMeta getMetaInfo(String apkFilePath, Locale locale) throws IOException { try (ApkFile apkFile = new ApkFile(apkFilePath)) { apkFile.setPreferredLocale(locale); return apkFile.getApkMeta(); } }
java
{ "resource": "" }
q155356
MathUtils.restrict
train
public static float restrict(float value, float minValue, float maxValue) { return Math.max(minValue, Math.min(value, maxValue)); }
java
{ "resource": "" }
q155357
DemoActivity.initDecorMargins
train
private void initDecorMargins() { if (DecorUtils.isCanHaveTransparentDecor()) { Views.getParams(views.appBar).height += DecorUtils.getStatusBarHeight(this); } DecorUtils.paddingForStatusBar(views.toolbar, true); DecorUtils.paddingForStatusBar(views.pagerToolbar, true); ...
java
{ "resource": "" }
q155358
DemoActivity.initTopImage
train
private void initTopImage() { views.fullImageToolbar.setNavigationIcon(R.drawable.ic_arrow_back_white_24dp); views.fullImageToolbar.setNavigationOnClickListener(view -> onBackPressed()); imageAnimator = GestureTransitions.from(views.appBarImage).into(views.fullImage); // Setting up and...
java
{ "resource": "" }
q155359
DemoActivity.initPager
train
private void initPager() { // Setting up pager adapter pagerAdapter = new PhotoPagerAdapter(views.pager, getSettingsController()); pagerListener = new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { onPhotoInP...
java
{ "resource": "" }
q155360
DemoActivity.onPhotoInPagerSelected
train
private void onPhotoInPagerSelected(int position) { Photo photo = pagerAdapter.getPhoto(position); if (photo == null) { views.pagerTitle.setText(null); } else { SpannableBuilder title = new SpannableBuilder(DemoActivity.this); title.append(photo.getTitle()).a...
java
{ "resource": "" }
q155361
DemoActivity.initPagerAnimator
train
private void initPagerAnimator() { final SimpleTracker gridTracker = new SimpleTracker() { @Override public View getViewAt(int pos) { RecyclerView.ViewHolder holder = views.grid.findViewHolderForLayoutPosition(pos); return holder == null ? null : PhotoList...
java
{ "resource": "" }
q155362
DemoActivity.onPhotosLoaded
train
@Result(FlickrApi.LOAD_IMAGES_EVENT) private void onPhotosLoaded(List<Photo> photos, boolean hasMore) { // RecyclerView will continue scrolling when new items are added, we need to stop it. // Seems like this buggy behavior was introduced in support library v26.0.x final boolean onBottom = ...
java
{ "resource": "" }
q155363
DemoActivity.onPhotosLoadFail
train
@Failure(FlickrApi.LOAD_IMAGES_EVENT) private void onPhotosLoadFail() { gridAdapter.onNextItemsError(); // Skipping state restoration if (savedPagerPosition != NO_POSITION) { // We can't show image right now, so we should return back to list applyFullPagerState(0f, t...
java
{ "resource": "" }
q155364
ViewPosition.pack
train
public String pack() { String viewStr = view.flattenToString(); String viewportStr = viewport.flattenToString(); String visibleStr = visible.flattenToString(); String imageStr = image.flattenToString(); return TextUtils.join(DELIMITER, new String[] { viewStr, view...
java
{ "resource": "" }
q155365
ScaleGestureDetectorFixed.warmUpScaleDetector
train
private void warmUpScaleDetector() { long time = System.currentTimeMillis(); MotionEvent event = MotionEvent.obtain(time, time, MotionEvent.ACTION_CANCEL, 0f, 0f, 0); onTouchEvent(event); event.recycle(); }
java
{ "resource": "" }
q155366
GravityUtils.getMovementAreaPosition
train
public static void getMovementAreaPosition(Settings settings, Rect out) { tmpRect1.set(0, 0, settings.getViewportW(), settings.getViewportH()); Gravity.apply(settings.getGravity(), settings.getMovementAreaW(), settings.getMovementAreaH(), tmpRect1, out); }
java
{ "resource": "" }
q155367
GravityUtils.getDefaultPivot
train
public static void getDefaultPivot(Settings settings, Point out) { getMovementAreaPosition(settings, tmpRect2); Gravity.apply(settings.getGravity(), 0, 0, tmpRect2, tmpRect1); out.set(tmpRect1.left, tmpRect1.top); }
java
{ "resource": "" }
q155368
FloatScroller.startScroll
train
public void startScroll(float startValue, float finalValue) { finished = false; startRtc = SystemClock.elapsedRealtime(); this.startValue = startValue; this.finalValue = finalValue; currValue = startValue; }
java
{ "resource": "" }
q155369
FloatScroller.computeScroll
train
public boolean computeScroll() { if (finished) { return false; } long elapsed = SystemClock.elapsedRealtime() - startRtc; if (elapsed >= duration) { finished = true; currValue = finalValue; return false; } float time = int...
java
{ "resource": "" }
q155370
GlideHelper.loadThumb
train
public static void loadThumb(ImageView image, int thumbId) { // We don't want Glide to crop or resize our image final RequestOptions options = new RequestOptions() .diskCacheStrategy(DiskCacheStrategy.NONE) .override(Target.SIZE_ORIGINAL) .dontTransform();...
java
{ "resource": "" }
q155371
GlideHelper.loadFull
train
public static void loadFull(ImageView image, int imageId, int thumbId) { // We don't want Glide to crop or resize our image final RequestOptions options = new RequestOptions() .diskCacheStrategy(DiskCacheStrategy.NONE) .override(Target.SIZE_ORIGINAL) .dont...
java
{ "resource": "" }
q155372
StateController.toggleMinMaxZoom
train
State toggleMinMaxZoom(State state, float pivotX, float pivotY) { zoomBounds.set(state); final float minZoom = zoomBounds.getFitZoom(); final float maxZoom = settings.getDoubleTapZoom() > 0f ? settings.getDoubleTapZoom() : zoomBounds.getMaxZoom(); final float middleZoom ...
java
{ "resource": "" }
q155373
StateController.restrictStateBoundsCopy
train
@SuppressWarnings("SameParameterValue") // Using same method params as in restrictStateBounds @Nullable State restrictStateBoundsCopy(State state, State prevState, float pivotX, float pivotY, boolean allowOverscroll, boolean allowOverzoom, boolean restrictRotation) { tmpState.set(state); ...
java
{ "resource": "" }
q155374
ImageViewHelper.applyScaleType
train
static void applyScaleType(ImageView.ScaleType type, int dwidth, int dheight, int vwidth, int vheight, Matrix imageMatrix, Matrix outMatrix) { if (ImageView.ScaleType.CENTER == type) { // Center bitmap in view, no scaling. outMatrix.setTra...
java
{ "resource": "" }
q155375
ViewsTransitionAnimator.swapAnimator
train
private void swapAnimator(ViewPositionAnimator old, ViewPositionAnimator next) { final float position = old.getPosition(); final boolean isLeaving = old.isLeaving(); final boolean isAnimating = old.isAnimating(); if (GestureDebug.isDebugAnimator()) { Log.d(TAG, "Swapping ani...
java
{ "resource": "" }
q155376
ZoomBounds.set
train
public ZoomBounds set(State state) { float imageWidth = settings.getImageW(); float imageHeight = settings.getImageH(); float areaWidth = settings.getMovementAreaW(); float areaHeight = settings.getMovementAreaH(); if (imageWidth == 0f || imageHeight == 0f || areaWidth == 0f ||...
java
{ "resource": "" }
q155377
Settings.setMovementArea
train
public Settings setMovementArea(int width, int height) { isMovementAreaSpecified = true; movementAreaW = width; movementAreaH = height; return this; }
java
{ "resource": "" }
q155378
FullImageActivity.runAfterImageDraw
train
private void runAfterImageDraw(final Runnable action) { image.getViewTreeObserver().addOnPreDrawListener(new OnPreDrawListener() { @Override public boolean onPreDraw() { image.getViewTreeObserver().removeOnPreDrawListener(this); runOnNextFrame(action); ...
java
{ "resource": "" }
q155379
CropAreaView.update
train
public void update(boolean animate) { final Settings settings = imageView == null ? null : imageView.getController().getSettings(); if (settings != null && getWidth() > 0 && getHeight() > 0) { // If aspect is specified we will automatically adjust movement area settings ...
java
{ "resource": "" }
q155380
CropAreaView.drawRectHole
train
private void drawRectHole(Canvas canvas) { paint.setStyle(Paint.Style.FILL); paint.setColor(backColor); // Top part tmpRectF.set(0f, 0f, canvas.getWidth(), areaRect.top); canvas.drawRect(tmpRectF, paint); // Bottom part tmpRectF.set(0f, areaRect.bottom, canvas.g...
java
{ "resource": "" }
q155381
CropAreaView.drawRoundedHole
train
@SuppressWarnings("deprecation") private void drawRoundedHole(Canvas canvas) { paint.setStyle(Paint.Style.FILL); paint.setColor(backColor); // Punching hole in background color requires offscreen drawing if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { canvas...
java
{ "resource": "" }
q155382
SmsResultBase.parseToJson
train
public JSONObject parseToJson(HTTPResponse response) throws JSONException { // Set raw response this.response = response; // May throw JSONException return new JSONObject(response.body); }
java
{ "resource": "" }
q155383
SmsBase.handleError
train
public HTTPResponse handleError(HTTPResponse response) throws HTTPException { if (response.statusCode < 200 || response.statusCode >= 300) { throw new HTTPException(response.statusCode, response.reason); } return response; }
java
{ "resource": "" }
q155384
DefaultAssetManager.addAsset
train
@Override public AssetPage addAsset(AssetPage asset, boolean renderImmediately) { final String assetKey = asset.getReference().toString(); if(assets.containsKey(assetKey)) { return assets.get(assetKey); } else { assets.put(assetKey, asset); if(rend...
java
{ "resource": "" }
q155385
OrchidUtils.getRelativeFilename
train
public static String getRelativeFilename(String sourcePath, String baseDir) { if (sourcePath.contains(baseDir)) { int indexOf = sourcePath.indexOf(baseDir); if (indexOf + baseDir.length() < sourcePath.length()) { String relative = sourcePath.substring((indexOf + baseDir....
java
{ "resource": "" }
q155386
OrchidUtils.first
train
public static <T> T first(List<T> items) { if(items != null && items.size() > 0) { return items.get(0); } return null; }
java
{ "resource": "" }
q155387
InternalScanner.findInPackage
train
List<String> findInPackage(Test test, String packageName) { List<String> localClsssOrPkgs = new ArrayList<String>(); packageName = packageName.replace('.', '/'); Enumeration<URL> urls; try { urls = classloader.getResources(packageName); // test for empty ...
java
{ "resource": "" }
q155388
PackageScanner.scan
train
public Set<String> scan() { // Initialize the pattern factories initPatterns(); // Determine which packages to start from List<String> roots = packagePatterns.getRoots(); InternalScanner scanner = new InternalScanner(getClassLoader()); // Kick off the scanning S...
java
{ "resource": "" }
q155389
XLSX2CSV.processSheet
train
public void processSheet(StylesTable styles, ReadOnlySharedStringsTable strings, SheetContentsHandler sheetHandler, InputStream sheetInputStream) throws IOException, ParserConfigurationException, SAXException { DataFormatter formatter = new DataFormatter(); InputSource sheetSource = new InputSource(sheetInputStr...
java
{ "resource": "" }
q155390
JDBCUtils.query
train
@Deprecated public static ResultSet query(String sql, Object... args) { ResultSet result = null; Connection con = getconnnection(); PreparedStatement ps = null; try { ps = con.prepareStatement(sql); if (args != null) { for (int i = 0; i < args.length; i++) { ps.setObject((i + 1), args[i]); }...
java
{ "resource": "" }
q155391
XLS2CSV.process
train
public List<String> process() throws IOException { MissingRecordAwareHSSFListener listener = new MissingRecordAwareHSSFListener(this); formatListener = new FormatTrackingHSSFListener(listener); HSSFEventFactory factory = new HSSFEventFactory(); HSSFRequest request = new HSSFRequest(); if(outputFormulaValues...
java
{ "resource": "" }
q155392
ZkClient.createPersistent
train
public void createPersistent(String path, boolean createParents) throws ZkInterruptedException, IllegalArgumentException, ZkException, RuntimeException { createPersistent(path, createParents, ZooDefs.Ids.OPEN_ACL_UNSAFE); }
java
{ "resource": "" }
q155393
ZkClient.setAcl
train
public void setAcl(final String path, final List<ACL> acl) throws ZkException { if (path == null) { throw new NullPointerException("Missing value for path"); } if (acl == null || acl.size() == 0) { throw new NullPointerException("Missing value for ACL"); } ...
java
{ "resource": "" }
q155394
ZkClient.getAcl
train
public Map.Entry<List<ACL>, Stat> getAcl(final String path) throws ZkException { if (path == null) { throw new NullPointerException("Missing value for path"); } if (!exists(path)) { throw new RuntimeException("trying to get acls on non existing node " + path); } ...
java
{ "resource": "" }
q155395
ZkClient.createEphemeral
train
public void createEphemeral(final String path, final List<ACL> acl) throws ZkInterruptedException, IllegalArgumentException, ZkException, RuntimeException { create(path, null, acl, CreateMode.EPHEMERAL); }
java
{ "resource": "" }
q155396
ZkClient.create
train
public String create(final String path, Object data, final List<ACL> acl, final CreateMode mode) { if (path == null) { throw new NullPointerException("Missing value for path"); } if (acl == null || acl.size() == 0) { throw new NullPointerException("Missing value for ACL")...
java
{ "resource": "" }
q155397
ZkClient.addAuthInfo
train
public void addAuthInfo(final String scheme, final byte[] auth) { retryUntilConnected(new Callable<Object>() { @Override public Object call() throws Exception { _connection.addAuthInfo(scheme, auth); return null; } }); }
java
{ "resource": "" }
q155398
ZkClient.connect
train
public void connect(final long maxMsToWaitUntilConnected, Watcher watcher) throws ZkInterruptedException, ZkTimeoutException, IllegalStateException { boolean started = false; acquireEventLock(); try { setShutdownTrigger(false); _eventThread = new ZkEventThread(_connection...
java
{ "resource": "" }
q155399
TcclAwareObjectIputStream.resolveProxyClass
train
protected Class resolveProxyClass(String[] interfaces) throws IOException, ClassNotFoundException { ClassLoader cl = getClass().getClassLoader(); Class[] cinterfaces = new Class[interfaces.length]; for (int i = 0; i < interfaces.length; i++) { try { cinterfaces[i] = cl.loadClass(interfaces[i]); } catch...
java
{ "resource": "" }