2 * Copyright (c) 2003 University of Murcia. All rights reserved.
3 * --------------------------------------------------------------
4 * For more information, please see <http://www.umu.euro6ix.org/>.
7 package org.umu.cops.stack;
9 import java.io.IOException;
10 import java.io.OutputStream;
11 import java.net.Socket;
14 * For extension by other COPS Timer Objects such as COPSAcctTimer & COPSKATimer
16 public abstract class COPSTimer extends COPSObjBase {
18 // TODO - determine what is the function of this member
19 private final short _reserved;
24 private final short _timerValue;
27 * Constructor generally used when parsing the bytes of an inbound COPS message but can also be used when the
28 * COPSObjHeader information is known
29 * @param header - the object header
30 * @param reserved - ???
31 * @param timerVal - the timer value
33 protected COPSTimer(final COPSObjHeader header, final short reserved, final short timerVal) {
36 _timerValue = timerVal;
43 public short getTimerVal() {
48 public void writeBody(Socket socket) throws IOException {
49 byte[] buf = new byte[4];
51 buf[0] = (byte) (_reserved >> 8);
52 buf[1] = (byte) _reserved;
53 buf[2] = (byte) (_timerValue >> 8);
54 buf[3] = (byte) _timerValue;
55 COPSUtil.writeData(socket, buf, 4);
59 protected int getDataLength() {
64 public void dumpBody(final OutputStream os) throws IOException {
65 os.write(("Timer val: " + _timerValue + "\n").getBytes());