1 package org.openflow.codec.protocol.action;
3 import java.io.Serializable;
5 import org.openflow.codec.io.IDataBuffer;
8 * Represents an ofp_bucket_counter structure
10 * @author Yugandhar Sarraju (ysarraju@in.ibm.com)
13 public class OFPBucketCounter implements Cloneable, Serializable {
14 public static int MINIMUM_LENGTH = 16;
16 protected long packet_count;
17 protected long byte_count;
19 public OFPBucketCounter() {
23 public long getPacket_count() {
27 public OFPBucketCounter setPacket_count(long packet_count) {
28 this.packet_count = packet_count;
32 public long getByte_count() {
36 public OFPBucketCounter setByte_count(long byte_count) {
37 this.byte_count = byte_count;
41 public String toString() {
42 return "ofbucketcounter" + ";packet_count=" + this.getPacket_count() + ";byte_count=" + this.getByte_count();
46 * Given the output from toString(), create a new OFPBucketCounter
51 public static OFPBucketCounter fromString(String val) {
52 String tokens[] = val.split(";");
53 if (!tokens[0].equals("ofbucket"))
54 throw new IllegalArgumentException("expected 'ofbucketcounter' but got '" + tokens[0] + "'");
55 String packet_token[] = tokens[1].split("=");
56 String byte_token[] = tokens[2].split("=");
57 OFPBucketCounter bucketCounter = new OFPBucketCounter();
58 bucketCounter.setPacket_count(Long.valueOf(packet_token[1]));
59 bucketCounter.setByte_count(Long.valueOf(byte_token[2]));
63 public void readFrom(IDataBuffer data) {
64 this.packet_count = data.getLong();
65 this.byte_count = data.getLong();
68 public void writeTo(IDataBuffer data) {
69 data.putLong(packet_count);
70 data.putLong(byte_count);
74 public int hashCode() {
75 final int prime = 347;
77 result = prime * result + (int) (packet_count ^ (packet_count >>> 32));
78 result = prime * result + (int) (byte_count ^ (byte_count >>> 32));
83 public boolean equals(Object obj) {
90 if (!(obj instanceof OFPBucketCounter)) {
93 OFPBucketCounter other = (OFPBucketCounter) obj;
94 if (packet_count != other.packet_count) {
97 if (byte_count != other.byte_count) {
106 * @see java.lang.Object#clone()
109 public OFPBucketCounter clone() throws CloneNotSupportedException {
110 return (OFPBucketCounter) super.clone();