Any way to search for casts in java source code?

Anyone know of a decent way to search your java source files to find all the casts?
I ended up doing a simple text search for
     " = ("(quote marks not included) which works for my code because I am strict about writing my casts with spaces like
     String s = (String) iterator.next();Unfortunately, the above search has all kinds of problems with both false positives and negatives. It picks up lots of irrelevant lines like
     int index = (number > 0) ? 0 : 1;as well as misses casts that appear nested inside expressions like
     ((String) iter.next()).charAt(...)I suppose that one could do a regular expression search for any pair of open and close parens which bound non-blank text, but that would pick up even more non-cast expressions in typical java code.
I think that the only way to properly do this is to have a tool which understands java syntax.
Anyone know of an IDE which will do this? Does IntelliJ or Netbeans support this kind of search?
In case you are wondering why I am interested in this, it is because I am refactoring some code to fully use generics, and searching for casts is one source of identifying candidates for genericity.

cliffblob wrote:
Better late than never?Yes!
cliffblob wrote:
...The answer I found to ID unnecessary casts was, using Eclipse IDE, In compiler error and warning preferences to warn on unnecessary casts.Thanks for pointing IDEs out. I just opened IntelliJ, and going back to at least version 7.04 (maybe earlier) they have an inspection for "Redundant type cast".
cliffblob wrote:
I would still be interested to know if there is a way to identify casts in general in your source, perhaps now four years later there is a way?The only solutions that I can think of are either a complicated regex search, or you must use some tool like an IDE that understand Java syntax and can determine if a cast is happening.

