/** * Adds a counter to this counter listener. If counter * events have been received already for the given <tt>oid</tt> * the provided counter will be incremented by the number of events * already counted and then <tt>counter</tt> replaces the old * counter. * @param oid * the object identifier of the counter instance (thus including * the .0 suffix). * @param counter * the counter to register. * @return * the counter previously associated with <tt>oid</tt> or * <tt>null</tt> if no such counter exist. * @since 2.0 */ public synchronized Counter32 add(OID oid, Counter32 counter) { Counter32 oldCounter = counters.get(oid); if (oldCounter != null) { long value = oldCounter.getValue(); counter.setValue(counter.getValue()+value); } return counters.put(oid, counter); }
/** * Adds a counter to this counter listener. If counter * events have been received already for the given <code>oid</code> * the provided counter will be incremented by the number of events * already counted and then <code>counter</code> replaces the old * counter. * @param oid * the object identifier of the counter instance (thus including * the .0 suffix). * @param counter * the counter to register. * @return * the counter previously associated with <code>oid</code> or * <code>null</code> if no such counter exist. * @since 2.0 */ public synchronized Counter32 add(OID oid, Counter32 counter) { Counter32 oldCounter = counters.get(oid); if (oldCounter != null) { long value = oldCounter.getValue(); counter.setValue(counter.getValue()+value); } return counters.put(oid, counter); }
public void decodeBER(BERInputStream inputStream) throws IOException { BER.MutableByte type = new BER.MutableByte(); long newValue = BER.decodeUnsignedInteger(inputStream, type); if (type.getValue() != BER.COUNTER32) { throw new IOException("Wrong type encountered when decoding Counter: "+ type.getValue()); } setValue(newValue); }
public void decodeBER(BERInputStream inputStream) throws IOException { BER.MutableByte type = new BER.MutableByte(); long newValue = BER.decodeUnsignedInteger(inputStream, type); if (type.getValue() != BER.COUNTER32) { throw new IOException("Wrong type encountered when decoding Counter: "+ type.getValue()); } setValue(newValue); }
public void decodeBER(BERInputStream inputStream) throws IOException { BER.MutableByte type = new BER.MutableByte(); long newValue = BER.decodeUnsignedInteger(inputStream, type); if (type.getValue() != BER.COUNTER32) { throw new IOException("Wrong type encountered when decoding Counter: "+ type.getValue()); } setValue(newValue); }