1 package org.openflow.codec.protocol.statistics.table;
3 import java.util.Arrays;
5 import org.openflow.codec.io.IDataBuffer;
8 * Represents struct ofp_table_feature_prop_experimenter
13 public class OFPTableFeaturePropExperimenter extends OFPTableFeaturePropHeader {
14 private static final short MINIMUM_LENGTH = 12;
17 private int[] expData = new int[0];
22 public OFPTableFeaturePropExperimenter() {
23 super.setOFTableFeaturePropType(OFPTableFeaturePropType.EXPERIMENTER);
24 super.setLength(OFPTableFeaturePropExperimenter.MINIMUM_LENGTH);
27 public int getExpId() {
31 public void setExpId(int expId) {
35 public int getExpType() {
39 public void setExpType(int expType) {
40 this.expType = expType;
43 public int[] getExpData() {
47 public void setExpData(int[] expData) {
48 this.expData = expData;
56 private void updateLength() {
57 int length = this.getLength() + (expData.length * 4);
58 this.setLength((short) length);
63 * read OFPTableFeaturePropExperimenter from buffer
67 public void readFrom(IDataBuffer data) {
69 this.expId = data.getInt();
70 this.expType = data.getInt();
71 int dataLength = this.getLengthU() - OFPTableFeaturePropExperimenter.MINIMUM_LENGTH;
72 int intDataLength = dataLength / 4;
73 expData = new int[intDataLength];
74 for (int i = 0; i < intDataLength; i++) {
75 expData[i] = data.getInt();
78 /* Read the padding, if any */
79 int paddingLength = ((this.getLengthU() % MULTIPLE_OF_EIGHT) == 0) ? 0 : (MULTIPLE_OF_EIGHT - (this
80 .getLengthU() % MULTIPLE_OF_EIGHT));
81 data.position(data.position() + paddingLength);
86 * write OFPTableFeaturePropExperimenter to buffer
90 public void writeTo(IDataBuffer data) {
92 data.putInt(this.expId);
93 data.putInt(this.expType);
94 for (int value : expData) {
98 /* Add padding if structure is not 8 byte aligned */
99 int paddingLength = ((this.getLengthU() % MULTIPLE_OF_EIGHT) == 0) ? 0 : (MULTIPLE_OF_EIGHT - (this
100 .getLengthU() % MULTIPLE_OF_EIGHT));
101 byte[] padding = new byte[paddingLength];
107 public int hashCode() {
108 final int prime = 746;
109 int result = super.hashCode();
110 result = prime * result + expId;
111 result = prime * result + expType;
112 result = prime * result + Arrays.hashCode(expData);
117 public boolean equals(Object obj) {
121 if (!super.equals(obj)) {
124 if (!(obj instanceof OFPTableFeaturePropExperimenter)) {
127 OFPTableFeaturePropExperimenter other = (OFPTableFeaturePropExperimenter) obj;
128 if (this.expId != other.expId) {
131 if (this.expType != other.expType) {
134 if (!Arrays.equals(expData, other.expData)) {