Similar Messages

  • Is there any way to search for a term using the Firefox search field, and have the results automatically open in a new tab?

    Is there any way to search for a term using the Firefox search field, and have the results automatically open in a new tab? When there was support for Google Toolbar, I was able to do this; now, whenever I want to search for something, I have to open a new tab to do it, and cut-and-paste my search into the search field in the new tab. I used to be able to highlight, drag, and drop something into the search field and have it automatically open in a new tab. This is enough for me to switch to Chrome . . .

    Set a preference to have searches from the Search Bar (upper right) automatically open all searches in a new tab
    #type '''about:config''' in the URL/Location/Address bar and press the Enter key
    #if you see a warning, accept it (promise to be careful)
    #Filter = '''browser.search.openintab'''
    #in the lower panel, double click the item (or right-click and choose "Toggle") to change the value to "true"
    #close the about:config tab and test
    #See:
    #*For help with opening/using about:config, also see: http://kb.mozillazine.org/About:config
    #*Also see: http://kb.mozillazine.org/About:config_entries (click on "Browser", scroll down to browser.search.openintab)
    '''Search Bar''': http://support.mozilla.com/en-US/kb/Search+bar
    '''If this reply solves your problem, please click "Solved It" next to this reply when <u>signed-in</u> to the forum.'''
    About Google toolbar............
    Google decided that they will no longer produce the Google Toolbar for Firefox 5 and newer version. It is best to move on to other alternatives than to try any "hacks" to the toolbar that may or may not perform in the future. Future versions of Google toolbar will only work with IE7-9. Google Toolbar is not available on any other browser, even Google's own browser.
    *http://googletoolbarhelp.blogspot.com/2011/07/update-on-google-toolbar-for-firefox.html
    *https://support.mozilla.com/en-US/kb/google-toolbar-not-compatible-firefox?s=google+toolbar&r=0&as=s
    *http://www.google.com/support/toolbar/bin/answer.py?answer=1342452&topic=15356%29
    *Google Toolbar 8 FAQ (IE only): https://www.google.com/support/toolbar/bin/answer.py?hl=en&answer=1111588
    '''''To access your Google Bookmarks visit''''' www.google.com/bookmarks.
    Alternatives:
    *http://kb.mozillazine.org/Using_Google_Toolbar_features_without_toolbars
    *https://addons.mozilla.org/en-US/firefox/addon/googlebar-lite/
    *https://addons.mozilla.org/en-US/firefox/addon/gbookmarks-google-bookmarks-fo/

  • Any way to search for transparent items?

    Is there any way to search for items that have an opacity of less than 100%?  I found that some of the advertisements I placed inexplicably came in at 76% opacity.  And I noticed some tiny endmark graphics came in with 0% opacity.  I don't know why.  I'm just trying to make sure I didn't miss correcting anything.
    Thanks, Phyllis

    Err, whoops. That's not going to work, because there's not a list of images in the document, only a list by page. And it's probably better to use Graphics instead, which include, e.g., PDFs.  So you probably want instead:
    var d=app.activeDocument, im=d.allGraphics, i;
    for (i=0; i<im.length; i++) {
      if (im[i].transparencySettings.blendingSettings.opacity < 80) {
        alert("Page "+im[i].parentPage.name+" has "+
          im[i].itemLink.filePath);
    And this iterates over Graphics which are the things inside containers (like rectangles). You might have the transparency applied to the container rectangle instead, in which case you'd probably need to replace allGraphics with allPageItems, except then it would fail on all the objects that don't have a transparency property [sigh...], so you'd need something (ick) like this:
    var d=app.activeDocument, im=d.allPageItems, i;
    for (i=0; i<im.length; i++) {
      try {
       if (im[i].transparencySettings.blendingSettings.opacity < 80) {
          alert("Page "+im[i].parentPage.name+" has "+
            im[i].itemLink.filePath);
      } catch (e) { }

  • Any way to search for and get rid of duplicate songs?

    Is there any way to recognize and then get rid of duplicate songs? I copied some songs from a different computer and ended up duplicating some of my existing songs. Any way to search for and then get rid of the duplicates?

    The apple algorithm for detecting duplicates is not great. I did this yesterday on a library which had got bloated by various itunes 'organisations' and had 15000 songs in it and downloaded idupe. It seemed to work very well and got me down to 10,000 songs. 8USD shareware.

  • Is there any way to search for bad blocks in my Macintoshi HD without formating it? I'm experiencing too much I/O problems...

    Is there any way to search for bad blocks in my Macintoshi HD without formating it? I'm experiencing too much I/O problems...

    Check the drive health with the free demo of SMART Utility.
    http://www.volitans-software.com/smart_utility.php
    Reformatting and zeroing out might keep a drive going a bit longer, but once bad blocks become noticeable, it's not a drive you should trust any longer.

  • Retrieve already deployed webdynpro for java source code from portal server

    HI ,
       We have webdynpro for java apllication already deployed on the J2EE server.  We found the ear file related to this application.  But I am not able to make any changes to the ear file in NWDS as it cannot be directly imported into NWDS.  We do not have NWDI for software logistics and the resource who built the WDJ application has left the company.  Is there any way that I can retrieve the complete source code of the application from the portal.  I need to make some changes to Webdynpro component and its view.  I have worked with basis team to retrieve the ear file from portal server.  But I could not make any progress just with the ear file.  Thank you for your help in advance
    Regards,
    KMM.

    You are probably breaking some license agreement by de-compiling the content of the 'war' files. Why not ask the people who provided the 'war' file if you could have the source and build system.

  • Is there a way to search for skipped songs in my iTunes library?

    I'd like to know whether there's a quicker way to find songs that are being skipped in my iTunes library, than simply manually checking each one.  I've been rearranging and deleting music files in Windows Explorer recently, so I know that there is a chance that I have demolished the link iTunes had to some of the files, but there's no way I can remember what all the modified albums are.  I know how to reestablish the links when I do find a song that is being skipped, but I'd love to go through the whole library and be able to find them all at once.
    The last time I did this, manually - and it seemed to take hours - I did find quite a lot of songs that were being skipped, and was able to reestablish the links or in some cases just delete the song from iTunes since i hadn't wanted it anyway.  But even then it was a little hard, since after manually checking in the quickest way I could - going through the song list and briefly playing each one for a second or fraction of a second - there was no way of sorting the songs by whether they were skipped or not.  I just had to be very careful as I scrolled, to catch each one that had the symbol indicating non-playability.
    All that to say - is there some better, automatic way of searching for non-playable, skipped songs, and is there some way of sorting them out from the rest so one can address them, and not miss any?

    Same question. Used to have an iPod. Lost it (best digital player ever), now I use other portable device. The mp3 files have their id3tag edited in the original file, but the .m4a don't!.
    Want to know someway to write the info from the library to the original .m4a files.

  • Any way to search from websites?

    Hi! Is there any way to search words from websites? E.g. User gives a word and a website address (can be also specified manually) and the program checks, is there that word in that website.
    Thanks!

    ForXy wrote:
    OK. Example, please?Pseudocode:boolean isWordOnPage(word, url) {
        return url.text.contains(word)
    url = new URL("http://java.sun.com")
    assert  isWordOnPage("Java", url)
    assert !isWordOnPage("luftmensch", url)~

  • Is there a way to search for movies on iTunes that have subtitles?

    Is there a way to search for movies on iTunes that have subtitles?
    I know if you look at any individual movie, it will say CC and below that, it will tell you if closed captioning is available in English or another language. I'm just wondering if there is some way to search for all the movies that have this available since many of them don't.

    The best solution I've come across so far is to dump all movies into a shareware app called iVI. It'll show whether each movie has subtitles or not.

  • Premiere Pro CC's sequence lost. Is there a way to "search" for it from outside the project?

    I seem to have lost a sequence created in Premiere Pro CC. I can't find it anywhere inside the Project bin.
    We have so many same-name, older projects (between Auto-Save, different drives and so on) that looking inside each of them would take forever.
    But we do know the name of the sequence. I am wondering  if there is a way to "search" for a sequence name from outside the project?
    Thanks

    there is a way to "search" for a sequence name outside of the project,
    but it would be a pointless waste of time.
    sequences are only saved within the project file itself!!
    We have so many same-name, older projects (between Auto-Save, different drives and so on) that looking inside each of them would take forever.
    better get at it then!
    hahahahahahahaha!!!

  • Is there any way to search words that are in the comment section of iTunes song info?

    Question is above. I have put some keywords in various comment sections but can't find a way to search for them

    Note if you find search isn't working as expected it may help to switch to the List view (left-hand view icon) and enable the column, then go back to the view you were using.
    tt2

  • Any way to search places where a style is used in RH?

    Hi
    I've a few questions about style management:
    Is there a way to search for where a style is used in a project or topic?
    If so, is there a way to search-and-replace, ie, find where a style is used and replace it with another style?
    When deleting a style, is there a way RH can be set to display a warning if the style to be deleted is being used anywhere?
    FrameMaker handles the above use cases very well. However, I can't yet see how these actions are done in RH.
    Thanks!
    -Kurt

    RH doesn't warn you if you delete a style that is in use.
    If you want to replace a specific style with another one, the easiest
    way is to use a search and replace operation. For example, to change the
    style 'myStyle1' into 'myStyle2', use the following search action:
    class="myStyle1"
    and replace by
    class="myStyle2"
    Make a backup before doing this though, as you can cripple a project in
    seconds.
    Kind regards,
    Willam

  • HT201328 Why do Orange and EE blame Apple for the delays in unlocking my iPhone. 10 months now. What is the exact process that these companies have to go through to unlock an iPhone and is Apple in any way to blame for the delays.  Indeed how long does Ap

    Why do Orange and EE blame Apple for the delays in unlocking my iPhone. 10 months now. What is the exact process that these companies have to go through to unlock an iPhone and is Apple in any way to blame for the delays.
    Indeed how long does Apple take to carry out its part of the process. 
    It seems to me that Orange are just trying to stall me despite the fact that I am out of contract with them now.  I originally paid to have the phone unlocked back last November.  This was never done. 
    I have phoned them numerous times over the last two months but still they haven't done it.  Can anyone advise me and has anyone had similar problems with them.
    Thanks

    I certainly understand that only Orange can unlock my phone.  My annoyance is that they blame Apple so I am keen to know what exactly is Apple's involvement. 
    I presume that Orange have to tell Apple that the phone has been authorised for unlocking by Orange and that Apple then notes that in some way on iTunes so that the user can then complete the process on iTunes. 
    What I would like to know is how much time Apples part in this process takes.
    I would also like to make contact with others who have had similar problems.
    Many thanks

  • Is there a way to search for damaged/corrupt files in itunes?

    Hi all,
    I have several itunes-purchased files that became damaged when a hard drive of mine went on the fritz a few months ago.  I managed to get most of my files transferred to a new hard drive, but I keep running across songs that are corrupt.  The way I know they are corrupt is they just won't play, even though the file shows up in my library no problem.
    My library is several thousand songs.  Is there any way to test for corrupt songs without going song-by-song manually?

    Sorry, but I don't know what it is you are trying to accomplish and how a spreadsheet program would be related to an iTunes issue. Can you please explain in more detail what it is you're trying to do? If your command of the English language is a barrier for you, try posting in your native language and someone who is fluent in that language may be able to help.
    Regards.

  • Easy way to search for jsp file

    is there a way to search for a file in jdeveloper. I have lots of jsp file. and I sometimes i know the full name or partial name of the jsp file, but not sure if there is a way to search for the file in JDev.
    Thanks in advnace.

    When you run the search all of the files that match your query will be listed in message log. Simply double click on the file in the message log to view it.
    --Ric                                                                                                                                                                                                                                                                                                                                           

Maybe you are looking for

  • How can I get the disk information in Solaris 9

    I am new to Solairs9. I use the format utility to list my partitions, but there are many unassigned partitions. I pasted the format response below: # format AVAILABLE DISK SELECTIONS: 0. c1t1d0 <SUN72G cyl 14087 alt 2 hd 24 sec 424> /pci@8,600000/SUN

  • How do I save a video after editing it?

    I just opened up an mp4 file, trimmed it and now wish to save the edited video. However, it seems I'm only able to save the Adobe project file and not the actual video itself. If 'export' is what I'm supposed to do, how do I export it as an mp4 file,

  • How to view sent mail on iPad mini?

    I can find my sent mail on my iPad mini. Where is it?

  • How to use the location reminder

    When I first accessed the new reminders app I clicked 'do not use my location'. However, I want to use the location reminder, but I can not find it in my settings to change my preferences. Anyone know how to turn the location on? Does it even work on

  • Adobe Intractive form

    Hi all, Could anyone provide me the link/url to find good beginners document for Adobe intractive form. Many thanks in advance. Regards, Nithya