org.opensolaris.opengrok.analysis
Class Definitions

java.lang.Object
  extended by org.opensolaris.opengrok.analysis.Definitions
All Implemented Interfaces:
java.io.Serializable

public class Definitions
extends java.lang.Object
implements java.io.Serializable

See Also:
Serialized Form

Nested Class Summary
static class Definitions.Tag
          Class that represents a single tag.
 
Method Summary
static Definitions deserialize(byte[] bytes)
          Deserialize a binary representation of a Definitions object.
 java.util.Set<java.lang.String> getSymbols()
          Get all symbols used in definitions.
 java.util.List<Definitions.Tag> getTags()
          Get a list of all tags.
 boolean hasDefinitionAt(java.lang.String symbol, int lineNumber)
          Check whether the specified symbol is defined on the given line.
 boolean hasSymbol(java.lang.String symbol)
          Check if there is a tag for a symbol.
 int numberOfSymbols()
          Return the number of distinct symbols.
 int occurrences(java.lang.String symbol)
          Return the number of occurrences of definitions with the specified symbol.
 byte[] serialize()
          Create a binary representation of this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getSymbols

public java.util.Set<java.lang.String> getSymbols()
Get all symbols used in definitions.

Returns:
a set containing all the symbols

hasSymbol

public boolean hasSymbol(java.lang.String symbol)
Check if there is a tag for a symbol.

Parameters:
symbol - the symbol to check
Returns:
true iff there is a tag for symbol

hasDefinitionAt

public boolean hasDefinitionAt(java.lang.String symbol,
                               int lineNumber)
Check whether the specified symbol is defined on the given line.

Parameters:
symbol - the symbol to look for
lineNumber - the line to check
Returns:
true iff symbol is defined on the specified line

occurrences

public int occurrences(java.lang.String symbol)
Return the number of occurrences of definitions with the specified symbol.

Parameters:
symbol - the symbol to count the occurrences of
Returns:
the number of times the specified symbol is defined

numberOfSymbols

public int numberOfSymbols()
Return the number of distinct symbols.

Returns:
number of distinct symbols

getTags

public java.util.List<Definitions.Tag> getTags()
Get a list of all tags.

Returns:
all tags

serialize

public byte[] serialize()
                 throws java.io.IOException
Create a binary representation of this object.

Returns:
a byte array representing this object
Throws:
java.io.IOException - if an error happens when writing to the array

deserialize

public static Definitions deserialize(byte[] bytes)
                               throws java.io.IOException,
                                      java.lang.ClassNotFoundException
Deserialize a binary representation of a Definitions object.

Parameters:
bytes - a byte array containing the Definitions object
Returns:
a Definitions object
Throws:
java.io.IOException - if an I/O error happens when reading the array
java.lang.ClassNotFoundException - if the class definition for an object stored in the byte array cannot be found
java.lang.ClassCastException - if the array contains an object of another type than Definitions