1. Removed type serializers, added (write|read)[0-9]*Byte[s]?(ChannelBuffer) method to value types instead.
2. Updated Masked fields for IPv4, IPv6 with specific string methods.
3. Added value types for other fields from the spec
4. Updated unit tests accordingly
5. Changed java_type.py to support multiple read/write operations per type, per OF version.
diff --git a/java_gen/pre-written/src/main/java/org/openflow/types/OFPort.java b/java_gen/pre-written/src/main/java/org/openflow/types/OFPort.java
index 22b347d..3272660 100644
--- a/java_gen/pre-written/src/main/java/org/openflow/types/OFPort.java
+++ b/java_gen/pre-written/src/main/java/org/openflow/types/OFPort.java
@@ -497,23 +497,6 @@
return LENGTH;
}
- volatile byte[] bytesCache;
-
- @Override
- public byte[] getBytes() {
- if (bytesCache == null) {
- synchronized (this) {
- if (bytesCache == null) {
- bytesCache = new byte[] { (byte)(portNumber & 0xFF),
- (byte)((portNumber >>> 8) & 0xFF),
- (byte)((portNumber >>> 16) & 0xFF),
- (byte)((portNumber >>> 24) & 0xFF) };
- }
- }
- }
- return bytesCache;
- }
-
@Override
public boolean equals(Object obj) {
if (!(obj instanceof OFPort))
@@ -532,36 +515,19 @@
return result;
}
- public static final Serializer<OFPort> SERIALIZER_V10 = new SerializerV10();
- public static final Serializer<OFPort> SERIALIZER_V11 = new SerializerV11();
- public static final Serializer<OFPort> SERIALIZER_V12 = SERIALIZER_V11;
- public static final Serializer<OFPort> SERIALIZER_V13 = SERIALIZER_V11;
-
- private static class SerializerV10 implements OFValueType.Serializer<OFPort> {
-
- @Override
- public void writeTo(OFPort value, ChannelBuffer c) {
- c.writeShort(value.portNumber);
- }
-
- @Override
- public OFPort readFrom(ChannelBuffer c) throws OFParseError {
- return OFPort.of((c.readUnsignedShort() & 0x0FFFF));
- }
-
+ public void write2Bytes(ChannelBuffer c) {
+ c.writeShort(this.portNumber);
}
- private static class SerializerV11 implements OFValueType.Serializer<OFPort> {
+ public static OFPort read2Bytes(ChannelBuffer c) throws OFParseError {
+ return OFPort.of((c.readUnsignedShort() & 0x0FFFF));
+ }
- @Override
- public void writeTo(OFPort value, ChannelBuffer c) {
- c.writeInt(value.portNumber);
- }
+ public void write4Bytes(ChannelBuffer c) {
+ c.writeInt(this.portNumber);
+ }
- @Override
- public OFPort readFrom(ChannelBuffer c) throws OFParseError {
- return OFPort.of((int)(c.readUnsignedInt() & 0xFFFFFFFF));
- }
-
+ public static OFPort read4Bytes(ChannelBuffer c) throws OFParseError {
+ return OFPort.of((int)(c.readUnsignedInt() & 0xFFFFFFFF));
}
}