/**
   * Adds the specified symbol to the symbol table and returns a reference to the unique symbol. If
   * the symbol already exists, the previous symbol reference is returned instead, in order
   * guarantee that symbol references remain unique.
   *
   * @param buffer The buffer containing the new symbol.
   * @param offset The offset into the buffer of the new symbol.
   * @param length The length of the new symbol in the buffer.
   */
  public String addSymbol(char[] buffer, int offset, int length)
      throws RemoteException, RemoteException {

    // search for identical symbol
    int bucket = hash(buffer, offset, length) % fTableSize;
    OUTER:
    for (SymbolTableSymbolTableEntryRemoteInterface entry = fBuckets[bucket];
        entry != null;
        entry = entry.getNext()) {
      if (length == entry.getCharacters().length) {
        for (int i = 0; i < length; i++) {
          if (buffer[offset + i] != entry.getCharacters()[i]) {
            continue OUTER;
          }
        }
        return entry.getSymbol();
      }
    }

    // add new entry
    SymbolTableSymbolTableEntryRemoteInterface entry =
        gerenciadornuvem0.getSymbolTableSymbolTableEntry(buffer, offset, length, fBuckets[bucket]);
    fBuckets[bucket] = entry;
    return entry.getSymbol();
  }
  /**
   * Adds the specified symbol to the symbol table and returns a reference to the unique symbol. If
   * the symbol already exists, the previous symbol reference is returned instead, in order
   * guarantee that symbol references remain unique.
   *
   * @param symbol The new symbol.
   */
  public String addSymbol(String symbol) throws RemoteException, RemoteException {

    // search for identical symbol
    int bucket = hash(symbol) % fTableSize;
    int length = symbol.length();
    OUTER:
    for (SymbolTableSymbolTableEntryRemoteInterface entry = fBuckets[bucket];
        entry != null;
        entry = entry.getNext()) {
      if (length == entry.getCharacters().length) {
        for (int i = 0; i < length; i++) {
          if (symbol.charAt(i) != entry.getCharacters()[i]) {
            continue OUTER;
          }
        }
        return entry.getSymbol();
      }
    }

    // create new entry
    SymbolTableSymbolTableEntryRemoteInterface entry =
        gerenciadornuvem0.getSymbolTableSymbolTableEntry(symbol, fBuckets[bucket]);
    fBuckets[bucket] = entry;
    return entry.getSymbol();
  }
  /**
   * Returns true if the symbol table already contains the specified symbol.
   *
   * @param buffer The buffer containing the symbol to look for.
   * @param offset The offset into the buffer.
   * @param length The length of the symbol in the buffer.
   */
  public boolean containsSymbol(char[] buffer, int offset, int length)
      throws RemoteException, RemoteException {

    // search for identical symbol
    int bucket = hash(buffer, offset, length) % fTableSize;
    OUTER:
    for (SymbolTableSymbolTableEntryRemoteInterface entry = fBuckets[bucket];
        entry != null;
        entry = entry.getNext()) {
      if (length == entry.getCharacters().length) {
        for (int i = 0; i < length; i++) {
          if (buffer[offset + i] != entry.getCharacters()[i]) {
            continue OUTER;
          }
        }
        return true;
      }
    }

    return false;
  }
  /**
   * Returns true if the symbol table already contains the specified symbol.
   *
   * @param symbol The symbol to look for.
   */
  public boolean containsSymbol(String symbol) throws RemoteException, RemoteException {

    // search for identical symbol
    int bucket = hash(symbol) % fTableSize;
    int length = symbol.length();
    OUTER:
    for (SymbolTableSymbolTableEntryRemoteInterface entry = fBuckets[bucket];
        entry != null;
        entry = entry.getNext()) {
      if (length == entry.getCharacters().length) {
        for (int i = 0; i < length; i++) {
          if (symbol.charAt(i) != entry.getCharacters()[i]) {
            continue OUTER;
          }
        }
        return true;
      }
    }

    return false;
  }