repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
partition
stringclasses
1 value
MKLab-ITI/simmo
src/main/java/gr/iti/mklab/simmo/core/morphia/MediaDAO.java
MediaDAO.findNear
public List<M> findNear(double latitude, double longitude, int numImages) { return getDatastore().find(clazz).field("location.coordinates").near(latitude, longitude).limit(numImages).asList(); }
java
public List<M> findNear(double latitude, double longitude, int numImages) { return getDatastore().find(clazz).field("location.coordinates").near(latitude, longitude).limit(numImages).asList(); }
[ "public", "List", "<", "M", ">", "findNear", "(", "double", "latitude", ",", "double", "longitude", ",", "int", "numImages", ")", "{", "return", "getDatastore", "(", ")", ".", "find", "(", "clazz", ")", ".", "field", "(", "\"location.coordinates\"", ")", ...
Returns a list of media items that are geographically near the specified coordinates @param latitude @param longitude @param numImages @return
[ "Returns", "a", "list", "of", "media", "items", "that", "are", "geographically", "near", "the", "specified", "coordinates" ]
a78436e982e160fb0260746c563c7e4d24736486
https://github.com/MKLab-ITI/simmo/blob/a78436e982e160fb0260746c563c7e4d24736486/src/main/java/gr/iti/mklab/simmo/core/morphia/MediaDAO.java#L41-L43
train
MKLab-ITI/simmo
src/main/java/gr/iti/mklab/simmo/core/morphia/MediaDAO.java
MediaDAO.search
public List<M> search(String datefield, Date date, int width, int height, int count, int offset, UserAccount account, String query, List<String> sources) { List<Criteria> l = new ArrayList<>(); Query<M> q = getDatastore().createQuery(clazz); if (query != null) { Pattern p = Pattern.compile("(.*)" + query + "(.*)", Pattern.CASE_INSENSITIVE); l.add(q.or( q.criteria("title").equal(p), q.criteria("description").equal(p) )); } if (account != null) { l.add(q.criteria("contributor").equal(account)); } if (width > 0) l.add(q.criteria("width").greaterThanOrEq(width)); if (height > 0) l.add(q.criteria("height").greaterThanOrEq(height)); if (date != null) l.add(q.criteria(datefield).greaterThanOrEq(date)); if (sources != null) l.add(q.criteria("source").in(sources)); q.and(l.toArray(new Criteria[l.size()])); return q.order("crawlDate").offset(offset).limit(count).asList(); }
java
public List<M> search(String datefield, Date date, int width, int height, int count, int offset, UserAccount account, String query, List<String> sources) { List<Criteria> l = new ArrayList<>(); Query<M> q = getDatastore().createQuery(clazz); if (query != null) { Pattern p = Pattern.compile("(.*)" + query + "(.*)", Pattern.CASE_INSENSITIVE); l.add(q.or( q.criteria("title").equal(p), q.criteria("description").equal(p) )); } if (account != null) { l.add(q.criteria("contributor").equal(account)); } if (width > 0) l.add(q.criteria("width").greaterThanOrEq(width)); if (height > 0) l.add(q.criteria("height").greaterThanOrEq(height)); if (date != null) l.add(q.criteria(datefield).greaterThanOrEq(date)); if (sources != null) l.add(q.criteria("source").in(sources)); q.and(l.toArray(new Criteria[l.size()])); return q.order("crawlDate").offset(offset).limit(count).asList(); }
[ "public", "List", "<", "M", ">", "search", "(", "String", "datefield", ",", "Date", "date", ",", "int", "width", ",", "int", "height", ",", "int", "count", ",", "int", "offset", ",", "UserAccount", "account", ",", "String", "query", ",", "List", "<", ...
A search function @param date @param width @param height @param count @param offset @return
[ "A", "search", "function" ]
a78436e982e160fb0260746c563c7e4d24736486
https://github.com/MKLab-ITI/simmo/blob/a78436e982e160fb0260746c563c7e4d24736486/src/main/java/gr/iti/mklab/simmo/core/morphia/MediaDAO.java#L65-L89
train
michael-rapp/AndroidUtil
library/src/main/java/de/mrapp/android/util/ViewUtil.java
ViewUtil.setBackground
@SuppressWarnings("deprecation") public static void setBackground(@NonNull final View view, @Nullable final Drawable background) { Condition.INSTANCE.ensureNotNull(view, "The view may not be null"); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { view.setBackground(background); } else { view.setBackgroundDrawable(background); } }
java
@SuppressWarnings("deprecation") public static void setBackground(@NonNull final View view, @Nullable final Drawable background) { Condition.INSTANCE.ensureNotNull(view, "The view may not be null"); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { view.setBackground(background); } else { view.setBackgroundDrawable(background); } }
[ "@", "SuppressWarnings", "(", "\"deprecation\"", ")", "public", "static", "void", "setBackground", "(", "@", "NonNull", "final", "View", "view", ",", "@", "Nullable", "final", "Drawable", "background", ")", "{", "Condition", ".", "INSTANCE", ".", "ensureNotNull"...
Sets the background of a view. Depending on the device's API level, different methods are used for setting the background. @param view The view, whose background should be set, as an instance of the class {@link View}. The view may not be null @param background The background, which should be set, as an instance of the class {@link Drawable}, or null, if no background should be set
[ "Sets", "the", "background", "of", "a", "view", ".", "Depending", "on", "the", "device", "s", "API", "level", "different", "methods", "are", "used", "for", "setting", "the", "background", "." ]
67ec0e5732344eeb4d946dd1f96d782939e449f4
https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/ViewUtil.java#L56-L66
train
michael-rapp/AndroidUtil
library/src/main/java/de/mrapp/android/util/ViewUtil.java
ViewUtil.removeOnGlobalLayoutListener
@SuppressWarnings("deprecation") public static void removeOnGlobalLayoutListener(@NonNull final ViewTreeObserver observer, @Nullable final OnGlobalLayoutListener listener) { Condition.INSTANCE.ensureNotNull(observer, "The view tree observer may not be null"); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { observer.removeOnGlobalLayoutListener(listener); } else { observer.removeGlobalOnLayoutListener(listener); } }
java
@SuppressWarnings("deprecation") public static void removeOnGlobalLayoutListener(@NonNull final ViewTreeObserver observer, @Nullable final OnGlobalLayoutListener listener) { Condition.INSTANCE.ensureNotNull(observer, "The view tree observer may not be null"); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { observer.removeOnGlobalLayoutListener(listener); } else { observer.removeGlobalOnLayoutListener(listener); } }
[ "@", "SuppressWarnings", "(", "\"deprecation\"", ")", "public", "static", "void", "removeOnGlobalLayoutListener", "(", "@", "NonNull", "final", "ViewTreeObserver", "observer", ",", "@", "Nullable", "final", "OnGlobalLayoutListener", "listener", ")", "{", "Condition", ...
Removes a previous registered global layout listener from a view tree observer. Depending on the device's API level, different methods are used for removing the listener. @param observer The view tree observer, the listener should be removed from, as an instance of the class {@link ViewTreeObserver}. The view tree observer may not be null @param listener The listener, which should be removed from the view tree observer, as an instance of the type {@link OnGlobalLayoutListener}
[ "Removes", "a", "previous", "registered", "global", "layout", "listener", "from", "a", "view", "tree", "observer", ".", "Depending", "on", "the", "device", "s", "API", "level", "different", "methods", "are", "used", "for", "removing", "the", "listener", "." ]
67ec0e5732344eeb4d946dd1f96d782939e449f4
https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/ViewUtil.java#L79-L89
train
michael-rapp/AndroidUtil
library/src/main/java/de/mrapp/android/util/ViewUtil.java
ViewUtil.removeFromParent
public static void removeFromParent(@NonNull final View view) { Condition.INSTANCE.ensureNotNull(view, "The view may not be null"); ViewParent parent = view.getParent(); if (parent instanceof ViewGroup) { ((ViewGroup) parent).removeView(view); } }
java
public static void removeFromParent(@NonNull final View view) { Condition.INSTANCE.ensureNotNull(view, "The view may not be null"); ViewParent parent = view.getParent(); if (parent instanceof ViewGroup) { ((ViewGroup) parent).removeView(view); } }
[ "public", "static", "void", "removeFromParent", "(", "@", "NonNull", "final", "View", "view", ")", "{", "Condition", ".", "INSTANCE", ".", "ensureNotNull", "(", "view", ",", "\"The view may not be null\"", ")", ";", "ViewParent", "parent", "=", "view", ".", "g...
Removes a specific view from its parent, if there is any. @param view The view, which should be removed from its parent, as an instance of the class {@link View}. The view may not be null
[ "Removes", "a", "specific", "view", "from", "its", "parent", "if", "there", "is", "any", "." ]
67ec0e5732344eeb4d946dd1f96d782939e449f4
https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/ViewUtil.java#L98-L105
train
michael-rapp/AndroidUtil
library/src/main/java/de/mrapp/android/util/view/SquareImageView.java
SquareImageView.obtainScaledEdge
private void obtainScaledEdge(@NonNull final TypedArray typedArray) { int defaultValue = Edge.VERTICAL.getValue(); Edge scaledEdge = Edge.fromValue( typedArray.getInt(R.styleable.SquareImageView_scaledEdge, defaultValue)); setScaledEdge(scaledEdge); }
java
private void obtainScaledEdge(@NonNull final TypedArray typedArray) { int defaultValue = Edge.VERTICAL.getValue(); Edge scaledEdge = Edge.fromValue( typedArray.getInt(R.styleable.SquareImageView_scaledEdge, defaultValue)); setScaledEdge(scaledEdge); }
[ "private", "void", "obtainScaledEdge", "(", "@", "NonNull", "final", "TypedArray", "typedArray", ")", "{", "int", "defaultValue", "=", "Edge", ".", "VERTICAL", ".", "getValue", "(", ")", ";", "Edge", "scaledEdge", "=", "Edge", ".", "fromValue", "(", "typedAr...
Obtains the scaled edge from a specific typed array. @param typedArray The typed array, the scaled edge should be obtained from, as an instance of the class {@link TypedArray}. The typed array may not be null
[ "Obtains", "the", "scaled", "edge", "from", "a", "specific", "typed", "array", "." ]
67ec0e5732344eeb4d946dd1f96d782939e449f4
https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/view/SquareImageView.java#L149-L154
train
phax/ph-datetime
ph-holiday/src/main/java/com/helger/holiday/parser/AbstractHolidayParser.java
AbstractHolidayParser._isValidForCycle
private static boolean _isValidForCycle (@Nonnull final Holiday aHoliday, final int nYear) { final String sEvery = aHoliday.getEvery (); if (sEvery != null && !"EVERY_YEAR".equals (sEvery)) { if ("ODD_YEARS".equals (sEvery)) return nYear % 2 != 0; if ("EVEN_YEARS".equals (sEvery)) return nYear % 2 == 0; if (aHoliday.getValidFrom () != null) { int nCycleYears = 0; if ("2_YEARS".equalsIgnoreCase (sEvery)) nCycleYears = 2; else if ("3_YEARS".equalsIgnoreCase (sEvery)) nCycleYears = 3; else if ("4_YEARS".equalsIgnoreCase (sEvery)) nCycleYears = 4; else if ("5_YEARS".equalsIgnoreCase (sEvery)) nCycleYears = 5; else if ("6_YEARS".equalsIgnoreCase (sEvery)) nCycleYears = 6; else throw new IllegalArgumentException ("Cannot handle unknown cycle type '" + sEvery + "'."); return (nYear - aHoliday.getValidFrom ().intValue ()) % nCycleYears == 0; } } return true; }
java
private static boolean _isValidForCycle (@Nonnull final Holiday aHoliday, final int nYear) { final String sEvery = aHoliday.getEvery (); if (sEvery != null && !"EVERY_YEAR".equals (sEvery)) { if ("ODD_YEARS".equals (sEvery)) return nYear % 2 != 0; if ("EVEN_YEARS".equals (sEvery)) return nYear % 2 == 0; if (aHoliday.getValidFrom () != null) { int nCycleYears = 0; if ("2_YEARS".equalsIgnoreCase (sEvery)) nCycleYears = 2; else if ("3_YEARS".equalsIgnoreCase (sEvery)) nCycleYears = 3; else if ("4_YEARS".equalsIgnoreCase (sEvery)) nCycleYears = 4; else if ("5_YEARS".equalsIgnoreCase (sEvery)) nCycleYears = 5; else if ("6_YEARS".equalsIgnoreCase (sEvery)) nCycleYears = 6; else throw new IllegalArgumentException ("Cannot handle unknown cycle type '" + sEvery + "'."); return (nYear - aHoliday.getValidFrom ().intValue ()) % nCycleYears == 0; } } return true; }
[ "private", "static", "boolean", "_isValidForCycle", "(", "@", "Nonnull", "final", "Holiday", "aHoliday", ",", "final", "int", "nYear", ")", "{", "final", "String", "sEvery", "=", "aHoliday", ".", "getEvery", "(", ")", ";", "if", "(", "sEvery", "!=", "null"...
Checks cyclic holidays and checks if the requested year is hit within the cycles. @param aHoliday Holiday @param nYear the year to check against @return is valid
[ "Checks", "cyclic", "holidays", "and", "checks", "if", "the", "requested", "year", "is", "hit", "within", "the", "cycles", "." ]
cfaff01cb76d9affb934800ff55734b5a7d8983e
https://github.com/phax/ph-datetime/blob/cfaff01cb76d9affb934800ff55734b5a7d8983e/ph-holiday/src/main/java/com/helger/holiday/parser/AbstractHolidayParser.java#L68-L102
train
phax/ph-datetime
ph-holiday/src/main/java/com/helger/holiday/parser/AbstractHolidayParser.java
AbstractHolidayParser._isValidInYear
private static boolean _isValidInYear (@Nonnull final Holiday aHoliday, final int nYear) { return (aHoliday.getValidFrom () == null || aHoliday.getValidFrom ().intValue () <= nYear) && (aHoliday.getValidTo () == null || aHoliday.getValidTo ().intValue () >= nYear); }
java
private static boolean _isValidInYear (@Nonnull final Holiday aHoliday, final int nYear) { return (aHoliday.getValidFrom () == null || aHoliday.getValidFrom ().intValue () <= nYear) && (aHoliday.getValidTo () == null || aHoliday.getValidTo ().intValue () >= nYear); }
[ "private", "static", "boolean", "_isValidInYear", "(", "@", "Nonnull", "final", "Holiday", "aHoliday", ",", "final", "int", "nYear", ")", "{", "return", "(", "aHoliday", ".", "getValidFrom", "(", ")", "==", "null", "||", "aHoliday", ".", "getValidFrom", "(",...
Checks whether the holiday is within the valid date range. @param aHoliday @param nYear @return is valid.
[ "Checks", "whether", "the", "holiday", "is", "within", "the", "valid", "date", "range", "." ]
cfaff01cb76d9affb934800ff55734b5a7d8983e
https://github.com/phax/ph-datetime/blob/cfaff01cb76d9affb934800ff55734b5a7d8983e/ph-holiday/src/main/java/com/helger/holiday/parser/AbstractHolidayParser.java#L111-L115
train
phax/ph-datetime
ph-holiday/src/main/java/com/helger/holiday/parser/AbstractHolidayParser.java
AbstractHolidayParser.shallBeMoved
protected static final boolean shallBeMoved (@Nonnull final LocalDate aFixed, @Nonnull final MovingCondition aMoveCond) { return aFixed.getDayOfWeek () == XMLHolidayHelper.getWeekday (aMoveCond.getSubstitute ()); }
java
protected static final boolean shallBeMoved (@Nonnull final LocalDate aFixed, @Nonnull final MovingCondition aMoveCond) { return aFixed.getDayOfWeek () == XMLHolidayHelper.getWeekday (aMoveCond.getSubstitute ()); }
[ "protected", "static", "final", "boolean", "shallBeMoved", "(", "@", "Nonnull", "final", "LocalDate", "aFixed", ",", "@", "Nonnull", "final", "MovingCondition", "aMoveCond", ")", "{", "return", "aFixed", ".", "getDayOfWeek", "(", ")", "==", "XMLHolidayHelper", "...
Determines if the provided date shall be substituted. @param aFixed The date to be checked. May not be <code>null</code>. @param aMoveCond The move condition. May not be <code>null</code>. @return <code>true</code> if it should be substituted
[ "Determines", "if", "the", "provided", "date", "shall", "be", "substituted", "." ]
cfaff01cb76d9affb934800ff55734b5a7d8983e
https://github.com/phax/ph-datetime/blob/cfaff01cb76d9affb934800ff55734b5a7d8983e/ph-holiday/src/main/java/com/helger/holiday/parser/AbstractHolidayParser.java#L126-L130
train
phax/ph-datetime
ph-holiday/src/main/java/com/helger/holiday/parser/AbstractHolidayParser.java
AbstractHolidayParser._moveDate
private static LocalDate _moveDate (final MovingCondition aMoveCond, final LocalDate aDate) { final DayOfWeek nWeekday = XMLHolidayHelper.getWeekday (aMoveCond.getWeekday ()); final int nDirection = aMoveCond.getWith () == With.NEXT ? 1 : -1; LocalDate aMovedDate = aDate; while (aMovedDate.getDayOfWeek () != nWeekday) { aMovedDate = aMovedDate.plusDays (nDirection); } return aMovedDate; }
java
private static LocalDate _moveDate (final MovingCondition aMoveCond, final LocalDate aDate) { final DayOfWeek nWeekday = XMLHolidayHelper.getWeekday (aMoveCond.getWeekday ()); final int nDirection = aMoveCond.getWith () == With.NEXT ? 1 : -1; LocalDate aMovedDate = aDate; while (aMovedDate.getDayOfWeek () != nWeekday) { aMovedDate = aMovedDate.plusDays (nDirection); } return aMovedDate; }
[ "private", "static", "LocalDate", "_moveDate", "(", "final", "MovingCondition", "aMoveCond", ",", "final", "LocalDate", "aDate", ")", "{", "final", "DayOfWeek", "nWeekday", "=", "XMLHolidayHelper", ".", "getWeekday", "(", "aMoveCond", ".", "getWeekday", "(", ")", ...
Moves the date using the FixedMoving information @param aMoveCond @param aDate @return The moved date
[ "Moves", "the", "date", "using", "the", "FixedMoving", "information" ]
cfaff01cb76d9affb934800ff55734b5a7d8983e
https://github.com/phax/ph-datetime/blob/cfaff01cb76d9affb934800ff55734b5a7d8983e/ph-holiday/src/main/java/com/helger/holiday/parser/AbstractHolidayParser.java#L139-L150
train
phax/ph-datetime
ph-holiday/src/main/java/com/helger/holiday/parser/AbstractHolidayParser.java
AbstractHolidayParser.moveDate
protected static final LocalDate moveDate (final MoveableHoliday aMoveableHoliday, final LocalDate aFixed) { for (final MovingCondition aMoveCond : aMoveableHoliday.getMovingCondition ()) if (shallBeMoved (aFixed, aMoveCond)) return _moveDate (aMoveCond, aFixed); return aFixed; }
java
protected static final LocalDate moveDate (final MoveableHoliday aMoveableHoliday, final LocalDate aFixed) { for (final MovingCondition aMoveCond : aMoveableHoliday.getMovingCondition ()) if (shallBeMoved (aFixed, aMoveCond)) return _moveDate (aMoveCond, aFixed); return aFixed; }
[ "protected", "static", "final", "LocalDate", "moveDate", "(", "final", "MoveableHoliday", "aMoveableHoliday", ",", "final", "LocalDate", "aFixed", ")", "{", "for", "(", "final", "MovingCondition", "aMoveCond", ":", "aMoveableHoliday", ".", "getMovingCondition", "(", ...
Moves a date if there are any moving conditions for this holiday and any of them fit. @param aMoveableHoliday Date @param aFixed Optional fixed date @return the moved date
[ "Moves", "a", "date", "if", "there", "are", "any", "moving", "conditions", "for", "this", "holiday", "and", "any", "of", "them", "fit", "." ]
cfaff01cb76d9affb934800ff55734b5a7d8983e
https://github.com/phax/ph-datetime/blob/cfaff01cb76d9affb934800ff55734b5a7d8983e/ph-holiday/src/main/java/com/helger/holiday/parser/AbstractHolidayParser.java#L162-L168
train
michael-rapp/AndroidUtil
library/src/main/java/de/mrapp/android/util/view/AbstractViewHolderAdapter.java
AbstractViewHolderAdapter.setCurrentParentView
protected final void setCurrentParentView(@NonNull final View currentParentView) { Condition.INSTANCE.ensureNotNull(currentParentView, "The parent view may not be null"); this.currentParentView = currentParentView; }
java
protected final void setCurrentParentView(@NonNull final View currentParentView) { Condition.INSTANCE.ensureNotNull(currentParentView, "The parent view may not be null"); this.currentParentView = currentParentView; }
[ "protected", "final", "void", "setCurrentParentView", "(", "@", "NonNull", "final", "View", "currentParentView", ")", "{", "Condition", ".", "INSTANCE", ".", "ensureNotNull", "(", "currentParentView", ",", "\"The parent view may not be null\"", ")", ";", "this", ".", ...
Sets the parent view, whose appearance should currently be customized by the decorator. This method should never be called or overridden by any custom adapter implementation. @param currentParentView The parent view, which should be set, as an instance of the class {@link View}. The parent view may not be null
[ "Sets", "the", "parent", "view", "whose", "appearance", "should", "currently", "be", "customized", "by", "the", "decorator", ".", "This", "method", "should", "never", "be", "called", "or", "overridden", "by", "any", "custom", "adapter", "implementation", "." ]
67ec0e5732344eeb4d946dd1f96d782939e449f4
https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/view/AbstractViewHolderAdapter.java#L46-L49
train
michael-rapp/AndroidUtil
library/src/main/java/de/mrapp/android/util/view/AbstractViewHolderAdapter.java
AbstractViewHolderAdapter.findViewById
@SuppressWarnings("unchecked") protected final <ViewType extends View> ViewType findViewById(@IdRes final int viewId) { Condition.INSTANCE.ensureNotNull(currentParentView, "No parent view set", IllegalStateException.class); ViewHolder viewHolder = (ViewHolder) currentParentView.getTag(); if (viewHolder == null) { viewHolder = new ViewHolder(currentParentView); currentParentView.setTag(viewHolder); } return (ViewType) viewHolder.findViewById(viewId); }
java
@SuppressWarnings("unchecked") protected final <ViewType extends View> ViewType findViewById(@IdRes final int viewId) { Condition.INSTANCE.ensureNotNull(currentParentView, "No parent view set", IllegalStateException.class); ViewHolder viewHolder = (ViewHolder) currentParentView.getTag(); if (viewHolder == null) { viewHolder = new ViewHolder(currentParentView); currentParentView.setTag(viewHolder); } return (ViewType) viewHolder.findViewById(viewId); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "protected", "final", "<", "ViewType", "extends", "View", ">", "ViewType", "findViewById", "(", "@", "IdRes", "final", "int", "viewId", ")", "{", "Condition", ".", "INSTANCE", ".", "ensureNotNull", "(", "curr...
References the view, which belongs to a specific resource ID by using the view holder pattern. The view is implicitly casted to the type of the field it is assigned to. @param <ViewType> The type, the view is implicitly casted to. It must be inherited from the class {@link View} @param viewId The resource ID of the view, which should be referenced, as an {@link Integer} value. The ID must be a valid resource ID of the parent view of the view, whose appearance is currently customized by the adapter @return The view, which belongs to the given resource ID, as an instance of the class {@link View} or null, if no view with the given ID is available
[ "References", "the", "view", "which", "belongs", "to", "a", "specific", "resource", "ID", "by", "using", "the", "view", "holder", "pattern", ".", "The", "view", "is", "implicitly", "casted", "to", "the", "type", "of", "the", "field", "it", "is", "assigned"...
67ec0e5732344eeb4d946dd1f96d782939e449f4
https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/view/AbstractViewHolderAdapter.java#L65-L77
train
revelytix/spark
sherpa-java/src/main/java/sherpa/client/SignalSlot.java
SignalSlot.writeSlot
private void writeSlot(T data, Throwable error) { dataLock.lock(); try { this.error = error; this.data = data; availableCondition.signalAll(); } finally { dataLock.unlock(); } }
java
private void writeSlot(T data, Throwable error) { dataLock.lock(); try { this.error = error; this.data = data; availableCondition.signalAll(); } finally { dataLock.unlock(); } }
[ "private", "void", "writeSlot", "(", "T", "data", ",", "Throwable", "error", ")", "{", "dataLock", ".", "lock", "(", ")", ";", "try", "{", "this", ".", "error", "=", "error", ";", "this", ".", "data", "=", "data", ";", "availableCondition", ".", "sig...
either data or error should be non-null
[ "either", "data", "or", "error", "should", "be", "non", "-", "null" ]
d777d40c962bc66fdc04b7c3a66d20b777ff6fb4
https://github.com/revelytix/spark/blob/d777d40c962bc66fdc04b7c3a66d20b777ff6fb4/sherpa-java/src/main/java/sherpa/client/SignalSlot.java#L46-L55
train
revelytix/spark
sherpa-java/src/main/java/sherpa/client/SignalSlot.java
SignalSlot.getAndClearUnderLock
private T getAndClearUnderLock() throws Throwable { if(error != null) { throw error; } else { // Return and clear current T retValue = data; data = null; return retValue; } }
java
private T getAndClearUnderLock() throws Throwable { if(error != null) { throw error; } else { // Return and clear current T retValue = data; data = null; return retValue; } }
[ "private", "T", "getAndClearUnderLock", "(", ")", "throws", "Throwable", "{", "if", "(", "error", "!=", "null", ")", "{", "throw", "error", ";", "}", "else", "{", "// Return and clear current", "T", "retValue", "=", "data", ";", "data", "=", "null", ";", ...
Get and clear the slot - MUST be called while holding the lock!! @return The data or null if no data or error exists @throws Throwable If producer encountered an error
[ "Get", "and", "clear", "the", "slot", "-", "MUST", "be", "called", "while", "holding", "the", "lock!!" ]
d777d40c962bc66fdc04b7c3a66d20b777ff6fb4
https://github.com/revelytix/spark/blob/d777d40c962bc66fdc04b7c3a66d20b777ff6fb4/sherpa-java/src/main/java/sherpa/client/SignalSlot.java#L62-L71
train
revelytix/spark
sherpa-java/src/main/java/sherpa/client/SignalSlot.java
SignalSlot.take
public T take() throws Throwable { dataLock.lock(); try { while(data == null && error == null) { try { availableCondition.await(); } catch(InterruptedException e) { // ignore and re-loop in case of spurious wake-ups } } // should only get to here if data or error is non-null return getAndClearUnderLock(); } finally { dataLock.unlock(); } }
java
public T take() throws Throwable { dataLock.lock(); try { while(data == null && error == null) { try { availableCondition.await(); } catch(InterruptedException e) { // ignore and re-loop in case of spurious wake-ups } } // should only get to here if data or error is non-null return getAndClearUnderLock(); } finally { dataLock.unlock(); } }
[ "public", "T", "take", "(", ")", "throws", "Throwable", "{", "dataLock", ".", "lock", "(", ")", ";", "try", "{", "while", "(", "data", "==", "null", "&&", "error", "==", "null", ")", "{", "try", "{", "availableCondition", ".", "await", "(", ")", ";...
Blocking read and remove. If the thread was interrupted by the producer due to an error, the producer's error will be thrown. @return The data, should never be null @throws Throwable If producer encountered an error
[ "Blocking", "read", "and", "remove", ".", "If", "the", "thread", "was", "interrupted", "by", "the", "producer", "due", "to", "an", "error", "the", "producer", "s", "error", "will", "be", "thrown", "." ]
d777d40c962bc66fdc04b7c3a66d20b777ff6fb4
https://github.com/revelytix/spark/blob/d777d40c962bc66fdc04b7c3a66d20b777ff6fb4/sherpa-java/src/main/java/sherpa/client/SignalSlot.java#L93-L109
train
jruby/yecht
src/main/org/yecht/DefaultYAMLParser.java
DefaultYAMLParser.yyparse
public Object yyparse (yyInput yyLex, Object yydebug) throws java.io.IOException { //t this.yydebug = (jay.yydebug.yyDebug)yydebug; return yyparse(yyLex); }
java
public Object yyparse (yyInput yyLex, Object yydebug) throws java.io.IOException { //t this.yydebug = (jay.yydebug.yyDebug)yydebug; return yyparse(yyLex); }
[ "public", "Object", "yyparse", "(", "yyInput", "yyLex", ",", "Object", "yydebug", ")", "throws", "java", ".", "io", ".", "IOException", "{", "//t this.yydebug = (jay.yydebug.yyDebug)yydebug;", "return", "yyparse", "(", "yyLex", ")", ";", "}" ]
the generated parser, with debugging messages. Maintains a dynamic state and value stack. @param yyLex scanner. @param yydebug debug message writer implementing <tt>yyDebug</tt>, or <tt>null</tt>. @return result of the last reduction, if any.
[ "the", "generated", "parser", "with", "debugging", "messages", ".", "Maintains", "a", "dynamic", "state", "and", "value", "stack", "." ]
d745f62de8c10556b8964d78a07d436b65eeb8a9
https://github.com/jruby/yecht/blob/d745f62de8c10556b8964d78a07d436b65eeb8a9/src/main/org/yecht/DefaultYAMLParser.java#L262-L266
train
revelytix/spark
spark-http-client/src/main/java/spark/protocol/ProtocolDataSource.java
ProtocolDataSource.createPooledClient
private HttpClient createPooledClient() { HttpParams connMgrParams = new BasicHttpParams(); SchemeRegistry schemeRegistry = new SchemeRegistry(); schemeRegistry.register(new Scheme(HTTP_SCHEME, PlainSocketFactory.getSocketFactory(), HTTP_PORT)); schemeRegistry.register(new Scheme(HTTPS_SCHEME, SSLSocketFactory.getSocketFactory(), HTTPS_PORT)); // All connections will be to the same endpoint, so no need for per-route configuration. // TODO See how this does in the presence of redirects. ConnManagerParams.setMaxTotalConnections(connMgrParams, poolSize); ConnManagerParams.setMaxConnectionsPerRoute(connMgrParams, new ConnPerRouteBean(poolSize)); ClientConnectionManager ccm = new ThreadSafeClientConnManager(connMgrParams, schemeRegistry); HttpParams httpParams = new BasicHttpParams(); HttpProtocolParams.setUseExpectContinue(httpParams, false); ConnManagerParams.setTimeout(httpParams, acquireTimeout * 1000); return new DefaultHttpClient(ccm, httpParams); }
java
private HttpClient createPooledClient() { HttpParams connMgrParams = new BasicHttpParams(); SchemeRegistry schemeRegistry = new SchemeRegistry(); schemeRegistry.register(new Scheme(HTTP_SCHEME, PlainSocketFactory.getSocketFactory(), HTTP_PORT)); schemeRegistry.register(new Scheme(HTTPS_SCHEME, SSLSocketFactory.getSocketFactory(), HTTPS_PORT)); // All connections will be to the same endpoint, so no need for per-route configuration. // TODO See how this does in the presence of redirects. ConnManagerParams.setMaxTotalConnections(connMgrParams, poolSize); ConnManagerParams.setMaxConnectionsPerRoute(connMgrParams, new ConnPerRouteBean(poolSize)); ClientConnectionManager ccm = new ThreadSafeClientConnManager(connMgrParams, schemeRegistry); HttpParams httpParams = new BasicHttpParams(); HttpProtocolParams.setUseExpectContinue(httpParams, false); ConnManagerParams.setTimeout(httpParams, acquireTimeout * 1000); return new DefaultHttpClient(ccm, httpParams); }
[ "private", "HttpClient", "createPooledClient", "(", ")", "{", "HttpParams", "connMgrParams", "=", "new", "BasicHttpParams", "(", ")", ";", "SchemeRegistry", "schemeRegistry", "=", "new", "SchemeRegistry", "(", ")", ";", "schemeRegistry", ".", "register", "(", "new...
Creates a new thread-safe HTTP connection pool for use with a data source. @param poolSize The size of the connection pool. @return A new connection pool with the given size.
[ "Creates", "a", "new", "thread", "-", "safe", "HTTP", "connection", "pool", "for", "use", "with", "a", "data", "source", "." ]
d777d40c962bc66fdc04b7c3a66d20b777ff6fb4
https://github.com/revelytix/spark/blob/d777d40c962bc66fdc04b7c3a66d20b777ff6fb4/spark-http-client/src/main/java/spark/protocol/ProtocolDataSource.java#L187-L205
train
misberner/duzzt
processor/src/main/java/com/github/misberner/duzzt/automaton/DuzztState.java
DuzztState.addTransition
public void addTransition(DuzztAction action, DuzztState succ) { transitions.put(action, new DuzztTransition(action, succ)); }
java
public void addTransition(DuzztAction action, DuzztState succ) { transitions.put(action, new DuzztTransition(action, succ)); }
[ "public", "void", "addTransition", "(", "DuzztAction", "action", ",", "DuzztState", "succ", ")", "{", "transitions", ".", "put", "(", "action", ",", "new", "DuzztTransition", "(", "action", ",", "succ", ")", ")", ";", "}" ]
Adds a transition to this state. @param action the action on which to trigger this transition @param succ the successor state
[ "Adds", "a", "transition", "to", "this", "state", "." ]
3fb784c1a9142967141743587fe7ad3945d0ac28
https://github.com/misberner/duzzt/blob/3fb784c1a9142967141743587fe7ad3945d0ac28/processor/src/main/java/com/github/misberner/duzzt/automaton/DuzztState.java#L73-L75
train
galan/verjson
src/main/java/de/galan/verjson/util/Transformations.java
Transformations.getObj
public static ObjectNode getObj(ObjectNode obj, String fieldName) { return obj != null ? obj(obj.get(fieldName)) : null; }
java
public static ObjectNode getObj(ObjectNode obj, String fieldName) { return obj != null ? obj(obj.get(fieldName)) : null; }
[ "public", "static", "ObjectNode", "getObj", "(", "ObjectNode", "obj", ",", "String", "fieldName", ")", "{", "return", "obj", "!=", "null", "?", "obj", "(", "obj", ".", "get", "(", "fieldName", ")", ")", ":", "null", ";", "}" ]
Returns the field from a ObjectNode as ObjectNode
[ "Returns", "the", "field", "from", "a", "ObjectNode", "as", "ObjectNode" ]
4db610fb5198fde913114ed628234f957e1c19d5
https://github.com/galan/verjson/blob/4db610fb5198fde913114ed628234f957e1c19d5/src/main/java/de/galan/verjson/util/Transformations.java#L25-L27
train
galan/verjson
src/main/java/de/galan/verjson/util/Transformations.java
Transformations.getObjAndRemove
public static ObjectNode getObjAndRemove(ObjectNode obj, String fieldName) { ObjectNode result = null; if (obj != null) { result = obj(remove(obj, fieldName)); } return result; }
java
public static ObjectNode getObjAndRemove(ObjectNode obj, String fieldName) { ObjectNode result = null; if (obj != null) { result = obj(remove(obj, fieldName)); } return result; }
[ "public", "static", "ObjectNode", "getObjAndRemove", "(", "ObjectNode", "obj", ",", "String", "fieldName", ")", "{", "ObjectNode", "result", "=", "null", ";", "if", "(", "obj", "!=", "null", ")", "{", "result", "=", "obj", "(", "remove", "(", "obj", ",",...
Removes the field from a ObjectNode and returns it as ObjectNode
[ "Removes", "the", "field", "from", "a", "ObjectNode", "and", "returns", "it", "as", "ObjectNode" ]
4db610fb5198fde913114ed628234f957e1c19d5
https://github.com/galan/verjson/blob/4db610fb5198fde913114ed628234f957e1c19d5/src/main/java/de/galan/verjson/util/Transformations.java#L31-L37
train
galan/verjson
src/main/java/de/galan/verjson/util/Transformations.java
Transformations.createArray
public static ArrayNode createArray(boolean fallbackToEmptyArray, JsonNode... nodes) { ArrayNode array = null; for (JsonNode element: nodes) { if (element != null) { if (array == null) { array = new ArrayNode(JsonNodeFactory.instance); } array.add(element); } } if ((array == null) && fallbackToEmptyArray) { array = new ArrayNode(JsonNodeFactory.instance); } return array; }
java
public static ArrayNode createArray(boolean fallbackToEmptyArray, JsonNode... nodes) { ArrayNode array = null; for (JsonNode element: nodes) { if (element != null) { if (array == null) { array = new ArrayNode(JsonNodeFactory.instance); } array.add(element); } } if ((array == null) && fallbackToEmptyArray) { array = new ArrayNode(JsonNodeFactory.instance); } return array; }
[ "public", "static", "ArrayNode", "createArray", "(", "boolean", "fallbackToEmptyArray", ",", "JsonNode", "...", "nodes", ")", "{", "ArrayNode", "array", "=", "null", ";", "for", "(", "JsonNode", "element", ":", "nodes", ")", "{", "if", "(", "element", "!=", ...
Creates an ArrayNode from the given nodes. Returns an empty ArrayNode if no elements are provided and fallbackToEmptyArray is true, null if false.
[ "Creates", "an", "ArrayNode", "from", "the", "given", "nodes", ".", "Returns", "an", "empty", "ArrayNode", "if", "no", "elements", "are", "provided", "and", "fallbackToEmptyArray", "is", "true", "null", "if", "false", "." ]
4db610fb5198fde913114ed628234f957e1c19d5
https://github.com/galan/verjson/blob/4db610fb5198fde913114ed628234f957e1c19d5/src/main/java/de/galan/verjson/util/Transformations.java#L50-L64
train
galan/verjson
src/main/java/de/galan/verjson/util/Transformations.java
Transformations.getArray
public static ArrayNode getArray(ObjectNode obj, String fieldName) { return obj == null ? null : array(obj.get(fieldName)); }
java
public static ArrayNode getArray(ObjectNode obj, String fieldName) { return obj == null ? null : array(obj.get(fieldName)); }
[ "public", "static", "ArrayNode", "getArray", "(", "ObjectNode", "obj", ",", "String", "fieldName", ")", "{", "return", "obj", "==", "null", "?", "null", ":", "array", "(", "obj", ".", "get", "(", "fieldName", ")", ")", ";", "}" ]
Returns the field from a ObjectNode as ArrayNode
[ "Returns", "the", "field", "from", "a", "ObjectNode", "as", "ArrayNode" ]
4db610fb5198fde913114ed628234f957e1c19d5
https://github.com/galan/verjson/blob/4db610fb5198fde913114ed628234f957e1c19d5/src/main/java/de/galan/verjson/util/Transformations.java#L74-L76
train
galan/verjson
src/main/java/de/galan/verjson/util/Transformations.java
Transformations.getArrayAndRemove
public static ArrayNode getArrayAndRemove(ObjectNode obj, String fieldName) { ArrayNode result = null; if (obj != null) { result = array(remove(obj, fieldName)); } return result; }
java
public static ArrayNode getArrayAndRemove(ObjectNode obj, String fieldName) { ArrayNode result = null; if (obj != null) { result = array(remove(obj, fieldName)); } return result; }
[ "public", "static", "ArrayNode", "getArrayAndRemove", "(", "ObjectNode", "obj", ",", "String", "fieldName", ")", "{", "ArrayNode", "result", "=", "null", ";", "if", "(", "obj", "!=", "null", ")", "{", "result", "=", "array", "(", "remove", "(", "obj", ",...
Removes the field from a ObjectNode and returns it as ArrayNode
[ "Removes", "the", "field", "from", "a", "ObjectNode", "and", "returns", "it", "as", "ArrayNode" ]
4db610fb5198fde913114ed628234f957e1c19d5
https://github.com/galan/verjson/blob/4db610fb5198fde913114ed628234f957e1c19d5/src/main/java/de/galan/verjson/util/Transformations.java#L80-L86
train
galan/verjson
src/main/java/de/galan/verjson/util/Transformations.java
Transformations.remove
public static JsonNode remove(ObjectNode obj, String fieldName) { JsonNode result = null; if (obj != null) { result = obj.remove(fieldName); } return result; }
java
public static JsonNode remove(ObjectNode obj, String fieldName) { JsonNode result = null; if (obj != null) { result = obj.remove(fieldName); } return result; }
[ "public", "static", "JsonNode", "remove", "(", "ObjectNode", "obj", ",", "String", "fieldName", ")", "{", "JsonNode", "result", "=", "null", ";", "if", "(", "obj", "!=", "null", ")", "{", "result", "=", "obj", ".", "remove", "(", "fieldName", ")", ";",...
Removes the field with the given name from the given ObjectNode
[ "Removes", "the", "field", "with", "the", "given", "name", "from", "the", "given", "ObjectNode" ]
4db610fb5198fde913114ed628234f957e1c19d5
https://github.com/galan/verjson/blob/4db610fb5198fde913114ed628234f957e1c19d5/src/main/java/de/galan/verjson/util/Transformations.java#L90-L96
train
galan/verjson
src/main/java/de/galan/verjson/util/Transformations.java
Transformations.rename
public static void rename(ObjectNode obj, String oldFieldName, String newFieldName) { if (obj != null && isNotBlank(oldFieldName) && isNotBlank(newFieldName)) { JsonNode node = remove(obj, oldFieldName); if (node != null) { obj.set(newFieldName, node); } } }
java
public static void rename(ObjectNode obj, String oldFieldName, String newFieldName) { if (obj != null && isNotBlank(oldFieldName) && isNotBlank(newFieldName)) { JsonNode node = remove(obj, oldFieldName); if (node != null) { obj.set(newFieldName, node); } } }
[ "public", "static", "void", "rename", "(", "ObjectNode", "obj", ",", "String", "oldFieldName", ",", "String", "newFieldName", ")", "{", "if", "(", "obj", "!=", "null", "&&", "isNotBlank", "(", "oldFieldName", ")", "&&", "isNotBlank", "(", "newFieldName", ")"...
Renames a field in a ObjectNode from the oldFieldName to the newFieldName
[ "Renames", "a", "field", "in", "a", "ObjectNode", "from", "the", "oldFieldName", "to", "the", "newFieldName" ]
4db610fb5198fde913114ed628234f957e1c19d5
https://github.com/galan/verjson/blob/4db610fb5198fde913114ed628234f957e1c19d5/src/main/java/de/galan/verjson/util/Transformations.java#L100-L107
train
revelytix/spark
spark-http-client/src/main/java/spark/protocol/parser/ResultFactory.java
ResultFactory.stripParams
private static final String stripParams(String mediaType) { int sc = mediaType.indexOf(';'); if (sc >= 0) mediaType = mediaType.substring(0, sc); return mediaType; }
java
private static final String stripParams(String mediaType) { int sc = mediaType.indexOf(';'); if (sc >= 0) mediaType = mediaType.substring(0, sc); return mediaType; }
[ "private", "static", "final", "String", "stripParams", "(", "String", "mediaType", ")", "{", "int", "sc", "=", "mediaType", ".", "indexOf", "(", "'", "'", ")", ";", "if", "(", "sc", ">=", "0", ")", "mediaType", "=", "mediaType", ".", "substring", "(", ...
Strips the parameters from the end of a mediaType description. @param mediaType The text in a Content-Type header. @return The content type string without any parameters.
[ "Strips", "the", "parameters", "from", "the", "end", "of", "a", "mediaType", "description", "." ]
d777d40c962bc66fdc04b7c3a66d20b777ff6fb4
https://github.com/revelytix/spark/blob/d777d40c962bc66fdc04b7c3a66d20b777ff6fb4/spark-http-client/src/main/java/spark/protocol/parser/ResultFactory.java#L109-L113
train
revelytix/spark
spark-http-client/src/main/java/spark/protocol/parser/ResultFactory.java
ResultFactory.getDefaultMediaType
public static String getDefaultMediaType(ResultType expectedType) { ResponseFormat format = (expectedType != null) ? defaultTypeFormats.get(expectedType) : null; // If the expected type is unknown, we should let the server decide, otherwise we could // wind up requesting a response type that doesn't match the actual resuts (e.g. xml with CONSTRUCT). // TODO: We could include multiple media types in the Accept: field, but that assumes that the // server has proper support for content negotiation. Many servers only look at the first value. return (format != null) ? format.mimeText : null; }
java
public static String getDefaultMediaType(ResultType expectedType) { ResponseFormat format = (expectedType != null) ? defaultTypeFormats.get(expectedType) : null; // If the expected type is unknown, we should let the server decide, otherwise we could // wind up requesting a response type that doesn't match the actual resuts (e.g. xml with CONSTRUCT). // TODO: We could include multiple media types in the Accept: field, but that assumes that the // server has proper support for content negotiation. Many servers only look at the first value. return (format != null) ? format.mimeText : null; }
[ "public", "static", "String", "getDefaultMediaType", "(", "ResultType", "expectedType", ")", "{", "ResponseFormat", "format", "=", "(", "expectedType", "!=", "null", ")", "?", "defaultTypeFormats", ".", "get", "(", "expectedType", ")", ":", "null", ";", "// If t...
Gets the default content type to use when sending a query request with the given expected result type. @param expectedType The expected result type, or null if none is specified. @return The default MIME content type to use for the given result type.
[ "Gets", "the", "default", "content", "type", "to", "use", "when", "sending", "a", "query", "request", "with", "the", "given", "expected", "result", "type", "." ]
d777d40c962bc66fdc04b7c3a66d20b777ff6fb4
https://github.com/revelytix/spark/blob/d777d40c962bc66fdc04b7c3a66d20b777ff6fb4/spark-http-client/src/main/java/spark/protocol/parser/ResultFactory.java#L135-L143
train
revelytix/spark
spark-http-client/src/main/java/spark/protocol/parser/ResultFactory.java
ResultFactory.findParser
private static final ResultParser findParser(String mediaType, ResultType expectedType) { ResponseFormat format = null; // Prefer MIME type when choosing result format. if (mediaType != null) { mediaType = stripParams(mediaType); format = mimeFormats.get(mediaType); if (format == null) { logger.warn("Unrecognized media type ({}) in SPARQL server response", mediaType); } else { logger.debug("Using result format {} for media type {}", format, mediaType); } } // If MIME type was absent or unrecognized, choose default based on expected result type. if (format == null) { logger.debug("Unable to determine result format from media type"); if (expectedType != null) { format = defaultTypeFormats.get(expectedType); logger.debug("Using default format {} for expected result type {}", format, expectedType); } else { format = DEFAULT_FORMAT; logger.debug("No expected type provided; using default format {}", format); } } assert format != null:"Could not determine result format"; // Validate that the chosen format can produce the expected result type. if (expectedType != null && !format.resultTypes.contains(expectedType)) { throw new SparqlException("Result format " + format + " does not support expected result type " + expectedType); } return format.parser; }
java
private static final ResultParser findParser(String mediaType, ResultType expectedType) { ResponseFormat format = null; // Prefer MIME type when choosing result format. if (mediaType != null) { mediaType = stripParams(mediaType); format = mimeFormats.get(mediaType); if (format == null) { logger.warn("Unrecognized media type ({}) in SPARQL server response", mediaType); } else { logger.debug("Using result format {} for media type {}", format, mediaType); } } // If MIME type was absent or unrecognized, choose default based on expected result type. if (format == null) { logger.debug("Unable to determine result format from media type"); if (expectedType != null) { format = defaultTypeFormats.get(expectedType); logger.debug("Using default format {} for expected result type {}", format, expectedType); } else { format = DEFAULT_FORMAT; logger.debug("No expected type provided; using default format {}", format); } } assert format != null:"Could not determine result format"; // Validate that the chosen format can produce the expected result type. if (expectedType != null && !format.resultTypes.contains(expectedType)) { throw new SparqlException("Result format " + format + " does not support expected result type " + expectedType); } return format.parser; }
[ "private", "static", "final", "ResultParser", "findParser", "(", "String", "mediaType", ",", "ResultType", "expectedType", ")", "{", "ResponseFormat", "format", "=", "null", ";", "// Prefer MIME type when choosing result format.", "if", "(", "mediaType", "!=", "null", ...
Find a parser to handle the protocol response body based on the content type found in the response and the expected result type specified by the user; if one or both fields is missing then attempts to choose a sensible default. @param mediaType The content type in the response, or null if none was given. @param expectedType The expected response type indicated by the user, or @return
[ "Find", "a", "parser", "to", "handle", "the", "protocol", "response", "body", "based", "on", "the", "content", "type", "found", "in", "the", "response", "and", "the", "expected", "result", "type", "specified", "by", "the", "user", ";", "if", "one", "or", ...
d777d40c962bc66fdc04b7c3a66d20b777ff6fb4
https://github.com/revelytix/spark/blob/d777d40c962bc66fdc04b7c3a66d20b777ff6fb4/spark-http-client/src/main/java/spark/protocol/parser/ResultFactory.java#L153-L187
train
sosandstrom/mardao
mardao-core/src/main/java/net/sf/mardao/core/filter/Filter.java
Filter.equalsFilter
public static Filter equalsFilter(String column, Object operand) { return new Filter(column, FilterOperator.EQUALS, operand); }
java
public static Filter equalsFilter(String column, Object operand) { return new Filter(column, FilterOperator.EQUALS, operand); }
[ "public", "static", "Filter", "equalsFilter", "(", "String", "column", ",", "Object", "operand", ")", "{", "return", "new", "Filter", "(", "column", ",", "FilterOperator", ".", "EQUALS", ",", "operand", ")", ";", "}" ]
Builds an EqualsFilter
[ "Builds", "an", "EqualsFilter" ]
b77e3a2ac1d8932e0a3174f3645f71b211dfc055
https://github.com/sosandstrom/mardao/blob/b77e3a2ac1d8932e0a3174f3645f71b211dfc055/mardao-core/src/main/java/net/sf/mardao/core/filter/Filter.java#L37-L39
train
sosandstrom/mardao
mardao-core/src/main/java/net/sf/mardao/core/filter/Filter.java
Filter.inFilter
public static Filter inFilter(String column, Object operand) { return new Filter(column, FilterOperator.IN, operand); }
java
public static Filter inFilter(String column, Object operand) { return new Filter(column, FilterOperator.IN, operand); }
[ "public", "static", "Filter", "inFilter", "(", "String", "column", ",", "Object", "operand", ")", "{", "return", "new", "Filter", "(", "column", ",", "FilterOperator", ".", "IN", ",", "operand", ")", ";", "}" ]
Builds an InFilter
[ "Builds", "an", "InFilter" ]
b77e3a2ac1d8932e0a3174f3645f71b211dfc055
https://github.com/sosandstrom/mardao/blob/b77e3a2ac1d8932e0a3174f3645f71b211dfc055/mardao-core/src/main/java/net/sf/mardao/core/filter/Filter.java#L42-L44
train
michael-rapp/AndroidUtil
library/src/main/java/de/mrapp/android/util/view/HeaderAndFooterGridView.java
HeaderAndFooterGridView.inflatePlaceholderView
@NonNull protected final View inflatePlaceholderView(@Nullable final View convertView, final int height) { View view = convertView; if (!(view instanceof PlaceholderView)) { view = new PlaceholderView(getContext()); } view.setMinimumHeight(height); return view; }
java
@NonNull protected final View inflatePlaceholderView(@Nullable final View convertView, final int height) { View view = convertView; if (!(view instanceof PlaceholderView)) { view = new PlaceholderView(getContext()); } view.setMinimumHeight(height); return view; }
[ "@", "NonNull", "protected", "final", "View", "inflatePlaceholderView", "(", "@", "Nullable", "final", "View", "convertView", ",", "final", "int", "height", ")", "{", "View", "view", "=", "convertView", ";", "if", "(", "!", "(", "view", "instanceof", "Placeh...
Inflates an invisible placeholder view with a specific height. @param convertView The old view to reuse, if possible, as an instance of the class {@link View} or null, if no view to reuse is available. @param height The height, which should be used, as an {@link Integer} value @return The view, which has been inflated, as an instance of the class {@link View}
[ "Inflates", "an", "invisible", "placeholder", "view", "with", "a", "specific", "height", "." ]
67ec0e5732344eeb4d946dd1f96d782939e449f4
https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/view/HeaderAndFooterGridView.java#L362-L373
train
michael-rapp/AndroidUtil
library/src/main/java/de/mrapp/android/util/view/HeaderAndFooterGridView.java
HeaderAndFooterGridView.getViewHeight
protected final int getViewHeight(@NonNull final ListAdapter adapter, final int position) { View view = adapter.getView(position, null, this); LayoutParams layoutParams = (LayoutParams) view.getLayoutParams(); if (layoutParams == null) { layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); view.setLayoutParams(layoutParams); } int widthMeasureSpec = getChildMeasureSpec( MeasureSpec.makeMeasureSpec(getColumnWidthCompatible(), MeasureSpec.EXACTLY), 0, layoutParams.width); int heightMeasureSpec = getChildMeasureSpec(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), 0, layoutParams.height); view.measure(widthMeasureSpec, heightMeasureSpec); return view.getMeasuredHeight(); }
java
protected final int getViewHeight(@NonNull final ListAdapter adapter, final int position) { View view = adapter.getView(position, null, this); LayoutParams layoutParams = (LayoutParams) view.getLayoutParams(); if (layoutParams == null) { layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); view.setLayoutParams(layoutParams); } int widthMeasureSpec = getChildMeasureSpec( MeasureSpec.makeMeasureSpec(getColumnWidthCompatible(), MeasureSpec.EXACTLY), 0, layoutParams.width); int heightMeasureSpec = getChildMeasureSpec(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), 0, layoutParams.height); view.measure(widthMeasureSpec, heightMeasureSpec); return view.getMeasuredHeight(); }
[ "protected", "final", "int", "getViewHeight", "(", "@", "NonNull", "final", "ListAdapter", "adapter", ",", "final", "int", "position", ")", "{", "View", "view", "=", "adapter", ".", "getView", "(", "position", ",", "null", ",", "this", ")", ";", "LayoutPar...
Returns the height of the view, which corresponds to a specific position of an adapter. @param adapter The adapter as an instance of the type {@link ListAdapter}. The adapter may not be null @param position The position of the view, whose height should be returned, as an {@link Integer} value @return The height of the view, which corresponds to the given position, in pixels as an {@link Integer} value
[ "Returns", "the", "height", "of", "the", "view", "which", "corresponds", "to", "a", "specific", "position", "of", "an", "adapter", "." ]
67ec0e5732344eeb4d946dd1f96d782939e449f4
https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/view/HeaderAndFooterGridView.java#L387-L404
train
michael-rapp/AndroidUtil
library/src/main/java/de/mrapp/android/util/view/HeaderAndFooterGridView.java
HeaderAndFooterGridView.createItemClickListener
private OnItemClickListener createItemClickListener( @NonNull final OnItemClickListener encapsulatedListener) { return new OnItemClickListener() { @Override public void onItemClick(final AdapterView<?> parent, final View view, final int position, final long id) { encapsulatedListener.onItemClick(parent, view, getItemPosition(position), id); } }; }
java
private OnItemClickListener createItemClickListener( @NonNull final OnItemClickListener encapsulatedListener) { return new OnItemClickListener() { @Override public void onItemClick(final AdapterView<?> parent, final View view, final int position, final long id) { encapsulatedListener.onItemClick(parent, view, getItemPosition(position), id); } }; }
[ "private", "OnItemClickListener", "createItemClickListener", "(", "@", "NonNull", "final", "OnItemClickListener", "encapsulatedListener", ")", "{", "return", "new", "OnItemClickListener", "(", ")", "{", "@", "Override", "public", "void", "onItemClick", "(", "final", "...
Creates and returns a listener, which encapsulates another listener in order to be able to adapt the position of the item, which has been clicked. @param encapsulatedListener The listener, which should be encapsulated, as an instance of the type {@link OnItemClickListener} @return The listener, which has been created, as an instance of the type {@link OnItemClickListener}
[ "Creates", "and", "returns", "a", "listener", "which", "encapsulates", "another", "listener", "in", "order", "to", "be", "able", "to", "adapt", "the", "position", "of", "the", "item", "which", "has", "been", "clicked", "." ]
67ec0e5732344eeb4d946dd1f96d782939e449f4
https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/view/HeaderAndFooterGridView.java#L456-L467
train
michael-rapp/AndroidUtil
library/src/main/java/de/mrapp/android/util/view/HeaderAndFooterGridView.java
HeaderAndFooterGridView.createItemLongClickListener
private OnItemLongClickListener createItemLongClickListener( @NonNull final OnItemLongClickListener encapsulatedListener) { return new OnItemLongClickListener() { @Override public boolean onItemLongClick(final AdapterView<?> parent, final View view, final int position, final long id) { return encapsulatedListener .onItemLongClick(parent, view, getItemPosition(position), id); } }; }
java
private OnItemLongClickListener createItemLongClickListener( @NonNull final OnItemLongClickListener encapsulatedListener) { return new OnItemLongClickListener() { @Override public boolean onItemLongClick(final AdapterView<?> parent, final View view, final int position, final long id) { return encapsulatedListener .onItemLongClick(parent, view, getItemPosition(position), id); } }; }
[ "private", "OnItemLongClickListener", "createItemLongClickListener", "(", "@", "NonNull", "final", "OnItemLongClickListener", "encapsulatedListener", ")", "{", "return", "new", "OnItemLongClickListener", "(", ")", "{", "@", "Override", "public", "boolean", "onItemLongClick"...
Creates and returns a listener, which encapsulates another listener in order to be able to adapt the position of the item, which has been long-clicked. @param encapsulatedListener The listener, which should be encapsulated, as an instance of the type {@link OnItemLongClickListener} @return The listener, which has been created, as an instance of the type {@link OnItemLongClickListener}
[ "Creates", "and", "returns", "a", "listener", "which", "encapsulates", "another", "listener", "in", "order", "to", "be", "able", "to", "adapt", "the", "position", "of", "the", "item", "which", "has", "been", "long", "-", "clicked", "." ]
67ec0e5732344eeb4d946dd1f96d782939e449f4
https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/view/HeaderAndFooterGridView.java#L479-L491
train
michael-rapp/AndroidUtil
library/src/main/java/de/mrapp/android/util/view/HeaderAndFooterGridView.java
HeaderAndFooterGridView.getItemPosition
private int getItemPosition(final int position) { int numColumns = getNumColumnsCompatible(); int headerItemCount = getHeaderViewsCount() * numColumns; int adapterCount = adapter.getEncapsulatedAdapter().getCount(); if (position < headerItemCount) { return position / numColumns; } else if (position < headerItemCount + adapterCount + getNumberOfPlaceholderViews()) { return position - headerItemCount + getHeaderViewsCount(); } else { return getHeaderViewsCount() + adapterCount + (position - headerItemCount - adapterCount - getNumberOfPlaceholderViews()) / numColumns; } }
java
private int getItemPosition(final int position) { int numColumns = getNumColumnsCompatible(); int headerItemCount = getHeaderViewsCount() * numColumns; int adapterCount = adapter.getEncapsulatedAdapter().getCount(); if (position < headerItemCount) { return position / numColumns; } else if (position < headerItemCount + adapterCount + getNumberOfPlaceholderViews()) { return position - headerItemCount + getHeaderViewsCount(); } else { return getHeaderViewsCount() + adapterCount + (position - headerItemCount - adapterCount - getNumberOfPlaceholderViews()) / numColumns; } }
[ "private", "int", "getItemPosition", "(", "final", "int", "position", ")", "{", "int", "numColumns", "=", "getNumColumnsCompatible", "(", ")", ";", "int", "headerItemCount", "=", "getHeaderViewsCount", "(", ")", "*", "numColumns", ";", "int", "adapterCount", "="...
Returns the index of the item, which corresponds to a specific flattened position. @param position The flattened position of the item, whose index should be returned, as an {@link Integer} value @return The index of the item, which corresponds to the given flattened position, as an {@link Integer} value
[ "Returns", "the", "index", "of", "the", "item", "which", "corresponds", "to", "a", "specific", "flattened", "position", "." ]
67ec0e5732344eeb4d946dd1f96d782939e449f4
https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/view/HeaderAndFooterGridView.java#L502-L516
train
michael-rapp/AndroidUtil
library/src/main/java/de/mrapp/android/util/view/HeaderAndFooterGridView.java
HeaderAndFooterGridView.getNumberOfPlaceholderViews
private int getNumberOfPlaceholderViews() { int numColumns = getNumColumnsCompatible(); int adapterCount = adapter.getEncapsulatedAdapter().getCount(); int lastLineCount = adapterCount % numColumns; return lastLineCount > 0 ? numColumns - lastLineCount : 0; }
java
private int getNumberOfPlaceholderViews() { int numColumns = getNumColumnsCompatible(); int adapterCount = adapter.getEncapsulatedAdapter().getCount(); int lastLineCount = adapterCount % numColumns; return lastLineCount > 0 ? numColumns - lastLineCount : 0; }
[ "private", "int", "getNumberOfPlaceholderViews", "(", ")", "{", "int", "numColumns", "=", "getNumColumnsCompatible", "(", ")", ";", "int", "adapterCount", "=", "adapter", ".", "getEncapsulatedAdapter", "(", ")", ".", "getCount", "(", ")", ";", "int", "lastLineCo...
Returns the number of placeholder views, which are necessary to complement the items of the encapsulated adapter in order to fill up all columns.. @return The number of placeholder views, which are necessary to complement the items of the encapsulated adapter in order to fill up all columns, as an {@link Integer} value
[ "Returns", "the", "number", "of", "placeholder", "views", "which", "are", "necessary", "to", "complement", "the", "items", "of", "the", "encapsulated", "adapter", "in", "order", "to", "fill", "up", "all", "columns", ".." ]
67ec0e5732344eeb4d946dd1f96d782939e449f4
https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/view/HeaderAndFooterGridView.java#L525-L530
train
michael-rapp/AndroidUtil
library/src/main/java/de/mrapp/android/util/view/HeaderAndFooterGridView.java
HeaderAndFooterGridView.addHeaderView
public final void addHeaderView(@NonNull final View view, @Nullable final Object data, final boolean selectable) { Condition.INSTANCE.ensureNotNull(view, "The view may not be null"); headers.add(new FullWidthItem(view, data, selectable)); notifyDataSetChanged(); }
java
public final void addHeaderView(@NonNull final View view, @Nullable final Object data, final boolean selectable) { Condition.INSTANCE.ensureNotNull(view, "The view may not be null"); headers.add(new FullWidthItem(view, data, selectable)); notifyDataSetChanged(); }
[ "public", "final", "void", "addHeaderView", "(", "@", "NonNull", "final", "View", "view", ",", "@", "Nullable", "final", "Object", "data", ",", "final", "boolean", "selectable", ")", "{", "Condition", ".", "INSTANCE", ".", "ensureNotNull", "(", "view", ",", ...
Adds a fixed view to appear at the top of the adapter view. If this method is called more than once, the views will appear in the order they were added. @param view The header view, which should be added, as an instance of the class {@link View}. The view may not be null @param data The data, which should be associated with the header view, as an instance of the class {@link Object}, or null, if no data should be associated with the view @param selectable True, if the header view should be selectable, false otherwise
[ "Adds", "a", "fixed", "view", "to", "appear", "at", "the", "top", "of", "the", "adapter", "view", ".", "If", "this", "method", "is", "called", "more", "than", "once", "the", "views", "will", "appear", "in", "the", "order", "they", "were", "added", "." ...
67ec0e5732344eeb4d946dd1f96d782939e449f4
https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/view/HeaderAndFooterGridView.java#L626-L631
train
michael-rapp/AndroidUtil
library/src/main/java/de/mrapp/android/util/view/HeaderAndFooterGridView.java
HeaderAndFooterGridView.addFooterView
public final void addFooterView(@NonNull final View view, @Nullable final Object data, final boolean selectable) { Condition.INSTANCE.ensureNotNull(view, "The view may not be null"); footers.add(new FullWidthItem(view, data, selectable)); notifyDataSetChanged(); }
java
public final void addFooterView(@NonNull final View view, @Nullable final Object data, final boolean selectable) { Condition.INSTANCE.ensureNotNull(view, "The view may not be null"); footers.add(new FullWidthItem(view, data, selectable)); notifyDataSetChanged(); }
[ "public", "final", "void", "addFooterView", "(", "@", "NonNull", "final", "View", "view", ",", "@", "Nullable", "final", "Object", "data", ",", "final", "boolean", "selectable", ")", "{", "Condition", ".", "INSTANCE", ".", "ensureNotNull", "(", "view", ",", ...
Adds a fixed view to appear at the bottom of the adapter view. If this method is called more than once, the views will appear in the order they were added. @param view The footer view, which should be added, as an instance of the class {@link View}. The view may not be null @param data The data, which should be associated with the footer view, as an instance of the class {@link Object}, or null, if no data should be associated with the view @param selectable True, if the footer view should be selectable, false otherwise
[ "Adds", "a", "fixed", "view", "to", "appear", "at", "the", "bottom", "of", "the", "adapter", "view", ".", "If", "this", "method", "is", "called", "more", "than", "once", "the", "views", "will", "appear", "in", "the", "order", "they", "were", "added", "...
67ec0e5732344eeb4d946dd1f96d782939e449f4
https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/view/HeaderAndFooterGridView.java#L646-L651
train
revelytix/spark
sherpa-java/src/main/java/sherpa/client/QueryExecution.java
QueryExecution.asyncMoreRequest
private void asyncMoreRequest(int startRow) { try { DataRequest moreRequest = new DataRequest(); moreRequest.queryId = queryId; moreRequest.startRow = startRow; moreRequest.maxSize = maxBatchSize; logger.debug("Client requesting {} .. {}", startRow, (startRow + maxBatchSize - 1)); DataResponse response = server.data(moreRequest); logger.debug("Client got response {} .. {}, more={}", new Object[] { response.startRow, (response.startRow + response.data.size() - 1), response.more }); nextData.add(new Window(response.data, response.more)); } catch (AvroRemoteException e) { this.nextData.addError(toSparqlException(e)); } catch (Throwable t) { this.nextData.addError(t); } }
java
private void asyncMoreRequest(int startRow) { try { DataRequest moreRequest = new DataRequest(); moreRequest.queryId = queryId; moreRequest.startRow = startRow; moreRequest.maxSize = maxBatchSize; logger.debug("Client requesting {} .. {}", startRow, (startRow + maxBatchSize - 1)); DataResponse response = server.data(moreRequest); logger.debug("Client got response {} .. {}, more={}", new Object[] { response.startRow, (response.startRow + response.data.size() - 1), response.more }); nextData.add(new Window(response.data, response.more)); } catch (AvroRemoteException e) { this.nextData.addError(toSparqlException(e)); } catch (Throwable t) { this.nextData.addError(t); } }
[ "private", "void", "asyncMoreRequest", "(", "int", "startRow", ")", "{", "try", "{", "DataRequest", "moreRequest", "=", "new", "DataRequest", "(", ")", ";", "moreRequest", ".", "queryId", "=", "queryId", ";", "moreRequest", ".", "startRow", "=", "startRow", ...
Send request for more data for this query. NOTE: This method is always run in a background thread!! @param startRow Start row needed in return batch
[ "Send", "request", "for", "more", "data", "for", "this", "query", "." ]
d777d40c962bc66fdc04b7c3a66d20b777ff6fb4
https://github.com/revelytix/spark/blob/d777d40c962bc66fdc04b7c3a66d20b777ff6fb4/sherpa-java/src/main/java/sherpa/client/QueryExecution.java#L166-L183
train
revelytix/spark
spark-http-client/src/main/java/spark/protocol/SparqlCall.java
SparqlCall.encode
private static final String encode(String s) { try { return URLEncoder.encode(s, UTF_8); } catch (UnsupportedEncodingException e) { throw new Error("JVM unable to handle UTF-8"); } }
java
private static final String encode(String s) { try { return URLEncoder.encode(s, UTF_8); } catch (UnsupportedEncodingException e) { throw new Error("JVM unable to handle UTF-8"); } }
[ "private", "static", "final", "String", "encode", "(", "String", "s", ")", "{", "try", "{", "return", "URLEncoder", ".", "encode", "(", "s", ",", "UTF_8", ")", ";", "}", "catch", "(", "UnsupportedEncodingException", "e", ")", "{", "throw", "new", "Error"...
URL-encode a string as UTF-8, catching any thrown UnsupportedEncodingException.
[ "URL", "-", "encode", "a", "string", "as", "UTF", "-", "8", "catching", "any", "thrown", "UnsupportedEncodingException", "." ]
d777d40c962bc66fdc04b7c3a66d20b777ff6fb4
https://github.com/revelytix/spark/blob/d777d40c962bc66fdc04b7c3a66d20b777ff6fb4/spark-http-client/src/main/java/spark/protocol/SparqlCall.java#L76-L82
train
revelytix/spark
spark-http-client/src/main/java/spark/protocol/SparqlCall.java
SparqlCall.dump
@SuppressWarnings("unused") private static final void dump(HttpClient client, HttpUriRequest req) { if (logger.isTraceEnabled()) { StringBuilder sb = new StringBuilder("\n=== Request ==="); sb.append("\n").append(req.getRequestLine()); for (Header h : req.getAllHeaders()) { sb.append("\n").append(h.getName()).append(": ").append(h.getValue()); } logger.trace(sb.toString()); HttpResponse resp = null; try { resp = client.execute(req); } catch (Exception e) { logger.trace("Error executing request", e); return; } sb = new StringBuilder("\n=== Response ==="); sb.append("\n").append(resp.getStatusLine()); for (Header h : resp.getAllHeaders()) { sb.append("\n").append(h.getName()).append(": ").append(h.getValue()); } logger.trace(sb.toString()); HttpEntity entity = resp.getEntity(); if (entity != null) { sb = new StringBuilder("\n=== Content ==="); try { int len = (int) entity.getContentLength(); if (len < 0) len = 100; ByteArrayOutputStream baos = new ByteArrayOutputStream(len); entity.writeTo(baos); sb.append("\n").append(baos.toString("UTF-8")); logger.trace(sb.toString()); } catch (IOException e) { logger.trace("Error reading content", e); } } } }
java
@SuppressWarnings("unused") private static final void dump(HttpClient client, HttpUriRequest req) { if (logger.isTraceEnabled()) { StringBuilder sb = new StringBuilder("\n=== Request ==="); sb.append("\n").append(req.getRequestLine()); for (Header h : req.getAllHeaders()) { sb.append("\n").append(h.getName()).append(": ").append(h.getValue()); } logger.trace(sb.toString()); HttpResponse resp = null; try { resp = client.execute(req); } catch (Exception e) { logger.trace("Error executing request", e); return; } sb = new StringBuilder("\n=== Response ==="); sb.append("\n").append(resp.getStatusLine()); for (Header h : resp.getAllHeaders()) { sb.append("\n").append(h.getName()).append(": ").append(h.getValue()); } logger.trace(sb.toString()); HttpEntity entity = resp.getEntity(); if (entity != null) { sb = new StringBuilder("\n=== Content ==="); try { int len = (int) entity.getContentLength(); if (len < 0) len = 100; ByteArrayOutputStream baos = new ByteArrayOutputStream(len); entity.writeTo(baos); sb.append("\n").append(baos.toString("UTF-8")); logger.trace(sb.toString()); } catch (IOException e) { logger.trace("Error reading content", e); } } } }
[ "@", "SuppressWarnings", "(", "\"unused\"", ")", "private", "static", "final", "void", "dump", "(", "HttpClient", "client", ",", "HttpUriRequest", "req", ")", "{", "if", "(", "logger", ".", "isTraceEnabled", "(", ")", ")", "{", "StringBuilder", "sb", "=", ...
Logs a request, executes it, and dumps the response to the logger. For development use only.
[ "Logs", "a", "request", "executes", "it", "and", "dumps", "the", "response", "to", "the", "logger", ".", "For", "development", "use", "only", "." ]
d777d40c962bc66fdc04b7c3a66d20b777ff6fb4
https://github.com/revelytix/spark/blob/d777d40c962bc66fdc04b7c3a66d20b777ff6fb4/spark-http-client/src/main/java/spark/protocol/SparqlCall.java#L85-L125
train
revelytix/spark
spark-http-client/src/main/java/spark/protocol/SparqlCall.java
SparqlCall.executeRequest
static HttpResponse executeRequest(ProtocolCommand command, String mimeType) { HttpClient client = ((ProtocolConnection)command.getConnection()).getHttpClient(); URL url = ((ProtocolDataSource)command.getConnection().getDataSource()).getUrl(); HttpUriRequest req; try { String params = "query=" + encode(command.getCommand()); String u = url.toString() + "?" + params; if (u.length() > QUERY_LIMIT) { // POST connection try { req = new HttpPost(url.toURI()); } catch (URISyntaxException e) { throw new SparqlException("Endpoint <" + url + "> not in an acceptable format", e); } ((HttpPost) req).setEntity((HttpEntity) new StringEntity(params)); } else { // GET connection req = new HttpGet(u); } if (command.getTimeout() != Command.NO_TIMEOUT) { HttpParams reqParams = new BasicHttpParams(); HttpConnectionParams.setSoTimeout(reqParams, (int) (command.getTimeout() * 1000)); req.setParams(reqParams); } // Add Accept and Content-Type (for POST'ed queries) headers to the request. addHeaders(req, mimeType); // There's a small chance the request could be aborted before it's even executed, we'll have to live with that. command.setRequest(req); //dump(client, req); HttpResponse response = client.execute(req); StatusLine status = response.getStatusLine(); int code = status.getStatusCode(); // TODO the client doesn't handle redirects for posts; should we do that here? if (code >= SUCCESS_MIN && code <= SUCCESS_MAX) { return response; } else { throw new SparqlException("Unexpected status code in server response: " + status.getReasonPhrase() + "(" + code + ")"); } } catch (UnsupportedEncodingException e) { throw new SparqlException("Unabled to encode data", e); } catch (ClientProtocolException cpe) { throw new SparqlException("Error in protocol", cpe); } catch (IOException e) { throw new SparqlException(e); } }
java
static HttpResponse executeRequest(ProtocolCommand command, String mimeType) { HttpClient client = ((ProtocolConnection)command.getConnection()).getHttpClient(); URL url = ((ProtocolDataSource)command.getConnection().getDataSource()).getUrl(); HttpUriRequest req; try { String params = "query=" + encode(command.getCommand()); String u = url.toString() + "?" + params; if (u.length() > QUERY_LIMIT) { // POST connection try { req = new HttpPost(url.toURI()); } catch (URISyntaxException e) { throw new SparqlException("Endpoint <" + url + "> not in an acceptable format", e); } ((HttpPost) req).setEntity((HttpEntity) new StringEntity(params)); } else { // GET connection req = new HttpGet(u); } if (command.getTimeout() != Command.NO_TIMEOUT) { HttpParams reqParams = new BasicHttpParams(); HttpConnectionParams.setSoTimeout(reqParams, (int) (command.getTimeout() * 1000)); req.setParams(reqParams); } // Add Accept and Content-Type (for POST'ed queries) headers to the request. addHeaders(req, mimeType); // There's a small chance the request could be aborted before it's even executed, we'll have to live with that. command.setRequest(req); //dump(client, req); HttpResponse response = client.execute(req); StatusLine status = response.getStatusLine(); int code = status.getStatusCode(); // TODO the client doesn't handle redirects for posts; should we do that here? if (code >= SUCCESS_MIN && code <= SUCCESS_MAX) { return response; } else { throw new SparqlException("Unexpected status code in server response: " + status.getReasonPhrase() + "(" + code + ")"); } } catch (UnsupportedEncodingException e) { throw new SparqlException("Unabled to encode data", e); } catch (ClientProtocolException cpe) { throw new SparqlException("Error in protocol", cpe); } catch (IOException e) { throw new SparqlException(e); } }
[ "static", "HttpResponse", "executeRequest", "(", "ProtocolCommand", "command", ",", "String", "mimeType", ")", "{", "HttpClient", "client", "=", "(", "(", "ProtocolConnection", ")", "command", ".", "getConnection", "(", ")", ")", ".", "getHttpClient", "(", ")", ...
Executes a SPARQL HTTP protocol request for the given command, and returns the response. @param command The SPARQL protocol command. @return The HTTP response.
[ "Executes", "a", "SPARQL", "HTTP", "protocol", "request", "for", "the", "given", "command", "and", "returns", "the", "response", "." ]
d777d40c962bc66fdc04b7c3a66d20b777ff6fb4
https://github.com/revelytix/spark/blob/d777d40c962bc66fdc04b7c3a66d20b777ff6fb4/spark-http-client/src/main/java/spark/protocol/SparqlCall.java#L132-L185
train
revelytix/spark
spark-http-client/src/main/java/spark/protocol/SparqlCall.java
SparqlCall.addHeaders
static void addHeaders(HttpUriRequest req, String mimeType) { if (POST.equalsIgnoreCase(req.getMethod())) { req.addHeader(CONTENT_TYPE, FORM_ENCODED); } if (mimeType != null) req.setHeader(ACCEPT, mimeType); }
java
static void addHeaders(HttpUriRequest req, String mimeType) { if (POST.equalsIgnoreCase(req.getMethod())) { req.addHeader(CONTENT_TYPE, FORM_ENCODED); } if (mimeType != null) req.setHeader(ACCEPT, mimeType); }
[ "static", "void", "addHeaders", "(", "HttpUriRequest", "req", ",", "String", "mimeType", ")", "{", "if", "(", "POST", ".", "equalsIgnoreCase", "(", "req", ".", "getMethod", "(", ")", ")", ")", "{", "req", ".", "addHeader", "(", "CONTENT_TYPE", ",", "FORM...
Add headers to a request. @param req The request to set the headers on.
[ "Add", "headers", "to", "a", "request", "." ]
d777d40c962bc66fdc04b7c3a66d20b777ff6fb4
https://github.com/revelytix/spark/blob/d777d40c962bc66fdc04b7c3a66d20b777ff6fb4/spark-http-client/src/main/java/spark/protocol/SparqlCall.java#L191-L196
train
phax/ph-datetime
ph-holiday/src/main/java/com/helger/holiday/mgr/XMLHolidayManagerJapan.java
XMLHolidayManagerJapan.getHolidays
@Override public HolidayMap getHolidays (final int nYear, @Nullable final String... aArgs) { final HolidayMap aHolidays = super.getHolidays (nYear, aArgs); final HolidayMap aAdditionalHolidays = new HolidayMap (); for (final Map.Entry <LocalDate, ISingleHoliday> aEntry : aHolidays.getMap ().entrySet ()) { final LocalDate aTwoDaysLater = aEntry.getKey ().plusDays (2); if (aHolidays.containsHolidayForDate (aTwoDaysLater)) { final LocalDate aBridgingDate = aTwoDaysLater.minusDays (1); aAdditionalHolidays.add (aBridgingDate, new ResourceBundleHoliday (EHolidayType.OFFICIAL_HOLIDAY, BRIDGING_HOLIDAY_PROPERTIES_KEY)); } } aHolidays.addAll (aAdditionalHolidays); return aHolidays; }
java
@Override public HolidayMap getHolidays (final int nYear, @Nullable final String... aArgs) { final HolidayMap aHolidays = super.getHolidays (nYear, aArgs); final HolidayMap aAdditionalHolidays = new HolidayMap (); for (final Map.Entry <LocalDate, ISingleHoliday> aEntry : aHolidays.getMap ().entrySet ()) { final LocalDate aTwoDaysLater = aEntry.getKey ().plusDays (2); if (aHolidays.containsHolidayForDate (aTwoDaysLater)) { final LocalDate aBridgingDate = aTwoDaysLater.minusDays (1); aAdditionalHolidays.add (aBridgingDate, new ResourceBundleHoliday (EHolidayType.OFFICIAL_HOLIDAY, BRIDGING_HOLIDAY_PROPERTIES_KEY)); } } aHolidays.addAll (aAdditionalHolidays); return aHolidays; }
[ "@", "Override", "public", "HolidayMap", "getHolidays", "(", "final", "int", "nYear", ",", "@", "Nullable", "final", "String", "...", "aArgs", ")", "{", "final", "HolidayMap", "aHolidays", "=", "super", ".", "getHolidays", "(", "nYear", ",", "aArgs", ")", ...
Implements the rule which requests if two holidays have one non holiday between each other than this day is also a holiday.
[ "Implements", "the", "rule", "which", "requests", "if", "two", "holidays", "have", "one", "non", "holiday", "between", "each", "other", "than", "this", "day", "is", "also", "a", "holiday", "." ]
cfaff01cb76d9affb934800ff55734b5a7d8983e
https://github.com/phax/ph-datetime/blob/cfaff01cb76d9affb934800ff55734b5a7d8983e/ph-holiday/src/main/java/com/helger/holiday/mgr/XMLHolidayManagerJapan.java#L51-L69
train
michael-rapp/AndroidUtil
library/src/main/java/de/mrapp/android/util/logging/Logger.java
Logger.setLogLevel
public final void setLogLevel(@NonNull final LogLevel logLevel) { Condition.INSTANCE.ensureNotNull(logLevel, "The log level may not be null"); this.logLevel = logLevel; }
java
public final void setLogLevel(@NonNull final LogLevel logLevel) { Condition.INSTANCE.ensureNotNull(logLevel, "The log level may not be null"); this.logLevel = logLevel; }
[ "public", "final", "void", "setLogLevel", "(", "@", "NonNull", "final", "LogLevel", "logLevel", ")", "{", "Condition", ".", "INSTANCE", ".", "ensureNotNull", "(", "logLevel", ",", "\"The log level may not be null\"", ")", ";", "this", ".", "logLevel", "=", "logL...
Sets the log level. Only log messages with a rank greater or equal than the rank of the currently applied log level, are written to the output. @param logLevel The log level, which should be set, as a value of the enum {@link LogLevel}. The log level may not be null
[ "Sets", "the", "log", "level", ".", "Only", "log", "messages", "with", "a", "rank", "greater", "or", "equal", "than", "the", "rank", "of", "the", "currently", "applied", "log", "level", "are", "written", "to", "the", "output", "." ]
67ec0e5732344eeb4d946dd1f96d782939e449f4
https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/logging/Logger.java#L67-L70
train
michael-rapp/AndroidUtil
library/src/main/java/de/mrapp/android/util/logging/Logger.java
Logger.logVerbose
public final void logVerbose(@NonNull final Class<?> tag, @NonNull final String message) { Condition.INSTANCE.ensureNotNull(tag, "The tag may not be null"); Condition.INSTANCE.ensureNotNull(message, "The message may not be null"); Condition.INSTANCE.ensureNotEmpty(message, "The message may not be empty"); if (LogLevel.VERBOSE.getRank() >= getLogLevel().getRank()) { Log.v(ClassUtil.INSTANCE.getTruncatedName(tag), message); } }
java
public final void logVerbose(@NonNull final Class<?> tag, @NonNull final String message) { Condition.INSTANCE.ensureNotNull(tag, "The tag may not be null"); Condition.INSTANCE.ensureNotNull(message, "The message may not be null"); Condition.INSTANCE.ensureNotEmpty(message, "The message may not be empty"); if (LogLevel.VERBOSE.getRank() >= getLogLevel().getRank()) { Log.v(ClassUtil.INSTANCE.getTruncatedName(tag), message); } }
[ "public", "final", "void", "logVerbose", "(", "@", "NonNull", "final", "Class", "<", "?", ">", "tag", ",", "@", "NonNull", "final", "String", "message", ")", "{", "Condition", ".", "INSTANCE", ".", "ensureNotNull", "(", "tag", ",", "\"The tag may not be null...
Logs a specific message on the log level VERBOSE. @param tag The tag, which identifies the source of the log message, as an instance of the class {@link Class}. The tag may not be null @param message The message, which should be logged, as a {@link String}. The message may neither be null, nor empty
[ "Logs", "a", "specific", "message", "on", "the", "log", "level", "VERBOSE", "." ]
67ec0e5732344eeb4d946dd1f96d782939e449f4
https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/logging/Logger.java#L82-L90
train
michael-rapp/AndroidUtil
library/src/main/java/de/mrapp/android/util/logging/Logger.java
Logger.logDebug
public final void logDebug(@NonNull final Class<?> tag, @NonNull final String message) { Condition.INSTANCE.ensureNotNull(tag, "The tag may not be null"); Condition.INSTANCE.ensureNotNull(message, "The message may not be null"); Condition.INSTANCE.ensureNotEmpty(message, "The message may not be empty"); if (LogLevel.DEBUG.getRank() >= getLogLevel().getRank()) { Log.d(ClassUtil.INSTANCE.getTruncatedName(tag), message); } }
java
public final void logDebug(@NonNull final Class<?> tag, @NonNull final String message) { Condition.INSTANCE.ensureNotNull(tag, "The tag may not be null"); Condition.INSTANCE.ensureNotNull(message, "The message may not be null"); Condition.INSTANCE.ensureNotEmpty(message, "The message may not be empty"); if (LogLevel.DEBUG.getRank() >= getLogLevel().getRank()) { Log.d(ClassUtil.INSTANCE.getTruncatedName(tag), message); } }
[ "public", "final", "void", "logDebug", "(", "@", "NonNull", "final", "Class", "<", "?", ">", "tag", ",", "@", "NonNull", "final", "String", "message", ")", "{", "Condition", ".", "INSTANCE", ".", "ensureNotNull", "(", "tag", ",", "\"The tag may not be null\"...
Logs a specific message on the log level DEBUG. @param tag The tag, which identifies the source of the log message, as an instance of the class {@link Class}. The tag may not be null @param message The message, which should be logged, as a {@link String}. The message may neither be null, nor empty
[ "Logs", "a", "specific", "message", "on", "the", "log", "level", "DEBUG", "." ]
67ec0e5732344eeb4d946dd1f96d782939e449f4
https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/logging/Logger.java#L127-L135
train
michael-rapp/AndroidUtil
library/src/main/java/de/mrapp/android/util/logging/Logger.java
Logger.logInfo
public final void logInfo(@NonNull final Class<?> tag, @NonNull final String message) { Condition.INSTANCE.ensureNotNull(tag, "The tag may not be null"); Condition.INSTANCE.ensureNotNull(message, "The message may not be null"); Condition.INSTANCE.ensureNotEmpty(message, "The message may not be empty"); if (LogLevel.INFO.getRank() >= getLogLevel().getRank()) { Log.i(ClassUtil.INSTANCE.getTruncatedName(tag), message); } }
java
public final void logInfo(@NonNull final Class<?> tag, @NonNull final String message) { Condition.INSTANCE.ensureNotNull(tag, "The tag may not be null"); Condition.INSTANCE.ensureNotNull(message, "The message may not be null"); Condition.INSTANCE.ensureNotEmpty(message, "The message may not be empty"); if (LogLevel.INFO.getRank() >= getLogLevel().getRank()) { Log.i(ClassUtil.INSTANCE.getTruncatedName(tag), message); } }
[ "public", "final", "void", "logInfo", "(", "@", "NonNull", "final", "Class", "<", "?", ">", "tag", ",", "@", "NonNull", "final", "String", "message", ")", "{", "Condition", ".", "INSTANCE", ".", "ensureNotNull", "(", "tag", ",", "\"The tag may not be null\""...
Logs a specific message on the log level INFO. @param tag The tag, which identifies the source of the log message, as an instance of the class {@link Class}. The tag may not be null @param message The message, which should be logged, as a {@link String}. The message may neither be null, nor empty
[ "Logs", "a", "specific", "message", "on", "the", "log", "level", "INFO", "." ]
67ec0e5732344eeb4d946dd1f96d782939e449f4
https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/logging/Logger.java#L172-L180
train
michael-rapp/AndroidUtil
library/src/main/java/de/mrapp/android/util/logging/Logger.java
Logger.logWarn
public final void logWarn(@NonNull final Class<?> tag, @NonNull final String message, @NonNull final Throwable cause) { Condition.INSTANCE.ensureNotNull(tag, "The tag may not be null"); Condition.INSTANCE.ensureNotNull(message, "The message may not be null"); Condition.INSTANCE.ensureNotEmpty(message, "The message may not be empty"); Condition.INSTANCE.ensureNotNull(cause, "The cause may not be null"); if (LogLevel.WARN.getRank() >= getLogLevel().getRank()) { Log.w(ClassUtil.INSTANCE.getTruncatedName(tag), message, cause); } }
java
public final void logWarn(@NonNull final Class<?> tag, @NonNull final String message, @NonNull final Throwable cause) { Condition.INSTANCE.ensureNotNull(tag, "The tag may not be null"); Condition.INSTANCE.ensureNotNull(message, "The message may not be null"); Condition.INSTANCE.ensureNotEmpty(message, "The message may not be empty"); Condition.INSTANCE.ensureNotNull(cause, "The cause may not be null"); if (LogLevel.WARN.getRank() >= getLogLevel().getRank()) { Log.w(ClassUtil.INSTANCE.getTruncatedName(tag), message, cause); } }
[ "public", "final", "void", "logWarn", "(", "@", "NonNull", "final", "Class", "<", "?", ">", "tag", ",", "@", "NonNull", "final", "String", "message", ",", "@", "NonNull", "final", "Throwable", "cause", ")", "{", "Condition", ".", "INSTANCE", ".", "ensure...
Logs a specific message and exception on the log level WARN. @param tag The tag, which identifies the source of the log message, as an instance of the class {@link Class}. The tag may not be null @param message The message, which should be logged, as a {@link String}. The message may neither be null, nor empty @param cause The exception, which caused the log message, as an instance of the class {@link Throwable}. The cause may not be null
[ "Logs", "a", "specific", "message", "and", "exception", "on", "the", "log", "level", "WARN", "." ]
67ec0e5732344eeb4d946dd1f96d782939e449f4
https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/logging/Logger.java#L240-L250
train
michael-rapp/AndroidUtil
library/src/main/java/de/mrapp/android/util/logging/Logger.java
Logger.logError
public final void logError(@NonNull final Class<?> tag, @NonNull final String message) { Condition.INSTANCE.ensureNotNull(tag, "The tag may not be null"); Condition.INSTANCE.ensureNotNull(message, "The message may not be null"); Condition.INSTANCE.ensureNotEmpty(message, "The message may not be empty"); if (LogLevel.ERROR.getRank() >= getLogLevel().getRank()) { Log.e(ClassUtil.INSTANCE.getTruncatedName(tag), message); } }
java
public final void logError(@NonNull final Class<?> tag, @NonNull final String message) { Condition.INSTANCE.ensureNotNull(tag, "The tag may not be null"); Condition.INSTANCE.ensureNotNull(message, "The message may not be null"); Condition.INSTANCE.ensureNotEmpty(message, "The message may not be empty"); if (LogLevel.ERROR.getRank() >= getLogLevel().getRank()) { Log.e(ClassUtil.INSTANCE.getTruncatedName(tag), message); } }
[ "public", "final", "void", "logError", "(", "@", "NonNull", "final", "Class", "<", "?", ">", "tag", ",", "@", "NonNull", "final", "String", "message", ")", "{", "Condition", ".", "INSTANCE", ".", "ensureNotNull", "(", "tag", ",", "\"The tag may not be null\"...
Logs a specific message on the log level ERROR. @param tag The tag, which identifies the source of the log message, as an instance of the class {@link Class}. The tag may not be null @param message The message, which should be logged, as a {@link String}. The message may neither be null, nor empty
[ "Logs", "a", "specific", "message", "on", "the", "log", "level", "ERROR", "." ]
67ec0e5732344eeb4d946dd1f96d782939e449f4
https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/logging/Logger.java#L262-L270
train
michael-rapp/AndroidUtil
library/src/main/java/de/mrapp/android/util/DisplayUtil.java
DisplayUtil.getOrientation
public static Orientation getOrientation(@NonNull final Context context) { Condition.INSTANCE.ensureNotNull(context, "The context may not be null"); int orientation = context.getResources().getConfiguration().orientation; if (orientation == Configuration.ORIENTATION_UNDEFINED) { int width = getDisplayWidth(context); int height = getDisplayHeight(context); if (width > height) { return Orientation.LANDSCAPE; } else if (width < height) { return Orientation.PORTRAIT; } else { return Orientation.SQUARE; } } else if (orientation == Configuration.ORIENTATION_LANDSCAPE) { return Orientation.LANDSCAPE; } else if (orientation == Configuration.ORIENTATION_PORTRAIT) { return Orientation.PORTRAIT; } else { return Orientation.SQUARE; } }
java
public static Orientation getOrientation(@NonNull final Context context) { Condition.INSTANCE.ensureNotNull(context, "The context may not be null"); int orientation = context.getResources().getConfiguration().orientation; if (orientation == Configuration.ORIENTATION_UNDEFINED) { int width = getDisplayWidth(context); int height = getDisplayHeight(context); if (width > height) { return Orientation.LANDSCAPE; } else if (width < height) { return Orientation.PORTRAIT; } else { return Orientation.SQUARE; } } else if (orientation == Configuration.ORIENTATION_LANDSCAPE) { return Orientation.LANDSCAPE; } else if (orientation == Configuration.ORIENTATION_PORTRAIT) { return Orientation.PORTRAIT; } else { return Orientation.SQUARE; } }
[ "public", "static", "Orientation", "getOrientation", "(", "@", "NonNull", "final", "Context", "context", ")", "{", "Condition", ".", "INSTANCE", ".", "ensureNotNull", "(", "context", ",", "\"The context may not be null\"", ")", ";", "int", "orientation", "=", "con...
Returns the orientation of the device. @param context The context, which should be used, as an instance of the class {@link Context}. The context may not be null @return The orientation of the device as a value of the enum {@link Orientation}. The orientation may either be <code>PORTRAIT</code>, <code>LANDSCAPE</code> or <code>SQUARE</code>
[ "Returns", "the", "orientation", "of", "the", "device", "." ]
67ec0e5732344eeb4d946dd1f96d782939e449f4
https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/DisplayUtil.java#L282-L304
train
michael-rapp/AndroidUtil
library/src/main/java/de/mrapp/android/util/DisplayUtil.java
DisplayUtil.getDeviceType
public static DeviceType getDeviceType(@NonNull final Context context) { Condition.INSTANCE.ensureNotNull(context, "The context may not be null"); return DeviceType.fromValue(context.getString(R.string.device_type)); }
java
public static DeviceType getDeviceType(@NonNull final Context context) { Condition.INSTANCE.ensureNotNull(context, "The context may not be null"); return DeviceType.fromValue(context.getString(R.string.device_type)); }
[ "public", "static", "DeviceType", "getDeviceType", "(", "@", "NonNull", "final", "Context", "context", ")", "{", "Condition", ".", "INSTANCE", ".", "ensureNotNull", "(", "context", ",", "\"The context may not be null\"", ")", ";", "return", "DeviceType", ".", "fro...
Returns the type of the device, depending on its display size. @param context The context, which should be used, as an instance of the class {@link Context}. The context may not be null @return The type of the device as a value of the enum {@link DeviceType}. The type may either be <code>PHONE</code>, <code>PHABLET</code> or <code>TABLET</code>
[ "Returns", "the", "type", "of", "the", "device", "depending", "on", "its", "display", "size", "." ]
67ec0e5732344eeb4d946dd1f96d782939e449f4
https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/DisplayUtil.java#L315-L318
train
michael-rapp/AndroidUtil
library/src/main/java/de/mrapp/android/util/DisplayUtil.java
DisplayUtil.getDisplayWidth
public static int getDisplayWidth(@NonNull final Context context) { Condition.INSTANCE.ensureNotNull(context, "The context may not be null"); return context.getResources().getDisplayMetrics().widthPixels; }
java
public static int getDisplayWidth(@NonNull final Context context) { Condition.INSTANCE.ensureNotNull(context, "The context may not be null"); return context.getResources().getDisplayMetrics().widthPixels; }
[ "public", "static", "int", "getDisplayWidth", "(", "@", "NonNull", "final", "Context", "context", ")", "{", "Condition", ".", "INSTANCE", ".", "ensureNotNull", "(", "context", ",", "\"The context may not be null\"", ")", ";", "return", "context", ".", "getResource...
Returns the width of the device's display. @param context The context, which should be used, as an instance of the class {@link Context}. The context may not be null @return The width of the device's display in pixels as an {@link Integer} value
[ "Returns", "the", "width", "of", "the", "device", "s", "display", "." ]
67ec0e5732344eeb4d946dd1f96d782939e449f4
https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/DisplayUtil.java#L328-L331
train
michael-rapp/AndroidUtil
library/src/main/java/de/mrapp/android/util/DisplayUtil.java
DisplayUtil.getDisplayHeight
public static int getDisplayHeight(@NonNull final Context context) { Condition.INSTANCE.ensureNotNull(context, "The context may not be null"); return context.getResources().getDisplayMetrics().heightPixels; }
java
public static int getDisplayHeight(@NonNull final Context context) { Condition.INSTANCE.ensureNotNull(context, "The context may not be null"); return context.getResources().getDisplayMetrics().heightPixels; }
[ "public", "static", "int", "getDisplayHeight", "(", "@", "NonNull", "final", "Context", "context", ")", "{", "Condition", ".", "INSTANCE", ".", "ensureNotNull", "(", "context", ",", "\"The context may not be null\"", ")", ";", "return", "context", ".", "getResourc...
Returns the height of the device's display. @param context The context, which should be used, as an instance of the class {@link Context}. The context may not be null @return The height of the device's display in pixels as an {@link Integer} value
[ "Returns", "the", "height", "of", "the", "device", "s", "display", "." ]
67ec0e5732344eeb4d946dd1f96d782939e449f4
https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/DisplayUtil.java#L341-L344
train
edwardcapriolo/teknek-core
src/main/java/io/teknek/driver/DriverFactory.java
DriverFactory.createDriver
public static Driver createDriver(FeedPartition feedPartition, Plan plan, MetricRegistry metricRegistry){ populateFeedMetricInfo(plan, feedPartition, metricRegistry); OperatorDesc desc = plan.getRootOperator(); Operator oper = buildOperator(desc, metricRegistry, plan.getName(), feedPartition); OffsetStorage offsetStorage = null; OffsetStorageDesc offsetDesc = plan.getOffsetStorageDesc(); if (offsetDesc != null && feedPartition.supportsOffsetManagement()){ offsetStorage = buildOffsetStorage(feedPartition, plan, offsetDesc); Offset offset = offsetStorage.findLatestPersistedOffset(); if (offset != null){ feedPartition.setOffset(new String(offset.serialize(), Charsets.UTF_8)); } } CollectorProcessor cp = new CollectorProcessor(); cp.setTupleRetry(plan.getTupleRetry()); int offsetCommitInterval = plan.getOffsetCommitInterval(); Driver driver = new Driver(feedPartition, oper, offsetStorage, cp, offsetCommitInterval, metricRegistry, plan.getName()); recurseOperatorAndDriverNode(desc, driver.getDriverNode(), metricRegistry, feedPartition); return driver; }
java
public static Driver createDriver(FeedPartition feedPartition, Plan plan, MetricRegistry metricRegistry){ populateFeedMetricInfo(plan, feedPartition, metricRegistry); OperatorDesc desc = plan.getRootOperator(); Operator oper = buildOperator(desc, metricRegistry, plan.getName(), feedPartition); OffsetStorage offsetStorage = null; OffsetStorageDesc offsetDesc = plan.getOffsetStorageDesc(); if (offsetDesc != null && feedPartition.supportsOffsetManagement()){ offsetStorage = buildOffsetStorage(feedPartition, plan, offsetDesc); Offset offset = offsetStorage.findLatestPersistedOffset(); if (offset != null){ feedPartition.setOffset(new String(offset.serialize(), Charsets.UTF_8)); } } CollectorProcessor cp = new CollectorProcessor(); cp.setTupleRetry(plan.getTupleRetry()); int offsetCommitInterval = plan.getOffsetCommitInterval(); Driver driver = new Driver(feedPartition, oper, offsetStorage, cp, offsetCommitInterval, metricRegistry, plan.getName()); recurseOperatorAndDriverNode(desc, driver.getDriverNode(), metricRegistry, feedPartition); return driver; }
[ "public", "static", "Driver", "createDriver", "(", "FeedPartition", "feedPartition", ",", "Plan", "plan", ",", "MetricRegistry", "metricRegistry", ")", "{", "populateFeedMetricInfo", "(", "plan", ",", "feedPartition", ",", "metricRegistry", ")", ";", "OperatorDesc", ...
Given a FeedParition and Plan create a Driver that will consume from the feed partition and execute the plan. @param feedPartition @param plan @return an uninitialized Driver
[ "Given", "a", "FeedParition", "and", "Plan", "create", "a", "Driver", "that", "will", "consume", "from", "the", "feed", "partition", "and", "execute", "the", "plan", "." ]
4fa972d11044dee2954c0cc5e1b53b18fba319b9
https://github.com/edwardcapriolo/teknek-core/blob/4fa972d11044dee2954c0cc5e1b53b18fba319b9/src/main/java/io/teknek/driver/DriverFactory.java#L60-L79
train
edwardcapriolo/teknek-core
src/main/java/io/teknek/driver/DriverFactory.java
DriverFactory.nitDescFromDynamic
private static NitDesc nitDescFromDynamic(DynamicInstantiatable d){ NitDesc nd = new NitDesc(); nd.setScript(d.getScript()); nd.setTheClass(d.getTheClass()); if (d.getSpec() == null || "java".equals(d.getSpec())){ nd.setSpec(NitDesc.NitSpec.JAVA_LOCAL_CLASSPATH); } else if ("groovy".equals(d.getSpec())){ nd.setSpec(NitDesc.NitSpec.GROOVY_CLASS_LOADER); } else if ("groovyclosure".equals(d.getSpec())){ nd.setSpec(NitDesc.NitSpec.GROOVY_CLOSURE); } else if ("url".equals(d.getSpec())){ nd.setSpec(NitDesc.NitSpec.JAVA_URL_CLASSLOADER); } else { nd.setSpec(NitDesc.NitSpec.valueOf(d.getSpec())); } return nd; }
java
private static NitDesc nitDescFromDynamic(DynamicInstantiatable d){ NitDesc nd = new NitDesc(); nd.setScript(d.getScript()); nd.setTheClass(d.getTheClass()); if (d.getSpec() == null || "java".equals(d.getSpec())){ nd.setSpec(NitDesc.NitSpec.JAVA_LOCAL_CLASSPATH); } else if ("groovy".equals(d.getSpec())){ nd.setSpec(NitDesc.NitSpec.GROOVY_CLASS_LOADER); } else if ("groovyclosure".equals(d.getSpec())){ nd.setSpec(NitDesc.NitSpec.GROOVY_CLOSURE); } else if ("url".equals(d.getSpec())){ nd.setSpec(NitDesc.NitSpec.JAVA_URL_CLASSLOADER); } else { nd.setSpec(NitDesc.NitSpec.valueOf(d.getSpec())); } return nd; }
[ "private", "static", "NitDesc", "nitDescFromDynamic", "(", "DynamicInstantiatable", "d", ")", "{", "NitDesc", "nd", "=", "new", "NitDesc", "(", ")", ";", "nd", ".", "setScript", "(", "d", ".", "getScript", "(", ")", ")", ";", "nd", ".", "setTheClass", "(...
DynamicInstantiatable has some pre-nit strings it uses as for spec that do not match nit-compiler. Here we correct these and return a new object @param d @return the
[ "DynamicInstantiatable", "has", "some", "pre", "-", "nit", "strings", "it", "uses", "as", "for", "spec", "that", "do", "not", "match", "nit", "-", "compiler", ".", "Here", "we", "correct", "these", "and", "return", "a", "new", "object" ]
4fa972d11044dee2954c0cc5e1b53b18fba319b9
https://github.com/edwardcapriolo/teknek-core/blob/4fa972d11044dee2954c0cc5e1b53b18fba319b9/src/main/java/io/teknek/driver/DriverFactory.java#L102-L118
train
edwardcapriolo/teknek-core
src/main/java/io/teknek/driver/DriverFactory.java
DriverFactory.buildOperator
public static Operator buildOperator(OperatorDesc operatorDesc, MetricRegistry metricRegistry, String planPath, FeedPartition feedPartition) { Operator operator = null; NitFactory nitFactory = new NitFactory(); NitDesc nitDesc = nitDescFromDynamic(operatorDesc); try { if (nitDesc.getSpec() == NitDesc.NitSpec.GROOVY_CLOSURE){ operator = new GroovyOperator((Closure) nitFactory.construct(nitDesc)); } else { operator = nitFactory.construct(nitDesc); } } catch (NitException e) { throw new RuntimeException(e); } operator.setProperties(operatorDesc.getParameters()); operator.setMetricRegistry(metricRegistry); operator.setPartitionId(feedPartition.getPartitionId()); String myName = operatorDesc.getName(); if (myName == null){ myName = operatorDesc.getTheClass(); if (myName.indexOf(".") > -1){ String[] parts = myName.split("\\."); myName = parts[parts.length-1]; } } operator.setPath(planPath + "." + myName); return operator; }
java
public static Operator buildOperator(OperatorDesc operatorDesc, MetricRegistry metricRegistry, String planPath, FeedPartition feedPartition) { Operator operator = null; NitFactory nitFactory = new NitFactory(); NitDesc nitDesc = nitDescFromDynamic(operatorDesc); try { if (nitDesc.getSpec() == NitDesc.NitSpec.GROOVY_CLOSURE){ operator = new GroovyOperator((Closure) nitFactory.construct(nitDesc)); } else { operator = nitFactory.construct(nitDesc); } } catch (NitException e) { throw new RuntimeException(e); } operator.setProperties(operatorDesc.getParameters()); operator.setMetricRegistry(metricRegistry); operator.setPartitionId(feedPartition.getPartitionId()); String myName = operatorDesc.getName(); if (myName == null){ myName = operatorDesc.getTheClass(); if (myName.indexOf(".") > -1){ String[] parts = myName.split("\\."); myName = parts[parts.length-1]; } } operator.setPath(planPath + "." + myName); return operator; }
[ "public", "static", "Operator", "buildOperator", "(", "OperatorDesc", "operatorDesc", ",", "MetricRegistry", "metricRegistry", ",", "String", "planPath", ",", "FeedPartition", "feedPartition", ")", "{", "Operator", "operator", "=", "null", ";", "NitFactory", "nitFacto...
OperatorDesc can describe local reasources, URL, loaded resources and dynamic resources like groovy code. This method instantiates an Operator based on the OperatorDesc. @param operatorDesc @return
[ "OperatorDesc", "can", "describe", "local", "reasources", "URL", "loaded", "resources", "and", "dynamic", "resources", "like", "groovy", "code", ".", "This", "method", "instantiates", "an", "Operator", "based", "on", "the", "OperatorDesc", "." ]
4fa972d11044dee2954c0cc5e1b53b18fba319b9
https://github.com/edwardcapriolo/teknek-core/blob/4fa972d11044dee2954c0cc5e1b53b18fba319b9/src/main/java/io/teknek/driver/DriverFactory.java#L127-L153
train
edwardcapriolo/teknek-core
src/main/java/io/teknek/driver/DriverFactory.java
DriverFactory.buildFeed
public static Feed buildFeed(FeedDesc feedDesc){ Feed feed = null; NitFactory nitFactory = new NitFactory(); NitDesc nitDesc = nitDescFromDynamic(feedDesc); nitDesc.setConstructorParameters(new Class [] { Map.class }); nitDesc.setConstructorArguments(new Object[] { feedDesc.getProperties() }); try { feed = nitFactory.construct(nitDesc); } catch (NitException e) { throw new RuntimeException(e); } return feed; }
java
public static Feed buildFeed(FeedDesc feedDesc){ Feed feed = null; NitFactory nitFactory = new NitFactory(); NitDesc nitDesc = nitDescFromDynamic(feedDesc); nitDesc.setConstructorParameters(new Class [] { Map.class }); nitDesc.setConstructorArguments(new Object[] { feedDesc.getProperties() }); try { feed = nitFactory.construct(nitDesc); } catch (NitException e) { throw new RuntimeException(e); } return feed; }
[ "public", "static", "Feed", "buildFeed", "(", "FeedDesc", "feedDesc", ")", "{", "Feed", "feed", "=", "null", ";", "NitFactory", "nitFactory", "=", "new", "NitFactory", "(", ")", ";", "NitDesc", "nitDesc", "=", "nitDescFromDynamic", "(", "feedDesc", ")", ";",...
Build a feed using reflection @param feedDesc @return
[ "Build", "a", "feed", "using", "reflection" ]
4fa972d11044dee2954c0cc5e1b53b18fba319b9
https://github.com/edwardcapriolo/teknek-core/blob/4fa972d11044dee2954c0cc5e1b53b18fba319b9/src/main/java/io/teknek/driver/DriverFactory.java#L176-L188
train
michael-rapp/AndroidUtil
library/src/main/java/de/mrapp/android/util/BitmapUtil.java
BitmapUtil.getSampleSize
private static int getSampleSize(@NonNull final Pair<Integer, Integer> imageDimensions, final int maxWidth, final int maxHeight) { Condition.INSTANCE.ensureNotNull(imageDimensions, "The image dimensions may not be null"); Condition.INSTANCE.ensureAtLeast(maxWidth, 1, "The maximum width must be at least 1"); Condition.INSTANCE.ensureAtLeast(maxHeight, 1, "The maximum height must be at least 1"); int width = imageDimensions.first; int height = imageDimensions.second; int sampleSize = 1; if (width > maxWidth || height > maxHeight) { int halfWidth = width / 2; int halfHeight = height / 2; while ((halfWidth / sampleSize) > maxWidth && (halfHeight / sampleSize) > maxHeight) { sampleSize *= 2; } } return sampleSize; }
java
private static int getSampleSize(@NonNull final Pair<Integer, Integer> imageDimensions, final int maxWidth, final int maxHeight) { Condition.INSTANCE.ensureNotNull(imageDimensions, "The image dimensions may not be null"); Condition.INSTANCE.ensureAtLeast(maxWidth, 1, "The maximum width must be at least 1"); Condition.INSTANCE.ensureAtLeast(maxHeight, 1, "The maximum height must be at least 1"); int width = imageDimensions.first; int height = imageDimensions.second; int sampleSize = 1; if (width > maxWidth || height > maxHeight) { int halfWidth = width / 2; int halfHeight = height / 2; while ((halfWidth / sampleSize) > maxWidth && (halfHeight / sampleSize) > maxHeight) { sampleSize *= 2; } } return sampleSize; }
[ "private", "static", "int", "getSampleSize", "(", "@", "NonNull", "final", "Pair", "<", "Integer", ",", "Integer", ">", "imageDimensions", ",", "final", "int", "maxWidth", ",", "final", "int", "maxHeight", ")", "{", "Condition", ".", "INSTANCE", ".", "ensure...
Calculates the sample size, which should be used to downsample an image to a maximum width and height. @param imageDimensions A pair, which contains the width and height of the image, which should be downsampled, as an instance of the class Pair. The pair may not be null @param maxWidth The maximum width in pixels as an {@link Integer} value. The maximum width must be at least 1 @param maxHeight The maximum height in pixels as an{@link Integer} value. The maximum height must be at least 1 @return The sample size, which has been calculated, as an {@link Integer} value
[ "Calculates", "the", "sample", "size", "which", "should", "be", "used", "to", "downsample", "an", "image", "to", "a", "maximum", "width", "and", "height", "." ]
67ec0e5732344eeb4d946dd1f96d782939e449f4
https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/BitmapUtil.java#L77-L96
train
michael-rapp/AndroidUtil
library/src/main/java/de/mrapp/android/util/BitmapUtil.java
BitmapUtil.clipCircle
public static Bitmap clipCircle(@NonNull final Bitmap bitmap, final int size) { Bitmap squareBitmap = clipSquare(bitmap, size); int squareSize = squareBitmap.getWidth(); float radius = (float) squareSize / 2.0f; Bitmap clippedBitmap = Bitmap.createBitmap(squareSize, squareSize, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(clippedBitmap); Paint paint = new Paint(); paint.setAntiAlias(true); paint.setColor(Color.BLACK); canvas.drawCircle(radius, radius, radius, paint); paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN)); canvas.drawBitmap(squareBitmap, new Rect(0, 0, squareSize, squareSize), new Rect(0, 0, squareSize, squareSize), paint); return clippedBitmap; }
java
public static Bitmap clipCircle(@NonNull final Bitmap bitmap, final int size) { Bitmap squareBitmap = clipSquare(bitmap, size); int squareSize = squareBitmap.getWidth(); float radius = (float) squareSize / 2.0f; Bitmap clippedBitmap = Bitmap.createBitmap(squareSize, squareSize, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(clippedBitmap); Paint paint = new Paint(); paint.setAntiAlias(true); paint.setColor(Color.BLACK); canvas.drawCircle(radius, radius, radius, paint); paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN)); canvas.drawBitmap(squareBitmap, new Rect(0, 0, squareSize, squareSize), new Rect(0, 0, squareSize, squareSize), paint); return clippedBitmap; }
[ "public", "static", "Bitmap", "clipCircle", "(", "@", "NonNull", "final", "Bitmap", "bitmap", ",", "final", "int", "size", ")", "{", "Bitmap", "squareBitmap", "=", "clipSquare", "(", "bitmap", ",", "size", ")", ";", "int", "squareSize", "=", "squareBitmap", ...
Clips the corners of a bitmap in order to transform it into a round shape. Additionally, the bitmap is resized to a specific size. Bitmaps, whose width and height are not equal, will be clipped to a square beforehand. @param bitmap The bitmap, which should be clipped, as an instance of the class {@link Bitmap}. The bitmap may not be null @param size The size, the bitmap should be resized to, as an {@link Integer} value in pixels. The size must be at least 1 @return The clipped bitmap as an instance of the class {@link Bitmap}
[ "Clips", "the", "corners", "of", "a", "bitmap", "in", "order", "to", "transform", "it", "into", "a", "round", "shape", ".", "Additionally", "the", "bitmap", "is", "resized", "to", "a", "specific", "size", ".", "Bitmaps", "whose", "width", "and", "height", ...
67ec0e5732344eeb4d946dd1f96d782939e449f4
https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/BitmapUtil.java#L134-L148
train
michael-rapp/AndroidUtil
library/src/main/java/de/mrapp/android/util/BitmapUtil.java
BitmapUtil.clipCircle
public static Bitmap clipCircle(@NonNull final Bitmap bitmap, final int size, final int borderWidth, @ColorInt final int borderColor) { Condition.INSTANCE.ensureAtLeast(borderWidth, 0, "The border width must be at least 0"); Bitmap clippedBitmap = clipCircle(bitmap, size); Bitmap result = Bitmap.createBitmap(clippedBitmap.getWidth(), clippedBitmap.getHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(result); float offset = borderWidth / 2.0f; Rect src = new Rect(0, 0, clippedBitmap.getWidth(), clippedBitmap.getHeight()); RectF dst = new RectF(offset, offset, result.getWidth() - offset, result.getHeight() - offset); canvas.drawBitmap(clippedBitmap, src, dst, null); if (borderWidth > 0 && Color.alpha(borderColor) != 0) { Paint paint = new Paint(); paint.setFilterBitmap(false); paint.setAntiAlias(true); paint.setStrokeCap(Paint.Cap.ROUND); paint.setStyle(Paint.Style.STROKE); paint.setStrokeWidth(borderWidth); paint.setColor(borderColor); offset = borderWidth / 2.0f; RectF bounds = new RectF(offset, offset, result.getWidth() - offset, result.getWidth() - offset); canvas.drawArc(bounds, 0, COMPLETE_ARC_ANGLE, false, paint); } return result; }
java
public static Bitmap clipCircle(@NonNull final Bitmap bitmap, final int size, final int borderWidth, @ColorInt final int borderColor) { Condition.INSTANCE.ensureAtLeast(borderWidth, 0, "The border width must be at least 0"); Bitmap clippedBitmap = clipCircle(bitmap, size); Bitmap result = Bitmap.createBitmap(clippedBitmap.getWidth(), clippedBitmap.getHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(result); float offset = borderWidth / 2.0f; Rect src = new Rect(0, 0, clippedBitmap.getWidth(), clippedBitmap.getHeight()); RectF dst = new RectF(offset, offset, result.getWidth() - offset, result.getHeight() - offset); canvas.drawBitmap(clippedBitmap, src, dst, null); if (borderWidth > 0 && Color.alpha(borderColor) != 0) { Paint paint = new Paint(); paint.setFilterBitmap(false); paint.setAntiAlias(true); paint.setStrokeCap(Paint.Cap.ROUND); paint.setStyle(Paint.Style.STROKE); paint.setStrokeWidth(borderWidth); paint.setColor(borderColor); offset = borderWidth / 2.0f; RectF bounds = new RectF(offset, offset, result.getWidth() - offset, result.getWidth() - offset); canvas.drawArc(bounds, 0, COMPLETE_ARC_ANGLE, false, paint); } return result; }
[ "public", "static", "Bitmap", "clipCircle", "(", "@", "NonNull", "final", "Bitmap", "bitmap", ",", "final", "int", "size", ",", "final", "int", "borderWidth", ",", "@", "ColorInt", "final", "int", "borderColor", ")", "{", "Condition", ".", "INSTANCE", ".", ...
Clips the corners of a bitmap in order to transform it into a round shape. Additionally, the bitmap is resized to a specific size and a border will be added. Bitmaps, whose width and height are not equal, will be clipped to a square beforehand. @param bitmap The bitmap, which should be clipped, as an instance of the class {@link Bitmap}. The bitmap may not be null @param size The size, the bitmap should be resized to, as an {@link Integer} value in pixels. The size must be at least 1 @param borderWidth The width of the border as an {@link Integer} value in pixels. The width must be at least 0 @param borderColor The color of the border as an {@link Integer} value @return The clipped bitmap as an instance of the class {@link Bitmap}
[ "Clips", "the", "corners", "of", "a", "bitmap", "in", "order", "to", "transform", "it", "into", "a", "round", "shape", ".", "Additionally", "the", "bitmap", "is", "resized", "to", "a", "specific", "size", "and", "a", "border", "will", "be", "added", ".",...
67ec0e5732344eeb4d946dd1f96d782939e449f4
https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/BitmapUtil.java#L191-L219
train
michael-rapp/AndroidUtil
library/src/main/java/de/mrapp/android/util/BitmapUtil.java
BitmapUtil.clipSquare
public static Bitmap clipSquare(@NonNull final Bitmap bitmap) { Condition.INSTANCE.ensureNotNull(bitmap, "The bitmap may not be null"); return clipSquare(bitmap, bitmap.getWidth() >= bitmap.getHeight() ? bitmap.getHeight() : bitmap.getWidth()); }
java
public static Bitmap clipSquare(@NonNull final Bitmap bitmap) { Condition.INSTANCE.ensureNotNull(bitmap, "The bitmap may not be null"); return clipSquare(bitmap, bitmap.getWidth() >= bitmap.getHeight() ? bitmap.getHeight() : bitmap.getWidth()); }
[ "public", "static", "Bitmap", "clipSquare", "(", "@", "NonNull", "final", "Bitmap", "bitmap", ")", "{", "Condition", ".", "INSTANCE", ".", "ensureNotNull", "(", "bitmap", ",", "\"The bitmap may not be null\"", ")", ";", "return", "clipSquare", "(", "bitmap", ","...
Clips the long edge of a bitmap, if its width and height are not equal, in order to form it into a square. @param bitmap The bitmap, which should be clipped, as an instance of the class {@link Bitmap}. The bitmap may not be null @return The clipped bitmap as an instance of the class {@link Bitmap}
[ "Clips", "the", "long", "edge", "of", "a", "bitmap", "if", "its", "width", "and", "height", "are", "not", "equal", "in", "order", "to", "form", "it", "into", "a", "square", "." ]
67ec0e5732344eeb4d946dd1f96d782939e449f4
https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/BitmapUtil.java#L230-L234
train
michael-rapp/AndroidUtil
library/src/main/java/de/mrapp/android/util/BitmapUtil.java
BitmapUtil.clipSquare
@SuppressWarnings("SuspiciousNameCombination") public static Bitmap clipSquare(@NonNull final Bitmap bitmap, final int size) { Condition.INSTANCE.ensureNotNull(bitmap, "The bitmap may not be null"); Condition.INSTANCE.ensureAtLeast(size, 1, "The size must be at least 1"); Bitmap clippedBitmap = bitmap; int width = bitmap.getWidth(); int height = bitmap.getHeight(); if (width > height) { clippedBitmap = Bitmap.createBitmap(bitmap, width / 2 - height / 2, 0, height, height); } else if (bitmap.getWidth() < bitmap.getHeight()) { clippedBitmap = Bitmap.createBitmap(bitmap, 0, bitmap.getHeight() / 2 - width / 2, width, width); } if (clippedBitmap.getWidth() != size) { clippedBitmap = resize(clippedBitmap, size, size); } return clippedBitmap; }
java
@SuppressWarnings("SuspiciousNameCombination") public static Bitmap clipSquare(@NonNull final Bitmap bitmap, final int size) { Condition.INSTANCE.ensureNotNull(bitmap, "The bitmap may not be null"); Condition.INSTANCE.ensureAtLeast(size, 1, "The size must be at least 1"); Bitmap clippedBitmap = bitmap; int width = bitmap.getWidth(); int height = bitmap.getHeight(); if (width > height) { clippedBitmap = Bitmap.createBitmap(bitmap, width / 2 - height / 2, 0, height, height); } else if (bitmap.getWidth() < bitmap.getHeight()) { clippedBitmap = Bitmap.createBitmap(bitmap, 0, bitmap.getHeight() / 2 - width / 2, width, width); } if (clippedBitmap.getWidth() != size) { clippedBitmap = resize(clippedBitmap, size, size); } return clippedBitmap; }
[ "@", "SuppressWarnings", "(", "\"SuspiciousNameCombination\"", ")", "public", "static", "Bitmap", "clipSquare", "(", "@", "NonNull", "final", "Bitmap", "bitmap", ",", "final", "int", "size", ")", "{", "Condition", ".", "INSTANCE", ".", "ensureNotNull", "(", "bit...
Clips the long edge of a bitmap, if its width and height are not equal, in order to form it into a square. Additionally, the bitmap is resized to a specific size. @param bitmap The bitmap, which should be clipped, as an instance of the class {@link Bitmap}. The bitmap may not be null @param size The size, the bitmap should be resized to, as an {@link Integer} value in pixels. The size must be at least 1 @return The clipped bitmap as an instance of the class {@link Bitmap}
[ "Clips", "the", "long", "edge", "of", "a", "bitmap", "if", "its", "width", "and", "height", "are", "not", "equal", "in", "order", "to", "form", "it", "into", "a", "square", ".", "Additionally", "the", "bitmap", "is", "resized", "to", "a", "specific", "...
67ec0e5732344eeb4d946dd1f96d782939e449f4
https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/BitmapUtil.java#L248-L269
train
michael-rapp/AndroidUtil
library/src/main/java/de/mrapp/android/util/BitmapUtil.java
BitmapUtil.clipSquare
public static Bitmap clipSquare(@NonNull final Bitmap bitmap, final int borderWidth, @ColorInt final int borderColor) { Condition.INSTANCE.ensureNotNull(bitmap, "The bitmap may not be null"); return clipSquare(bitmap, bitmap.getWidth() >= bitmap.getHeight() ? bitmap.getHeight() : bitmap.getWidth(), borderWidth, borderColor); }
java
public static Bitmap clipSquare(@NonNull final Bitmap bitmap, final int borderWidth, @ColorInt final int borderColor) { Condition.INSTANCE.ensureNotNull(bitmap, "The bitmap may not be null"); return clipSquare(bitmap, bitmap.getWidth() >= bitmap.getHeight() ? bitmap.getHeight() : bitmap.getWidth(), borderWidth, borderColor); }
[ "public", "static", "Bitmap", "clipSquare", "(", "@", "NonNull", "final", "Bitmap", "bitmap", ",", "final", "int", "borderWidth", ",", "@", "ColorInt", "final", "int", "borderColor", ")", "{", "Condition", ".", "INSTANCE", ".", "ensureNotNull", "(", "bitmap", ...
Clips the long edge of a bitmap, if its width and height are not equal, in order to transform it into a square. Additionally, a border will be added. @param bitmap The bitmap, which should be clipped, as an instance of the class {@link Bitmap}. The bitmap may not be null @param borderWidth The width of the border as an {@link Integer} value in pixels. The width must be at least 0 @param borderColor The color of the border as an {@link Integer} value @return The clipped bitmap as an instance of the class {@link Bitmap}
[ "Clips", "the", "long", "edge", "of", "a", "bitmap", "if", "its", "width", "and", "height", "are", "not", "equal", "in", "order", "to", "transform", "it", "into", "a", "square", ".", "Additionally", "a", "border", "will", "be", "added", "." ]
67ec0e5732344eeb4d946dd1f96d782939e449f4
https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/BitmapUtil.java#L285-L291
train
michael-rapp/AndroidUtil
library/src/main/java/de/mrapp/android/util/BitmapUtil.java
BitmapUtil.clipSquare
public static Bitmap clipSquare(@NonNull final Bitmap bitmap, final int size, final int borderWidth, @ColorInt final int borderColor) { Condition.INSTANCE.ensureAtLeast(borderWidth, 0, "The border width must be at least 0"); Bitmap clippedBitmap = clipSquare(bitmap, size); Bitmap result = Bitmap.createBitmap(clippedBitmap.getWidth(), clippedBitmap.getHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(result); float offset = borderWidth / 2.0f; Rect src = new Rect(0, 0, clippedBitmap.getWidth(), clippedBitmap.getHeight()); RectF dst = new RectF(offset, offset, result.getWidth() - offset, result.getHeight() - offset); canvas.drawBitmap(clippedBitmap, src, dst, null); if (borderWidth > 0 && Color.alpha(borderColor) != 0) { Paint paint = new Paint(); paint.setFilterBitmap(false); paint.setStyle(Paint.Style.STROKE); paint.setStrokeWidth(borderWidth); paint.setColor(borderColor); offset = borderWidth / 2.0f; RectF bounds = new RectF(offset, offset, result.getWidth() - offset, result.getWidth() - offset); canvas.drawRect(bounds, paint); } return result; }
java
public static Bitmap clipSquare(@NonNull final Bitmap bitmap, final int size, final int borderWidth, @ColorInt final int borderColor) { Condition.INSTANCE.ensureAtLeast(borderWidth, 0, "The border width must be at least 0"); Bitmap clippedBitmap = clipSquare(bitmap, size); Bitmap result = Bitmap.createBitmap(clippedBitmap.getWidth(), clippedBitmap.getHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(result); float offset = borderWidth / 2.0f; Rect src = new Rect(0, 0, clippedBitmap.getWidth(), clippedBitmap.getHeight()); RectF dst = new RectF(offset, offset, result.getWidth() - offset, result.getHeight() - offset); canvas.drawBitmap(clippedBitmap, src, dst, null); if (borderWidth > 0 && Color.alpha(borderColor) != 0) { Paint paint = new Paint(); paint.setFilterBitmap(false); paint.setStyle(Paint.Style.STROKE); paint.setStrokeWidth(borderWidth); paint.setColor(borderColor); offset = borderWidth / 2.0f; RectF bounds = new RectF(offset, offset, result.getWidth() - offset, result.getWidth() - offset); canvas.drawRect(bounds, paint); } return result; }
[ "public", "static", "Bitmap", "clipSquare", "(", "@", "NonNull", "final", "Bitmap", "bitmap", ",", "final", "int", "size", ",", "final", "int", "borderWidth", ",", "@", "ColorInt", "final", "int", "borderColor", ")", "{", "Condition", ".", "INSTANCE", ".", ...
Clips the long edge of a bitmap, if its width and height are not equal, in order to transform it into a square. Additionally, the bitmap is resized to a specific size and a border will be added. @param bitmap The bitmap, which should be clipped, as an instance of the class {@link Bitmap}. The bitmap may not be null @param size The size, the bitmap should be resized to, as an {@link Integer} value in pixels. The size must be at least 1 @param borderWidth The width of the border as an {@link Integer} value in pixels. The width must be at least 0 @param borderColor The color of the border as an {@link Integer} value @return The clipped bitmap as an instance of the class {@link Bitmap}
[ "Clips", "the", "long", "edge", "of", "a", "bitmap", "if", "its", "width", "and", "height", "are", "not", "equal", "in", "order", "to", "transform", "it", "into", "a", "square", ".", "Additionally", "the", "bitmap", "is", "resized", "to", "a", "specific"...
67ec0e5732344eeb4d946dd1f96d782939e449f4
https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/BitmapUtil.java#L311-L337
train
michael-rapp/AndroidUtil
library/src/main/java/de/mrapp/android/util/BitmapUtil.java
BitmapUtil.resize
public static Bitmap resize(@NonNull final Bitmap bitmap, final int width, final int height) { Condition.INSTANCE.ensureNotNull(bitmap, "The bitmap may not be null"); Condition.INSTANCE.ensureAtLeast(width, 1, "The width must be at least 1"); Condition.INSTANCE.ensureAtLeast(height, 1, "The height must be at least 1"); return Bitmap.createScaledBitmap(bitmap, width, height, false); }
java
public static Bitmap resize(@NonNull final Bitmap bitmap, final int width, final int height) { Condition.INSTANCE.ensureNotNull(bitmap, "The bitmap may not be null"); Condition.INSTANCE.ensureAtLeast(width, 1, "The width must be at least 1"); Condition.INSTANCE.ensureAtLeast(height, 1, "The height must be at least 1"); return Bitmap.createScaledBitmap(bitmap, width, height, false); }
[ "public", "static", "Bitmap", "resize", "(", "@", "NonNull", "final", "Bitmap", "bitmap", ",", "final", "int", "width", ",", "final", "int", "height", ")", "{", "Condition", ".", "INSTANCE", ".", "ensureNotNull", "(", "bitmap", ",", "\"The bitmap may not be nu...
Resizes a bitmap to a specific width and height. If the ratio between width and height differs from the bitmap's original ratio, the bitmap is stretched. @param bitmap The bitmap, which should be resized, as an instance of the class {@link Bitmap}. The bitmap may not be null @param width The width, the bitmap should be resized to, as an {@link Integer} value in pixels. The width must be at least 1 @param height The height, the bitmap should be resized to, as an {@link Integer} value in pixels. The height must be at least 1 @return The resized bitmap as an instance of the class {@link Bitmap}
[ "Resizes", "a", "bitmap", "to", "a", "specific", "width", "and", "height", ".", "If", "the", "ratio", "between", "width", "and", "height", "differs", "from", "the", "bitmap", "s", "original", "ratio", "the", "bitmap", "is", "stretched", "." ]
67ec0e5732344eeb4d946dd1f96d782939e449f4
https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/BitmapUtil.java#L354-L359
train
michael-rapp/AndroidUtil
library/src/main/java/de/mrapp/android/util/BitmapUtil.java
BitmapUtil.splitHorizontally
public static Pair<Bitmap, Bitmap> splitHorizontally(@NonNull final Bitmap bitmap) { return splitHorizontally(bitmap, bitmap.getHeight() / 2); }
java
public static Pair<Bitmap, Bitmap> splitHorizontally(@NonNull final Bitmap bitmap) { return splitHorizontally(bitmap, bitmap.getHeight() / 2); }
[ "public", "static", "Pair", "<", "Bitmap", ",", "Bitmap", ">", "splitHorizontally", "(", "@", "NonNull", "final", "Bitmap", "bitmap", ")", "{", "return", "splitHorizontally", "(", "bitmap", ",", "bitmap", ".", "getHeight", "(", ")", "/", "2", ")", ";", "...
Splits a specific bitmap horizontally at half. @param bitmap The bitmap, which should be split, as an instance of the class {@link Bitmap}. The bitmap may not be null @return A pair, which contains the two bitmaps, which the original bitmap has been split into, as an instance of the class Pair
[ "Splits", "a", "specific", "bitmap", "horizontally", "at", "half", "." ]
67ec0e5732344eeb4d946dd1f96d782939e449f4
https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/BitmapUtil.java#L370-L372
train
michael-rapp/AndroidUtil
library/src/main/java/de/mrapp/android/util/BitmapUtil.java
BitmapUtil.splitHorizontally
public static Pair<Bitmap, Bitmap> splitHorizontally(@NonNull final Bitmap bitmap, final int splitPoint) { Condition.INSTANCE.ensureNotNull(bitmap, "The bitmap may not be null"); Condition.INSTANCE.ensureGreater(splitPoint, 0, "The split point must be greater than 0"); Condition.INSTANCE.ensureSmaller(splitPoint, bitmap.getHeight(), "The split point must be smaller than " + bitmap.getHeight()); Bitmap topBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), splitPoint); Bitmap bottomBitmap = Bitmap.createBitmap(bitmap, 0, splitPoint, bitmap.getWidth(), bitmap.getHeight() - splitPoint); return new Pair<>(topBitmap, bottomBitmap); }
java
public static Pair<Bitmap, Bitmap> splitHorizontally(@NonNull final Bitmap bitmap, final int splitPoint) { Condition.INSTANCE.ensureNotNull(bitmap, "The bitmap may not be null"); Condition.INSTANCE.ensureGreater(splitPoint, 0, "The split point must be greater than 0"); Condition.INSTANCE.ensureSmaller(splitPoint, bitmap.getHeight(), "The split point must be smaller than " + bitmap.getHeight()); Bitmap topBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), splitPoint); Bitmap bottomBitmap = Bitmap.createBitmap(bitmap, 0, splitPoint, bitmap.getWidth(), bitmap.getHeight() - splitPoint); return new Pair<>(topBitmap, bottomBitmap); }
[ "public", "static", "Pair", "<", "Bitmap", ",", "Bitmap", ">", "splitHorizontally", "(", "@", "NonNull", "final", "Bitmap", "bitmap", ",", "final", "int", "splitPoint", ")", "{", "Condition", ".", "INSTANCE", ".", "ensureNotNull", "(", "bitmap", ",", "\"The ...
Splits a specific bitmap horizontally at a specific split point. @param bitmap The bitmap, which should be split, as an instance of the class {@link Bitmap}. The bitmap may not be null @param splitPoint The row, the bitmap should be split at, counted from the top edge in pixels as an {@link Integer} value @return A pair, which contains the two bitmaps, the original bitmap has been split into, as an instance of the class Pair
[ "Splits", "a", "specific", "bitmap", "horizontally", "at", "a", "specific", "split", "point", "." ]
67ec0e5732344eeb4d946dd1f96d782939e449f4
https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/BitmapUtil.java#L386-L396
train
michael-rapp/AndroidUtil
library/src/main/java/de/mrapp/android/util/BitmapUtil.java
BitmapUtil.splitVertically
public static Pair<Bitmap, Bitmap> splitVertically(@NonNull final Bitmap bitmap) { return splitVertically(bitmap, bitmap.getWidth() / 2); }
java
public static Pair<Bitmap, Bitmap> splitVertically(@NonNull final Bitmap bitmap) { return splitVertically(bitmap, bitmap.getWidth() / 2); }
[ "public", "static", "Pair", "<", "Bitmap", ",", "Bitmap", ">", "splitVertically", "(", "@", "NonNull", "final", "Bitmap", "bitmap", ")", "{", "return", "splitVertically", "(", "bitmap", ",", "bitmap", ".", "getWidth", "(", ")", "/", "2", ")", ";", "}" ]
Splits a specific bitmap vertically at half. @param bitmap The bitmap, which should be split, as an instance of the class {@link Bitmap}. The bitmap may not be null @return A pair, which contains the two bitmaps, the original bitmap has been split into, as an instance of the class Pair
[ "Splits", "a", "specific", "bitmap", "vertically", "at", "half", "." ]
67ec0e5732344eeb4d946dd1f96d782939e449f4
https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/BitmapUtil.java#L407-L409
train
michael-rapp/AndroidUtil
library/src/main/java/de/mrapp/android/util/BitmapUtil.java
BitmapUtil.splitVertically
public static Pair<Bitmap, Bitmap> splitVertically(@NonNull final Bitmap bitmap, final int splitPoint) { Condition.INSTANCE.ensureNotNull(bitmap, "The bitmap may not be null"); Condition.INSTANCE.ensureGreater(splitPoint, 0, "The split point must be greater than 0"); Condition.INSTANCE.ensureSmaller(splitPoint, bitmap.getWidth(), "The split point must be smaller than " + bitmap.getWidth()); Bitmap leftBitmap = Bitmap.createBitmap(bitmap, 0, 0, splitPoint, bitmap.getHeight()); Bitmap rightBitmap = Bitmap.createBitmap(bitmap, splitPoint, 0, bitmap.getWidth() - splitPoint, bitmap.getHeight()); return new Pair<>(leftBitmap, rightBitmap); }
java
public static Pair<Bitmap, Bitmap> splitVertically(@NonNull final Bitmap bitmap, final int splitPoint) { Condition.INSTANCE.ensureNotNull(bitmap, "The bitmap may not be null"); Condition.INSTANCE.ensureGreater(splitPoint, 0, "The split point must be greater than 0"); Condition.INSTANCE.ensureSmaller(splitPoint, bitmap.getWidth(), "The split point must be smaller than " + bitmap.getWidth()); Bitmap leftBitmap = Bitmap.createBitmap(bitmap, 0, 0, splitPoint, bitmap.getHeight()); Bitmap rightBitmap = Bitmap.createBitmap(bitmap, splitPoint, 0, bitmap.getWidth() - splitPoint, bitmap.getHeight()); return new Pair<>(leftBitmap, rightBitmap); }
[ "public", "static", "Pair", "<", "Bitmap", ",", "Bitmap", ">", "splitVertically", "(", "@", "NonNull", "final", "Bitmap", "bitmap", ",", "final", "int", "splitPoint", ")", "{", "Condition", ".", "INSTANCE", ".", "ensureNotNull", "(", "bitmap", ",", "\"The bi...
Splits a specific bitmap vertically at a specific split point. @param bitmap The bitmap, which should be split, as an instance of the class {@link Bitmap}. The bitmap may not be null @param splitPoint The column, the bitmap should be split at, counted from the left edge in pixels as an {@link Integer} value @return A pair, which contains the two bitmaps, the original bitmap has been split into, as an instance of the class Pair
[ "Splits", "a", "specific", "bitmap", "vertically", "at", "a", "specific", "split", "point", "." ]
67ec0e5732344eeb4d946dd1f96d782939e449f4
https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/BitmapUtil.java#L423-L434
train
michael-rapp/AndroidUtil
library/src/main/java/de/mrapp/android/util/BitmapUtil.java
BitmapUtil.tile
public static Bitmap tile(final Bitmap bitmap, final int width, final int height) { Condition.INSTANCE.ensureNotNull(bitmap, "The bitmap may not be null"); Condition.INSTANCE.ensureAtLeast(width, 1, "The width must be at least 1"); Condition.INSTANCE.ensureAtLeast(height, 1, "The height must be at least 1"); Bitmap result = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(result); int originalWidth = bitmap.getWidth(); int originalHeight = bitmap.getHeight(); for (int x = 0; x < width; x += originalWidth) { for (int y = 0; y < width; y += originalHeight) { int copyWidth = (width - x >= originalWidth) ? originalWidth : width - x; int copyHeight = (height - y >= originalHeight) ? originalHeight : height - y; Rect src = new Rect(0, 0, copyWidth, copyHeight); Rect dest = new Rect(x, y, x + copyWidth, y + copyHeight); canvas.drawBitmap(bitmap, src, dest, null); } } return result; }
java
public static Bitmap tile(final Bitmap bitmap, final int width, final int height) { Condition.INSTANCE.ensureNotNull(bitmap, "The bitmap may not be null"); Condition.INSTANCE.ensureAtLeast(width, 1, "The width must be at least 1"); Condition.INSTANCE.ensureAtLeast(height, 1, "The height must be at least 1"); Bitmap result = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(result); int originalWidth = bitmap.getWidth(); int originalHeight = bitmap.getHeight(); for (int x = 0; x < width; x += originalWidth) { for (int y = 0; y < width; y += originalHeight) { int copyWidth = (width - x >= originalWidth) ? originalWidth : width - x; int copyHeight = (height - y >= originalHeight) ? originalHeight : height - y; Rect src = new Rect(0, 0, copyWidth, copyHeight); Rect dest = new Rect(x, y, x + copyWidth, y + copyHeight); canvas.drawBitmap(bitmap, src, dest, null); } } return result; }
[ "public", "static", "Bitmap", "tile", "(", "final", "Bitmap", "bitmap", ",", "final", "int", "width", ",", "final", "int", "height", ")", "{", "Condition", ".", "INSTANCE", ".", "ensureNotNull", "(", "bitmap", ",", "\"The bitmap may not be null\"", ")", ";", ...
Creates and returns a bitmap with a specific width and height by tiling another bitmap. @param bitmap The bitmap, which should be tiled, as an instance of the class {@link Bitmap}. The bitmap may not be null @param width The width of the bitmap as an {@link Integer} value in pixels. The width must be at least 1 @param height The height of the bitmap as an {@link Integer} value in pixels. The height must be at least 1 @return The bitmap, which has been created as an instance of the class {@link Bitmap}
[ "Creates", "and", "returns", "a", "bitmap", "with", "a", "specific", "width", "and", "height", "by", "tiling", "another", "bitmap", "." ]
67ec0e5732344eeb4d946dd1f96d782939e449f4
https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/BitmapUtil.java#L450-L470
train
michael-rapp/AndroidUtil
library/src/main/java/de/mrapp/android/util/BitmapUtil.java
BitmapUtil.tint
public static Bitmap tint(@NonNull final Bitmap bitmap, @ColorInt final int color) { Condition.INSTANCE.ensureNotNull(bitmap, "The bitmap may not be null"); Canvas canvas = new Canvas(bitmap); Paint paint = new Paint(); paint.setColor(color); canvas.drawRect(new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()), paint); return bitmap; }
java
public static Bitmap tint(@NonNull final Bitmap bitmap, @ColorInt final int color) { Condition.INSTANCE.ensureNotNull(bitmap, "The bitmap may not be null"); Canvas canvas = new Canvas(bitmap); Paint paint = new Paint(); paint.setColor(color); canvas.drawRect(new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()), paint); return bitmap; }
[ "public", "static", "Bitmap", "tint", "(", "@", "NonNull", "final", "Bitmap", "bitmap", ",", "@", "ColorInt", "final", "int", "color", ")", "{", "Condition", ".", "INSTANCE", ".", "ensureNotNull", "(", "bitmap", ",", "\"The bitmap may not be null\"", ")", ";",...
Creates and returns a bitmap by overlaying it with a specific color. @param bitmap The bitmap, which should be tinted, as an instance of the class {@link Bitmap}. The bitmap may not be null @param color The color, which should be used for tinting, as an {@link Integer} value @return The bitmap, which has been created, as an instance of the class {@link Bitmap}
[ "Creates", "and", "returns", "a", "bitmap", "by", "overlaying", "it", "with", "a", "specific", "color", "." ]
67ec0e5732344eeb4d946dd1f96d782939e449f4
https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/BitmapUtil.java#L482-L489
train
michael-rapp/AndroidUtil
library/src/main/java/de/mrapp/android/util/BitmapUtil.java
BitmapUtil.drawableToBitmap
public static Bitmap drawableToBitmap(@NonNull final Drawable drawable) { Condition.INSTANCE.ensureNotNull(drawable, "The drawable may not be null"); if (drawable instanceof BitmapDrawable) { BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable; if (bitmapDrawable.getBitmap() != null) { return bitmapDrawable.getBitmap(); } } Bitmap bitmap; if (drawable.getIntrinsicWidth() <= 0 || drawable.getIntrinsicHeight() <= 0) { bitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888); } else { bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888); } Canvas canvas = new Canvas(bitmap); drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); drawable.draw(canvas); return bitmap; }
java
public static Bitmap drawableToBitmap(@NonNull final Drawable drawable) { Condition.INSTANCE.ensureNotNull(drawable, "The drawable may not be null"); if (drawable instanceof BitmapDrawable) { BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable; if (bitmapDrawable.getBitmap() != null) { return bitmapDrawable.getBitmap(); } } Bitmap bitmap; if (drawable.getIntrinsicWidth() <= 0 || drawable.getIntrinsicHeight() <= 0) { bitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888); } else { bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888); } Canvas canvas = new Canvas(bitmap); drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); drawable.draw(canvas); return bitmap; }
[ "public", "static", "Bitmap", "drawableToBitmap", "(", "@", "NonNull", "final", "Drawable", "drawable", ")", "{", "Condition", ".", "INSTANCE", ".", "ensureNotNull", "(", "drawable", ",", "\"The drawable may not be null\"", ")", ";", "if", "(", "drawable", "instan...
Creates and returns a bitmap from a specific drawable. @param drawable The drawable, which should be converted, as an instance of the class {@link Drawable}. The drawable may not be null @return The bitmap, which has been created, as an instance of the class {@link Bitmap}
[ "Creates", "and", "returns", "a", "bitmap", "from", "a", "specific", "drawable", "." ]
67ec0e5732344eeb4d946dd1f96d782939e449f4
https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/BitmapUtil.java#L499-L524
train
michael-rapp/AndroidUtil
library/src/main/java/de/mrapp/android/util/BitmapUtil.java
BitmapUtil.colorToBitmap
public static Bitmap colorToBitmap(final int width, final int height, @ColorInt final int color) { Condition.INSTANCE.ensureAtLeast(width, 1, "The width must be at least 1"); Condition.INSTANCE.ensureAtLeast(height, 1, "The height must be at least 1"); Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); Paint paint = new Paint(); paint.setColor(color); canvas.drawRect(0, 0, width, height, paint); return bitmap; }
java
public static Bitmap colorToBitmap(final int width, final int height, @ColorInt final int color) { Condition.INSTANCE.ensureAtLeast(width, 1, "The width must be at least 1"); Condition.INSTANCE.ensureAtLeast(height, 1, "The height must be at least 1"); Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); Paint paint = new Paint(); paint.setColor(color); canvas.drawRect(0, 0, width, height, paint); return bitmap; }
[ "public", "static", "Bitmap", "colorToBitmap", "(", "final", "int", "width", ",", "final", "int", "height", ",", "@", "ColorInt", "final", "int", "color", ")", "{", "Condition", ".", "INSTANCE", ".", "ensureAtLeast", "(", "width", ",", "1", ",", "\"The wid...
Creates and returns a bitmap from a specific color. @param width The width of the bitmap, which should be created, in pixels as an {@link Integer} value. The width must be at least 1 @param height The height of the bitmap, which should be created, in pixels as an {@link Integer} value. The height must be at least 1 @param color The color, which should be used, as an {@link Integer} value @return The bitmap, which has been created, as an instance of the class {@link Bitmap}
[ "Creates", "and", "returns", "a", "bitmap", "from", "a", "specific", "color", "." ]
67ec0e5732344eeb4d946dd1f96d782939e449f4
https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/BitmapUtil.java#L626-L636
train
michael-rapp/AndroidUtil
library/src/main/java/de/mrapp/android/util/BitmapUtil.java
BitmapUtil.getImageDimensions
public static Pair<Integer, Integer> getImageDimensions(@NonNull final File file) throws IOException { Condition.INSTANCE.ensureNotNull(file, "The file may not be null"); Condition.INSTANCE .ensureFileIsNoDirectory(file, "The file must exist and must not be a directory"); String path = file.getPath(); BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeFile(path, options); int width = options.outWidth; int height = options.outHeight; if (width == -1 || height == -1) { throw new IOException("Failed to decode image \"" + path + "\""); } return Pair.create(width, height); }
java
public static Pair<Integer, Integer> getImageDimensions(@NonNull final File file) throws IOException { Condition.INSTANCE.ensureNotNull(file, "The file may not be null"); Condition.INSTANCE .ensureFileIsNoDirectory(file, "The file must exist and must not be a directory"); String path = file.getPath(); BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeFile(path, options); int width = options.outWidth; int height = options.outHeight; if (width == -1 || height == -1) { throw new IOException("Failed to decode image \"" + path + "\""); } return Pair.create(width, height); }
[ "public", "static", "Pair", "<", "Integer", ",", "Integer", ">", "getImageDimensions", "(", "@", "NonNull", "final", "File", "file", ")", "throws", "IOException", "{", "Condition", ".", "INSTANCE", ".", "ensureNotNull", "(", "file", ",", "\"The file may not be n...
Returns the width and height of a specific image file. @param file The image file, whose width and height should be returned, as an instance of the class {@link File}. The file may not be null. The file must exist and must not be a directory @return A pair, which contains the width and height of the given image file, as an instance of the class Pair @throws IOException The exception, which is thrown, if an error occurs while decoding the image file
[ "Returns", "the", "width", "and", "height", "of", "a", "specific", "image", "file", "." ]
67ec0e5732344eeb4d946dd1f96d782939e449f4
https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/BitmapUtil.java#L650-L667
train
michael-rapp/AndroidUtil
library/src/main/java/de/mrapp/android/util/BitmapUtil.java
BitmapUtil.getImageDimensions
public static Pair<Integer, Integer> getImageDimensions(@NonNull final Context context, @DrawableRes final int resourceId) throws IOException { Condition.INSTANCE.ensureNotNull(context, "The context may not be null"); BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeResource(context.getResources(), resourceId, options); int width = options.outWidth; int height = options.outHeight; if (width == -1 || height == -1) { throw new IOException("Failed to decode image resource with id " + resourceId); } return Pair.create(width, height); }
java
public static Pair<Integer, Integer> getImageDimensions(@NonNull final Context context, @DrawableRes final int resourceId) throws IOException { Condition.INSTANCE.ensureNotNull(context, "The context may not be null"); BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeResource(context.getResources(), resourceId, options); int width = options.outWidth; int height = options.outHeight; if (width == -1 || height == -1) { throw new IOException("Failed to decode image resource with id " + resourceId); } return Pair.create(width, height); }
[ "public", "static", "Pair", "<", "Integer", ",", "Integer", ">", "getImageDimensions", "(", "@", "NonNull", "final", "Context", "context", ",", "@", "DrawableRes", "final", "int", "resourceId", ")", "throws", "IOException", "{", "Condition", ".", "INSTANCE", "...
Returns the width and height of a specific image resource. @param context The context, which should be used, as an instance of the class {@link Context}. The context may not be null @param resourceId The resource id of the image resource, whose width and height should be returned, as an {@link Integer} value. The resource id must correspond to a valid drawable resource @return A pair, which contains the width and height of the given image resource, as an instance of the class Pair @throws IOException The exception, which is thrown, if an error occurs while decoding the image resource
[ "Returns", "the", "width", "and", "height", "of", "a", "specific", "image", "resource", "." ]
67ec0e5732344eeb4d946dd1f96d782939e449f4
https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/BitmapUtil.java#L684-L699
train
michael-rapp/AndroidUtil
library/src/main/java/de/mrapp/android/util/BitmapUtil.java
BitmapUtil.loadThumbnail
public static Bitmap loadThumbnail(@NonNull final File file, final int maxWidth, final int maxHeight) throws IOException { Pair<Integer, Integer> imageDimensions = getImageDimensions(file); int sampleSize = getSampleSize(imageDimensions, maxWidth, maxHeight); BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = false; options.inSampleSize = sampleSize; String path = file.getAbsolutePath(); Bitmap thumbnail = BitmapFactory.decodeFile(path, options); if (thumbnail == null) { throw new IOException("Failed to decode image \"" + path + "\""); } return thumbnail; }
java
public static Bitmap loadThumbnail(@NonNull final File file, final int maxWidth, final int maxHeight) throws IOException { Pair<Integer, Integer> imageDimensions = getImageDimensions(file); int sampleSize = getSampleSize(imageDimensions, maxWidth, maxHeight); BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = false; options.inSampleSize = sampleSize; String path = file.getAbsolutePath(); Bitmap thumbnail = BitmapFactory.decodeFile(path, options); if (thumbnail == null) { throw new IOException("Failed to decode image \"" + path + "\""); } return thumbnail; }
[ "public", "static", "Bitmap", "loadThumbnail", "(", "@", "NonNull", "final", "File", "file", ",", "final", "int", "maxWidth", ",", "final", "int", "maxHeight", ")", "throws", "IOException", "{", "Pair", "<", "Integer", ",", "Integer", ">", "imageDimensions", ...
Loads a downsampled thumbnail of a specific image file while maintaining its aspect ratio. @param file The image file, which should be loaded, as an instance of the class {@link File}. The file may not be null. The file must exist and must not be a directory @param maxWidth The maximum width of the thumbnail in pixels as an {@link Integer} value. The maximum width must be at least 1 @param maxHeight The maximum height of the thumbnail in pixels as an {@link Integer} value. The maximum height must be at least 1 @return The thumbnail, which has been loaded, as an instance of the class {@link Bitmap} @throws IOException The exception, which is thrown, if an error occurs while decoding the image file
[ "Loads", "a", "downsampled", "thumbnail", "of", "a", "specific", "image", "file", "while", "maintaining", "its", "aspect", "ratio", "." ]
67ec0e5732344eeb4d946dd1f96d782939e449f4
https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/BitmapUtil.java#L717-L732
train
michael-rapp/AndroidUtil
library/src/main/java/de/mrapp/android/util/BitmapUtil.java
BitmapUtil.compressToFile
public static void compressToFile(@NonNull final Bitmap bitmap, @NonNull final File file, @NonNull final CompressFormat format, final int quality) throws IOException { Condition.INSTANCE.ensureNotNull(bitmap, "The bitmap may not be null"); Condition.INSTANCE.ensureNotNull(file, "The file may not be null"); Condition.INSTANCE.ensureNotNull(format, "The format may not be null"); Condition.INSTANCE.ensureAtLeast(quality, 0, "The quality must be at least 0"); Condition.INSTANCE.ensureAtMaximum(quality, 100, "The quality must be at maximum 100"); OutputStream outputStream = null; try { outputStream = new FileOutputStream(file); boolean result = bitmap.compress(format, quality, outputStream); if (!result) { throw new IOException( "Failed to compress bitmap to file \"" + file + "\" using format " + format + " and quality " + quality); } } finally { StreamUtil.INSTANCE.close(outputStream); } }
java
public static void compressToFile(@NonNull final Bitmap bitmap, @NonNull final File file, @NonNull final CompressFormat format, final int quality) throws IOException { Condition.INSTANCE.ensureNotNull(bitmap, "The bitmap may not be null"); Condition.INSTANCE.ensureNotNull(file, "The file may not be null"); Condition.INSTANCE.ensureNotNull(format, "The format may not be null"); Condition.INSTANCE.ensureAtLeast(quality, 0, "The quality must be at least 0"); Condition.INSTANCE.ensureAtMaximum(quality, 100, "The quality must be at maximum 100"); OutputStream outputStream = null; try { outputStream = new FileOutputStream(file); boolean result = bitmap.compress(format, quality, outputStream); if (!result) { throw new IOException( "Failed to compress bitmap to file \"" + file + "\" using format " + format + " and quality " + quality); } } finally { StreamUtil.INSTANCE.close(outputStream); } }
[ "public", "static", "void", "compressToFile", "(", "@", "NonNull", "final", "Bitmap", "bitmap", ",", "@", "NonNull", "final", "File", "file", ",", "@", "NonNull", "final", "CompressFormat", "format", ",", "final", "int", "quality", ")", "throws", "IOException"...
Compresses a specific bitmap and stores it within a file. @param bitmap The bitmap, which should be compressed, as an instance of the class {@link Bitmap}. The bitmap may not be null @param file The file, the bitmap should be compressed to, as an instance of the class {@link File}. The file may not be null @param format The format, which should be used to compress the bitmap, as a value of the enum {@link CompressFormat}. The format must either be <code>JPEG</code>, <code>PNG</code> or <code>WEBP</code> @param quality The quality, which should be used to compress the bitmap, as an {@link Integer} value. The quality must be at least 0 (lowest quality) and at maximum 100 (highest quality) @throws FileNotFoundException The exception, which is thrown, if the given file could not be opened for writing @throws IOException The exception, which is thrown, if an error occurs while compressing the bitmap
[ "Compresses", "a", "specific", "bitmap", "and", "stores", "it", "within", "a", "file", "." ]
67ec0e5732344eeb4d946dd1f96d782939e449f4
https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/BitmapUtil.java#L793-L815
train
michael-rapp/AndroidUtil
library/src/main/java/de/mrapp/android/util/BitmapUtil.java
BitmapUtil.compressToByteArray
public static byte[] compressToByteArray(@NonNull final Bitmap bitmap, @NonNull final CompressFormat format, final int quality) throws IOException { Condition.INSTANCE.ensureNotNull(bitmap, "The bitmap may not be null"); Condition.INSTANCE.ensureNotNull(format, "The format may not be null"); Condition.INSTANCE.ensureAtLeast(quality, 0, "The quality must be at least 0"); Condition.INSTANCE.ensureAtMaximum(quality, 100, "The quality must be at maximum 100"); ByteArrayOutputStream outputStream = null; try { outputStream = new ByteArrayOutputStream(); boolean result = bitmap.compress(format, quality, outputStream); if (result) { return outputStream.toByteArray(); } throw new IOException("Failed to compress bitmap to byte array using format " + format + " and quality " + quality); } finally { StreamUtil.INSTANCE.close(outputStream); } }
java
public static byte[] compressToByteArray(@NonNull final Bitmap bitmap, @NonNull final CompressFormat format, final int quality) throws IOException { Condition.INSTANCE.ensureNotNull(bitmap, "The bitmap may not be null"); Condition.INSTANCE.ensureNotNull(format, "The format may not be null"); Condition.INSTANCE.ensureAtLeast(quality, 0, "The quality must be at least 0"); Condition.INSTANCE.ensureAtMaximum(quality, 100, "The quality must be at maximum 100"); ByteArrayOutputStream outputStream = null; try { outputStream = new ByteArrayOutputStream(); boolean result = bitmap.compress(format, quality, outputStream); if (result) { return outputStream.toByteArray(); } throw new IOException("Failed to compress bitmap to byte array using format " + format + " and quality " + quality); } finally { StreamUtil.INSTANCE.close(outputStream); } }
[ "public", "static", "byte", "[", "]", "compressToByteArray", "(", "@", "NonNull", "final", "Bitmap", "bitmap", ",", "@", "NonNull", "final", "CompressFormat", "format", ",", "final", "int", "quality", ")", "throws", "IOException", "{", "Condition", ".", "INSTA...
Compresses a specific bitmap and returns it as a byte array. @param bitmap The bitmap, which should be compressed, as an instance of the class {@link Bitmap}. The bitmap may not be null @param format The format, which should be used to compress the bitmap, as a value of the enum {@link CompressFormat}. The format must either be <code>JPEG</code>, <code>PNG</code> or <code>WEBP</code> @param quality The quality, which should be used to compress the bitmap, as an {@link Integer} value. The quality must be at least 0 (lowest quality) and at maximum 100 (highest quality) @return The byte array, the given bitmap has been compressed to, as a {@link Byte} array @throws IOException The exception, which is thrown, if an error occurs while compressing the bitmap
[ "Compresses", "a", "specific", "bitmap", "and", "returns", "it", "as", "a", "byte", "array", "." ]
67ec0e5732344eeb4d946dd1f96d782939e449f4
https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/BitmapUtil.java#L835-L857
train
edwardcapriolo/teknek-core
src/main/java/io/teknek/daemon/TeknekDaemon.java
TeknekDaemon.isPlanSane
public boolean isPlanSane(Plan plan){ if (plan == null){ logger.warn("did not find plan"); return false; } if (plan.isDisabled()){ logger.debug("disabled "+ plan.getName()); return false; } if (plan.getFeedDesc() == null){ logger.warn("feed was null "+ plan.getName()); return false; } return true; }
java
public boolean isPlanSane(Plan plan){ if (plan == null){ logger.warn("did not find plan"); return false; } if (plan.isDisabled()){ logger.debug("disabled "+ plan.getName()); return false; } if (plan.getFeedDesc() == null){ logger.warn("feed was null "+ plan.getName()); return false; } return true; }
[ "public", "boolean", "isPlanSane", "(", "Plan", "plan", ")", "{", "if", "(", "plan", "==", "null", ")", "{", "logger", ".", "warn", "(", "\"did not find plan\"", ")", ";", "return", "false", ";", "}", "if", "(", "plan", ".", "isDisabled", "(", ")", "...
Determines if the plan can be run. IE not disabled and not malformed @return true if the plan seems reasonable enough to run
[ "Determines", "if", "the", "plan", "can", "be", "run", ".", "IE", "not", "disabled", "and", "not", "malformed" ]
4fa972d11044dee2954c0cc5e1b53b18fba319b9
https://github.com/edwardcapriolo/teknek-core/blob/4fa972d11044dee2954c0cc5e1b53b18fba319b9/src/main/java/io/teknek/daemon/TeknekDaemon.java#L196-L210
train
michael-rapp/AndroidUtil
library/src/main/java/de/mrapp/android/util/view/ExpandableGridView.java
ExpandableGridView.createItemClickListener
private OnItemClickListener createItemClickListener() { return new OnItemClickListener() { @Override public void onItemClick(final AdapterView<?> parent, final View view, final int position, final long id) { Pair<Integer, Integer> itemPosition = getItemPosition(position - getHeaderViewsCount()); int groupIndex = itemPosition.first; int childIndex = itemPosition.second; long packedId; if (childIndex != -1) { packedId = getPackedPositionForChild(groupIndex, childIndex); notifyOnChildClicked(view, groupIndex, childIndex, packedId); } else if (groupIndex != -1) { packedId = getPackedPositionForGroup(groupIndex); notifyOnGroupClicked(view, groupIndex, packedId); } else { packedId = getPackedPositionForChild(Integer.MAX_VALUE, position); } notifyOnItemClicked(view, getPackedPosition(position), packedId); } }; }
java
private OnItemClickListener createItemClickListener() { return new OnItemClickListener() { @Override public void onItemClick(final AdapterView<?> parent, final View view, final int position, final long id) { Pair<Integer, Integer> itemPosition = getItemPosition(position - getHeaderViewsCount()); int groupIndex = itemPosition.first; int childIndex = itemPosition.second; long packedId; if (childIndex != -1) { packedId = getPackedPositionForChild(groupIndex, childIndex); notifyOnChildClicked(view, groupIndex, childIndex, packedId); } else if (groupIndex != -1) { packedId = getPackedPositionForGroup(groupIndex); notifyOnGroupClicked(view, groupIndex, packedId); } else { packedId = getPackedPositionForChild(Integer.MAX_VALUE, position); } notifyOnItemClicked(view, getPackedPosition(position), packedId); } }; }
[ "private", "OnItemClickListener", "createItemClickListener", "(", ")", "{", "return", "new", "OnItemClickListener", "(", ")", "{", "@", "Override", "public", "void", "onItemClick", "(", "final", "AdapterView", "<", "?", ">", "parent", ",", "final", "View", "view...
Creates and returns a listener, which allows to delegate, when any item of the grid view has been clicked, to the appropriate listeners. @return The listener, which has been created, as an instance of the type {@link OnItemClickListener}
[ "Creates", "and", "returns", "a", "listener", "which", "allows", "to", "delegate", "when", "any", "item", "of", "the", "grid", "view", "has", "been", "clicked", "to", "the", "appropriate", "listeners", "." ]
67ec0e5732344eeb4d946dd1f96d782939e449f4
https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/view/ExpandableGridView.java#L327-L353
train
michael-rapp/AndroidUtil
library/src/main/java/de/mrapp/android/util/view/ExpandableGridView.java
ExpandableGridView.createItemLongClickListener
private OnItemLongClickListener createItemLongClickListener() { return new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { Pair<Integer, Integer> itemPosition = getItemPosition(position - getHeaderViewsCount()); int groupIndex = itemPosition.first; int childIndex = itemPosition.second; long packedId; if (childIndex != -1) { packedId = getPackedPositionForChild(groupIndex, childIndex); } else if (groupIndex != -1) { packedId = getPackedPositionForGroup(groupIndex); } else { packedId = getPackedPositionForChild(Integer.MAX_VALUE, position); } return notifyOnItemLongClicked(view, getPackedPosition(position), packedId); } }; }
java
private OnItemLongClickListener createItemLongClickListener() { return new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { Pair<Integer, Integer> itemPosition = getItemPosition(position - getHeaderViewsCount()); int groupIndex = itemPosition.first; int childIndex = itemPosition.second; long packedId; if (childIndex != -1) { packedId = getPackedPositionForChild(groupIndex, childIndex); } else if (groupIndex != -1) { packedId = getPackedPositionForGroup(groupIndex); } else { packedId = getPackedPositionForChild(Integer.MAX_VALUE, position); } return notifyOnItemLongClicked(view, getPackedPosition(position), packedId); } }; }
[ "private", "OnItemLongClickListener", "createItemLongClickListener", "(", ")", "{", "return", "new", "OnItemLongClickListener", "(", ")", "{", "@", "Override", "public", "boolean", "onItemLongClick", "(", "AdapterView", "<", "?", ">", "parent", ",", "View", "view", ...
Creates and returns a listener, which allows to delegate, when any item of the grid view has been long-clicked, to the appropriate listeners. @return The listener, which has been created, as an instance of the type {@link OnItemLongClickListener}
[ "Creates", "and", "returns", "a", "listener", "which", "allows", "to", "delegate", "when", "any", "item", "of", "the", "grid", "view", "has", "been", "long", "-", "clicked", "to", "the", "appropriate", "listeners", "." ]
67ec0e5732344eeb4d946dd1f96d782939e449f4
https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/view/ExpandableGridView.java#L362-L386
train
michael-rapp/AndroidUtil
library/src/main/java/de/mrapp/android/util/view/ExpandableGridView.java
ExpandableGridView.getPackedPosition
private int getPackedPosition(final int position) { if (position < getHeaderViewsCount()) { return position; } else { Pair<Integer, Integer> pair = getItemPosition(position - getHeaderViewsCount()); int groupIndex = pair.first; int childIndex = pair.second; if (childIndex == -1 && groupIndex == -1) { int childCount = 0; for (int i = 0; i < getExpandableListAdapter().getGroupCount(); i++) { childCount += getExpandableListAdapter().getChildrenCount(i); } return getHeaderViewsCount() + getExpandableListAdapter().getGroupCount() + childCount + position - (getHeaderViewsCount() + adapter.getCount()); } else if (childIndex != -1) { return getPackedChildPosition(groupIndex, childIndex); } else { return getPackedGroupPosition(groupIndex); } } }
java
private int getPackedPosition(final int position) { if (position < getHeaderViewsCount()) { return position; } else { Pair<Integer, Integer> pair = getItemPosition(position - getHeaderViewsCount()); int groupIndex = pair.first; int childIndex = pair.second; if (childIndex == -1 && groupIndex == -1) { int childCount = 0; for (int i = 0; i < getExpandableListAdapter().getGroupCount(); i++) { childCount += getExpandableListAdapter().getChildrenCount(i); } return getHeaderViewsCount() + getExpandableListAdapter().getGroupCount() + childCount + position - (getHeaderViewsCount() + adapter.getCount()); } else if (childIndex != -1) { return getPackedChildPosition(groupIndex, childIndex); } else { return getPackedGroupPosition(groupIndex); } } }
[ "private", "int", "getPackedPosition", "(", "final", "int", "position", ")", "{", "if", "(", "position", "<", "getHeaderViewsCount", "(", ")", ")", "{", "return", "position", ";", "}", "else", "{", "Pair", "<", "Integer", ",", "Integer", ">", "pair", "="...
Returns the packed position of an item, which corresponds to a specific position. @param position The position of the item, whose packed position should be returned, as an {@link Integer} value @return The packed position, which corresponds to the given position, as an {@link Integer} value
[ "Returns", "the", "packed", "position", "of", "an", "item", "which", "corresponds", "to", "a", "specific", "position", "." ]
67ec0e5732344eeb4d946dd1f96d782939e449f4
https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/view/ExpandableGridView.java#L397-L420
train
michael-rapp/AndroidUtil
library/src/main/java/de/mrapp/android/util/view/ExpandableGridView.java
ExpandableGridView.getPackedGroupPosition
private int getPackedGroupPosition(final int groupIndex) { int packedPosition = getHeaderViewsCount(); if (groupIndex > 0) { for (int i = groupIndex - 1; i >= 0; i--) { packedPosition += getExpandableListAdapter().getChildrenCount(i) + 1; } } return packedPosition; }
java
private int getPackedGroupPosition(final int groupIndex) { int packedPosition = getHeaderViewsCount(); if (groupIndex > 0) { for (int i = groupIndex - 1; i >= 0; i--) { packedPosition += getExpandableListAdapter().getChildrenCount(i) + 1; } } return packedPosition; }
[ "private", "int", "getPackedGroupPosition", "(", "final", "int", "groupIndex", ")", "{", "int", "packedPosition", "=", "getHeaderViewsCount", "(", ")", ";", "if", "(", "groupIndex", ">", "0", ")", "{", "for", "(", "int", "i", "=", "groupIndex", "-", "1", ...
Returns the packed position of a group, which corresponds to a specific index. @param groupIndex The index of the group, whose packed position should be returned, as an {@link Integer} value @return The packed position of the group, which corresponds to the given index, as an {@link Integer} value
[ "Returns", "the", "packed", "position", "of", "a", "group", "which", "corresponds", "to", "a", "specific", "index", "." ]
67ec0e5732344eeb4d946dd1f96d782939e449f4
https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/view/ExpandableGridView.java#L431-L441
train
michael-rapp/AndroidUtil
library/src/main/java/de/mrapp/android/util/view/ExpandableGridView.java
ExpandableGridView.getItemPosition
private Pair<Integer, Integer> getItemPosition(final int packedPosition) { int currentPosition = packedPosition; int groupIndex = -1; int childIndex = -1; int numColumns = getNumColumnsCompatible(); for (int i = 0; i < getExpandableListAdapter().getGroupCount(); i++) { if (currentPosition == 0) { groupIndex = i; break; } else if (currentPosition < numColumns) { break; } else { currentPosition -= numColumns; if (isGroupExpanded(i)) { int childCount = getExpandableListAdapter().getChildrenCount(i); if (currentPosition < childCount) { groupIndex = i; childIndex = currentPosition; break; } else { int lastLineCount = childCount % numColumns; currentPosition -= childCount + (lastLineCount > 0 ? numColumns - lastLineCount : 0); } } } } return new Pair<>(groupIndex, childIndex); }
java
private Pair<Integer, Integer> getItemPosition(final int packedPosition) { int currentPosition = packedPosition; int groupIndex = -1; int childIndex = -1; int numColumns = getNumColumnsCompatible(); for (int i = 0; i < getExpandableListAdapter().getGroupCount(); i++) { if (currentPosition == 0) { groupIndex = i; break; } else if (currentPosition < numColumns) { break; } else { currentPosition -= numColumns; if (isGroupExpanded(i)) { int childCount = getExpandableListAdapter().getChildrenCount(i); if (currentPosition < childCount) { groupIndex = i; childIndex = currentPosition; break; } else { int lastLineCount = childCount % numColumns; currentPosition -= childCount + (lastLineCount > 0 ? numColumns - lastLineCount : 0); } } } } return new Pair<>(groupIndex, childIndex); }
[ "private", "Pair", "<", "Integer", ",", "Integer", ">", "getItemPosition", "(", "final", "int", "packedPosition", ")", "{", "int", "currentPosition", "=", "packedPosition", ";", "int", "groupIndex", "=", "-", "1", ";", "int", "childIndex", "=", "-", "1", "...
Returns a pair, which contains the group and child index of the item, which corresponds to a specific packed position. @param packedPosition The packed position of the item, whose group and child index should be returned, as an {@link Integer} value @return A pair, which contains the group and child index of the item, which corresponds to the given packed position, as an instance of the class {@link Pair}
[ "Returns", "a", "pair", "which", "contains", "the", "group", "and", "child", "index", "of", "the", "item", "which", "corresponds", "to", "a", "specific", "packed", "position", "." ]
67ec0e5732344eeb4d946dd1f96d782939e449f4
https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/view/ExpandableGridView.java#L470-L502
train
michael-rapp/AndroidUtil
library/src/main/java/de/mrapp/android/util/view/ExpandableGridView.java
ExpandableGridView.notifyOnGroupClicked
private boolean notifyOnGroupClicked(@NonNull final View view, final int groupIndex, final long id) { return groupClickListener != null && groupClickListener.onGroupClick(this, view, groupIndex, id); }
java
private boolean notifyOnGroupClicked(@NonNull final View view, final int groupIndex, final long id) { return groupClickListener != null && groupClickListener.onGroupClick(this, view, groupIndex, id); }
[ "private", "boolean", "notifyOnGroupClicked", "(", "@", "NonNull", "final", "View", "view", ",", "final", "int", "groupIndex", ",", "final", "long", "id", ")", "{", "return", "groupClickListener", "!=", "null", "&&", "groupClickListener", ".", "onGroupClick", "(...
Notifies the listener, which has been registered to be notified, when a group has been clicked, about a group being clicked. @param view The view within the expandable grid view, which has been clicked, as an instance of the class {@link View}. The view may not be null @param groupIndex The index of the group, which has been clicked, as an {@link Integer} value @param id The id of the group, which has been clicked, as a {@link Long} value @return True, if the click has been handled by the listener, false otherwise
[ "Notifies", "the", "listener", "which", "has", "been", "registered", "to", "be", "notified", "when", "a", "group", "has", "been", "clicked", "about", "a", "group", "being", "clicked", "." ]
67ec0e5732344eeb4d946dd1f96d782939e449f4
https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/view/ExpandableGridView.java#L517-L521
train
michael-rapp/AndroidUtil
library/src/main/java/de/mrapp/android/util/view/ExpandableGridView.java
ExpandableGridView.notifyOnChildClicked
private boolean notifyOnChildClicked(@NonNull final View view, final int groupIndex, final int childIndex, final long id) { return childClickListener != null && childClickListener.onChildClick(this, view, groupIndex, childIndex, id); }
java
private boolean notifyOnChildClicked(@NonNull final View view, final int groupIndex, final int childIndex, final long id) { return childClickListener != null && childClickListener.onChildClick(this, view, groupIndex, childIndex, id); }
[ "private", "boolean", "notifyOnChildClicked", "(", "@", "NonNull", "final", "View", "view", ",", "final", "int", "groupIndex", ",", "final", "int", "childIndex", ",", "final", "long", "id", ")", "{", "return", "childClickListener", "!=", "null", "&&", "childCl...
Notifies the listener, which has been registered to be notified, when a child has been clicked, about a child being clicked. @param view The view within the expandable grid view, which has been clicked, as an instance of the class {@link View}. The view may not be null @param groupIndex The index of the group, the child, which has been clicked, belongs to, as an {@link Integer} value @param childIndex The index of the child, which has been clicked, as an {@link Integer} value @param id The id of the child, which has been clicked, as a {@link Long} value @return True, if the click has been handled by the listener, false otherwise
[ "Notifies", "the", "listener", "which", "has", "been", "registered", "to", "be", "notified", "when", "a", "child", "has", "been", "clicked", "about", "a", "child", "being", "clicked", "." ]
67ec0e5732344eeb4d946dd1f96d782939e449f4
https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/view/ExpandableGridView.java#L539-L543
train
michael-rapp/AndroidUtil
library/src/main/java/de/mrapp/android/util/view/ExpandableGridView.java
ExpandableGridView.notifyOnItemClicked
private void notifyOnItemClicked(@NonNull final View view, final int position, final long id) { if (itemClickListener != null) { itemClickListener.onItemClick(this, view, position, id); } }
java
private void notifyOnItemClicked(@NonNull final View view, final int position, final long id) { if (itemClickListener != null) { itemClickListener.onItemClick(this, view, position, id); } }
[ "private", "void", "notifyOnItemClicked", "(", "@", "NonNull", "final", "View", "view", ",", "final", "int", "position", ",", "final", "long", "id", ")", "{", "if", "(", "itemClickListener", "!=", "null", ")", "{", "itemClickListener", ".", "onItemClick", "(...
Notifies, the listener, which has been registered to be notified, when any item has been clicked, about an item being clicked. @param view The view within the expandable grid view, which has been clicked, as an instance of the class {@link View}. The view may not be null @param position The position of the item, which has been clicked, as an {@link Integer} value @param id The id of the item, which has been clicked, as a {@link Long} value
[ "Notifies", "the", "listener", "which", "has", "been", "registered", "to", "be", "notified", "when", "any", "item", "has", "been", "clicked", "about", "an", "item", "being", "clicked", "." ]
67ec0e5732344eeb4d946dd1f96d782939e449f4
https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/view/ExpandableGridView.java#L557-L561
train
michael-rapp/AndroidUtil
library/src/main/java/de/mrapp/android/util/view/ExpandableGridView.java
ExpandableGridView.notifyOnItemLongClicked
private boolean notifyOnItemLongClicked(@NonNull final View view, final int position, final long id) { return itemLongClickListener != null && itemLongClickListener.onItemLongClick(this, view, position, id); }
java
private boolean notifyOnItemLongClicked(@NonNull final View view, final int position, final long id) { return itemLongClickListener != null && itemLongClickListener.onItemLongClick(this, view, position, id); }
[ "private", "boolean", "notifyOnItemLongClicked", "(", "@", "NonNull", "final", "View", "view", ",", "final", "int", "position", ",", "final", "long", "id", ")", "{", "return", "itemLongClickListener", "!=", "null", "&&", "itemLongClickListener", ".", "onItemLongCl...
Notifies the listener, which has been registered to be notified, when any item has been long-clicked, about an item being long-clicked. @param view The view within the expandable grid view, which has been long-clicked, as an instance of the class {@link View}. The view may not be null @param position The position of the item, which has been long-clicked, as an {@link Integer} value @param id The id of the item, which has been long-clicked, as a {@link Long} value @return True, if the long-click has been handled by the listener, false otherwise
[ "Notifies", "the", "listener", "which", "has", "been", "registered", "to", "be", "notified", "when", "any", "item", "has", "been", "long", "-", "clicked", "about", "an", "item", "being", "long", "-", "clicked", "." ]
67ec0e5732344eeb4d946dd1f96d782939e449f4
https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/view/ExpandableGridView.java#L576-L580
train
michael-rapp/AndroidUtil
library/src/main/java/de/mrapp/android/util/view/ExpandableGridView.java
ExpandableGridView.getPackedPositionType
public static int getPackedPositionType(final long packedPosition) { if (packedPosition == PACKED_POSITION_VALUE_NULL) { return PACKED_POSITION_TYPE_NULL; } return (packedPosition & PACKED_POSITION_MASK_TYPE) == PACKED_POSITION_MASK_TYPE ? PACKED_POSITION_TYPE_CHILD : PACKED_POSITION_TYPE_GROUP; }
java
public static int getPackedPositionType(final long packedPosition) { if (packedPosition == PACKED_POSITION_VALUE_NULL) { return PACKED_POSITION_TYPE_NULL; } return (packedPosition & PACKED_POSITION_MASK_TYPE) == PACKED_POSITION_MASK_TYPE ? PACKED_POSITION_TYPE_CHILD : PACKED_POSITION_TYPE_GROUP; }
[ "public", "static", "int", "getPackedPositionType", "(", "final", "long", "packedPosition", ")", "{", "if", "(", "packedPosition", "==", "PACKED_POSITION_VALUE_NULL", ")", "{", "return", "PACKED_POSITION_TYPE_NULL", ";", "}", "return", "(", "packedPosition", "&", "P...
Returns the type of the item, which corresponds to a specific packed position. @param packedPosition The packed position of the item, whose type should be returned, as an {@link Integer} value @return The type of the item, which corresponds to the given packed position, as an {@link Integer} value. The type may either be <code>PACKED_POSITION_TYPE_GROUP</code>, <code>PACKED_POSITION_TYPE_CHILD</code> or <code>PACKED_POSITION_TYPE_NULL</code>
[ "Returns", "the", "type", "of", "the", "item", "which", "corresponds", "to", "a", "specific", "packed", "position", "." ]
67ec0e5732344eeb4d946dd1f96d782939e449f4
https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/view/ExpandableGridView.java#L680-L687
train
michael-rapp/AndroidUtil
library/src/main/java/de/mrapp/android/util/view/ExpandableGridView.java
ExpandableGridView.setAdapter
public final void setAdapter(@Nullable final ExpandableListAdapter adapter) { expandedGroups.clear(); if (adapter != null) { this.adapter = new AdapterWrapper(adapter); super.setAdapter(this.adapter); } else { this.adapter = null; super.setAdapter(null); } }
java
public final void setAdapter(@Nullable final ExpandableListAdapter adapter) { expandedGroups.clear(); if (adapter != null) { this.adapter = new AdapterWrapper(adapter); super.setAdapter(this.adapter); } else { this.adapter = null; super.setAdapter(null); } }
[ "public", "final", "void", "setAdapter", "(", "@", "Nullable", "final", "ExpandableListAdapter", "adapter", ")", "{", "expandedGroups", ".", "clear", "(", ")", ";", "if", "(", "adapter", "!=", "null", ")", "{", "this", ".", "adapter", "=", "new", "AdapterW...
Sets the adapter that provides data to this view. @param adapter The adapter, which should be set, as an instance of the type {@link ExpandableListAdapter} or null, if no adapter should be set
[ "Sets", "the", "adapter", "that", "provides", "data", "to", "this", "view", "." ]
67ec0e5732344eeb4d946dd1f96d782939e449f4
https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/view/ExpandableGridView.java#L764-L774
train
michael-rapp/AndroidUtil
library/src/main/java/de/mrapp/android/util/view/ExpandableGridView.java
ExpandableGridView.expandGroup
public final boolean expandGroup(final int groupIndex) { ExpandableListAdapter adapter = getExpandableListAdapter(); if (adapter != null && !isGroupExpanded(groupIndex)) { expandedGroups.add(groupIndex); notifyDataSetChanged(); return true; } return false; }
java
public final boolean expandGroup(final int groupIndex) { ExpandableListAdapter adapter = getExpandableListAdapter(); if (adapter != null && !isGroupExpanded(groupIndex)) { expandedGroups.add(groupIndex); notifyDataSetChanged(); return true; } return false; }
[ "public", "final", "boolean", "expandGroup", "(", "final", "int", "groupIndex", ")", "{", "ExpandableListAdapter", "adapter", "=", "getExpandableListAdapter", "(", ")", ";", "if", "(", "adapter", "!=", "null", "&&", "!", "isGroupExpanded", "(", "groupIndex", ")"...
Expands the group, which corresponds to a specific index. @param groupIndex The index of the group, which should be expanded, as an {@link Integer} value @return True, if the group has been expanded, false otherwise
[ "Expands", "the", "group", "which", "corresponds", "to", "a", "specific", "index", "." ]
67ec0e5732344eeb4d946dd1f96d782939e449f4
https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/view/ExpandableGridView.java#L806-L816
train
michael-rapp/AndroidUtil
library/src/main/java/de/mrapp/android/util/view/ExpandableGridView.java
ExpandableGridView.collapseGroup
public final boolean collapseGroup(final int groupIndex) { ExpandableListAdapter adapter = getExpandableListAdapter(); if (adapter != null && isGroupExpanded(groupIndex)) { expandedGroups.remove(groupIndex); notifyDataSetChanged(); return true; } return false; }
java
public final boolean collapseGroup(final int groupIndex) { ExpandableListAdapter adapter = getExpandableListAdapter(); if (adapter != null && isGroupExpanded(groupIndex)) { expandedGroups.remove(groupIndex); notifyDataSetChanged(); return true; } return false; }
[ "public", "final", "boolean", "collapseGroup", "(", "final", "int", "groupIndex", ")", "{", "ExpandableListAdapter", "adapter", "=", "getExpandableListAdapter", "(", ")", ";", "if", "(", "adapter", "!=", "null", "&&", "isGroupExpanded", "(", "groupIndex", ")", "...
Collapses the group, which corresponds to a specific index. @param groupIndex The index of the group, which should be collapsed, as an {@link Integer} value @return True if the group has been collapsed, false otherwise
[ "Collapses", "the", "group", "which", "corresponds", "to", "a", "specific", "index", "." ]
67ec0e5732344eeb4d946dd1f96d782939e449f4
https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/view/ExpandableGridView.java#L825-L835
train
avarabyeu/restendpoint
src/main/java/com/github/avarabyeu/restendpoint/serializer/StringSerializer.java
StringSerializer.validateString
private void validateString(Class<?> clazz) throws SerializerException { if (null != clazz && !clazz.isAssignableFrom(String.class)) { throw new SerializerException("String serializer is able to work only with data types assignable from java.lang.String"); } }
java
private void validateString(Class<?> clazz) throws SerializerException { if (null != clazz && !clazz.isAssignableFrom(String.class)) { throw new SerializerException("String serializer is able to work only with data types assignable from java.lang.String"); } }
[ "private", "void", "validateString", "(", "Class", "<", "?", ">", "clazz", ")", "throws", "SerializerException", "{", "if", "(", "null", "!=", "clazz", "&&", "!", "clazz", ".", "isAssignableFrom", "(", "String", ".", "class", ")", ")", "{", "throw", "new...
Validates that provided class is assignable from java.lang.String @param clazz Type of object to be validated @throws SerializerException
[ "Validates", "that", "provided", "class", "is", "assignable", "from", "java", ".", "lang", ".", "String" ]
e11fc0813ea4cefbe4d8bca292cd48b40abf185d
https://github.com/avarabyeu/restendpoint/blob/e11fc0813ea4cefbe4d8bca292cd48b40abf185d/src/main/java/com/github/avarabyeu/restendpoint/serializer/StringSerializer.java#L105-L109
train
avarabyeu/restendpoint
src/main/java/com/github/avarabyeu/restendpoint/serializer/StringSerializer.java
StringSerializer.validateString
private void validateString(Type type) throws SerializerException { if (null == type || !String.class.equals(TypeToken.of(type).getRawType())) { throw new SerializerException("String serializer is able to work only with data types assignable from java.lang.String"); } }
java
private void validateString(Type type) throws SerializerException { if (null == type || !String.class.equals(TypeToken.of(type).getRawType())) { throw new SerializerException("String serializer is able to work only with data types assignable from java.lang.String"); } }
[ "private", "void", "validateString", "(", "Type", "type", ")", "throws", "SerializerException", "{", "if", "(", "null", "==", "type", "||", "!", "String", ".", "class", ".", "equals", "(", "TypeToken", ".", "of", "(", "type", ")", ".", "getRawType", "(",...
Validates that provided type is assignable from java.lang.String @param type Type of object to be validated @throws SerializerException
[ "Validates", "that", "provided", "type", "is", "assignable", "from", "java", ".", "lang", ".", "String" ]
e11fc0813ea4cefbe4d8bca292cd48b40abf185d
https://github.com/avarabyeu/restendpoint/blob/e11fc0813ea4cefbe4d8bca292cd48b40abf185d/src/main/java/com/github/avarabyeu/restendpoint/serializer/StringSerializer.java#L117-L121
train
avarabyeu/restendpoint
src/main/java/com/github/avarabyeu/restendpoint/http/PreemptiveAuthInterceptor.java
PreemptiveAuthInterceptor.process
@Override public final void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException { AuthState authState = (AuthState) context.getAttribute(HttpClientContext.TARGET_AUTH_STATE); if (authState.getAuthScheme() == null) { HttpHost targetHost = (HttpHost) context.getAttribute(HttpCoreContext.HTTP_TARGET_HOST); AuthCache authCache = new BasicAuthCache(); authCache.put(targetHost, new BasicScheme()); context.setAttribute(HttpClientContext.AUTH_CACHE, authCache); } }
java
@Override public final void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException { AuthState authState = (AuthState) context.getAttribute(HttpClientContext.TARGET_AUTH_STATE); if (authState.getAuthScheme() == null) { HttpHost targetHost = (HttpHost) context.getAttribute(HttpCoreContext.HTTP_TARGET_HOST); AuthCache authCache = new BasicAuthCache(); authCache.put(targetHost, new BasicScheme()); context.setAttribute(HttpClientContext.AUTH_CACHE, authCache); } }
[ "@", "Override", "public", "final", "void", "process", "(", "final", "HttpRequest", "request", ",", "final", "HttpContext", "context", ")", "throws", "HttpException", ",", "IOException", "{", "AuthState", "authState", "=", "(", "AuthState", ")", "context", ".", ...
Adds provided auth scheme to the client if there are no another provided auth schemes
[ "Adds", "provided", "auth", "scheme", "to", "the", "client", "if", "there", "are", "no", "another", "provided", "auth", "schemes" ]
e11fc0813ea4cefbe4d8bca292cd48b40abf185d
https://github.com/avarabyeu/restendpoint/blob/e11fc0813ea4cefbe4d8bca292cd48b40abf185d/src/main/java/com/github/avarabyeu/restendpoint/http/PreemptiveAuthInterceptor.java#L44-L55
train
avarabyeu/restendpoint
src/main/java/com/github/avarabyeu/restendpoint/http/HttpClientRestEndpoint.java
HttpClientRestEndpoint.executeRequest
@Override public final <RQ, RS> Maybe<Response<RS>> executeRequest(RestCommand<RQ, RS> command) throws RestEndpointIOException { URI uri = spliceUrl(command.getUri()); HttpUriRequest rq; Serializer serializer; switch (command.getHttpMethod()) { case GET: rq = new HttpGet(uri); break; case POST: if (command.isMultipart()) { MultiPartRequest rqData = (MultiPartRequest) command.getRequest(); rq = buildMultipartRequest(uri, rqData); } else { serializer = getSupportedSerializer(command.getRequest()); rq = new HttpPost(uri); ((HttpPost) rq) .setEntity(new ByteArrayEntity(serializer.serialize(command.getRequest()), ContentType.create( serializer.getMimeType()))); } break; case PUT: serializer = getSupportedSerializer(command.getRequest()); rq = new HttpPut(uri); ((HttpPut) rq).setEntity(new ByteArrayEntity(serializer.serialize(command.getRequest()), ContentType.create( serializer.getMimeType()))); break; case DELETE: rq = new HttpDelete(uri); break; case PATCH: serializer = getSupportedSerializer(command.getRequest()); rq = new HttpPatch(uri); ((HttpPatch) rq) .setEntity(new ByteArrayEntity(serializer.serialize(command.getRequest()), ContentType.create( serializer.getMimeType()))); break; default: throw new IllegalArgumentException("Method '" + command.getHttpMethod() + "' is unsupported"); } return executeInternal(rq, new TypeConverterCallback<RS>(serializers, command.getResponseType())); }
java
@Override public final <RQ, RS> Maybe<Response<RS>> executeRequest(RestCommand<RQ, RS> command) throws RestEndpointIOException { URI uri = spliceUrl(command.getUri()); HttpUriRequest rq; Serializer serializer; switch (command.getHttpMethod()) { case GET: rq = new HttpGet(uri); break; case POST: if (command.isMultipart()) { MultiPartRequest rqData = (MultiPartRequest) command.getRequest(); rq = buildMultipartRequest(uri, rqData); } else { serializer = getSupportedSerializer(command.getRequest()); rq = new HttpPost(uri); ((HttpPost) rq) .setEntity(new ByteArrayEntity(serializer.serialize(command.getRequest()), ContentType.create( serializer.getMimeType()))); } break; case PUT: serializer = getSupportedSerializer(command.getRequest()); rq = new HttpPut(uri); ((HttpPut) rq).setEntity(new ByteArrayEntity(serializer.serialize(command.getRequest()), ContentType.create( serializer.getMimeType()))); break; case DELETE: rq = new HttpDelete(uri); break; case PATCH: serializer = getSupportedSerializer(command.getRequest()); rq = new HttpPatch(uri); ((HttpPatch) rq) .setEntity(new ByteArrayEntity(serializer.serialize(command.getRequest()), ContentType.create( serializer.getMimeType()))); break; default: throw new IllegalArgumentException("Method '" + command.getHttpMethod() + "' is unsupported"); } return executeInternal(rq, new TypeConverterCallback<RS>(serializers, command.getResponseType())); }
[ "@", "Override", "public", "final", "<", "RQ", ",", "RS", ">", "Maybe", "<", "Response", "<", "RS", ">", ">", "executeRequest", "(", "RestCommand", "<", "RQ", ",", "RS", ">", "command", ")", "throws", "RestEndpointIOException", "{", "URI", "uri", "=", ...
Executes request command @param command REST request representation @return Future wrapper of REST response @throws RestEndpointIOException In case of error @see Maybe
[ "Executes", "request", "command" ]
e11fc0813ea4cefbe4d8bca292cd48b40abf185d
https://github.com/avarabyeu/restendpoint/blob/e11fc0813ea4cefbe4d8bca292cd48b40abf185d/src/main/java/com/github/avarabyeu/restendpoint/http/HttpClientRestEndpoint.java#L399-L442
train
avarabyeu/restendpoint
src/main/java/com/github/avarabyeu/restendpoint/http/HttpClientRestEndpoint.java
HttpClientRestEndpoint.getSupportedSerializer
private Serializer getSupportedSerializer(Object o) throws SerializerException { for (Serializer s : serializers) { if (s.canWrite(o)) { return s; } } throw new SerializerException("Unable to find serializer for object with type '" + o.getClass() + "'"); }
java
private Serializer getSupportedSerializer(Object o) throws SerializerException { for (Serializer s : serializers) { if (s.canWrite(o)) { return s; } } throw new SerializerException("Unable to find serializer for object with type '" + o.getClass() + "'"); }
[ "private", "Serializer", "getSupportedSerializer", "(", "Object", "o", ")", "throws", "SerializerException", "{", "for", "(", "Serializer", "s", ":", "serializers", ")", "{", "if", "(", "s", ".", "canWrite", "(", "o", ")", ")", "{", "return", "s", ";", "...
Finds supported serializer for this type of object @param o Object to be serialized @return Serializer @throws SerializerException if serializer not found
[ "Finds", "supported", "serializer", "for", "this", "type", "of", "object" ]
e11fc0813ea4cefbe4d8bca292cd48b40abf185d
https://github.com/avarabyeu/restendpoint/blob/e11fc0813ea4cefbe4d8bca292cd48b40abf185d/src/main/java/com/github/avarabyeu/restendpoint/http/HttpClientRestEndpoint.java#L494-L501
train
michael-rapp/AndroidUtil
library/src/main/java/de/mrapp/android/util/view/ViewRecycler.java
ViewRecycler.inflate
@SafeVarargs @NonNull public final Pair<View, Boolean> inflate(@NonNull final ItemType item, @Nullable final ViewGroup parent, final boolean useCache, @NonNull final ParamType... params) { Condition.INSTANCE.ensureNotNull(params, "The array may not be null"); Condition.INSTANCE.ensureNotNull(getAdapter(), "No adapter has been set", IllegalStateException.class); View view = getView(item); boolean inflated = false; if (view == null) { int viewType = getAdapter().getViewType(item); if (useCache) { view = pollUnusedView(viewType); } if (view == null) { view = getAdapter() .onInflateView(getLayoutInflater(), parent, item, viewType, params); inflated = true; getLogger().logInfo(getClass(), "Inflated view to visualize item " + item + " using view type " + viewType); } else { getLogger().logInfo(getClass(), "Reusing view to visualize item " + item + " using view type " + viewType); } getActiveViews().put(item, view); } getAdapter().onShowView(getContext(), view, item, inflated, params); getLogger().logDebug(getClass(), "Updated view of item " + item); return Pair.create(view, inflated); }
java
@SafeVarargs @NonNull public final Pair<View, Boolean> inflate(@NonNull final ItemType item, @Nullable final ViewGroup parent, final boolean useCache, @NonNull final ParamType... params) { Condition.INSTANCE.ensureNotNull(params, "The array may not be null"); Condition.INSTANCE.ensureNotNull(getAdapter(), "No adapter has been set", IllegalStateException.class); View view = getView(item); boolean inflated = false; if (view == null) { int viewType = getAdapter().getViewType(item); if (useCache) { view = pollUnusedView(viewType); } if (view == null) { view = getAdapter() .onInflateView(getLayoutInflater(), parent, item, viewType, params); inflated = true; getLogger().logInfo(getClass(), "Inflated view to visualize item " + item + " using view type " + viewType); } else { getLogger().logInfo(getClass(), "Reusing view to visualize item " + item + " using view type " + viewType); } getActiveViews().put(item, view); } getAdapter().onShowView(getContext(), view, item, inflated, params); getLogger().logDebug(getClass(), "Updated view of item " + item); return Pair.create(view, inflated); }
[ "@", "SafeVarargs", "@", "NonNull", "public", "final", "Pair", "<", "View", ",", "Boolean", ">", "inflate", "(", "@", "NonNull", "final", "ItemType", "item", ",", "@", "Nullable", "final", "ViewGroup", "parent", ",", "final", "boolean", "useCache", ",", "@...
Inflates the view, which is used to visualize a specific item. @param item The item, which should be visualized by the inflated view, as an instance of the generic type ItemType. The item may not be null @param parent The parent of the inflated view as an instance of the class {@link ViewGroup} or null, if no parent is available @param useCache True, if an unused view should retrieved from the cache, if possible, false, if a new instance should be inflated instead @param params An array, which may contain optional parameters, as an array of the generic type ParamType or an empty array, if no optional parameters are available @return A pair, which contains the view, which is used to visualize the given item, as well as a boolean value, which indicates, whether a new view has been inflated, or if an unused view has been reused from the cache, as an instance of the class Pair. The pair may not be null
[ "Inflates", "the", "view", "which", "is", "used", "to", "visualize", "a", "specific", "item", "." ]
67ec0e5732344eeb4d946dd1f96d782939e449f4
https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/view/ViewRecycler.java#L111-L148
train