idx int64 0 165k | question stringlengths 73 4.15k | target stringlengths 5 918 | len_question int64 21 890 | len_target int64 3 255 |
|---|---|---|---|---|
7,600 | private T getAndClearUnderLock ( ) throws Throwable { if ( error != null ) { throw error ; } else { // Return and clear current T retValue = data ; data = null ; return retValue ; } } | Get and clear the slot - MUST be called while holding the lock!! | 47 | 14 |
7,601 | 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 getAndClearUnderLoc... | Blocking read and remove . If the thread was interrupted by the producer due to an error the producer s error will be thrown . | 97 | 26 |
7,602 | 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 . | 63 | 17 |
7,603 | 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_SCHE... | Creates a new thread - safe HTTP connection pool for use with a data source . | 285 | 17 |
7,604 | public void addTransition ( DuzztAction action , DuzztState succ ) { transitions . put ( action , new DuzztTransition ( action , succ ) ) ; } | Adds a transition to this state . | 39 | 7 |
7,605 | public static ObjectNode getObj ( ObjectNode obj , String fieldName ) { return obj != null ? obj ( obj . get ( fieldName ) ) : null ; } | Returns the field from a ObjectNode as ObjectNode | 35 | 10 |
7,606 | public static ObjectNode getObjAndRemove ( ObjectNode obj , String fieldName ) { ObjectNode result = null ; if ( obj != null ) { result = obj ( remove ( obj , fieldName ) ) ; } return result ; } | Removes the field from a ObjectNode and returns it as ObjectNode | 49 | 14 |
7,607 | 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 ) && fallbac... | Creates an ArrayNode from the given nodes . Returns an empty ArrayNode if no elements are provided and fallbackToEmptyArray is true null if false . | 109 | 32 |
7,608 | public static ArrayNode getArray ( ObjectNode obj , String fieldName ) { return obj == null ? null : array ( obj . get ( fieldName ) ) ; } | Returns the field from a ObjectNode as ArrayNode | 35 | 10 |
7,609 | public static ArrayNode getArrayAndRemove ( ObjectNode obj , String fieldName ) { ArrayNode result = null ; if ( obj != null ) { result = array ( remove ( obj , fieldName ) ) ; } return result ; } | Removes the field from a ObjectNode and returns it as ArrayNode | 49 | 14 |
7,610 | public static JsonNode remove ( ObjectNode obj , String fieldName ) { JsonNode result = null ; if ( obj != null ) { result = obj . remove ( fieldName ) ; } return result ; } | Removes the field with the given name from the given ObjectNode | 45 | 13 |
7,611 | 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 ) ; } } } | Renames a field in a ObjectNode from the oldFieldName to the newFieldName | 82 | 18 |
7,612 | private static final String stripParams ( String mediaType ) { int sc = mediaType . indexOf ( ' ' ) ; if ( sc >= 0 ) mediaType = mediaType . substring ( 0 , sc ) ; return mediaType ; } | Strips the parameters from the end of a mediaType description . | 51 | 14 |
7,613 | 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 th... | Gets the default content type to use when sending a query request with the given expected result type . | 136 | 20 |
7,614 | 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 . war... | 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 . | 323 | 43 |
7,615 | public static Filter equalsFilter ( String column , Object operand ) { return new Filter ( column , FilterOperator . EQUALS , operand ) ; } | Builds an EqualsFilter | 32 | 6 |
7,616 | public static Filter inFilter ( String column , Object operand ) { return new Filter ( column , FilterOperator . IN , operand ) ; } | Builds an InFilter | 31 | 5 |
7,617 | @ 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 ; } | Inflates an invisible placeholder view with a specific height . | 71 | 12 |
7,618 | 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_PAREN... | Returns the height of the view which corresponds to a specific position of an adapter . | 210 | 16 |
7,619 | 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 ( pare... | 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 . | 88 | 28 |
7,620 | 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 encapsulate... | 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 . | 95 | 30 |
7,621 | 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 ( positio... | Returns the index of the item which corresponds to a specific flattened position . | 158 | 14 |
7,622 | private int getNumberOfPlaceholderViews ( ) { int numColumns = getNumColumnsCompatible ( ) ; int adapterCount = adapter . getEncapsulatedAdapter ( ) . getCount ( ) ; int lastLineCount = adapterCount % numColumns ; return lastLineCount > 0 ? numColumns - lastLineCount : 0 ; } | Returns the number of placeholder views which are necessary to complement the items of the encapsulated adapter in order to fill up all columns .. | 75 | 26 |
7,623 | 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 ( ) ; } | 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 . | 74 | 33 |
7,624 | 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 ( ) ; } | 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 . | 76 | 33 |
7,625 | 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 ... | Send request for more data for this query . | 209 | 9 |
7,626 | 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" ) ; } } | URL - encode a string as UTF - 8 catching any thrown UnsupportedEncodingException . | 56 | 18 |
7,627 | @ 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 . a... | Logs a request executes it and dumps the response to the logger . For development use only . | 439 | 19 |
7,628 | 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... | Executes a SPARQL HTTP protocol request for the given command and returns the response . | 564 | 18 |
7,629 | 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 ) ; } | Add headers to a request . | 78 | 6 |
7,630 | @ 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 ( ) . ent... | Implements the rule which requests if two holidays have one non holiday between each other than this day is also a holiday . | 236 | 25 |
7,631 | public final void setLogLevel ( @ NonNull final LogLevel logLevel ) { Condition . INSTANCE . ensureNotNull ( logLevel , "The log level may not be null" ) ; this . logLevel = logLevel ; } | 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 . | 49 | 30 |
7,632 | 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... | Logs a specific message on the log level VERBOSE . | 140 | 13 |
7,633 | 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 m... | Logs a specific message on the log level DEBUG . | 136 | 11 |
7,634 | 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 ma... | Logs a specific message on the log level INFO . | 136 | 11 |
7,635 | 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 . ensureNo... | Logs a specific message and exception on the log level WARN . | 168 | 13 |
7,636 | 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 m... | Logs a specific message on the log level ERROR . | 136 | 11 |
7,637 | 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 = ... | Returns the orientation of the device . | 201 | 7 |
7,638 | 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 ) ) ; } | Returns the type of the device depending on its display size . | 60 | 12 |
7,639 | public static int getDisplayWidth ( @ NonNull final Context context ) { Condition . INSTANCE . ensureNotNull ( context , "The context may not be null" ) ; return context . getResources ( ) . getDisplayMetrics ( ) . widthPixels ; } | Returns the width of the device s display . | 56 | 9 |
7,640 | public static int getDisplayHeight ( @ NonNull final Context context ) { Condition . INSTANCE . ensureNotNull ( context , "The context may not be null" ) ; return context . getResources ( ) . getDisplayMetrics ( ) . heightPixels ; } | Returns the height of the device s display . | 56 | 9 |
7,641 | 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 )... | Given a FeedParition and Plan create a Driver that will consume from the feed partition and execute the plan . | 305 | 22 |
7,642 | 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 ) ; } e... | 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 | 271 | 32 |
7,643 | 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... | OperatorDesc can describe local reasources URL loaded resources and dynamic resources like groovy code . This method instantiates an Operator based on the OperatorDesc . | 287 | 32 |
7,644 | 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 ( ... | Build a feed using reflection | 120 | 5 |
7,645 | 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 b... | Calculates the sample size which should be used to downsample an image to a maximum width and height . | 201 | 22 |
7,646 | 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 .... | 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 . | 225 | 47 |
7,647 | 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 ... | 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 . | 382 | 53 |
7,648 | 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 ( ) ) ; } | Clips the long edge of a bitmap if its width and height are not equal in order to form it into a square . | 81 | 26 |
7,649 | @ 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 clippedBitma... | 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 . | 245 | 38 |
7,650 | 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 .... | 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 . | 100 | 33 |
7,651 | 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 ... | 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 . | 343 | 44 |
7,652 | 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 , ... | 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 . | 118 | 33 |
7,653 | public static Pair < Bitmap , Bitmap > splitHorizontally ( @ NonNull final Bitmap bitmap ) { return splitHorizontally ( bitmap , bitmap . getHeight ( ) / 2 ) ; } | Splits a specific bitmap horizontally at half . | 46 | 10 |
7,654 | 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 .... | Splits a specific bitmap horizontally at a specific split point . | 207 | 13 |
7,655 | public static Pair < Bitmap , Bitmap > splitVertically ( @ NonNull final Bitmap bitmap ) { return splitVertically ( bitmap , bitmap . getWidth ( ) / 2 ) ; } | Splits a specific bitmap vertically at half . | 44 | 10 |
7,656 | 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 . e... | Splits a specific bitmap vertically at a specific split point . | 206 | 13 |
7,657 | 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 ... | Creates and returns a bitmap with a specific width and height by tiling another bitmap . | 290 | 20 |
7,658 | 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 . g... | Creates and returns a bitmap by overlaying it with a specific color . | 111 | 16 |
7,659 | 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 ) { ret... | Creates and returns a bitmap from a specific drawable . | 266 | 13 |
7,660 | 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 ( w... | Creates and returns a bitmap from a specific color . | 152 | 12 |
7,661 | 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 . g... | Returns the width and height of a specific image file . | 183 | 11 |
7,662 | 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 . inJus... | Returns the width and height of a specific image resource . | 162 | 11 |
7,663 | 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 Bi... | Loads a downsampled thumbnail of a specific image file while maintaining its aspect ratio . | 162 | 18 |
7,664 | 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 no... | Compresses a specific bitmap and stores it within a file . | 250 | 13 |
7,665 | 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" ) ; ... | Compresses a specific bitmap and returns it as a byte array . | 230 | 14 |
7,666 | 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 ( ) ) ;... | Determines if the plan can be run . IE not disabled and not malformed | 104 | 17 |
7,667 | 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 ( ) ) ;... | Creates and returns a listener which allows to delegate when any item of the grid view has been clicked to the appropriate listeners . | 228 | 25 |
7,668 | 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 ... | Creates and returns a listener which allows to delegate when any item of the grid view has been long - clicked to the appropriate listeners . | 197 | 27 |
7,669 | 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 =... | Returns the packed position of an item which corresponds to a specific position . | 227 | 14 |
7,670 | 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 ; } | Returns the packed position of a group which corresponds to a specific index . | 80 | 14 |
7,671 | 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 == ... | Returns a pair which contains the group and child index of the item which corresponds to a specific packed position . | 229 | 21 |
7,672 | private boolean notifyOnGroupClicked ( @ NonNull final View view , final int groupIndex , final long id ) { return groupClickListener != null && groupClickListener . onGroupClick ( this , view , groupIndex , id ) ; } | Notifies the listener which has been registered to be notified when a group has been clicked about a group being clicked . | 51 | 23 |
7,673 | 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 ) ; } | Notifies the listener which has been registered to be notified when a child has been clicked about a child being clicked . | 59 | 23 |
7,674 | private void notifyOnItemClicked ( @ NonNull final View view , final int position , final long id ) { if ( itemClickListener != null ) { itemClickListener . onItemClick ( this , view , position , id ) ; } } | Notifies the listener which has been registered to be notified when any item has been clicked about an item being clicked . | 52 | 23 |
7,675 | private boolean notifyOnItemLongClicked ( @ NonNull final View view , final int position , final long id ) { return itemLongClickListener != null && itemLongClickListener . onItemLongClick ( this , view , position , id ) ; } | Notifies the listener which has been registered to be notified when any item has been long - clicked about an item being long - clicked . | 53 | 27 |
7,676 | 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 ; } | Returns the type of the item which corresponds to a specific packed position . | 93 | 14 |
7,677 | 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 ) ; } } | Sets the adapter that provides data to this view . | 73 | 11 |
7,678 | public final boolean expandGroup ( final int groupIndex ) { ExpandableListAdapter adapter = getExpandableListAdapter ( ) ; if ( adapter != null && ! isGroupExpanded ( groupIndex ) ) { expandedGroups . add ( groupIndex ) ; notifyDataSetChanged ( ) ; return true ; } return false ; } | Expands the group which corresponds to a specific index . | 69 | 11 |
7,679 | public final boolean collapseGroup ( final int groupIndex ) { ExpandableListAdapter adapter = getExpandableListAdapter ( ) ; if ( adapter != null && isGroupExpanded ( groupIndex ) ) { expandedGroups . remove ( groupIndex ) ; notifyDataSetChanged ( ) ; return true ; } return false ; } | Collapses the group which corresponds to a specific index . | 68 | 11 |
7,680 | 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" ) ; } } | Validates that provided class is assignable from java . lang . String | 71 | 14 |
7,681 | 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" ) ; } } | Validates that provided type is assignable from java . lang . String | 73 | 14 |
7,682 | @ 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 ) con... | Adds provided auth scheme to the client if there are no another provided auth schemes | 151 | 15 |
7,683 | @ 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 ) ; brea... | Executes request command | 478 | 4 |
7,684 | 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 ( ) + "'" ) ; } | Finds supported serializer for this type of object | 74 | 10 |
7,685 | @ 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 . ensureNotNul... | Inflates the view which is used to visualize a specific item . | 344 | 14 |
7,686 | private static void mkdir ( @ NonNull final File directory , final boolean createParents ) throws IOException { Condition . INSTANCE . ensureNotNull ( directory , "The directory may not be null" ) ; boolean result = createParents ? directory . mkdirs ( ) : directory . mkdir ( ) ; if ( ! result && ! directory . exists (... | Creates a specific directory if it does not already exist . | 100 | 12 |
7,687 | public static void deleteRecursively ( @ NonNull final File file ) throws IOException { Condition . INSTANCE . ensureNotNull ( file , "The file or directory may not be null" ) ; if ( file . isDirectory ( ) ) { for ( File child : file . listFiles ( ) ) { deleteRecursively ( child ) ; } } delete ( file ) ; } | Deletes a specific file or directory . If the file is a directory all contained files and subdirectories are deleted recursively . | 81 | 27 |
7,688 | public static void createNewFile ( @ NonNull final File file , final boolean overwrite ) throws IOException { Condition . INSTANCE . ensureNotNull ( file , "The file may not be null" ) ; boolean result = file . createNewFile ( ) ; if ( ! result ) { if ( overwrite ) { try { delete ( file ) ; createNewFile ( file , false... | Creates a new empty file . | 166 | 7 |
7,689 | public void maybeDoOffset ( ) { long seen = tuplesSeen ; if ( offsetCommitInterval > 0 && seen % offsetCommitInterval == 0 && offsetStorage != null && fp . supportsOffsetManagement ( ) ) { doOffsetInternal ( ) ; } } | To do offset storage we let the topology drain itself out . Then we commit . | 59 | 17 |
7,690 | private static TypedArray obtainStyledAttributes ( @ NonNull final Context context , @ StyleRes final int themeResourceId , @ AttrRes final int resourceId ) { Condition . INSTANCE . ensureNotNull ( context , "The context may not be null" ) ; Theme theme = context . getTheme ( ) ; int [ ] attrs = new int [ ] { resourceI... | Obtains the attribute which corresponds to a specific resource id from a theme . | 125 | 15 |
7,691 | public static boolean getBoolean ( @ NonNull final Context context , @ StyleRes final int themeResourceId , @ AttrRes final int resourceId ) { TypedArray typedArray = null ; try { typedArray = obtainStyledAttributes ( context , themeResourceId , resourceId ) ; return typedArray . getBoolean ( 0 , false ) ; } finally { ... | Obtains the boolean value which corresponds to a specific resource id from a specific theme . | 95 | 17 |
7,692 | public static boolean getBoolean ( @ NonNull final Context context , @ AttrRes final int resourceId , final boolean defaultValue ) { return getBoolean ( context , - 1 , resourceId , defaultValue ) ; } | Obtains the boolean value which corresponds to a specific resource id from a context s theme . | 47 | 18 |
7,693 | public static int getInt ( @ NonNull final Context context , @ AttrRes final int resourceId , final int defaultValue ) { return getInt ( context , - 1 , resourceId , defaultValue ) ; } | Obtains the integer value which corresponds to a specific resource id from a context s theme . | 45 | 18 |
7,694 | public static float getFloat ( @ NonNull final Context context , @ AttrRes final int resourceId , final float defaultValue ) { return getFloat ( context , - 1 , resourceId , defaultValue ) ; } | Obtains the float value which corresponds to a specific resource id from a context s theme . | 45 | 18 |
7,695 | public static int getResId ( @ NonNull final Context context , @ AttrRes final int resourceId , final int defaultValue ) { return getResId ( context , - 1 , resourceId , defaultValue ) ; } | Obtains the resource id which corresponds to a specific resource id from a context s theme . | 47 | 18 |
7,696 | void setRequest ( HttpUriRequest request ) { requestLock . lock ( ) ; try { if ( this . request != null ) { throw new SparqlException ( "Command is already executing a request." ) ; } this . request = request ; } finally { requestLock . unlock ( ) ; } } | Sets the currently executing request . | 66 | 7 |
7,697 | private Result execute ( ResultType cmdType ) throws SparqlException { String mimeType = contentType ; // Validate the user-supplied MIME type. if ( mimeType != null && ! ResultFactory . supports ( mimeType , cmdType ) ) { logger . warn ( "Requested MIME content type '{}' does not support expected response type: {}" , ... | Executes the request and parses the response . | 230 | 10 |
7,698 | private void logRequest ( ResultType cmdType , String mimeType ) { StringBuilder sb = new StringBuilder ( "Executing SPARQL protocol request " ) ; sb . append ( "to endpoint <" ) . append ( ( ( ProtocolDataSource ) getConnection ( ) . getDataSource ( ) ) . getUrl ( ) ) . append ( "> " ) ; if ( mimeType != null ) { sb .... | Log the enpoint URL and request parameters . | 199 | 9 |
7,699 | public void initialize ( ) { thread = new Thread ( collectorProcessor ) ; thread . start ( ) ; for ( DriverNode dn : this . children ) { dn . initialize ( ) ; } } | initialize driver node and all children of the node | 43 | 10 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.