idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
153,200
public void draw ( Canvas canvas , Projection pj ) { if ( mIcon == null ) return ; if ( mPosition == null ) return ; pj . toPixels ( mPosition , mPositionPixels ) ; int width = mIcon . getIntrinsicWidth ( ) ; int height = mIcon . getIntrinsicHeight ( ) ; Rect rect = new Rect ( 0 , 0 , width , height ) ; rect . offset (...
Draw the icon .
153,201
public double getX01FromLongitude ( double longitude , boolean wrapEnabled ) { longitude = wrapEnabled ? Clip ( longitude , getMinLongitude ( ) , getMaxLongitude ( ) ) : longitude ; final double result = getX01FromLongitude ( longitude ) ; return wrapEnabled ? Clip ( result , 0 , 1 ) : result ; }
Converts a longitude to its X01 value id est a double between 0 and 1 for the whole longitude range
153,202
public double getY01FromLatitude ( double latitude , boolean wrapEnabled ) { latitude = wrapEnabled ? Clip ( latitude , getMinLatitude ( ) , getMaxLatitude ( ) ) : latitude ; final double result = getY01FromLatitude ( latitude ) ; return wrapEnabled ? Clip ( result , 0 , 1 ) : result ; }
Converts a latitude to its Y01 value id est a double between 0 and 1 for the whole latitude range
153,203
public void open ( Object object , GeoPoint position , int offsetX , int offsetY ) { close ( ) ; mRelatedObject = object ; mPosition = position ; mOffsetX = offsetX ; mOffsetY = offsetY ; onOpen ( object ) ; MapView . LayoutParams lp = new MapView . LayoutParams ( MapView . LayoutParams . WRAP_CONTENT , MapView . Layou...
open the InfoWindow at the specified GeoPosition + offset . If it was already opened close it before reopening .
153,204
public void close ( ) { if ( mIsVisible ) { mIsVisible = false ; ( ( ViewGroup ) mView . getParent ( ) ) . removeView ( mView ) ; onClose ( ) ; } }
hides the info window which triggers another render of the map
153,205
public void onDetach ( ) { close ( ) ; if ( mView != null ) mView . setTag ( null ) ; mView = null ; mMapView = null ; if ( Configuration . getInstance ( ) . isDebugMode ( ) ) Log . d ( IMapView . LOGTAG , "Marked detached" ) ; }
this destroys the window and all references to views
153,206
public static void closeAllInfoWindowsOn ( MapView mapView ) { ArrayList < InfoWindow > opened = getOpenedInfoWindowsOn ( mapView ) ; for ( InfoWindow infoWindow : opened ) { infoWindow . close ( ) ; } }
close all InfoWindows currently opened on this MapView
153,207
public static ArrayList < InfoWindow > getOpenedInfoWindowsOn ( MapView mapView ) { int count = mapView . getChildCount ( ) ; ArrayList < InfoWindow > opened = new ArrayList < InfoWindow > ( count ) ; for ( int i = 0 ; i < count ; i ++ ) { final View child = mapView . getChildAt ( i ) ; Object tag = child . getTag ( ) ...
return all InfoWindows currently opened on this MapView
153,208
private MilestoneManager getHalfKilometerManager ( ) { final Path arrowPath = new Path ( ) ; arrowPath . moveTo ( - 5 , - 5 ) ; arrowPath . lineTo ( 5 , 0 ) ; arrowPath . lineTo ( - 5 , 5 ) ; arrowPath . close ( ) ; final Paint backgroundPaint = getFillPaint ( COLOR_BACKGROUND ) ; return new MilestoneManager ( new Mile...
Half - kilometer milestones
153,209
public Point toWgs84 ( Point point ) { if ( projection != null ) { point = toWgs84 . transform ( point ) ; } return point ; }
Transform a projection point to WGS84
153,210
public Point toProjection ( Point point ) { if ( projection != null ) { point = fromWgs84 . transform ( point ) ; } return point ; }
Transform a WGS84 point to the projection
153,211
public static Polyline addPolylineToMap ( MapView map , Polyline polyline ) { if ( polyline . getInfoWindow ( ) == null ) polyline . setInfoWindow ( new BasicInfoWindow ( R . layout . bonuspack_bubble , map ) ) ; map . getOverlayManager ( ) . add ( polyline ) ; return polyline ; }
Add a Polyline to the map
153,212
public synchronized void close ( ) throws IOException { if ( journalWriter == null ) { return ; } for ( Entry entry : new ArrayList < Entry > ( lruEntries . values ( ) ) ) { if ( entry . currentEditor != null ) { entry . currentEditor . abort ( ) ; } } trimToSize ( ) ; journalWriter . close ( ) ; journalWriter = null ;...
Closes this cache . Stored values will remain on the filesystem .
153,213
protected boolean isSOFnMarker ( int marker ) { if ( marker <= 0xC3 && marker >= 0xC0 ) { return true ; } if ( marker <= 0xCB && marker >= 0xC5 ) { return true ; } if ( marker <= 0xCF && marker >= 0xCD ) { return true ; } return false ; }
can opt using array
153,214
protected void writeFull ( ) { byte [ ] imageData = rawImage . getData ( ) ; int numOfComponents = frameHeader . getNf ( ) ; int [ ] pixes = new int [ numOfComponents * DCTSIZE2 ] ; int blockIndex = 0 ; int startCoordinate = 0 , scanlineStride = numOfComponents * rawImage . getWidth ( ) , row = 0 ; x = 0 ; y = 0 ; for ...
Used by progressive mode
153,215
public int getValueId ( Clusterable c ) { currentItems ++ ; int index = TreeUtils . findNearestNodeIndex ( subNodes , c ) ; if ( index >= 0 ) { KMeansTreeNode node = subNodes . get ( index ) ; return node . getValueId ( c ) ; } return id ; }
Adds a clusterable to the current vocab tree for word creation
153,216
public static Node cloneNode ( Node node ) { if ( node == null ) { return null ; } IIOMetadataNode newNode = new IIOMetadataNode ( node . getNodeName ( ) ) ; if ( node instanceof IIOMetadataNode ) { IIOMetadataNode iioNode = ( IIOMetadataNode ) node ; Object obj = iioNode . getUserObject ( ) ; if ( obj instanceof byte ...
Currently only use by GIFStreamMetadata and GIFImageMetadata
153,217
protected Cluster [ ] calculateInitialClusters ( List < ? extends Clusterable > values , int numClusters ) { Cluster [ ] clusters = new Cluster [ numClusters ] ; Random random = new Random ( 1 ) ; Set < Integer > clusterCenters = new HashSet < Integer > ( ) ; for ( int i = 0 ; i < numClusters ; i ++ ) { int index = ran...
Calculates the initial clusters randomly this could be replaced with a better algorithm
153,218
public float [ ] getClusterMean ( ) { float [ ] normedCurrentLocation = new float [ mCurrentMeanLocation . length ] ; for ( int i = 0 ; i < mCurrentMeanLocation . length ; i ++ ) { normedCurrentLocation [ i ] = mCurrentMeanLocation [ i ] / ( ( float ) mClusterItems . size ( ) ) ; } return normedCurrentLocation ; }
Get the current mean value of the cluster s items
153,219
private void setItem ( int index , Timepoint time ) { time = roundToValidTime ( time , index ) ; mCurrentTime = time ; reselectSelector ( time , false , index ) ; }
Set either the hour the minute or the second . Will set the internal value and set the selection .
153,220
private boolean isHourInnerCircle ( int hourOfDay ) { boolean isMorning = hourOfDay <= 12 && hourOfDay != 0 ; if ( mController . getVersion ( ) != TimePickerDialog . Version . VERSION_1 ) isMorning = ! isMorning ; return mIs24HourMode && isMorning ; }
Check if a given hour appears in the outer circle or the inner circle
153,221
private int getCurrentlyShowingValue ( ) { int currentIndex = getCurrentItemShowing ( ) ; switch ( currentIndex ) { case HOUR_INDEX : return mCurrentTime . getHour ( ) ; case MINUTE_INDEX : return mCurrentTime . getMinute ( ) ; case SECOND_INDEX : return mCurrentTime . getSecond ( ) ; default : return - 1 ; } }
If the hours are showing return the current hour . If the minutes are showing return the current minute .
153,222
private Timepoint roundToValidTime ( Timepoint newSelection , int currentItemShowing ) { switch ( currentItemShowing ) { case HOUR_INDEX : return mController . roundToNearest ( newSelection , null ) ; case MINUTE_INDEX : return mController . roundToNearest ( newSelection , Timepoint . TYPE . HOUR ) ; default : return m...
Snap the input to a selectable value
153,223
public boolean trySettingInputEnabled ( boolean inputEnabled ) { if ( mDoingTouch && ! inputEnabled ) { return false ; } mInputEnabled = inputEnabled ; mGrayBox . setVisibility ( inputEnabled ? View . INVISIBLE : View . VISIBLE ) ; return true ; }
Set touch input as enabled or disabled for use with keyboard mode .
153,224
public static ObjectAnimator getPulseAnimator ( View labelToAnimate , float decreaseRatio , float increaseRatio ) { Keyframe k0 = Keyframe . ofFloat ( 0f , 1f ) ; Keyframe k1 = Keyframe . ofFloat ( 0.275f , decreaseRatio ) ; Keyframe k2 = Keyframe . ofFloat ( 0.69f , increaseRatio ) ; Keyframe k3 = Keyframe . ofFloat (...
Render an animator to pulsate a view in place .
153,225
public static Calendar trimToMidnight ( Calendar calendar ) { calendar . set ( Calendar . HOUR_OF_DAY , 0 ) ; calendar . set ( Calendar . MINUTE , 0 ) ; calendar . set ( Calendar . SECOND , 0 ) ; calendar . set ( Calendar . MILLISECOND , 0 ) ; return calendar ; }
Trims off all time information effectively setting it to midnight Makes it easier to compare at just the day level
153,226
@ SuppressWarnings ( "unused" ) public static DatePickerDialog newInstance ( OnDateSetListener callback ) { Calendar now = Calendar . getInstance ( ) ; return DatePickerDialog . newInstance ( callback , now ) ; }
Create a new DatePickerDialog instance initialised to the current system date .
153,227
@ SuppressWarnings ( "unused" ) public void setHighlightedDays ( Calendar [ ] highlightedDays ) { for ( Calendar highlightedDay : highlightedDays ) { this . highlightedDays . add ( Utils . trimToMidnight ( ( Calendar ) highlightedDay . clone ( ) ) ) ; } if ( mDayPickerView != null ) mDayPickerView . onChange ( ) ; }
Sets an array of dates which should be highlighted when the picker is drawn
153,228
@ SuppressWarnings ( "DeprecatedIsStillUsed" ) public void setTimeZone ( TimeZone timeZone ) { mTimezone = timeZone ; mCalendar . setTimeZone ( timeZone ) ; YEAR_FORMAT . setTimeZone ( timeZone ) ; MONTH_FORMAT . setTimeZone ( timeZone ) ; DAY_FORMAT . setTimeZone ( timeZone ) ; }
Set which timezone the picker should use
153,229
public void setLocale ( Locale locale ) { mLocale = locale ; mWeekStart = Calendar . getInstance ( mTimezone , mLocale ) . getFirstDayOfWeek ( ) ; YEAR_FORMAT = new SimpleDateFormat ( "yyyy" , locale ) ; MONTH_FORMAT = new SimpleDateFormat ( "MMM" , locale ) ; DAY_FORMAT = new SimpleDateFormat ( "dd" , locale ) ; }
Set a custom locale to be used when generating various strings in the picker
153,230
public void start ( ) { if ( hasVibratePermission ( mContext ) ) { mVibrator = ( Vibrator ) mContext . getSystemService ( Service . VIBRATOR_SERVICE ) ; } mIsGloballyEnabled = checkGlobalSetting ( mContext ) ; Uri uri = Settings . System . getUriFor ( Settings . System . HAPTIC_FEEDBACK_ENABLED ) ; mContext . getConten...
Call to setup the controller .
153,231
private boolean hasVibratePermission ( Context context ) { PackageManager pm = context . getPackageManager ( ) ; int hasPerm = pm . checkPermission ( android . Manifest . permission . VIBRATE , context . getPackageName ( ) ) ; return hasPerm == PackageManager . PERMISSION_GRANTED ; }
Method to verify that vibrate permission has been granted .
153,232
@ SuppressWarnings ( "SameParameterValue" ) public static TimePickerDialog newInstance ( OnTimeSetListener callback , int hourOfDay , int minute , int second , boolean is24HourMode ) { TimePickerDialog ret = new TimePickerDialog ( ) ; ret . initialize ( callback , hourOfDay , minute , second , is24HourMode ) ; return r...
Create a new TimePickerDialog instance with a given intial selection
153,233
public static TimePickerDialog newInstance ( OnTimeSetListener callback , int hourOfDay , int minute , boolean is24HourMode ) { return TimePickerDialog . newInstance ( callback , hourOfDay , minute , 0 , is24HourMode ) ; }
Create a new TimePickerDialog instance with a given initial selection
153,234
@ SuppressWarnings ( { "unused" , "SameParameterValue" } ) public static TimePickerDialog newInstance ( OnTimeSetListener callback , boolean is24HourMode ) { Calendar now = Calendar . getInstance ( ) ; return TimePickerDialog . newInstance ( callback , now . get ( Calendar . HOUR_OF_DAY ) , now . get ( Calendar . MINUT...
Create a new TimePickerDialog instance initialized to the current system time
153,235
private boolean processKeyUp ( int keyCode ) { if ( keyCode == KeyEvent . KEYCODE_TAB ) { if ( mInKbMode ) { if ( isTypedTimeFullyLegal ( ) ) { finishKbMode ( true ) ; } return true ; } } else if ( keyCode == KeyEvent . KEYCODE_ENTER ) { if ( mInKbMode ) { if ( ! isTypedTimeFullyLegal ( ) ) { return true ; } finishKbMo...
For keyboard mode processes key events .
153,236
public void setMonthParams ( int selectedDay , int year , int month , int weekStart ) { if ( month == - 1 && year == - 1 ) { throw new InvalidParameterException ( "You must specify month and year for this view" ) ; } mSelectedDay = selectedDay ; mMonth = month ; mYear = year ; final Calendar today = Calendar . getInsta...
Sets all the parameters for displaying this week . The only required parameter is the week number . Other parameters have a default value and will only update if a new value is included except for focus month which will always default to no focus month if no value is passed in .
153,237
public int getDayFromLocation ( float x , float y ) { final int day = getInternalDayFromLocation ( x , y ) ; if ( day < 1 || day > mNumCells ) { return - 1 ; } return day ; }
Calculates the day that the given x position is in accounting for week number . Returns the day or - 1 if the position wasn t in a day .
153,238
protected int getInternalDayFromLocation ( float x , float y ) { int dayStart = mEdgePadding ; if ( x < dayStart || x > mWidth - mEdgePadding ) { return - 1 ; } int row = ( int ) ( y - getMonthHeaderSize ( ) ) / mRowHeight ; int column = ( int ) ( ( x - dayStart ) * mNumDays / ( mWidth - dayStart - mEdgePadding ) ) ; i...
Calculates the day that the given x position is in accounting for week number .
153,239
private String getWeekDayLabel ( Calendar day ) { Locale locale = mController . getLocale ( ) ; if ( Build . VERSION . SDK_INT < 18 ) { String dayName = new SimpleDateFormat ( "E" , locale ) . format ( day . getTime ( ) ) ; String dayLabel = dayName . toUpperCase ( locale ) . substring ( 0 , 1 ) ; if ( locale . equals ...
Return a 1 or 2 letter String for use as a weekday label
153,240
private void calculateGridSizes ( float numbersRadius , float xCenter , float yCenter , float textSize , float [ ] textGridHeights , float [ ] textGridWidths ) { float offset1 = numbersRadius ; float offset2 = numbersRadius * ( ( float ) Math . sqrt ( 3 ) ) / 2f ; float offset3 = numbersRadius / 2f ; mPaint . setTextSi...
Using the trigonometric Unit Circle calculate the positions that the text will need to be drawn at based on the specified circle radius . Place the values in the textGridHeights and textGridWidths parameters .
153,241
private void drawTexts ( Canvas canvas , float textSize , Typeface typeface , String [ ] texts , float [ ] textGridWidths , float [ ] textGridHeights ) { mPaint . setTextSize ( textSize ) ; mPaint . setTypeface ( typeface ) ; Paint [ ] textPaints = assignTextColors ( texts ) ; canvas . drawText ( texts [ 0 ] , textGrid...
Draw the 12 text values at the positions specified by the textGrid parameters .
153,242
public void setSelection ( int selectionDegrees , boolean isInnerCircle , boolean forceDrawDot ) { mSelectionDegrees = selectionDegrees ; mSelectionRadians = selectionDegrees * Math . PI / 180 ; mForceDrawDot = forceDrawDot ; if ( mHasInnerCircle ) { if ( isInnerCircle ) { mNumbersRadiusMultiplier = mInnerNumbersRadius...
Set the selection .
153,243
protected void setUpRecyclerView ( DatePickerDialog . ScrollOrientation scrollOrientation ) { setVerticalScrollBarEnabled ( false ) ; setFadingEdgeLength ( 0 ) ; int gravity = scrollOrientation == DatePickerDialog . ScrollOrientation . VERTICAL ? Gravity . TOP : Gravity . START ; GravitySnapHelper helper = new GravityS...
Sets all the required fields for the list view . Override this method to set a different list view behavior .
153,244
public boolean dispatchPopulateAccessibilityEvent ( AccessibilityEvent event ) { if ( event . getEventType ( ) == AccessibilityEvent . TYPE_WINDOW_STATE_CHANGED ) { event . getText ( ) . clear ( ) ; int flags = DateUtils . FORMAT_SHOW_DATE | DateUtils . FORMAT_SHOW_YEAR | DateUtils . FORMAT_SHOW_WEEKDAY ; String dateSt...
Announce the currently - selected date when launched .
153,245
public int getIsTouchingAmOrPm ( float xCoord , float yCoord ) { if ( ! mDrawValuesReady ) { return - 1 ; } int squaredYDistance = ( int ) ( ( yCoord - mAmPmYCenter ) * ( yCoord - mAmPmYCenter ) ) ; int distanceToAmCenter = ( int ) Math . sqrt ( ( xCoord - mAmXCenter ) * ( xCoord - mAmXCenter ) + squaredYDistance ) ; i...
Calculate whether the coordinates are touching the AM or PM circle .
153,246
public void setExcludeFilter ( File filterFile ) { if ( filterFile != null && filterFile . length ( ) > 0 ) { excludeFile = filterFile ; } else { if ( filterFile != null ) { log ( "Warning: exclude filter file " + filterFile + ( filterFile . exists ( ) ? " is empty" : " does not exist" ) ) ; } excludeFile = null ; } }
Set the exclude filter file
153,247
public void setIncludeFilter ( File filterFile ) { if ( filterFile != null && filterFile . length ( ) > 0 ) { includeFile = filterFile ; } else { if ( filterFile != null ) { log ( "Warning: include filter file " + filterFile + ( filterFile . exists ( ) ? " is empty" : " does not exist" ) ) ; } includeFile = null ; } }
Set the include filter file
153,248
public void setBaselineBugs ( File baselineBugs ) { if ( baselineBugs != null && baselineBugs . length ( ) > 0 ) { this . baselineBugs = baselineBugs ; } else { if ( baselineBugs != null ) { log ( "Warning: baseline bugs file " + baselineBugs + ( baselineBugs . exists ( ) ? " is empty" : " does not exist" ) ) ; } this ...
Set the baseline bugs file
153,249
public void setAuxClasspath ( Path src ) { boolean nonEmpty = false ; String [ ] elementList = src . list ( ) ; for ( String anElementList : elementList ) { if ( ! "" . equals ( anElementList ) ) { nonEmpty = true ; break ; } } if ( nonEmpty ) { if ( auxClasspath == null ) { auxClasspath = src ; } else { auxClasspath ....
the auxclasspath to use .
153,250
public void setAuxClasspathRef ( Reference r ) { Path path = createAuxClasspath ( ) ; path . setRefid ( r ) ; path . toString ( ) ; }
Adds a reference to a sourcepath defined elsewhere .
153,251
public void setAuxAnalyzepath ( Path src ) { boolean nonEmpty = false ; String [ ] elementList = src . list ( ) ; for ( String anElementList : elementList ) { if ( ! "" . equals ( anElementList ) ) { nonEmpty = true ; break ; } } if ( nonEmpty ) { if ( auxAnalyzepath == null ) { auxAnalyzepath = src ; } else { auxAnaly...
the auxAnalyzepath to use .
153,252
public void setSourcePath ( Path src ) { if ( sourcePath == null ) { sourcePath = src ; } else { sourcePath . append ( src ) ; } }
the sourcepath to use .
153,253
public void setExcludePath ( Path src ) { if ( excludePath == null ) { excludePath = src ; } else { excludePath . append ( src ) ; } }
the excludepath to use .
153,254
public void setIncludePath ( Path src ) { if ( includePath == null ) { includePath = src ; } else { includePath . append ( src ) ; } }
the includepath to use .
153,255
protected void checkParameters ( ) { super . checkParameters ( ) ; if ( projectFile == null && classLocations . size ( ) == 0 && filesets . size ( ) == 0 && dirsets . size ( ) == 0 && auxAnalyzepath == null ) { throw new BuildException ( "either projectfile, <class/>, <fileset/> or <auxAnalyzepath/> child " + "elements...
Check that all required attributes have been set
153,256
static boolean isEclipsePluginDisabled ( String pluginId , Map < URI , Plugin > allPlugins ) { for ( Plugin plugin : allPlugins . values ( ) ) { if ( pluginId . equals ( plugin . getPluginId ( ) ) ) { return false ; } } return true ; }
Eclipse plugin can be disabled ONLY by user so it must NOT be in the list of loaded plugins
153,257
public static < Fact , AnalysisType extends BasicAbstractDataflowAnalysis < Fact > > void printCFG ( Dataflow < Fact , AnalysisType > dataflow , PrintStream out ) { DataflowCFGPrinter < Fact , AnalysisType > printer = new DataflowCFGPrinter < > ( dataflow ) ; printer . print ( out ) ; }
Print CFG annotated with results from given dataflow analysis .
153,258
private void fillMenu ( ) { isBugItem = new MenuItem ( menu , SWT . RADIO ) ; isBugItem . setText ( "Bug" ) ; notBugItem = new MenuItem ( menu , SWT . RADIO ) ; notBugItem . setText ( "Not Bug" ) ; isBugItem . addSelectionListener ( new SelectionAdapter ( ) { public void widgetSelected ( SelectionEvent e ) { if ( bugIn...
Fill the classification menu .
153,259
private void syncMenu ( ) { if ( bugInstance != null ) { isBugItem . setEnabled ( true ) ; notBugItem . setEnabled ( true ) ; BugProperty isBugProperty = bugInstance . lookupProperty ( BugProperty . IS_BUG ) ; if ( isBugProperty == null ) { isBugItem . setSelection ( false ) ; notBugItem . setSelection ( false ) ; } el...
Update menu to match currently selected BugInstance .
153,260
public PatternMatcher execute ( ) throws DataflowAnalysisException { workList . addLast ( cfg . getEntry ( ) ) ; while ( ! workList . isEmpty ( ) ) { BasicBlock basicBlock = workList . removeLast ( ) ; visitedBlockMap . put ( basicBlock , basicBlock ) ; BasicBlock . InstructionIterator i = basicBlock . instructionItera...
Search for examples of the ByteCodePattern .
153,261
private void attemptMatch ( BasicBlock basicBlock , BasicBlock . InstructionIterator instructionIterator ) throws DataflowAnalysisException { work ( new State ( basicBlock , instructionIterator , pattern . getFirst ( ) ) ) ; }
Attempt to begin a match .
153,262
public static final String getString ( Type type ) { if ( type instanceof GenericObjectType ) { return ( ( GenericObjectType ) type ) . toString ( true ) ; } else if ( type instanceof ArrayType ) { return TypeCategory . asString ( ( ArrayType ) type ) ; } else { return type . toString ( ) ; } }
Get String representation of a Type including Generic information
153,263
private boolean askToSave ( ) { if ( mainFrame . isProjectChanged ( ) ) { int response = JOptionPane . showConfirmDialog ( mainFrame , L10N . getLocalString ( "dlg.save_current_changes" , "The current project has been changed, Save current changes?" ) , L10N . getLocalString ( "dlg.save_changes" , "Save Changes?" ) , J...
Returns true if cancelled
153,264
SaveReturn saveAnalysis ( final File f ) { Future < Object > waiter = mainFrame . getBackgroundExecutor ( ) . submit ( ( ) -> { BugSaver . saveBugs ( f , mainFrame . getBugCollection ( ) , mainFrame . getProject ( ) ) ; return null ; } ) ; try { waiter . get ( ) ; } catch ( InterruptedException e ) { return SaveReturn ...
Save current analysis as file passed in . Return SAVE_SUCCESSFUL if save successful . Method doesn t do much . This method is more if need to do other things in the future for saving analysis . And to keep saving naming convention .
153,265
public String getClassPath ( ) { StringBuilder buf = new StringBuilder ( ) ; for ( Entry entry : entryList ) { if ( buf . length ( ) > 0 ) { buf . append ( File . pathSeparator ) ; } buf . append ( entry . getURL ( ) ) ; } return buf . toString ( ) ; }
Return the classpath string .
153,266
private InputStream getInputStreamForResource ( String resourceName ) { for ( Entry entry : entryList ) { InputStream in ; try { in = entry . openStream ( resourceName ) ; if ( in != null ) { if ( URLClassPathRepository . DEBUG ) { System . out . println ( "\t==> found " + resourceName + " in " + entry . getURL ( ) ) ;...
Open a stream to read given resource .
153,267
public JavaClass lookupClass ( String className ) throws ClassNotFoundException { if ( classesThatCantBeFound . contains ( className ) ) { throw new ClassNotFoundException ( "Error while looking for class " + className + ": class not found" ) ; } String resourceName = className . replace ( '.' , '/' ) + ".class" ; Inpu...
Look up a class from the classpath .
153,268
public static String getURLProtocol ( String urlString ) { String protocol = null ; int firstColon = urlString . indexOf ( ':' ) ; if ( firstColon >= 0 ) { String specifiedProtocol = urlString . substring ( 0 , firstColon ) ; if ( FindBugs . knownURLProtocolSet . contains ( specifiedProtocol ) ) { protocol = specifiedP...
Get the URL protocol of given URL string .
153,269
public static String getFileExtension ( String fileName ) { int lastDot = fileName . lastIndexOf ( '.' ) ; return ( lastDot >= 0 ) ? fileName . substring ( lastDot ) : null ; }
Get the file extension of given fileName .
153,270
public void killLoadsOfField ( XField field ) { if ( ! REDUNDANT_LOAD_ELIMINATION ) { return ; } HashSet < AvailableLoad > killMe = new HashSet < > ( ) ; for ( AvailableLoad availableLoad : getAvailableLoadMap ( ) . keySet ( ) ) { if ( availableLoad . getField ( ) . equals ( field ) ) { if ( RLE_DEBUG ) { System . out ...
Kill all loads of given field .
153,271
public void addMeta ( char meta , String replacement ) { metaCharacterSet . set ( meta ) ; replacementMap . put ( new String ( new char [ ] { meta } ) , replacement ) ; }
Add a metacharacter and its replacement .
153,272
public static String getResourceString ( String key ) { ResourceBundle bundle = FindbugsPlugin . getDefault ( ) . getResourceBundle ( ) ; try { return bundle . getString ( key ) ; } catch ( MissingResourceException e ) { return key ; } }
Returns the string from the plugin s resource bundle or key if not found .
153,273
public static String getFindBugsEnginePluginLocation ( ) { URL u = plugin . getBundle ( ) . getEntry ( "/" ) ; try { URL bundleRoot = FileLocator . resolve ( u ) ; String path = bundleRoot . getPath ( ) ; if ( FindBugsBuilder . DEBUG ) { System . out . println ( "Pluginpath: " + path ) ; } if ( path . endsWith ( "/ecli...
Find the filesystem path of the FindBugs plugin directory .
153,274
public void logException ( Throwable e , String message ) { logMessage ( IStatus . ERROR , message , e ) ; }
Log an exception .
153,275
public static IPath getBugCollectionFile ( IProject project ) { IPath path = getDefault ( ) . getStateLocation ( ) ; return path . append ( project . getName ( ) + ".fbwarnings.xml" ) ; }
Get the file resource used to store findbugs warnings for a project .
153,276
public static SortedBugCollection getBugCollection ( IProject project , IProgressMonitor monitor ) throws CoreException { SortedBugCollection bugCollection = ( SortedBugCollection ) project . getSessionProperty ( SESSION_PROPERTY_BUG_COLLECTION ) ; if ( bugCollection == null ) { try { readBugCollectionAndProject ( proj...
Get the stored BugCollection for project . If there is no stored bug collection for the project or if an error occurs reading the stored bug collection a default empty collection is created and returned .
153,277
private static void readBugCollectionAndProject ( IProject project , IProgressMonitor monitor ) throws IOException , DocumentException , CoreException { SortedBugCollection bugCollection ; IPath bugCollectionPath = getBugCollectionFile ( project ) ; File bugCollectionFile = bugCollectionPath . toFile ( ) ; if ( ! bugCo...
Read saved bug collection and findbugs project from file . Will populate the bug collection and findbugs project session properties if successful . If there is no saved bug collection and project for the eclipse project then FileNotFoundException will be thrown .
153,278
public static void storeBugCollection ( IProject project , final SortedBugCollection bugCollection , IProgressMonitor monitor ) throws IOException , CoreException { project . setSessionProperty ( SESSION_PROPERTY_BUG_COLLECTION , bugCollection ) ; if ( bugCollection != null ) { writeBugCollection ( project , bugCollect...
Store a new bug collection for a project . The collection is stored in the session and also in a file in the project .
153,279
public static void saveCurrentBugCollection ( IProject project , IProgressMonitor monitor ) throws CoreException { if ( isBugCollectionDirty ( project ) ) { SortedBugCollection bugCollection = ( SortedBugCollection ) project . getSessionProperty ( SESSION_PROPERTY_BUG_COLLECTION ) ; if ( bugCollection != null ) { write...
If necessary save current bug collection for project to disk .
153,280
public static UserPreferences getProjectPreferences ( IProject project , boolean forceRead ) { try { UserPreferences prefs = ( UserPreferences ) project . getSessionProperty ( SESSION_PROPERTY_USERPREFS ) ; if ( prefs == null || forceRead ) { prefs = readUserPreferences ( project ) ; if ( prefs == null ) { prefs = getW...
Get project own preferences set .
153,281
public static void saveUserPreferences ( IProject project , final UserPreferences userPrefs ) throws CoreException { FileOutput userPrefsOutput = new FileOutput ( ) { public void writeFile ( OutputStream os ) throws IOException { userPrefs . write ( os ) ; } public String getTaskDescription ( ) { return "writing user p...
Save current UserPreferences for given project or workspace .
153,282
private static void resetStore ( IPreferenceStore store , String prefix ) { int start = 0 ; while ( start < 99 ) { String name = prefix + start ; if ( store . contains ( name ) ) { store . setToDefault ( name ) ; } else { break ; } start ++ ; } }
Removes all consequent enumerated keys from given store staring with given prefix
153,283
private static void ensureReadWrite ( IFile file ) throws CoreException { if ( file . isReadOnly ( ) ) { IStatus checkOutStatus = ResourcesPlugin . getWorkspace ( ) . validateEdit ( new IFile [ ] { file } , null ) ; if ( ! checkOutStatus . isOK ( ) ) { throw new CoreException ( checkOutStatus ) ; } } }
Ensure that a file is writable . If not currently writable check it as so that we can edit it .
153,284
private static UserPreferences readUserPreferences ( IProject project ) throws CoreException { IFile userPrefsFile = getUserPreferencesFile ( project ) ; if ( ! userPrefsFile . exists ( ) ) { return null ; } try { InputStream in = userPrefsFile . getContents ( true ) ; UserPreferences userPrefs = FindBugsPreferenceInit...
Read UserPreferences for project from the file in the project directory . Returns null if the preferences have not been saved to a file or if there is an error reading the preferences file .
153,285
public RecursiveFileSearch search ( ) throws InterruptedException { File baseFile = new File ( baseDir ) ; String basePath = bestEffortCanonicalPath ( baseFile ) ; directoryWorkList . add ( baseFile ) ; directoriesScanned . add ( basePath ) ; directoriesScannedList . add ( basePath ) ; while ( ! directoryWorkList . isE...
Perform the search .
153,286
public static MethodDescriptor getMethodDescriptor ( JavaClass jclass , Method method ) { return DescriptorFactory . instance ( ) . getMethodDescriptor ( jclass . getClassName ( ) . replace ( '.' , '/' ) , method . getName ( ) , method . getSignature ( ) , method . isStatic ( ) ) ; }
Construct a MethodDescriptor from JavaClass and method .
153,287
public static ClassDescriptor getClassDescriptor ( JavaClass jclass ) { return DescriptorFactory . instance ( ) . getClassDescriptor ( ClassName . toSlashedClassName ( jclass . getClassName ( ) ) ) ; }
Construct a ClassDescriptor from a JavaClass .
153,288
public static boolean preTiger ( JavaClass jclass ) { return jclass . getMajor ( ) < JDK15_MAJOR || ( jclass . getMajor ( ) == JDK15_MAJOR && jclass . getMinor ( ) < JDK15_MINOR ) ; }
Checks if classfile was compiled for pre 1 . 5 target
153,289
public void addBugCategory ( BugCategory bugCategory ) { BugCategory old = bugCategories . get ( bugCategory . getCategory ( ) ) ; if ( old != null ) { throw new IllegalArgumentException ( "Category already exists" ) ; } bugCategories . put ( bugCategory . getCategory ( ) , bugCategory ) ; }
Add a BugCategory reported by the Plugin .
153,290
public DetectorFactory getFactoryByShortName ( final String shortName ) { return findFirstMatchingFactory ( factory -> factory . getShortName ( ) . equals ( shortName ) ) ; }
Look up a DetectorFactory by short name .
153,291
public DetectorFactory getFactoryByFullName ( final String fullName ) { return findFirstMatchingFactory ( factory -> factory . getFullName ( ) . equals ( fullName ) ) ; }
Look up a DetectorFactory by full name .
153,292
public Collection < TypeQualifierValue < ? > > getDirectlyRelevantTypeQualifiers ( MethodDescriptor m ) { Collection < TypeQualifierValue < ? > > result = methodToDirectlyRelevantQualifiersMap . get ( m ) ; if ( result != null ) { return result ; } return Collections . < TypeQualifierValue < ? > > emptyList ( ) ; }
Get the directly - relevant type qualifiers applied to given method .
153,293
public void setDirectlyRelevantTypeQualifiers ( MethodDescriptor methodDescriptor , Collection < TypeQualifierValue < ? > > qualifiers ) { methodToDirectlyRelevantQualifiersMap . put ( methodDescriptor , qualifiers ) ; allKnownQualifiers . addAll ( qualifiers ) ; }
Set the collection of directly - relevant type qualifiers for a given method .
153,294
private int adjustPriority ( int priority ) { try { Subtypes2 subtypes2 = AnalysisContext . currentAnalysisContext ( ) . getSubtypes2 ( ) ; if ( ! subtypes2 . hasSubtypes ( getClassDescriptor ( ) ) ) { priority ++ ; } else { Set < ClassDescriptor > mySubtypes = subtypes2 . getSubtypes ( getClassDescriptor ( ) ) ; Strin...
Adjust the priority of a warning about to be reported .
153,295
void registerDetector ( DetectorFactory factory ) { if ( FindBugs . DEBUG ) { System . out . println ( "Registering detector: " + factory . getFullName ( ) ) ; } String detectorName = factory . getShortName ( ) ; if ( ! factoryList . contains ( factory ) ) { factoryList . add ( factory ) ; } else { LOGGER . log ( Level...
Register a DetectorFactory .
153,296
public BugPattern lookupBugPattern ( String bugType ) { if ( bugType == null ) { return null ; } return bugPatternMap . get ( bugType ) ; }
Look up bug pattern .
153,297
public Collection < String > getBugCategories ( ) { ArrayList < String > result = new ArrayList < > ( categoryDescriptionMap . size ( ) ) ; for ( BugCategory c : categoryDescriptionMap . values ( ) ) { if ( ! c . isHidden ( ) ) { result . add ( c . getCategory ( ) ) ; } } return result ; }
Get a Collection containing all known bug category keys . E . g . CORRECTNESS MT_CORRECTNESS PERFORMANCE etc .
153,298
public static boolean isGetterMethod ( ClassContext classContext , Method method ) { MethodGen methodGen = classContext . getMethodGen ( method ) ; if ( methodGen == null ) { return false ; } InstructionList il = methodGen . getInstructionList ( ) ; if ( il . getLength ( ) > 60 ) { return false ; } int count = 0 ; Iter...
Determine whether or not the the given method is a getter method . I . e . if it just returns the value of an instance field .
153,299
private FieldStats getStats ( XField field ) { FieldStats stats = statMap . get ( field ) ; if ( stats == null ) { stats = new FieldStats ( field ) ; statMap . put ( field , stats ) ; } return stats ; }
Get the access statistics for given field .