protected int tightMarshalThrowable1(OpenWireFormat wireFormat, Throwable o, BooleanStream bs)
     throws IOException {
   if (o == null) {
     bs.writeBoolean(false);
     return 0;
   } else {
     int rc = 0;
     bs.writeBoolean(true);
     rc += tightMarshalString1(o.getClass().getName(), bs);
     rc += tightMarshalString1(o.getMessage(), bs);
     if (wireFormat.isStackTraceEnabled()) {
       rc += 2;
       StackTraceElement[] stackTrace = o.getStackTrace();
       for (int i = 0; i < stackTrace.length; i++) {
         StackTraceElement element = stackTrace[i];
         rc += tightMarshalString1(element.getClassName(), bs);
         rc += tightMarshalString1(element.getMethodName(), bs);
         rc += tightMarshalString1(element.getFileName(), bs);
         rc += 4;
       }
       rc += tightMarshalThrowable1(wireFormat, o.getCause(), bs);
     }
     return rc;
   }
 }
  protected int tightMarshalString1(String value, BooleanStream bs) throws IOException {
    bs.writeBoolean(value != null);
    if (value != null) {

      int strlen = value.length();
      int utflen = 0;
      char[] charr = new char[strlen];
      int c = 0;
      boolean isOnlyAscii = true;

      value.getChars(0, strlen, charr, 0);

      for (int i = 0; i < strlen; i++) {
        c = charr[i];
        if ((c >= 0x0001) && (c <= 0x007F)) {
          utflen++;
        } else if (c > 0x07FF) {
          utflen += 3;
          isOnlyAscii = false;
        } else {
          isOnlyAscii = false;
          utflen += 2;
        }
      }

      if (utflen >= Short.MAX_VALUE) {
        throw new IOException("Encountered a String value that is too long to encode.");
      }
      bs.writeBoolean(isOnlyAscii);
      return utflen + 2;

    } else {
      return 0;
    }
  }
  /**
   * Un-marshal an object instance from the data input stream
   *
   * @param o the object to un-marshal
   * @param dataIn the data input stream to build the object from
   * @throws IOException
   */
  public void tightUnmarshal(
      OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException {
    super.tightUnmarshal(wireFormat, o, dataIn, bs);

    ConnectionControl info = (ConnectionControl) o;
    info.setClose(bs.readBoolean());
    info.setExit(bs.readBoolean());
    info.setFaultTolerant(bs.readBoolean());
    info.setResume(bs.readBoolean());
    info.setSuspend(bs.readBoolean());
  }
  /**
   * Un-marshal an object instance from the data input stream
   *
   * @param o the object to un-marshal
   * @param dataIn the data input stream to build the object from
   * @throws IOException
   */
  public void tightUnmarshal(
      OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException {
    super.tightUnmarshal(wireFormat, o, dataIn, bs);

    ConsumerInfo info = (ConsumerInfo) o;
    info.setConsumerId(
        (org.apache.activemq.command.ConsumerId) tightUnmarsalCachedObject(wireFormat, dataIn, bs));
    info.setBrowser(bs.readBoolean());
    info.setDestination(
        (org.apache.activemq.command.ActiveMQDestination)
            tightUnmarsalCachedObject(wireFormat, dataIn, bs));
    info.setPrefetchSize(dataIn.readInt());
    info.setMaximumPendingMessageLimit(dataIn.readInt());
    info.setDispatchAsync(bs.readBoolean());
    info.setSelector(tightUnmarshalString(dataIn, bs));
    info.setSubscriptionName(tightUnmarshalString(dataIn, bs));
    info.setNoLocal(bs.readBoolean());
    info.setExclusive(bs.readBoolean());
    info.setRetroactive(bs.readBoolean());
    info.setPriority(dataIn.readByte());

    if (bs.readBoolean()) {
      short size = dataIn.readShort();
      org.apache.activemq.command.BrokerId value[] = new org.apache.activemq.command.BrokerId[size];
      for (int i = 0; i < size; i++) {
        value[i] =
            (org.apache.activemq.command.BrokerId)
                tightUnmarsalNestedObject(wireFormat, dataIn, bs);
      }
      info.setBrokerPath(value);
    } else {
      info.setBrokerPath(null);
    }
    info.setAdditionalPredicate(
        (org.apache.activemq.filter.BooleanExpression)
            tightUnmarsalNestedObject(wireFormat, dataIn, bs));
    info.setNetworkSubscription(bs.readBoolean());
    info.setOptimizedAcknowledge(bs.readBoolean());
    info.setNoRangeAcks(bs.readBoolean());

    if (bs.readBoolean()) {
      short size = dataIn.readShort();
      org.apache.activemq.command.ConsumerId value[] =
          new org.apache.activemq.command.ConsumerId[size];
      for (int i = 0; i < size; i++) {
        value[i] =
            (org.apache.activemq.command.ConsumerId)
                tightUnmarsalNestedObject(wireFormat, dataIn, bs);
      }
      info.setNetworkConsumerPath(value);
    } else {
      info.setNetworkConsumerPath(null);
    }
  }
 protected void tightMarshalString2(String value, DataOutput dataOut, BooleanStream bs)
     throws IOException {
   if (bs.readBoolean()) {
     // If we verified it only holds ascii values
     if (bs.readBoolean()) {
       dataOut.writeShort(value.length());
       dataOut.writeBytes(value);
     } else {
       dataOut.writeUTF(value);
     }
   }
 }
  /**
   * Write a object instance to data output stream
   *
   * @param o the instance to be marshaled
   * @param dataOut the output stream
   * @throws IOException thrown if an error occurs
   */
  public void tightMarshal2(
      OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs)
      throws IOException {
    super.tightMarshal2(wireFormat, o, dataOut, bs);

    ConnectionControl info = (ConnectionControl) o;
    bs.readBoolean();
    bs.readBoolean();
    bs.readBoolean();
    bs.readBoolean();
    bs.readBoolean();
  }
  /** Write the booleans that this object uses to a BooleanStream */
  public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs)
      throws IOException {

    ConnectionControl info = (ConnectionControl) o;

    int rc = super.tightMarshal1(wireFormat, o, bs);
    bs.writeBoolean(info.isClose());
    bs.writeBoolean(info.isExit());
    bs.writeBoolean(info.isFaultTolerant());
    bs.writeBoolean(info.isResume());
    bs.writeBoolean(info.isSuspend());

    return rc + 0;
  }
 public void tightMarshalLong2(
     OpenWireFormat wireFormat, long o, DataOutput dataOut, BooleanStream bs) throws IOException {
   if (bs.readBoolean()) {
     if (bs.readBoolean()) {
       dataOut.writeLong(o);
     } else {
       dataOut.writeInt((int) o);
     }
   } else {
     if (bs.readBoolean()) {
       dataOut.writeShort((int) o);
     }
   }
 }
 protected int tightMarshalObjectArray1(
     OpenWireFormat wireFormat, DataStructure[] objects, BooleanStream bs) throws IOException {
   if (objects != null) {
     int rc = 0;
     bs.writeBoolean(true);
     rc += 2;
     for (int i = 0; i < objects.length; i++) {
       rc += tightMarshalNestedObject1(wireFormat, objects[i], bs);
     }
     return rc;
   } else {
     bs.writeBoolean(false);
     return 0;
   }
 }
 protected void tightMarshalByteArray2(byte[] data, DataOutput dataOut, BooleanStream bs)
     throws IOException {
   if (bs.readBoolean()) {
     dataOut.writeInt(data.length);
     dataOut.write(data);
   }
 }
 protected void tightMarshalByteSequence2(ByteSequence data, DataOutput dataOut, BooleanStream bs)
     throws IOException {
   if (bs.readBoolean()) {
     dataOut.writeInt(data.getLength());
     dataOut.write(data.getData(), data.getOffset(), data.getLength());
   }
 }
 public long tightUnmarshalLong(OpenWireFormat wireFormat, DataInput dataIn, BooleanStream bs)
     throws IOException {
   if (bs.readBoolean()) {
     if (bs.readBoolean()) {
       return dataIn.readLong();
     } else {
       return toLong(dataIn.readInt());
     }
   } else {
     if (bs.readBoolean()) {
       return toLong(dataIn.readShort());
     } else {
       return 0;
     }
   }
 }
 @SuppressWarnings("deprecation")
 protected String tightUnmarshalString(DataInput dataIn, BooleanStream bs) throws IOException {
   if (bs.readBoolean()) {
     if (bs.readBoolean()) {
       int size = dataIn.readShort();
       byte data[] = new byte[size];
       dataIn.readFully(data);
       // Yes deprecated, but we know what we are doing.
       // This allows us to create a String from a ASCII byte array. (no UTF-8 decoding)
       return new String(data, 0);
     } else {
       return dataIn.readUTF();
     }
   } else {
     return null;
   }
 }
 protected int tightMarshalByteArray1(byte[] data, BooleanStream bs) throws IOException {
   bs.writeBoolean(data != null);
   if (data != null) {
     return data.length + 4;
   } else {
     return 0;
   }
 }
 protected int tightMarshalByteSequence1(ByteSequence data, BooleanStream bs) throws IOException {
   bs.writeBoolean(data != null);
   if (data != null) {
     return data.getLength() + 4;
   } else {
     return 0;
   }
 }
 protected byte[] tightUnmarshalByteArray(DataInput dataIn, BooleanStream bs) throws IOException {
   byte rc[] = null;
   if (bs.readBoolean()) {
     int size = dataIn.readInt();
     rc = new byte[size];
     dataIn.readFully(rc);
   }
   return rc;
 }
 protected void tightMarshalObjectArray2(
     OpenWireFormat wireFormat, DataStructure[] objects, DataOutput dataOut, BooleanStream bs)
     throws IOException {
   if (bs.readBoolean()) {
     dataOut.writeShort(objects.length);
     for (int i = 0; i < objects.length; i++) {
       tightMarshalNestedObject2(wireFormat, objects[i], dataOut, bs);
     }
   }
 }
 protected ByteSequence tightUnmarshalByteSequence(DataInput dataIn, BooleanStream bs)
     throws IOException {
   ByteSequence rc = null;
   if (bs.readBoolean()) {
     int size = dataIn.readInt();
     byte[] t = new byte[size];
     dataIn.readFully(t);
     return new ByteSequence(t, 0, size);
   }
   return rc;
 }
  /**
   * Write a object instance to data output stream
   *
   * @param o the instance to be marshaled
   * @param dataOut the output stream
   * @throws IOException thrown if an error occurs
   */
  public void tightMarshal2(
      OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs)
      throws IOException {
    super.tightMarshal2(wireFormat, o, dataOut, bs);

    ConsumerInfo info = (ConsumerInfo) o;
    tightMarshalCachedObject2(wireFormat, (DataStructure) info.getConsumerId(), dataOut, bs);
    bs.readBoolean();
    tightMarshalCachedObject2(wireFormat, (DataStructure) info.getDestination(), dataOut, bs);
    dataOut.writeInt(info.getPrefetchSize());
    dataOut.writeInt(info.getMaximumPendingMessageLimit());
    bs.readBoolean();
    tightMarshalString2(info.getSelector(), dataOut, bs);
    tightMarshalString2(info.getSubscriptionName(), dataOut, bs);
    bs.readBoolean();
    bs.readBoolean();
    bs.readBoolean();
    dataOut.writeByte(info.getPriority());
    tightMarshalObjectArray2(wireFormat, info.getBrokerPath(), dataOut, bs);
    tightMarshalNestedObject2(
        wireFormat, (DataStructure) info.getAdditionalPredicate(), dataOut, bs);
    bs.readBoolean();
    bs.readBoolean();
    bs.readBoolean();
    tightMarshalObjectArray2(wireFormat, info.getNetworkConsumerPath(), dataOut, bs);
  }
 protected void tightMarshalCachedObject2(
     OpenWireFormat wireFormat, DataStructure o, DataOutput dataOut, BooleanStream bs)
     throws IOException {
   if (wireFormat.isCacheEnabled()) {
     Short index = wireFormat.getMarshallCacheIndex(o);
     if (bs.readBoolean()) {
       dataOut.writeShort(index.shortValue());
       wireFormat.tightMarshalNestedObject2(o, dataOut, bs);
     } else {
       dataOut.writeShort(index.shortValue());
     }
   } else {
     wireFormat.tightMarshalNestedObject2(o, dataOut, bs);
   }
 }
 protected DataStructure tightUnmarsalCachedObject(
     OpenWireFormat wireFormat, DataInput dataIn, BooleanStream bs) throws IOException {
   if (wireFormat.isCacheEnabled()) {
     if (bs.readBoolean()) {
       short index = dataIn.readShort();
       DataStructure object = wireFormat.tightUnmarshalNestedObject(dataIn, bs);
       wireFormat.setInUnmarshallCache(index, object);
       return object;
     } else {
       short index = dataIn.readShort();
       return wireFormat.getFromUnmarshallCache(index);
     }
   } else {
     return wireFormat.tightUnmarshalNestedObject(dataIn, bs);
   }
 }
 protected int tightMarshalCachedObject1(
     OpenWireFormat wireFormat, DataStructure o, BooleanStream bs) throws IOException {
   if (wireFormat.isCacheEnabled()) {
     Short index = wireFormat.getMarshallCacheIndex(o);
     bs.writeBoolean(index == null);
     if (index == null) {
       int rc = wireFormat.tightMarshalNestedObject1(o, bs);
       wireFormat.addToMarshallCache(o);
       return 2 + rc;
     } else {
       return 2;
     }
   } else {
     return wireFormat.tightMarshalNestedObject1(o, bs);
   }
 }
 protected Throwable tightUnmarsalThrowable(
     OpenWireFormat wireFormat, DataInput dataIn, BooleanStream bs) throws IOException {
   if (bs.readBoolean()) {
     String clazz = tightUnmarshalString(dataIn, bs);
     String message = tightUnmarshalString(dataIn, bs);
     Throwable o = createThrowable(clazz, message);
     if (wireFormat.isStackTraceEnabled()) {
       if (STACK_TRACE_ELEMENT_CONSTRUCTOR != null) {
         StackTraceElement ss[] = new StackTraceElement[dataIn.readShort()];
         for (int i = 0; i < ss.length; i++) {
           try {
             ss[i] =
                 (StackTraceElement)
                     STACK_TRACE_ELEMENT_CONSTRUCTOR.newInstance(
                         new Object[] {
                           tightUnmarshalString(dataIn, bs),
                           tightUnmarshalString(dataIn, bs),
                           tightUnmarshalString(dataIn, bs),
                           Integer.valueOf(dataIn.readInt())
                         });
           } catch (IOException e) {
             throw e;
           } catch (Throwable e) {
           }
         }
         o.setStackTrace(ss);
       } else {
         short size = dataIn.readShort();
         for (int i = 0; i < size; i++) {
           tightUnmarshalString(dataIn, bs);
           tightUnmarshalString(dataIn, bs);
           tightUnmarshalString(dataIn, bs);
           dataIn.readInt();
         }
       }
       o.initCause(tightUnmarsalThrowable(wireFormat, dataIn, bs));
     }
     return o;
   } else {
     return null;
   }
 }
 protected void tightMarshalThrowable2(
     OpenWireFormat wireFormat, Throwable o, DataOutput dataOut, BooleanStream bs)
     throws IOException {
   if (bs.readBoolean()) {
     tightMarshalString2(o.getClass().getName(), dataOut, bs);
     tightMarshalString2(o.getMessage(), dataOut, bs);
     if (wireFormat.isStackTraceEnabled()) {
       StackTraceElement[] stackTrace = o.getStackTrace();
       dataOut.writeShort(stackTrace.length);
       for (int i = 0; i < stackTrace.length; i++) {
         StackTraceElement element = stackTrace[i];
         tightMarshalString2(element.getClassName(), dataOut, bs);
         tightMarshalString2(element.getMethodName(), dataOut, bs);
         tightMarshalString2(element.getFileName(), dataOut, bs);
         dataOut.writeInt(element.getLineNumber());
       }
       tightMarshalThrowable2(wireFormat, o.getCause(), dataOut, bs);
     }
   }
 }
  /** Write the booleans that this object uses to a BooleanStream */
  public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs)
      throws IOException {

    ConsumerInfo info = (ConsumerInfo) o;

    int rc = super.tightMarshal1(wireFormat, o, bs);
    rc += tightMarshalCachedObject1(wireFormat, (DataStructure) info.getConsumerId(), bs);
    bs.writeBoolean(info.isBrowser());
    rc += tightMarshalCachedObject1(wireFormat, (DataStructure) info.getDestination(), bs);
    bs.writeBoolean(info.isDispatchAsync());
    rc += tightMarshalString1(info.getSelector(), bs);
    rc += tightMarshalString1(info.getSubscriptionName(), bs);
    bs.writeBoolean(info.isNoLocal());
    bs.writeBoolean(info.isExclusive());
    bs.writeBoolean(info.isRetroactive());
    rc += tightMarshalObjectArray1(wireFormat, info.getBrokerPath(), bs);
    rc += tightMarshalNestedObject1(wireFormat, (DataStructure) info.getAdditionalPredicate(), bs);
    bs.writeBoolean(info.isNetworkSubscription());
    bs.writeBoolean(info.isOptimizedAcknowledge());
    bs.writeBoolean(info.isNoRangeAcks());
    rc += tightMarshalObjectArray1(wireFormat, info.getNetworkConsumerPath(), bs);

    return rc + 9;
  }
 public int tightMarshalLong1(OpenWireFormat wireFormat, long o, BooleanStream bs)
     throws IOException {
   if (o == 0) {
     bs.writeBoolean(false);
     bs.writeBoolean(false);
     return 0;
   } else if ((o & 0xFFFFFFFFFFFF0000L) == 0) {
     bs.writeBoolean(false);
     bs.writeBoolean(true);
     return 2;
   } else if ((o & 0xFFFFFFFF00000000L) == 0) {
     bs.writeBoolean(true);
     bs.writeBoolean(false);
     return 4;
   } else {
     bs.writeBoolean(true);
     bs.writeBoolean(true);
     return 8;
   }
 }