1 package org.openflow.codec.protocol.statistics;
3 import java.io.Serializable;
5 import org.openflow.codec.io.IDataBuffer;
6 import org.openflow.codec.util.StringByteSerializer;
9 * Represents an ofp_desc structure
11 * @author David Erickson (daviderickson@cs.stanford.edu)
13 public class OFPDescriptionStatistics implements OFPStatistics, Serializable {
14 public static int DESCRIPTION_STRING_LENGTH = 256;
15 public static int SERIAL_NUMBER_LENGTH = 32;
17 protected String manufacturerDescription;
18 protected String hardwareDescription;
19 protected String softwareDescription;
20 protected String serialNumber;
21 protected String datapathDescription;
24 * @return the manufacturerDescription
26 public String getManufacturerDescription() {
27 return manufacturerDescription;
31 * @param manufacturerDescription
32 * the manufacturerDescription to set
34 public void setManufacturerDescription(String manufacturerDescription) {
35 this.manufacturerDescription = manufacturerDescription;
39 * @return the hardwareDescription
41 public String getHardwareDescription() {
42 return hardwareDescription;
46 * @param hardwareDescription
47 * the hardwareDescription to set
49 public void setHardwareDescription(String hardwareDescription) {
50 this.hardwareDescription = hardwareDescription;
54 * @return the softwareDescription
56 public String getSoftwareDescription() {
57 return softwareDescription;
61 * @param softwareDescription
62 * the softwareDescription to set
64 public void setSoftwareDescription(String softwareDescription) {
65 this.softwareDescription = softwareDescription;
69 * @return the serialNumber
71 public String getSerialNumber() {
72 if (serialNumber.equals("None"))
79 * the serialNumber to set
81 public void setSerialNumber(String serialNumber) {
82 this.serialNumber = serialNumber;
86 * @return the datapathDescription
88 public String getDatapathDescription() {
89 return datapathDescription;
93 * @param datapathDescription
94 * the datapathDescription to set
96 public void setDatapathDescription(String datapathDescription) {
97 this.datapathDescription = datapathDescription;
101 public int getLength() {
106 public void readFrom(IDataBuffer data) {
107 this.manufacturerDescription = StringByteSerializer.readFrom(data, DESCRIPTION_STRING_LENGTH);
108 this.hardwareDescription = StringByteSerializer.readFrom(data, DESCRIPTION_STRING_LENGTH);
109 this.softwareDescription = StringByteSerializer.readFrom(data, DESCRIPTION_STRING_LENGTH);
110 this.serialNumber = StringByteSerializer.readFrom(data, SERIAL_NUMBER_LENGTH);
111 this.datapathDescription = StringByteSerializer.readFrom(data, DESCRIPTION_STRING_LENGTH);
115 public void writeTo(IDataBuffer data) {
116 StringByteSerializer.writeTo(data, DESCRIPTION_STRING_LENGTH, this.manufacturerDescription);
117 StringByteSerializer.writeTo(data, DESCRIPTION_STRING_LENGTH, this.hardwareDescription);
118 StringByteSerializer.writeTo(data, DESCRIPTION_STRING_LENGTH, this.softwareDescription);
119 StringByteSerializer.writeTo(data, SERIAL_NUMBER_LENGTH, this.serialNumber);
120 StringByteSerializer.writeTo(data, DESCRIPTION_STRING_LENGTH, this.datapathDescription);
124 public int hashCode() {
125 final int prime = 409;
127 result = prime * result + ((datapathDescription == null) ? 0 : datapathDescription.hashCode());
128 result = prime * result + ((hardwareDescription == null) ? 0 : hardwareDescription.hashCode());
129 result = prime * result + ((manufacturerDescription == null) ? 0 : manufacturerDescription.hashCode());
130 result = prime * result + ((serialNumber == null) ? 0 : serialNumber.hashCode());
131 result = prime * result + ((softwareDescription == null) ? 0 : softwareDescription.hashCode());
136 public boolean equals(Object obj) {
143 if (!(obj instanceof OFPDescriptionStatistics)) {
146 OFPDescriptionStatistics other = (OFPDescriptionStatistics) obj;
147 if (datapathDescription == null) {
148 if (other.datapathDescription != null) {
151 } else if (!datapathDescription.equals(other.datapathDescription)) {
154 if (hardwareDescription == null) {
155 if (other.hardwareDescription != null) {
158 } else if (!hardwareDescription.equals(other.hardwareDescription)) {
161 if (manufacturerDescription == null) {
162 if (other.manufacturerDescription != null) {
165 } else if (!manufacturerDescription.equals(other.manufacturerDescription)) {
168 if (serialNumber == null) {
169 if (other.serialNumber != null) {
172 } else if (!serialNumber.equals(other.serialNumber)) {
175 if (softwareDescription == null) {
176 if (other.softwareDescription != null) {
179 } else if (!softwareDescription.equals(other.softwareDescription)) {