idx int64 0 41.2k | question stringlengths 74 4.21k | target stringlengths 5 888 |
|---|---|---|
33,000 | public void extract ( final InputStream inputStream , final Metadata metadata ) throws IOException { RandomAccessStreamReader reader = new RandomAccessStreamReader ( inputStream ) ; EpsDirectory directory = new EpsDirectory ( ) ; metadata . addDirectory ( directory ) ; switch ( reader . getInt32 ( 0 ) ) { case 0xC5D0D3C6 : reader . setMotorolaByteOrder ( false ) ; int postScriptOffset = reader . getInt32 ( 4 ) ; int postScriptLength = reader . getInt32 ( 8 ) ; int wmfOffset = reader . getInt32 ( 12 ) ; int wmfSize = reader . getInt32 ( 16 ) ; int tifOffset = reader . getInt32 ( 20 ) ; int tifSize = reader . getInt32 ( 24 ) ; if ( tifSize != 0 ) { directory . setInt ( EpsDirectory . TAG_TIFF_PREVIEW_SIZE , tifSize ) ; directory . setInt ( EpsDirectory . TAG_TIFF_PREVIEW_OFFSET , tifOffset ) ; try { ByteArrayReader byteArrayReader = new ByteArrayReader ( reader . getBytes ( tifOffset , tifSize ) ) ; new TiffReader ( ) . processTiff ( byteArrayReader , new PhotoshopTiffHandler ( metadata , null ) , 0 ) ; } catch ( TiffProcessingException ex ) { directory . addError ( "Unable to process TIFF data: " + ex . getMessage ( ) ) ; } } else if ( wmfSize != 0 ) { directory . setInt ( EpsDirectory . TAG_WMF_PREVIEW_SIZE , wmfSize ) ; directory . setInt ( EpsDirectory . TAG_WMF_PREVIEW_OFFSET , wmfOffset ) ; } extract ( directory , metadata , new SequentialByteArrayReader ( reader . getBytes ( postScriptOffset , postScriptLength ) ) ) ; break ; case 0x25215053 : inputStream . reset ( ) ; extract ( directory , metadata , new StreamReader ( inputStream ) ) ; break ; default : directory . addError ( "File type not supported." ) ; break ; } } | Filter method that determines if file will contain an EPS Header . If it does it will read the necessary data and then set the position to the beginning of the PostScript data . If it does not the position will not be changed . After both scenarios the main extract method is called . |
33,001 | private void addToDirectory ( final EpsDirectory directory , String name , String value ) throws IOException { Integer tag = EpsDirectory . _tagIntegerMap . get ( name ) ; if ( tag == null ) return ; switch ( tag ) { case EpsDirectory . TAG_IMAGE_DATA : extractImageData ( directory , value ) ; break ; case EpsDirectory . TAG_CONTINUE_LINE : directory . setString ( _previousTag , directory . getString ( _previousTag ) + " " + value ) ; break ; default : if ( EpsDirectory . _tagNameMap . containsKey ( tag ) && ! directory . containsTag ( tag ) ) { directory . setString ( tag , value ) ; _previousTag = tag ; } else { _previousTag = 0 ; } break ; } _previousTag = tag ; } | Default case that adds comment with keyword to directory |
33,002 | private static int tryHexToInt ( byte b ) { if ( b >= '0' && b <= '9' ) return b - '0' ; if ( b >= 'A' && b <= 'F' ) return b - 'A' + 10 ; if ( b >= 'a' && b <= 'f' ) return b - 'a' + 10 ; return - 1 ; } | Treats a byte as an ASCII character and returns it s numerical value in hexadecimal . If conversion is not possible returns - 1 . |
33,003 | public GeoLocation getGeoLocation ( ) { Rational [ ] latitudes = getRationalArray ( TAG_LATITUDE ) ; Rational [ ] longitudes = getRationalArray ( TAG_LONGITUDE ) ; String latitudeRef = getString ( TAG_LATITUDE_REF ) ; String longitudeRef = getString ( TAG_LONGITUDE_REF ) ; if ( latitudes == null || latitudes . length != 3 ) return null ; if ( longitudes == null || longitudes . length != 3 ) return null ; if ( latitudeRef == null || longitudeRef == null ) return null ; Double lat = GeoLocation . degreesMinutesSecondsToDecimal ( latitudes [ 0 ] , latitudes [ 1 ] , latitudes [ 2 ] , latitudeRef . equalsIgnoreCase ( "S" ) ) ; Double lon = GeoLocation . degreesMinutesSecondsToDecimal ( longitudes [ 0 ] , longitudes [ 1 ] , longitudes [ 2 ] , longitudeRef . equalsIgnoreCase ( "W" ) ) ; if ( lat == null || lon == null ) return null ; return new GeoLocation ( lat , lon ) ; } | Parses various tags in an attempt to obtain a single object representing the latitude and longitude at which this image was captured . |
33,004 | public Date getGpsDate ( ) { String date = getString ( TAG_DATE_STAMP ) ; Rational [ ] timeComponents = getRationalArray ( TAG_TIME_STAMP ) ; if ( date == null ) return null ; if ( timeComponents == null || timeComponents . length != 3 ) return null ; String dateTime = String . format ( Locale . US , "%s %02d:%02d:%02.3f UTC" , date , timeComponents [ 0 ] . intValue ( ) , timeComponents [ 1 ] . intValue ( ) , timeComponents [ 2 ] . doubleValue ( ) ) ; try { DateFormat parser = new SimpleDateFormat ( "yyyy:MM:dd HH:mm:ss.S z" ) ; return parser . parse ( dateTime ) ; } catch ( ParseException e ) { return null ; } } | Parses the date stamp tag and the time stamp tag to obtain a single Date object representing the date and time when this image was captured . |
33,005 | public boolean getBit ( int index ) throws IOException { int byteIndex = index / 8 ; int bitIndex = index % 8 ; validateIndex ( byteIndex , 1 ) ; byte b = getByte ( byteIndex ) ; return ( ( b >> bitIndex ) & 1 ) == 1 ; } | Gets whether a bit at a specific index is set or not . |
33,006 | public int getUInt16 ( int index ) throws IOException { validateIndex ( index , 2 ) ; if ( _isMotorolaByteOrder ) { return ( getByte ( index ) << 8 & 0xFF00 ) | ( getByte ( index + 1 ) & 0xFF ) ; } else { return ( getByte ( index + 1 ) << 8 & 0xFF00 ) | ( getByte ( index ) & 0xFF ) ; } } | Returns an unsigned 16 - bit int calculated from two bytes of data at the specified index . |
33,007 | public int getInt24 ( int index ) throws IOException { validateIndex ( index , 3 ) ; if ( _isMotorolaByteOrder ) { return ( ( ( int ) getByte ( index ) ) << 16 & 0xFF0000 ) | ( ( ( int ) getByte ( index + 1 ) ) << 8 & 0xFF00 ) | ( ( ( int ) getByte ( index + 2 ) ) & 0xFF ) ; } else { return ( ( ( int ) getByte ( index + 2 ) ) << 16 & 0xFF0000 ) | ( ( ( int ) getByte ( index + 1 ) ) << 8 & 0xFF00 ) | ( ( ( int ) getByte ( index ) ) & 0xFF ) ; } } | Get a 24 - bit unsigned integer from the buffer returning it as an int . |
33,008 | public int getInt32 ( int index ) throws IOException { validateIndex ( index , 4 ) ; if ( _isMotorolaByteOrder ) { return ( getByte ( index ) << 24 & 0xFF000000 ) | ( getByte ( index + 1 ) << 16 & 0xFF0000 ) | ( getByte ( index + 2 ) << 8 & 0xFF00 ) | ( getByte ( index + 3 ) & 0xFF ) ; } else { return ( getByte ( index + 3 ) << 24 & 0xFF000000 ) | ( getByte ( index + 2 ) << 16 & 0xFF0000 ) | ( getByte ( index + 1 ) << 8 & 0xFF00 ) | ( getByte ( index ) & 0xFF ) ; } } | Returns a signed 32 - bit integer from four bytes of data at the specified index the buffer . |
33,009 | protected String getEncodedTextDescription ( int tagType ) { byte [ ] commentBytes = _directory . getByteArray ( tagType ) ; if ( commentBytes == null ) return null ; if ( commentBytes . length == 0 ) return "" ; final Map < String , String > encodingMap = new HashMap < String , String > ( ) ; encodingMap . put ( "ASCII" , System . getProperty ( "file.encoding" ) ) ; encodingMap . put ( "UNICODE" , "UTF-16LE" ) ; encodingMap . put ( "JIS" , "Shift-JIS" ) ; try { if ( commentBytes . length >= 10 ) { String firstTenBytesString = new String ( commentBytes , 0 , 10 ) ; for ( Map . Entry < String , String > pair : encodingMap . entrySet ( ) ) { String encodingName = pair . getKey ( ) ; String charset = pair . getValue ( ) ; if ( firstTenBytesString . startsWith ( encodingName ) ) { for ( int j = encodingName . length ( ) ; j < 10 ; j ++ ) { byte b = commentBytes [ j ] ; if ( b != '\0' && b != ' ' ) return new String ( commentBytes , j , commentBytes . length - j , charset ) . trim ( ) ; } return new String ( commentBytes , 10 , commentBytes . length - 10 , charset ) . trim ( ) ; } } } return new String ( commentBytes , System . getProperty ( "file.encoding" ) ) . trim ( ) ; } catch ( UnsupportedEncodingException ex ) { return null ; } } | EXIF UserComment GPSProcessingMethod and GPSAreaInformation |
33,010 | public int getInt32 ( ) throws IOException { if ( _isMotorolaByteOrder ) { return ( getByte ( ) << 24 & 0xFF000000 ) | ( getByte ( ) << 16 & 0xFF0000 ) | ( getByte ( ) << 8 & 0xFF00 ) | ( getByte ( ) & 0xFF ) ; } else { return ( getByte ( ) & 0xFF ) | ( getByte ( ) << 8 & 0xFF00 ) | ( getByte ( ) << 16 & 0xFF0000 ) | ( getByte ( ) << 24 & 0xFF000000 ) ; } } | Returns a signed 32 - bit integer from four bytes of data . |
33,011 | void draw ( Canvas canvas ) { mCanvasRect . set ( 0.0f , 0.0f , canvas . getWidth ( ) , canvas . getHeight ( ) ) ; switch ( mShape ) { case SHAPE_RECTANGLE : canvas . drawRect ( mCanvasRect , mCanvasPaint ) ; break ; case SHAPE_OVAL : canvas . drawOval ( mCanvasRect , mCanvasPaint ) ; break ; case SHAPE_STAR_3_VERTICES : case SHAPE_STAR_4_VERTICES : case SHAPE_STAR_5_VERTICES : case SHAPE_STAR_6_VERTICES : drawStar ( canvas , mShape ) ; break ; case SHAPE_HEART : drawHeart ( canvas ) ; break ; } } | draw s specified shape |
33,012 | private void refreshMargin ( ) { if ( isWeakReferenceValid ( ) ) { ViewGroup . MarginLayoutParams layoutParams = ( ViewGroup . MarginLayoutParams ) getTextView ( ) . get ( ) . getLayoutParams ( ) ; layoutParams . bottomMargin = mEdgeMarginInPx ; layoutParams . topMargin = mEdgeMarginInPx ; layoutParams . rightMargin = mEdgeMarginInPx ; layoutParams . leftMargin = mEdgeMarginInPx ; getTextView ( ) . get ( ) . setLayoutParams ( layoutParams ) ; } } | refresh s margin if set |
33,013 | private void refreshDrawable ( ) { if ( isWeakReferenceValid ( ) ) { TextView textView = getTextView ( ) . get ( ) ; textView . setBackgroundDrawable ( getBadgeDrawable ( textView . getContext ( ) ) ) ; } } | refresh s background drawable |
33,014 | private void setTextColor ( ) { if ( isWeakReferenceValid ( ) ) { TextView textView = getTextView ( ) . get ( ) ; textView . setTextColor ( getTextColor ( textView . getContext ( ) ) ) ; } } | set s new text color |
33,015 | void bindToBottomTab ( BottomNavigationTab bottomNavigationTab ) { bottomNavigationTab . badgeView . clearPrevious ( ) ; if ( bottomNavigationTab . badgeItem != null ) { bottomNavigationTab . badgeItem . setTextView ( null ) ; } bottomNavigationTab . setBadgeItem ( this ) ; setTextView ( bottomNavigationTab . badgeView ) ; bindToBottomTabInternal ( bottomNavigationTab ) ; bottomNavigationTab . badgeView . setVisibility ( View . VISIBLE ) ; FrameLayout . LayoutParams layoutParams = ( FrameLayout . LayoutParams ) bottomNavigationTab . badgeView . getLayoutParams ( ) ; layoutParams . gravity = getGravity ( ) ; bottomNavigationTab . badgeView . setLayoutParams ( layoutParams ) ; if ( isHidden ( ) ) { hide ( ) ; } } | binds all badgeItem BottomNavigationTab and BadgeTextView |
33,016 | public static int fetchContextColor ( Context context , int androidAttribute ) { TypedValue typedValue = new TypedValue ( ) ; TypedArray a = context . obtainStyledAttributes ( typedValue . data , new int [ ] { androidAttribute } ) ; int color = a . getColor ( 0 , 0 ) ; a . recycle ( ) ; return color ; } | This method can be extended to get all android attributes color string dimension ... etc |
33,017 | private void parseAttrs ( Context context , AttributeSet attrs ) { if ( attrs != null ) { TypedArray typedArray = context . getTheme ( ) . obtainStyledAttributes ( attrs , R . styleable . BottomNavigationBar , 0 , 0 ) ; mActiveColor = typedArray . getColor ( R . styleable . BottomNavigationBar_bnbActiveColor , Utils . fetchContextColor ( context , R . attr . colorAccent ) ) ; mInActiveColor = typedArray . getColor ( R . styleable . BottomNavigationBar_bnbInactiveColor , Color . LTGRAY ) ; mBackgroundColor = typedArray . getColor ( R . styleable . BottomNavigationBar_bnbBackgroundColor , Color . WHITE ) ; mAutoHideEnabled = typedArray . getBoolean ( R . styleable . BottomNavigationBar_bnbAutoHideEnabled , true ) ; mElevation = typedArray . getDimension ( R . styleable . BottomNavigationBar_bnbElevation , getResources ( ) . getDimension ( R . dimen . bottom_navigation_elevation ) ) ; setAnimationDuration ( typedArray . getInt ( R . styleable . BottomNavigationBar_bnbAnimationDuration , DEFAULT_ANIMATION_DURATION ) ) ; switch ( typedArray . getInt ( R . styleable . BottomNavigationBar_bnbMode , MODE_DEFAULT ) ) { case MODE_FIXED : mMode = MODE_FIXED ; break ; case MODE_SHIFTING : mMode = MODE_SHIFTING ; break ; case MODE_FIXED_NO_TITLE : mMode = MODE_FIXED_NO_TITLE ; break ; case MODE_SHIFTING_NO_TITLE : mMode = MODE_SHIFTING_NO_TITLE ; break ; case MODE_DEFAULT : default : mMode = MODE_DEFAULT ; break ; } switch ( typedArray . getInt ( R . styleable . BottomNavigationBar_bnbBackgroundStyle , BACKGROUND_STYLE_DEFAULT ) ) { case BACKGROUND_STYLE_STATIC : mBackgroundStyle = BACKGROUND_STYLE_STATIC ; break ; case BACKGROUND_STYLE_RIPPLE : mBackgroundStyle = BACKGROUND_STYLE_RIPPLE ; break ; case BACKGROUND_STYLE_DEFAULT : default : mBackgroundStyle = BACKGROUND_STYLE_DEFAULT ; break ; } typedArray . recycle ( ) ; } else { mActiveColor = Utils . fetchContextColor ( context , R . attr . colorAccent ) ; mInActiveColor = Color . LTGRAY ; mBackgroundColor = Color . WHITE ; mElevation = getResources ( ) . getDimension ( R . dimen . bottom_navigation_elevation ) ; } } | This method initiates the bottomNavigationBar properties Tries to get them form XML if not preset sets them to their default values . |
33,018 | private void init ( ) { setLayoutParams ( new ViewGroup . LayoutParams ( new ViewGroup . LayoutParams ( ViewGroup . LayoutParams . MATCH_PARENT , ViewGroup . LayoutParams . WRAP_CONTENT ) ) ) ; LayoutInflater inflater = LayoutInflater . from ( getContext ( ) ) ; View parentView = inflater . inflate ( R . layout . bottom_navigation_bar_container , this , true ) ; mBackgroundOverlay = parentView . findViewById ( R . id . bottom_navigation_bar_overLay ) ; mContainer = parentView . findViewById ( R . id . bottom_navigation_bar_container ) ; mTabContainer = parentView . findViewById ( R . id . bottom_navigation_bar_item_container ) ; if ( Build . VERSION . SDK_INT >= Build . VERSION_CODES . LOLLIPOP ) { this . setOutlineProvider ( ViewOutlineProvider . BOUNDS ) ; } else { } ViewCompat . setElevation ( this , mElevation ) ; setClipToPadding ( false ) ; } | This method initiates the bottomNavigationBar and handles layout related values |
33,019 | public void initialise ( ) { mSelectedPosition = DEFAULT_SELECTED_POSITION ; mBottomNavigationTabs . clear ( ) ; if ( ! mBottomNavigationItems . isEmpty ( ) ) { mTabContainer . removeAllViews ( ) ; if ( mMode == MODE_DEFAULT ) { if ( mBottomNavigationItems . size ( ) <= MIN_SIZE ) { mMode = MODE_FIXED ; } else { mMode = MODE_SHIFTING ; } } if ( mBackgroundStyle == BACKGROUND_STYLE_DEFAULT ) { if ( mMode == MODE_FIXED ) { mBackgroundStyle = BACKGROUND_STYLE_STATIC ; } else { mBackgroundStyle = BACKGROUND_STYLE_RIPPLE ; } } if ( mBackgroundStyle == BACKGROUND_STYLE_STATIC ) { mBackgroundOverlay . setVisibility ( View . GONE ) ; mContainer . setBackgroundColor ( mBackgroundColor ) ; } int screenWidth = Utils . getScreenWidth ( getContext ( ) ) ; if ( mMode == MODE_FIXED || mMode == MODE_FIXED_NO_TITLE ) { int [ ] widths = BottomNavigationHelper . getMeasurementsForFixedMode ( getContext ( ) , screenWidth , mBottomNavigationItems . size ( ) , mScrollable ) ; int itemWidth = widths [ 0 ] ; for ( BottomNavigationItem currentItem : mBottomNavigationItems ) { FixedBottomNavigationTab bottomNavigationTab = new FixedBottomNavigationTab ( getContext ( ) ) ; setUpTab ( mMode == MODE_FIXED_NO_TITLE , bottomNavigationTab , currentItem , itemWidth , itemWidth ) ; } } else if ( mMode == MODE_SHIFTING || mMode == MODE_SHIFTING_NO_TITLE ) { int [ ] widths = BottomNavigationHelper . getMeasurementsForShiftingMode ( getContext ( ) , screenWidth , mBottomNavigationItems . size ( ) , mScrollable ) ; int itemWidth = widths [ 0 ] ; int itemActiveWidth = widths [ 1 ] ; for ( BottomNavigationItem currentItem : mBottomNavigationItems ) { ShiftingBottomNavigationTab bottomNavigationTab = new ShiftingBottomNavigationTab ( getContext ( ) ) ; setUpTab ( mMode == MODE_SHIFTING_NO_TITLE , bottomNavigationTab , currentItem , itemWidth , itemActiveWidth ) ; } } if ( mBottomNavigationTabs . size ( ) > mFirstSelectedPosition ) { selectTabInternal ( mFirstSelectedPosition , true , false , false ) ; } else if ( ! mBottomNavigationTabs . isEmpty ( ) ) { selectTabInternal ( 0 , true , false , false ) ; } } } | This method should be called at the end of all customisation method . This method will take all changes in to consideration and redraws tabs . |
33,020 | public void clearAll ( ) { mTabContainer . removeAllViews ( ) ; mBottomNavigationTabs . clear ( ) ; mBottomNavigationItems . clear ( ) ; mBackgroundOverlay . setVisibility ( View . GONE ) ; mContainer . setBackgroundColor ( Color . TRANSPARENT ) ; mSelectedPosition = DEFAULT_SELECTED_POSITION ; } | Clears all stored data and this helps to re - initialise tabs from scratch |
33,021 | private void setUpTab ( boolean isNoTitleMode , BottomNavigationTab bottomNavigationTab , BottomNavigationItem currentItem , int itemWidth , int itemActiveWidth ) { bottomNavigationTab . setIsNoTitleMode ( isNoTitleMode ) ; bottomNavigationTab . setInactiveWidth ( itemWidth ) ; bottomNavigationTab . setActiveWidth ( itemActiveWidth ) ; bottomNavigationTab . setPosition ( mBottomNavigationItems . indexOf ( currentItem ) ) ; bottomNavigationTab . setOnClickListener ( new OnClickListener ( ) { public void onClick ( View v ) { BottomNavigationTab bottomNavigationTabView = ( BottomNavigationTab ) v ; selectTabInternal ( bottomNavigationTabView . getPosition ( ) , false , true , false ) ; } } ) ; mBottomNavigationTabs . add ( bottomNavigationTab ) ; BottomNavigationHelper . bindTabWithData ( currentItem , bottomNavigationTab , this ) ; bottomNavigationTab . initialise ( mBackgroundStyle == BACKGROUND_STYLE_STATIC ) ; mTabContainer . addView ( bottomNavigationTab ) ; } | Internal method to setup tabs |
33,022 | private void selectTabInternal ( int newPosition , boolean firstTab , boolean callListener , boolean forcedSelection ) { int oldPosition = mSelectedPosition ; if ( mSelectedPosition != newPosition ) { if ( mBackgroundStyle == BACKGROUND_STYLE_STATIC ) { if ( mSelectedPosition != - 1 ) mBottomNavigationTabs . get ( mSelectedPosition ) . unSelect ( true , mAnimationDuration ) ; mBottomNavigationTabs . get ( newPosition ) . select ( true , mAnimationDuration ) ; } else if ( mBackgroundStyle == BACKGROUND_STYLE_RIPPLE ) { if ( mSelectedPosition != - 1 ) mBottomNavigationTabs . get ( mSelectedPosition ) . unSelect ( false , mAnimationDuration ) ; mBottomNavigationTabs . get ( newPosition ) . select ( false , mAnimationDuration ) ; final BottomNavigationTab clickedView = mBottomNavigationTabs . get ( newPosition ) ; if ( firstTab ) { mContainer . setBackgroundColor ( clickedView . getActiveColor ( ) ) ; mBackgroundOverlay . setVisibility ( View . GONE ) ; } else { mBackgroundOverlay . post ( new Runnable ( ) { public void run ( ) { BottomNavigationHelper . setBackgroundWithRipple ( clickedView , mContainer , mBackgroundOverlay , clickedView . getActiveColor ( ) , mRippleAnimationDuration ) ; } } ) ; } } mSelectedPosition = newPosition ; } if ( callListener ) { sendListenerCall ( oldPosition , newPosition , forcedSelection ) ; } } | Internal Method to select a tab |
33,023 | private void sendListenerCall ( int oldPosition , int newPosition , boolean forcedSelection ) { if ( mTabSelectedListener != null ) { if ( forcedSelection ) { mTabSelectedListener . onTabSelected ( newPosition ) ; } else { if ( oldPosition == newPosition ) { mTabSelectedListener . onTabReselected ( newPosition ) ; } else { mTabSelectedListener . onTabSelected ( newPosition ) ; if ( oldPosition != - 1 ) { mTabSelectedListener . onTabUnselected ( oldPosition ) ; } } } } } | Internal method used to send callbacks to listener |
33,024 | void setDimens ( int width , int height ) { mAreDimensOverridden = true ; mDesiredWidth = width ; mDesiredHeight = height ; requestLayout ( ) ; } | if width and height of the view needs to be changed |
33,025 | static int [ ] getMeasurementsForFixedMode ( Context context , int screenWidth , int noOfTabs , boolean scrollable ) { int [ ] result = new int [ 2 ] ; int minWidth = ( int ) context . getResources ( ) . getDimension ( R . dimen . fixed_min_width_small_views ) ; int maxWidth = ( int ) context . getResources ( ) . getDimension ( R . dimen . fixed_min_width ) ; int itemWidth = screenWidth / noOfTabs ; if ( itemWidth < minWidth && scrollable ) { itemWidth = ( int ) context . getResources ( ) . getDimension ( R . dimen . fixed_min_width ) ; } else if ( itemWidth > maxWidth ) { itemWidth = maxWidth ; } result [ 0 ] = itemWidth ; return result ; } | Used to get Measurements for MODE_FIXED |
33,026 | static int [ ] getMeasurementsForShiftingMode ( Context context , int screenWidth , int noOfTabs , boolean scrollable ) { int [ ] result = new int [ 2 ] ; int minWidth = ( int ) context . getResources ( ) . getDimension ( R . dimen . shifting_min_width_inactive ) ; int maxWidth = ( int ) context . getResources ( ) . getDimension ( R . dimen . shifting_max_width_inactive ) ; double minPossibleWidth = minWidth * ( noOfTabs + 0.5 ) ; double maxPossibleWidth = maxWidth * ( noOfTabs + 0.75 ) ; int itemWidth ; int itemActiveWidth ; if ( screenWidth < minPossibleWidth ) { if ( scrollable ) { itemWidth = minWidth ; itemActiveWidth = ( int ) ( minWidth * 1.5 ) ; } else { itemWidth = ( int ) ( screenWidth / ( noOfTabs + 0.5 ) ) ; itemActiveWidth = ( int ) ( itemWidth * 1.5 ) ; } } else if ( screenWidth > maxPossibleWidth ) { itemWidth = maxWidth ; itemActiveWidth = ( int ) ( itemWidth * 1.75 ) ; } else { double minPossibleWidth1 = minWidth * ( noOfTabs + 0.625 ) ; double minPossibleWidth2 = minWidth * ( noOfTabs + 0.75 ) ; itemWidth = ( int ) ( screenWidth / ( noOfTabs + 0.5 ) ) ; itemActiveWidth = ( int ) ( itemWidth * 1.5 ) ; if ( screenWidth > minPossibleWidth1 ) { itemWidth = ( int ) ( screenWidth / ( noOfTabs + 0.625 ) ) ; itemActiveWidth = ( int ) ( itemWidth * 1.625 ) ; if ( screenWidth > minPossibleWidth2 ) { itemWidth = ( int ) ( screenWidth / ( noOfTabs + 0.75 ) ) ; itemActiveWidth = ( int ) ( itemWidth * 1.75 ) ; } } } result [ 0 ] = itemWidth ; result [ 1 ] = itemActiveWidth ; return result ; } | Used to get Measurements for MODE_SHIFTING |
33,027 | static void bindTabWithData ( BottomNavigationItem bottomNavigationItem , BottomNavigationTab bottomNavigationTab , BottomNavigationBar bottomNavigationBar ) { Context context = bottomNavigationBar . getContext ( ) ; bottomNavigationTab . setLabel ( bottomNavigationItem . getTitle ( context ) ) ; bottomNavigationTab . setIcon ( bottomNavigationItem . getIcon ( context ) ) ; int activeColor = bottomNavigationItem . getActiveColor ( context ) ; int inActiveColor = bottomNavigationItem . getInActiveColor ( context ) ; if ( activeColor != Utils . NO_COLOR ) { bottomNavigationTab . setActiveColor ( activeColor ) ; } else { bottomNavigationTab . setActiveColor ( bottomNavigationBar . getActiveColor ( ) ) ; } if ( inActiveColor != Utils . NO_COLOR ) { bottomNavigationTab . setInactiveColor ( inActiveColor ) ; } else { bottomNavigationTab . setInactiveColor ( bottomNavigationBar . getInActiveColor ( ) ) ; } if ( bottomNavigationItem . isInActiveIconAvailable ( ) ) { Drawable inactiveDrawable = bottomNavigationItem . getInactiveIcon ( context ) ; if ( inactiveDrawable != null ) { bottomNavigationTab . setInactiveIcon ( inactiveDrawable ) ; } } bottomNavigationTab . setItemBackgroundColor ( bottomNavigationBar . getBackgroundColor ( ) ) ; BadgeItem badgeItem = bottomNavigationItem . getBadgeItem ( ) ; if ( badgeItem != null ) { badgeItem . bindToBottomTab ( bottomNavigationTab ) ; } } | Used to get set data to the Tab views from navigation items |
33,028 | static void setBackgroundWithRipple ( View clickedView , final View backgroundView , final View bgOverlay , final int newColor , int animationDuration ) { int centerX = ( int ) ( clickedView . getX ( ) + ( clickedView . getMeasuredWidth ( ) / 2 ) ) ; int centerY = clickedView . getMeasuredHeight ( ) / 2 ; int finalRadius = backgroundView . getWidth ( ) ; backgroundView . clearAnimation ( ) ; bgOverlay . clearAnimation ( ) ; Animator circularReveal ; if ( Build . VERSION . SDK_INT >= Build . VERSION_CODES . LOLLIPOP ) { circularReveal = ViewAnimationUtils . createCircularReveal ( bgOverlay , centerX , centerY , 0 , finalRadius ) ; } else { bgOverlay . setAlpha ( 0 ) ; circularReveal = ObjectAnimator . ofFloat ( bgOverlay , "alpha" , 0 , 1 ) ; } circularReveal . setDuration ( animationDuration ) ; circularReveal . addListener ( new AnimatorListenerAdapter ( ) { public void onAnimationEnd ( Animator animation ) { onCancel ( ) ; } public void onAnimationCancel ( Animator animation ) { onCancel ( ) ; } private void onCancel ( ) { backgroundView . setBackgroundColor ( newColor ) ; bgOverlay . setVisibility ( View . GONE ) ; } } ) ; bgOverlay . setBackgroundColor ( newColor ) ; bgOverlay . setVisibility ( View . VISIBLE ) ; circularReveal . start ( ) ; } | Used to set the ripple animation when a tab is selected |
33,029 | public Iterable < ? extends File > getClassPath ( File root , Iterable < ? extends File > classPath ) { return this . classPath == null ? new PrefixIterable ( root , classPath ) : this . classPath ; } | Returns the class path or builds a class path from the supplied arguments if no class path was set . |
33,030 | private List < TypeDescription > filterRelevant ( TypeDescription typeDescription ) { List < TypeDescription > filtered = new ArrayList < TypeDescription > ( prioritizedInterfaces . size ( ) ) ; Set < TypeDescription > relevant = new HashSet < TypeDescription > ( typeDescription . getInterfaces ( ) . asErasures ( ) ) ; for ( TypeDescription prioritizedInterface : prioritizedInterfaces ) { if ( relevant . remove ( prioritizedInterface ) ) { filtered . add ( prioritizedInterface ) ; } } return filtered ; } | Filters the relevant prioritized interfaces for a given type i . e . finds the types that are directly declared on a given instrumented type . |
33,031 | public static < T extends FieldDescription > ElementMatcher . Junction < T > definedField ( ElementMatcher < ? super FieldDescription . InDefinedShape > matcher ) { return new DefinedShapeMatcher < T , FieldDescription . InDefinedShape > ( matcher ) ; } | Matches a field in its defined shape . |
33,032 | public static < T extends MethodDescription > ElementMatcher . Junction < T > definedMethod ( ElementMatcher < ? super MethodDescription . InDefinedShape > matcher ) { return new DefinedShapeMatcher < T , MethodDescription . InDefinedShape > ( matcher ) ; } | Matches a method in its defined shape . |
33,033 | public static < T extends ParameterDescription > ElementMatcher . Junction < T > definedParameter ( ElementMatcher < ? super ParameterDescription . InDefinedShape > matcher ) { return new DefinedShapeMatcher < T , ParameterDescription . InDefinedShape > ( matcher ) ; } | Matches a parameter in its defined shape . |
33,034 | public static < T extends ParameterDescription > ElementMatcher . Junction < T > hasType ( ElementMatcher < ? super TypeDescription > matcher ) { return hasGenericType ( erasure ( matcher ) ) ; } | Matches a parameter s type by the given matcher . |
33,035 | public static < T extends ParameterDescription > ElementMatcher . Junction < T > hasGenericType ( ElementMatcher < ? super TypeDescription . Generic > matcher ) { return new MethodParameterTypeMatcher < T > ( matcher ) ; } | Matches a method parameter by its generic type . |
33,036 | public static < T > ElementMatcher . Junction < T > not ( ElementMatcher < ? super T > matcher ) { return new NegatingMatcher < T > ( matcher ) ; } | Inverts another matcher . |
33,037 | public static < T > ElementMatcher . Junction < Iterable < ? extends T > > whereAny ( ElementMatcher < ? super T > matcher ) { return new CollectionItemMatcher < T > ( matcher ) ; } | Matches an iterable by assuring that at least one element of the iterable collection matches the provided matcher . |
33,038 | public static < T > ElementMatcher . Junction < Iterable < ? extends T > > whereNone ( ElementMatcher < ? super T > matcher ) { return not ( whereAny ( matcher ) ) ; } | Matches an iterable by assuring that no element of the iterable collection matches the provided matcher . |
33,039 | public static < T extends TypeDescription . Generic > ElementMatcher . Junction < T > erasure ( Class < ? > type ) { return erasure ( is ( type ) ) ; } | Matches a generic type s erasure against the provided type . As a wildcard does not define an erasure a runtime exception is thrown when this matcher is applied to a wildcard . |
33,040 | public static < T extends TypeDescription . Generic > ElementMatcher . Junction < T > erasure ( ElementMatcher < ? super TypeDescription > matcher ) { return new ErasureMatcher < T > ( matcher ) ; } | Converts a matcher for a type description into a matcher for the matched type s erasure . As a wildcard does not define an erasure a runtime exception is thrown when this matcher is applied to a wildcard . |
33,041 | public static < T extends Iterable < ? extends TypeDescription . Generic > > ElementMatcher . Junction < T > erasures ( ElementMatcher < ? super Iterable < ? extends TypeDescription > > matcher ) { return new CollectionErasureMatcher < T > ( matcher ) ; } | Applies the provided matchers to an iteration og generic types erasures . As a wildcard does not define an erasure a runtime exception is thrown when this matcher is applied to a wildcard . |
33,042 | public static < T extends MethodDescription > ElementMatcher . Junction < T > returns ( ElementMatcher < ? super TypeDescription > matcher ) { return returnsGeneric ( erasure ( matcher ) ) ; } | Matches a method s return type s erasure by the given matcher . |
33,043 | public static < T extends MethodDescription > ElementMatcher . Junction < T > declaresGenericException ( ElementMatcher < ? super Iterable < ? extends TypeDescription . Generic > > matcher ) { return new MethodExceptionTypeMatcher < T > ( matcher ) ; } | Matches a method s generic exception types against the provided matcher . |
33,044 | public static < T extends MethodDescription > ElementMatcher . Junction < T > isVirtual ( ) { return new MethodSortMatcher < T > ( MethodSortMatcher . Sort . VIRTUAL ) ; } | Matches any method that is virtual i . e . non - constructors that are non - static and non - private . |
33,045 | public static < T extends MethodDescription > ElementMatcher . Junction < T > isDefaultMethod ( ) { return new MethodSortMatcher < T > ( MethodSortMatcher . Sort . DEFAULT_METHOD ) ; } | Only matches Java 8 default methods . |
33,046 | public static < T extends MethodDescription > ElementMatcher . Junction < T > isSetter ( ) { return nameStartsWith ( "set" ) . and ( takesArguments ( 1 ) ) . and ( returns ( TypeDescription . VOID ) ) ; } | Matches any Java bean setter method . |
33,047 | public static < T extends MethodDescription > ElementMatcher . Junction < T > isGetter ( ) { return takesArguments ( 0 ) . and ( not ( returns ( TypeDescription . VOID ) ) ) . and ( nameStartsWith ( "get" ) . or ( nameStartsWith ( "is" ) . and ( returnsGeneric ( anyOf ( boolean . class , Boolean . class ) ) ) ) ) ; } | Matches any Java bean getter method . |
33,048 | public static < T extends MethodDescription > ElementMatcher . Junction < T > hasMethodName ( String internalName ) { if ( MethodDescription . CONSTRUCTOR_INTERNAL_NAME . equals ( internalName ) ) { return isConstructor ( ) ; } else if ( MethodDescription . TYPE_INITIALIZER_INTERNAL_NAME . equals ( internalName ) ) { return isTypeInitializer ( ) ; } else { return named ( internalName ) ; } } | Matches a method against its internal name such that constructors and type initializers are matched appropriately . |
33,049 | public static < T extends MethodDescription > ElementMatcher . Junction < T > hasSignature ( MethodDescription . SignatureToken token ) { return new SignatureTokenMatcher < T > ( is ( token ) ) ; } | Only matches method descriptions that yield the provided signature token . |
33,050 | public static < T extends TypeDescription > ElementMatcher . Junction < T > isSubTypeOf ( TypeDescription type ) { return new SubTypeMatcher < T > ( type ) ; } | Matches any type description that is a subtype of the given type . |
33,051 | public static < T extends TypeDescription > ElementMatcher . Junction < T > inheritsAnnotation ( TypeDescription type ) { return inheritsAnnotation ( is ( type ) ) ; } | Matches any annotations by their type on a type that declared these annotations or inherited them from its super classes . |
33,052 | public static < T extends TypeDescription > ElementMatcher . Junction < T > inheritsAnnotation ( ElementMatcher < ? super TypeDescription > matcher ) { return hasAnnotation ( annotationType ( matcher ) ) ; } | Matches any annotations by a given matcher on a type that declared these annotations or inherited them from its super classes . |
33,053 | public static < T extends TypeDescription > ElementMatcher . Junction < T > hasAnnotation ( ElementMatcher < ? super AnnotationDescription > matcher ) { return new InheritedAnnotationMatcher < T > ( new CollectionItemMatcher < AnnotationDescription > ( matcher ) ) ; } | Matches a list of annotations by a given matcher on a type that declared these annotations or inherited them from its super classes . |
33,054 | public static < T extends TypeDefinition > ElementMatcher . Junction < T > declaresField ( ElementMatcher < ? super FieldDescription > matcher ) { return new DeclaringFieldMatcher < T > ( new CollectionItemMatcher < FieldDescription > ( matcher ) ) ; } | Matches a type by a another matcher that is applied on any of its declared fields . |
33,055 | public static < T extends TypeDefinition > ElementMatcher . Junction < T > declaresMethod ( ElementMatcher < ? super MethodDescription > matcher ) { return new DeclaringMethodMatcher < T > ( new CollectionItemMatcher < MethodDescription > ( matcher ) ) ; } | Matches a type by a another matcher that is applied on any of its declared methods . |
33,056 | public static < T extends AnnotationDescription > ElementMatcher . Junction < T > annotationType ( ElementMatcher < ? super TypeDescription > matcher ) { return new AnnotationTypeMatcher < T > ( matcher ) ; } | Matches if an annotation s type matches the supplied matcher . |
33,057 | public static < T extends ClassLoader > ElementMatcher . Junction < T > isChildOf ( ClassLoader classLoader ) { return classLoader == BOOTSTRAP_CLASSLOADER ? new BooleanMatcher < T > ( true ) : ElementMatchers . < T > hasChild ( is ( classLoader ) ) ; } | Matches any class loader that is either the given class loader or a child of the given class loader . |
33,058 | public static < T extends ClassLoader > ElementMatcher . Junction < T > hasChild ( ElementMatcher < ? super ClassLoader > matcher ) { return new ClassLoaderHierarchyMatcher < T > ( matcher ) ; } | Matches all class loaders in the hierarchy of the matched class loader against a given matcher . |
33,059 | public static < T extends ClassLoader > ElementMatcher . Junction < T > isParentOf ( ClassLoader classLoader ) { return classLoader == BOOTSTRAP_CLASSLOADER ? ElementMatchers . < T > isBootstrapClassLoader ( ) : new ClassLoaderParentMatcher < T > ( classLoader ) ; } | Matches any class loader that is either the given class loader or a parent of the given class loader . |
33,060 | public static < T extends ClassLoader > ElementMatcher . Junction < T > ofType ( ElementMatcher < ? super TypeDescription > matcher ) { return new InstanceTypeMatcher < T > ( matcher ) ; } | Matches a class loader s type unless it is the bootstrap class loader which is never matched . |
33,061 | private static String findJavaVersionString ( MavenProject project ) { while ( project != null ) { String target = project . getProperties ( ) . getProperty ( "maven.compiler.target" ) ; if ( target != null ) { return target ; } for ( org . apache . maven . model . Plugin plugin : CompoundList . of ( project . getBuildPlugins ( ) , project . getPluginManagement ( ) . getPlugins ( ) ) ) { if ( "maven-compiler-plugin" . equals ( plugin . getArtifactId ( ) ) ) { if ( plugin . getConfiguration ( ) instanceof Xpp3Dom ) { Xpp3Dom node = ( ( Xpp3Dom ) plugin . getConfiguration ( ) ) . getChild ( "target" ) ; if ( node != null ) { return node . getValue ( ) ; } } } } project = project . getParent ( ) ; } return null ; } | Makes a best effort of locating the configured Java target version . |
33,062 | private static LinkedHashMap < String , TypeDescription > extractFields ( MethodDescription methodDescription ) { LinkedHashMap < String , TypeDescription > typeDescriptions = new LinkedHashMap < String , TypeDescription > ( ) ; int currentIndex = 0 ; if ( ! methodDescription . isStatic ( ) ) { typeDescriptions . put ( fieldName ( currentIndex ++ ) , methodDescription . getDeclaringType ( ) . asErasure ( ) ) ; } for ( ParameterDescription parameterDescription : methodDescription . getParameters ( ) ) { typeDescriptions . put ( fieldName ( currentIndex ++ ) , parameterDescription . getType ( ) . asErasure ( ) ) ; } return typeDescriptions ; } | Creates a linked hash map of field names to their types where each field represents a parameter of the method . |
33,063 | public static TypeVariableToken of ( TypeDescription . Generic typeVariable , ElementMatcher < ? super TypeDescription > matcher ) { return new TypeVariableToken ( typeVariable . getSymbol ( ) , typeVariable . getUpperBounds ( ) . accept ( new TypeDescription . Generic . Visitor . Substitutor . ForDetachment ( matcher ) ) , typeVariable . getDeclaredAnnotations ( ) ) ; } | Transforms a type variable into a type variable token with its bounds detached . |
33,064 | public static StackManipulation to ( TypeDefinition typeDefinition ) { if ( typeDefinition . isPrimitive ( ) ) { throw new IllegalArgumentException ( "Cannot cast to primitive type: " + typeDefinition ) ; } return new TypeCasting ( typeDefinition . asErasure ( ) ) ; } | Creates a casting to the given non - primitive type . |
33,065 | public void argument ( Closure < ? > closure ) { arguments . add ( ( PluginArgument ) project . configure ( new PluginArgument ( ) , closure ) ) ; } | Adds a plugin argument to consider during instantiation . |
33,066 | public List < Plugin . Factory . UsingReflection . ArgumentResolver > makeArgumentResolvers ( ) { if ( arguments == null ) { return Collections . emptyList ( ) ; } else { List < Plugin . Factory . UsingReflection . ArgumentResolver > argumentResolvers = new ArrayList < Plugin . Factory . UsingReflection . ArgumentResolver > ( ) ; for ( PluginArgument argument : arguments ) { argumentResolvers . add ( argument . toArgumentResolver ( ) ) ; } return argumentResolvers ; } } | Creates the argument resolvers for the plugin s constructor by transforming the plugin arguments . |
33,067 | public static StackManipulation of ( TypeDescription typeDescription ) { if ( typeDescription . isArray ( ) || typeDescription . isPrimitive ( ) || typeDescription . isAbstract ( ) ) { throw new IllegalArgumentException ( typeDescription + " is not instantiable" ) ; } return new TypeCreation ( typeDescription ) ; } | Creates a type creation for the given type . |
33,068 | public Object [ ] method ( Object arg1 , Object arg2 , Object arg3 ) { return new Object [ ] { arg1 , arg2 , arg3 } ; } | An example method . |
33,069 | private boolean matches ( MethodDescription target , List < ? extends TypeDefinition > typeDefinitions , Set < TypeDescription > duplicates ) { for ( TypeDefinition anInterface : typeDefinitions ) { if ( duplicates . add ( anInterface . asErasure ( ) ) && ( matches ( target , anInterface ) || matches ( target , anInterface . getInterfaces ( ) , duplicates ) ) ) { return true ; } } return false ; } | Matches a method against a list of types . |
33,070 | public static MethodHandle of ( MethodDescription . InDefinedShape methodDescription ) { return new MethodHandle ( HandleType . of ( methodDescription ) , methodDescription . getDeclaringType ( ) . asErasure ( ) , methodDescription . getInternalName ( ) , methodDescription . getReturnType ( ) . asErasure ( ) , methodDescription . getParameters ( ) . asTypeList ( ) . asErasures ( ) ) ; } | Creates a method handle representation of the given method . |
33,071 | public static MethodHandle ofGetter ( FieldDescription . InDefinedShape fieldDescription ) { return new MethodHandle ( HandleType . ofGetter ( fieldDescription ) , fieldDescription . getDeclaringType ( ) . asErasure ( ) , fieldDescription . getInternalName ( ) , fieldDescription . getType ( ) . asErasure ( ) , Collections . < TypeDescription > emptyList ( ) ) ; } | Returns a method handle for a setter of the given field . |
33,072 | public static MethodHandle ofSetter ( FieldDescription . InDefinedShape fieldDescription ) { return new MethodHandle ( HandleType . ofSetter ( fieldDescription ) , fieldDescription . getDeclaringType ( ) . asErasure ( ) , fieldDescription . getInternalName ( ) , TypeDescription . VOID , Collections . singletonList ( fieldDescription . getType ( ) . asErasure ( ) ) ) ; } | Returns a method handle for a getter of the given field . |
33,073 | public String getDescriptor ( ) { StringBuilder stringBuilder = new StringBuilder ( ) . append ( '(' ) ; for ( TypeDescription parameterType : parameterTypes ) { stringBuilder . append ( parameterType . getDescriptor ( ) ) ; } return stringBuilder . append ( ')' ) . append ( returnType . getDescriptor ( ) ) . toString ( ) ; } | Returns the method descriptor of this method handle representation . |
33,074 | public static JavaConstant ofVarHandle ( FieldDescription . InDefinedShape fieldDescription ) { return new Dynamic ( new ConstantDynamic ( fieldDescription . getInternalName ( ) , JavaType . VAR_HANDLE . getTypeStub ( ) . getDescriptor ( ) , new Handle ( Opcodes . H_INVOKESTATIC , CONSTANT_BOOTSTRAPS , fieldDescription . isStatic ( ) ? "staticFieldVarHandle" : "fieldVarHandle" , "(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/Class;Ljava/lang/Class;Ljava/lang/Class;)Ljava/lang/invoke/VarHandle;" , false ) , Type . getType ( fieldDescription . getDeclaringType ( ) . getDescriptor ( ) ) , Type . getType ( fieldDescription . getType ( ) . asErasure ( ) . getDescriptor ( ) ) ) , JavaType . VAR_HANDLE . getTypeStub ( ) ) ; } | Resolves a var handle constant for a field . |
33,075 | public static JavaConstant ofArrayVarHandle ( TypeDescription typeDescription ) { if ( ! typeDescription . isArray ( ) ) { throw new IllegalArgumentException ( "Not an array type: " + typeDescription ) ; } return new Dynamic ( new ConstantDynamic ( "arrayVarHandle" , JavaType . VAR_HANDLE . getTypeStub ( ) . getDescriptor ( ) , new Handle ( Opcodes . H_INVOKESTATIC , CONSTANT_BOOTSTRAPS , "arrayVarHandle" , "(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/Class;Ljava/lang/Class;)Ljava/lang/invoke/VarHandle;" , false ) , Type . getType ( typeDescription . getDescriptor ( ) ) ) , JavaType . VAR_HANDLE . getTypeStub ( ) ) ; } | Resolves a var handle constant for an array . |
33,076 | public Class < ? > benchmarkJavassist ( ) { ProxyFactory proxyFactory = new ProxyFactory ( ) { protected ClassLoader getClassLoader ( ) { return newClassLoader ( ) ; } } ; proxyFactory . setUseCache ( false ) ; proxyFactory . setUseWriteReplace ( false ) ; proxyFactory . setSuperclass ( baseClass ) ; proxyFactory . setFilter ( new MethodFilter ( ) { public boolean isHandled ( Method method ) { return false ; } } ) ; return proxyFactory . createClass ( ) ; } | Performs a benchmark for a trivial class creation using javassist proxies . |
33,077 | public MemberRemoval stripFields ( ElementMatcher < ? super FieldDescription . InDefinedShape > matcher ) { return new MemberRemoval ( fieldMatcher . or ( matcher ) , methodMatcher ) ; } | Specifies that any field that matches the specified matcher should be removed . |
33,078 | public MemberRemoval stripInvokables ( ElementMatcher < ? super MethodDescription > matcher ) { return new MemberRemoval ( fieldMatcher , methodMatcher . or ( matcher ) ) ; } | Specifies that any method or constructor that matches the specified matcher should be removed . |
33,079 | @ SuppressFBWarnings ( value = "REC_CATCH_EXCEPTION" , justification = "Exception should not be rethrown but trigger a fallback" ) public static void main ( String [ ] args ) { try { String argument ; if ( args . length < 4 || args [ 3 ] . length ( ) == 0 ) { argument = null ; } else { StringBuilder stringBuilder = new StringBuilder ( args [ 3 ] . substring ( 1 ) ) ; for ( int index = 4 ; index < args . length ; index ++ ) { stringBuilder . append ( ' ' ) . append ( args [ index ] ) ; } argument = stringBuilder . toString ( ) ; } install ( Class . forName ( args [ 0 ] ) , args [ 1 ] , args [ 2 ] , argument ) ; } catch ( Exception ignored ) { System . exit ( 1 ) ; } } | Runs the attacher as a Java application . |
33,080 | protected static void install ( Class < ? > virtualMachineType , String processId , String agent , String argument ) throws NoSuchMethodException , InvocationTargetException , IllegalAccessException { Object virtualMachineInstance = virtualMachineType . getMethod ( ATTACH_METHOD_NAME , String . class ) . invoke ( STATIC_MEMBER , processId ) ; try { virtualMachineType . getMethod ( LOAD_AGENT_METHOD_NAME , String . class , String . class ) . invoke ( virtualMachineInstance , agent , argument ) ; } finally { virtualMachineType . getMethod ( DETACH_METHOD_NAME ) . invoke ( virtualMachineInstance ) ; } } | Installs a Java agent on a target VM . |
33,081 | public byte [ ] drain ( InputStream inputStream ) throws IOException { List < byte [ ] > previousBytes = new ArrayList < byte [ ] > ( ) ; byte [ ] currentArray = new byte [ bufferSize ] ; int currentIndex = 0 ; int currentRead ; do { currentRead = inputStream . read ( currentArray , currentIndex , bufferSize - currentIndex ) ; currentIndex += currentRead > 0 ? currentRead : 0 ; if ( currentIndex == bufferSize ) { previousBytes . add ( currentArray ) ; currentArray = new byte [ bufferSize ] ; currentIndex = 0 ; } } while ( currentRead != END_OF_STREAM ) ; byte [ ] result = new byte [ previousBytes . size ( ) * bufferSize + currentIndex ] ; int arrayIndex = 0 ; for ( byte [ ] previousByte : previousBytes ) { System . arraycopy ( previousByte , FROM_BEGINNING , result , arrayIndex ++ * bufferSize , bufferSize ) ; } System . arraycopy ( currentArray , FROM_BEGINNING , result , arrayIndex * bufferSize , currentIndex ) ; return result ; } | Drains an input stream into a byte array . The given input stream is not closed . |
33,082 | private static String nonAnonymous ( String typeName ) { int anonymousLoaderIndex = typeName . indexOf ( '/' ) ; return anonymousLoaderIndex == - 1 ? typeName : typeName . substring ( 0 , anonymousLoaderIndex ) ; } | Normalizes a type name if it is loaded by an anonymous class loader . |
33,083 | protected void onVisitFieldInsn ( int opcode , String owner , String name , String descriptor ) { super . visitFieldInsn ( opcode , owner , name , descriptor ) ; } | Visits a field instruction . |
33,084 | protected void onVisitTableSwitchInsn ( int minimum , int maximum , Label defaultTarget , Label ... label ) { super . visitTableSwitchInsn ( minimum , maximum , defaultTarget , label ) ; } | Visits a table switch instruction . |
33,085 | protected void onVisitLookupSwitchInsn ( Label defaultTarget , int [ ] key , Label [ ] label ) { super . visitLookupSwitchInsn ( defaultTarget , key , label ) ; } | Visits a lookup switch instruction . |
33,086 | protected String getGroupId ( String groupId ) { return this . groupId == null || this . groupId . length ( ) == 0 ? groupId : this . groupId ; } | Returns the group id to use . |
33,087 | protected String getArtifactId ( String artifactId ) { return this . artifactId == null || this . artifactId . length ( ) == 0 ? artifactId : this . artifactId ; } | Returns the artifact id to use . |
33,088 | public MavenCoordinate asCoordinate ( String groupId , String artifactId , String version , String packaging ) { return new MavenCoordinate ( getGroupId ( groupId ) , getArtifactId ( artifactId ) , getVersion ( version ) , getPackaging ( packaging ) ) ; } | Resolves this transformation to a Maven coordinate . |
33,089 | protected static LatentMatcher < MethodDescription > of ( LatentMatcher < ? super MethodDescription > ignoredMethods , TypeDescription originalType ) { ElementMatcher . Junction < MethodDescription > predefinedMethodSignatures = none ( ) ; for ( MethodDescription methodDescription : originalType . getDeclaredMethods ( ) ) { ElementMatcher . Junction < MethodDescription > signature = methodDescription . isConstructor ( ) ? isConstructor ( ) : ElementMatchers . < MethodDescription > named ( methodDescription . getName ( ) ) ; signature = signature . and ( returns ( methodDescription . getReturnType ( ) . asErasure ( ) ) ) ; signature = signature . and ( takesArguments ( methodDescription . getParameters ( ) . asTypeList ( ) . asErasures ( ) ) ) ; predefinedMethodSignatures = predefinedMethodSignatures . or ( signature ) ; } return new InliningImplementationMatcher ( ignoredMethods , predefinedMethodSignatures ) ; } | Creates a matcher where only overridable or declared methods are matched unless those are ignored . Methods that are declared by the target type are only matched if they are not ignored . Declared methods that are not found on the target type are always matched . |
33,090 | public ClassReloadingStrategy reset ( Class < ? > ... type ) throws IOException { return type . length == 0 ? this : reset ( ClassFileLocator . ForClassLoader . of ( type [ 0 ] . getClassLoader ( ) ) , type ) ; } | Resets all classes to their original definition while using the first type s class loader as a class file locator . |
33,091 | public ClassReloadingStrategy reset ( ClassFileLocator classFileLocator , Class < ? > ... type ) throws IOException { if ( type . length > 0 ) { try { strategy . reset ( instrumentation , classFileLocator , Arrays . asList ( type ) ) ; } catch ( ClassNotFoundException exception ) { throw new IllegalArgumentException ( "Cannot locate types " + Arrays . toString ( type ) , exception ) ; } catch ( UnmodifiableClassException exception ) { throw new IllegalStateException ( "Cannot reset types " + Arrays . toString ( type ) , exception ) ; } } return this ; } | Resets all classes to their original definition . |
33,092 | public ClassReloadingStrategy enableBootstrapInjection ( File folder ) { return new ClassReloadingStrategy ( instrumentation , strategy , new BootstrapInjection . Enabled ( folder ) , preregisteredTypes ) ; } | Enables bootstrap injection for this class reloading strategy . |
33,093 | public ClassReloadingStrategy preregistered ( Class < ? > ... type ) { Map < String , Class < ? > > preregisteredTypes = new HashMap < String , Class < ? > > ( this . preregisteredTypes ) ; for ( Class < ? > aType : type ) { preregisteredTypes . put ( TypeDescription . ForLoadedType . getName ( aType ) , aType ) ; } return new ClassReloadingStrategy ( instrumentation , strategy , bootstrapInjection , preregisteredTypes ) ; } | Registers a type to be explicitly available without explicit lookup . |
33,094 | private Implementation . SpecialMethodInvocation invokeConstructor ( MethodDescription . SignatureToken token ) { TypeDescription . Generic superClass = instrumentedType . getSuperClass ( ) ; MethodList < ? > candidates = superClass == null ? new MethodList . Empty < MethodDescription . InGenericShape > ( ) : superClass . getDeclaredMethods ( ) . filter ( hasSignature ( token ) . and ( isVisibleTo ( instrumentedType ) ) ) ; return candidates . size ( ) == 1 ? Implementation . SpecialMethodInvocation . Simple . of ( candidates . getOnly ( ) , instrumentedType . getSuperClass ( ) . asErasure ( ) ) : Implementation . SpecialMethodInvocation . Illegal . INSTANCE ; } | Resolves a special method invocation for a constructor invocation . |
33,095 | private Implementation . SpecialMethodInvocation invokeMethod ( MethodDescription . SignatureToken token ) { MethodGraph . Node methodNode = methodGraph . getSuperClassGraph ( ) . locate ( token ) ; return methodNode . getSort ( ) . isUnique ( ) ? Implementation . SpecialMethodInvocation . Simple . of ( methodNode . getRepresentative ( ) , instrumentedType . getSuperClass ( ) . asErasure ( ) ) : Implementation . SpecialMethodInvocation . Illegal . INSTANCE ; } | Resolves a special method invocation for a non - constructor invocation . |
33,096 | public static ClassFileVersion ofMinorMajor ( int versionNumber ) { ClassFileVersion classFileVersion = new ClassFileVersion ( versionNumber ) ; if ( classFileVersion . getMajorVersion ( ) <= BASE_VERSION ) { throw new IllegalArgumentException ( "Class version " + versionNumber + " is not valid" ) ; } return classFileVersion ; } | Creates a wrapper for a given minor - major release of the Java class file file . |
33,097 | public static ClassFileVersion ofJavaVersion ( int javaVersion ) { switch ( javaVersion ) { case 1 : return JAVA_V1 ; case 2 : return JAVA_V2 ; case 3 : return JAVA_V3 ; case 4 : return JAVA_V4 ; case 5 : return JAVA_V5 ; case 6 : return JAVA_V6 ; case 7 : return JAVA_V7 ; case 8 : return JAVA_V8 ; case 9 : return JAVA_V9 ; case 10 : return JAVA_V10 ; case 11 : return JAVA_V11 ; case 12 : return JAVA_V12 ; case 13 : return JAVA_V13 ; default : if ( OpenedClassReader . EXPERIMENTAL && javaVersion > 0 ) { return new ClassFileVersion ( BASE_VERSION + javaVersion ) ; } else { throw new IllegalArgumentException ( "Unknown Java version: " + javaVersion ) ; } } } | Creates a class file version for a given major release of Java . Currently all versions reaching from Java 1 to Java 9 are supported . |
33,098 | @ OperationsPerInvocation ( 20 ) public void baseline ( Blackhole blackHole ) { blackHole . consume ( baselineInstance . method ( booleanValue ) ) ; blackHole . consume ( baselineInstance . method ( byteValue ) ) ; blackHole . consume ( baselineInstance . method ( shortValue ) ) ; blackHole . consume ( baselineInstance . method ( intValue ) ) ; blackHole . consume ( baselineInstance . method ( charValue ) ) ; blackHole . consume ( baselineInstance . method ( intValue ) ) ; blackHole . consume ( baselineInstance . method ( longValue ) ) ; blackHole . consume ( baselineInstance . method ( floatValue ) ) ; blackHole . consume ( baselineInstance . method ( doubleValue ) ) ; blackHole . consume ( baselineInstance . method ( stringValue ) ) ; blackHole . consume ( baselineInstance . method ( booleanValue , booleanValue , booleanValue ) ) ; blackHole . consume ( baselineInstance . method ( byteValue , byteValue , byteValue ) ) ; blackHole . consume ( baselineInstance . method ( shortValue , shortValue , shortValue ) ) ; blackHole . consume ( baselineInstance . method ( intValue , intValue , intValue ) ) ; blackHole . consume ( baselineInstance . method ( charValue , charValue , charValue ) ) ; blackHole . consume ( baselineInstance . method ( intValue , intValue , intValue ) ) ; blackHole . consume ( baselineInstance . method ( longValue , longValue , longValue ) ) ; blackHole . consume ( baselineInstance . method ( floatValue , floatValue , floatValue ) ) ; blackHole . consume ( baselineInstance . method ( doubleValue , doubleValue , doubleValue ) ) ; blackHole . consume ( baselineInstance . method ( stringValue , stringValue , stringValue ) ) ; } | Performs a benchmark for a casual class as a baseline . |
33,099 | @ OperationsPerInvocation ( 20 ) public void benchmarkJavassist ( Blackhole blackHole ) { blackHole . consume ( javassistInstance . method ( booleanValue ) ) ; blackHole . consume ( javassistInstance . method ( byteValue ) ) ; blackHole . consume ( javassistInstance . method ( shortValue ) ) ; blackHole . consume ( javassistInstance . method ( intValue ) ) ; blackHole . consume ( javassistInstance . method ( charValue ) ) ; blackHole . consume ( javassistInstance . method ( intValue ) ) ; blackHole . consume ( javassistInstance . method ( longValue ) ) ; blackHole . consume ( javassistInstance . method ( floatValue ) ) ; blackHole . consume ( javassistInstance . method ( doubleValue ) ) ; blackHole . consume ( javassistInstance . method ( stringValue ) ) ; blackHole . consume ( javassistInstance . method ( booleanValue , booleanValue , booleanValue ) ) ; blackHole . consume ( javassistInstance . method ( byteValue , byteValue , byteValue ) ) ; blackHole . consume ( javassistInstance . method ( shortValue , shortValue , shortValue ) ) ; blackHole . consume ( javassistInstance . method ( intValue , intValue , intValue ) ) ; blackHole . consume ( javassistInstance . method ( charValue , charValue , charValue ) ) ; blackHole . consume ( javassistInstance . method ( intValue , intValue , intValue ) ) ; blackHole . consume ( javassistInstance . method ( longValue , longValue , longValue ) ) ; blackHole . consume ( javassistInstance . method ( floatValue , floatValue , floatValue ) ) ; blackHole . consume ( javassistInstance . method ( doubleValue , doubleValue , doubleValue ) ) ; blackHole . consume ( javassistInstance . method ( stringValue , stringValue , stringValue ) ) ; } | Performs a benchmark for a trivial class creation using javassist . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.