/**
   * entry method to the TypeCode reader logic
   *
   * @param logger used to log informational/debug information
   * @param in the InputStream from which should be read from
   * @param recursiveTCMap Map that should be used to store the buffer positions of not completely
   *     read in TypeCodes
   * @param repeatedTCMap Map that should be used to store the buffer positions of completely read
   *     in TypeCodes
   */
  public TypeCode readTypeCode(
      Logger logger, CDRInputStream in, Map recursiveTCMap, Map repeatedTCMap) {
    in.mark(0);

    final int kind = in.read_long();
    final int start_pos = in.get_pos() - 4;

    try {
      in.reset();
    } catch (IOException e) {
      assert false;
      throw new RuntimeException("should not happen");
    }

    if (logger.isDebugEnabled()) {
      logger.debug(
          in.getIndentString() + "read TypeCode kind " + kind + " at startposition " + start_pos);
    }

    final TypeCode result = doReadTypeCode(in, recursiveTCMap, repeatedTCMap, kind);

    if (logger.isDebugEnabled()) {
      logger.debug(
          in.getIndentString()
              + "return "
              + result
              + " ("
              + result.getClass().getName()
              + "@"
              + System.identityHashCode(result)
              + ")");
    }

    return result;
  }