1 package org.openflow.protocol.queue;
3 import java.nio.ByteBuffer;
5 import org.openflow.util.U16;
8 * Corresponds to the struct ofp_queue_prop_header OpenFlow structure
10 * @author David Erickson (daviderickson@cs.stanford.edu)
12 public class OFQueueProperty implements Cloneable {
13 public static int MINIMUM_LENGTH = 8;
15 protected OFQueuePropertyType type;
16 protected short length;
21 public OFQueuePropertyType getType() {
26 * @param type the type to set
28 public void setType(OFQueuePropertyType type) {
35 public short getLength() {
40 * Returns the unsigned length
44 public int getLengthU() {
49 * @param length the length to set
51 public void setLength(short length) {
55 public void readFrom(ByteBuffer data) {
56 this.type = OFQueuePropertyType.valueOf(data.getShort());
57 this.length = data.getShort();
61 public void writeTo(ByteBuffer data) {
62 data.putShort(this.type.getTypeValue());
63 data.putShort(this.length);
64 data.putInt(0); // pad
68 public int hashCode() {
69 final int prime = 2777;
71 result = prime * result + length;
72 result = prime * result + ((type == null) ? 0 : type.hashCode());
77 public boolean equals(Object obj) {
82 if (!(obj instanceof OFQueueProperty))
84 OFQueueProperty other = (OFQueueProperty) obj;
85 if (length != other.length)
87 if (type != other.type)
93 protected OFQueueProperty clone() {
95 return (OFQueueProperty) super.clone();
96 } catch (CloneNotSupportedException e) {
97 throw new RuntimeException(e);