Beispiel #1
0
  /**
   * If the object has already been written, just write its ref.
   *
   * @return true if we're writing a ref.
   */
  public boolean addRef(Object object) throws IOException {
    int ref = _refs.get(object);

    if (ref >= 0) {
      writeRef(ref);

      return true;
    } else {
      _refs.put(object, _refs.size());

      return false;
    }
  }
Beispiel #2
0
  /**
   * Writes a fault. The fault will be written as a descriptive string followed by an object: <code>
   * <pre>
   * F map
   * </pre></code> <code><pre>
   * F H
   * \x04code
   * \x10the fault code
   *
   * \x07message
   * \x11the fault message
   *
   * \x06detail
   * M\xnnjavax.ejb.FinderException
   *     ...
   * Z
   * Z
   * </pre></code>
   *
   * @param code the fault code, a three digit
   */
  public void writeFault(String code, String message, Object detail) throws IOException {
    flushIfFull();

    writeVersion();

    _buffer[_offset++] = (byte) 'F';
    _buffer[_offset++] = (byte) 'H';

    _refs.put(new HashMap(), _refs.size());

    writeString("code");
    writeString(code);

    writeString("message");
    writeString(message);

    if (detail != null) {
      writeString("detail");
      writeObject(detail);
    }

    flushIfFull();
    _buffer[_offset++] = (byte) 'Z';
  }