org.fife.ctags
Class CTagReader

java.lang.Object
  extended byorg.fife.ctags.CTagReader

public class CTagReader
extends java.lang.Object

A class capable of reading a ctags file and searching for identifiers in it. CTags are a useful little tool for things like programmers' text editors. See http://ctags.sourceforge.net for more information.

This file is simply a translation of readtags.c from the Exuberant Ctags' source distribution into Java. This particular class is public domain.

Version:
0.01
Author:
Robert Futrell

Field Summary
static java.lang.String EmptyString
           
static java.lang.String PseudoTagPrefix
           
static byte TAG_FOLDSORTED
           
static int TAG_FULLMATCH
           
static int TAG_IGNORECASE
           
static int TAG_OBSERVECASE
           
static int TAG_PARTIALMATCH
           
static byte TAG_SORTED
           
static byte TAG_UNSORTED
           
static int TAGRESULT_FAILURE
           
static int TAGRESULT_SUCCESS
           
 
Constructor Summary
CTagReader()
          Creates a new CTagReader.
 
Method Summary
 boolean tagsClose()
          "Closes" the current ctag file.
 java.lang.String tagsField(TagEntry entry, java.lang.String key)
          Retrieve the value associated with the extension field for a specified key.
 boolean tagsFind(TagEntry entry, java.lang.String name, int options)
          Find the first tag matching `name'.
 boolean tagsFindNext(TagEntry entry)
          Find the next tag matching the name and options supplied to the most recent call to tagsFind() for the same tag file.
 boolean tagsFirst(TagEntry entry)
          Returns the first ctag from the ctag file.
 boolean tagsNext(TagEntry entry)
          Returns the next ctag from the given ctag file.
 void tagsOpen(java.lang.String filePath, TagFileInfo info)
          Sets the ctag file to be read by this reader.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TAG_UNSORTED

public static final byte TAG_UNSORTED
See Also:
Constant Field Values

TAG_SORTED

public static final byte TAG_SORTED
See Also:
Constant Field Values

TAG_FOLDSORTED

public static final byte TAG_FOLDSORTED
See Also:
Constant Field Values

TAG_FULLMATCH

public static final int TAG_FULLMATCH
See Also:
Constant Field Values

TAG_PARTIALMATCH

public static final int TAG_PARTIALMATCH
See Also:
Constant Field Values

TAG_OBSERVECASE

public static final int TAG_OBSERVECASE
See Also:
Constant Field Values

TAG_IGNORECASE

public static final int TAG_IGNORECASE
See Also:
Constant Field Values

TAGRESULT_FAILURE

public static final int TAGRESULT_FAILURE
See Also:
Constant Field Values

TAGRESULT_SUCCESS

public static final int TAGRESULT_SUCCESS
See Also:
Constant Field Values

EmptyString

public static final java.lang.String EmptyString
See Also:
Constant Field Values

PseudoTagPrefix

public static final java.lang.String PseudoTagPrefix
See Also:
Constant Field Values
Constructor Detail

CTagReader

public CTagReader()
Creates a new CTagReader. After this you should call tagsOpen.

Method Detail

tagsOpen

public void tagsOpen(java.lang.String filePath,
                     TagFileInfo info)
              throws java.io.FileNotFoundException,
                     java.io.IOException
Sets the ctag file to be read by this reader.

Parameters:
filePath - The ctag file from which to read.
info - Will be populated with information about the ctag file.
Throws:
java.io.FileNotFoundException - If the specified file does not exist or cannot be opened for some reason.
java.io.IOException - If an I/O error occurs.

tagsFirst

public boolean tagsFirst(TagEntry entry)
                  throws java.io.IOException
Returns the first ctag from the ctag file.

Parameters:
entry - Will contain the tag read, ??? or null if the read fails ???
Returns:
Whether or not the read was successful.
Throws:
java.io.IOException

tagsNext

public boolean tagsNext(TagEntry entry)
                 throws java.io.IOException
Returns the next ctag from the given ctag file.

Parameters:
entry - Will be the next ctag in the file, ??? or null if the read fails???
Returns:
true if a tag was read, or false if EOF was reached.
Throws:
java.io.IOException

tagsField

public java.lang.String tagsField(TagEntry entry,
                                  java.lang.String key)
Retrieve the value associated with the extension field for a specified key. It is passed a pointer to a structure already populated with values by a previous call to tagsNext(), tagsFind(), or tagsFindNext(), and a string containing the key of the desired extension field. If no such field of the specified key exists, the function will return null.

Parameters:
entry - The tag entry gotten from a call such as tagsNext.
key - The key to search for.
Returns:
The value associated with key, or null if none exists.

tagsFind

public boolean tagsFind(TagEntry entry,
                        java.lang.String name,
                        int options)
                 throws java.io.IOException
Find the first tag matching `name'. The structure pointed to by `entry' will be populated with information about the tag file entry. If a tag file is sorted using the C locale, a binary search algorithm is used to search the tag file, resulting in very fast tag lookups, even in huge tag files. Various options controlling the matches can be combined by bit-wise or-ing certain values together. The available values are:

Parameters:
entry - Will be the ctag entry found, ??? or null if it isn't found or an error occurs???
name - ???
options - ???
Returns:
true if the tag was found, or false if it wasn't or file wasn't initialized.
Throws:
java.io.IOException

tagsFindNext

public boolean tagsFindNext(TagEntry entry)
                     throws java.io.IOException
Find the next tag matching the name and options supplied to the most recent call to tagsFind() for the same tag file. The structure pointed to by 'entry' will be populated with information about the tag file entry.

Returns:
Whether or not another tag matching the name is found.
Throws:
java.io.IOException

tagsClose

public boolean tagsClose()
                  throws java.io.IOException
"Closes" the current ctag file. This reader can still be reused by calling the tagsOpen method again.

Returns:
true if the file was closed, false if this reader wasn't even initialized so there was no reason to call close.
Throws:
java.io.IOException