This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Java in General and the fly likes Way to SEARCH the APIs ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Way to SEARCH the APIs ?" Watch "Way to SEARCH the APIs ?" New topic
Author

Way to SEARCH the APIs ?

bob connolly
Ranch Hand

Joined: Mar 10, 2004
Posts: 204
Hi there!

Is there a way to do a complete text search on the JAVA APIs?

ie: JavaTM 2 Platform, Standard Edition, v 1.4.2
API Specification

In other words, if i'm trying to find something in a comment area or trying to find every single reference to byte[], no matter where it's located, is there such a way?

I know that i can copy 1 particular class html to a text file and do a search on that, so maybe there's a way to copy the whole API document to a text file and do a search?

Thanks alot for any ideas!

bc
Julian Kennedy
Ranch Hand

Joined: Aug 02, 2004
Posts: 823
The J2SE Javadoc is online here.

You could use the Google toolbar to search the site. Is that what you want?

Jules
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
something like this?

Search Sun API docs for byte[]
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

To search for a method-name (including constructors) I wrote a shell script find_java_method.sh which has to be invoked with the name of the method, i.e.:

Feel free to adapt it to your needs.
Grep and especially sed aren't standard-tools on the win-plattforms, but freely available.

And this is find_java_method.sed, to remove html-tags from output:


[ August 06, 2004: Message edited by: Stefan Wagner ]

[ August 06, 2004: Message edited by: Stefan Wagner ]
[ August 06, 2004: Message edited by: Stefan Wagner ]

http://home.arcor.de/hirnstrom/bewerbung
bob connolly
Ranch Hand

Joined: Mar 10, 2004
Posts: 204
Well for instance, right now i'm trying to find out how to handle HEX values and don't have an idea which class to use, so i'd like to do a complete search on the API to find every reference to the HEX word in the API listing!

I may get back alot of finds, but i can probably get an idea which classes to go and check into!

Thanks again!
bc
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

So if you don't have grep get it.


-i: ignore Case
-R: recursive

will return every token containing some kind of 'Hex', including 'TouchExpand...'.
This will be problematic, if your search contains some html-token, included in every java-page.
But in the other cases it will do a fast and easy rough impression.

If you use sed, you may clean up the output as shown above.

My results:

[ August 09, 2004: Message edited by: Stefan Wagner ]
[ August 09, 2004: Message edited by: Stefan Wagner ]
bob connolly
Ranch Hand

Joined: Mar 10, 2004
Posts: 204
Thanks Stefan!

This is exactly what i'm looking for!

I looked too complex initially, but now i understand what your doing!

This will get me alot more creative for sure!

I'm still mystified why the regular APIs dont' have such a capability!

Take care Stefan, das is good!
Julian Kennedy
Ranch Hand

Joined: Aug 02, 2004
Posts: 823
Sun does provide this search page for developers but it's not as useful as it could be as I can't see an easy way to isolate one set of API docs. D'oh! :roll:

Jules
bob connolly
Ranch Hand

Joined: Mar 10, 2004
Posts: 204
Works great Stefan!

I downloaded grep, very easy to run and it's free!

This is what i've been looking for YEARS! and i'm going to write a script to process the output, but absolutely ASTONISHED! this capability is not in the JAVADOC search!

The follwoing command printed out the file names and number of "finds" per file:

C:\UNZIPPED DOWNLOADS\JAVADOC 1.5\docs\api\java>grep -iSc hex *

.\lang\Integer.html:16
.\lang\InternalError.html:0
.\lang\InterruptedException.html:0
.\lang\Iterable.html:0
.\lang\LinkageError.html:0
.\lang\Long.html:16
.\lang\Math.html:0
........

And this command gets the actual text:

C:\UNZIPPED DOWNLOADS\JAVADOC 1.5\docs\api\java>grep -iS hex *

.\lang\Integer.html:<META NAME="keywords" CONTENT="toHexString()">
.\lang\Integer.html:<TD><CODE><B><A HREF="../../java/lang/Integer.html#toHexStr
ng(int)">toHexString</A></B>(int i)</CODE>
.\lang\Integer.html: the digits for hexadecimal (radix 16) are
.\lang\Integer.html:<A NAME="toHexString(int)"><!-- --></A><H3>
.\lang\Integer.html:toHexString</H3>
.\lang\Integer.html ublic static <A HREF="../../java/lang/String.html" title="
lass in java.lang">String</A> <B>toHexString</B>(int i)</PRE>
.\lang\Integer.html: in hexadecimal (base 16) with no extra leading
.\lang\Integer.html: hexadecimal digits:
.\lang\Integer.html: Integer.toHexString(n).toUpperCase()
.\lang\Integer.html: represented by the argument in hexadecimal (base&
bsp;16).<DT><B>Since:</B></DT>
.\lang\Integer.html: hexadecimal integer exactly as by the method
.\lang\Integer.html: Accepts decimal, hexadecimal, and octal numbers given
.\lang\Integer.html: <dd><i>Sign<sub>opt</sub></i> <code>0x</code> <i>HexDigits
/i>
.\lang\Integer.html: <dd><i>Sign<sub>opt</sub></i> <code>0X</code> <i>HexDigits
/i>
.\lang\Integer.html: <dd><i>Sign<sub>opt</sub></i> <code>#</code> <i>HexDigits<
i>
.\lang\Integer.html: <i>DecimalNumeral</i>, <i>HexDigits</i>, and <i>OctalDigit
</i>
.\lang\Long.html:<META NAME="keywords" CONTENT="toHexString()">
.\lang\Long.html:<TD><CODE><B><A HREF="../../java/lang/Long.html#toHexString(lo
g)">toHexString</A></B>(long i)</CODE>
.\lang\Long.html: the digits for hexadecimal (radix 16) are
.\lang\Long.html:<A NAME="toHexString(long)"><!-- --></A><H3>
.\lang\Long.html:toHexString</H3>
.\lang\Long.html ublic static <A HREF="../../java/lang/String.html" title="cla
s in java.lang">String</A> <B>toHexString</B>(long i)</PRE>
.\lang\Long.html: ASCII digits in hexadecimal (base 16) with no extra
.\lang\Long.html: hexadecimal digits:
.\lang\Long.html: Long.toHexString(n).toUpperCase()
.\lang\Long.html: value represented by the argument in hexadecim
l
.\lang\Long.html: Accepts decimal, hexadecimal, and octal numbers given by the
.\lang\Long.html: <dd><i>Sign<sub>opt</sub></i> <code>0x</code> <i>HexDigits</i

.\lang\Long.html: <dd><i>Sign<sub>opt</sub></i> <code>0X</code> <i>HexDigits</i

.\lang\Long.html: <dd><i>Sign<sub>opt</sub></i> <code>#</code> <i>HexDigits</i>
.\lang\Long.html: <i>DecimalNumeral</i>, <i>HexDigits</i>, and <i>OctalDigits</
>
.\lang\Long.html: a minus sign, then the rest of it is parsed as a hexadecimal
nteger
.\lang\Object.html: the unsigned hexadecimal representation of the hash code of
the
.\lang\Object.html: getClass().getName() + '@' + Integer.toHexString(hashCode()

.\lang\RuntimeException.html:<DT><B>Direct Known Subclasses:</B> <DD><A HREF=".
 
Don't get me started about those stupid light bulbs.
 
subject: Way to SEARCH the APIs ?
 
Similar Threads
Help regarding search API
Find - replace functionality
File Access and Alteration
Opening a File with the appropriate program with highlighted text
how can i convert vox to wave file or directly play vox file in java