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/EthType.java b/java_gen/pre-written/src/main/java/org/openflow/types/EthType.java
index b86a38f..f0f0a2c 100644
--- a/java_gen/pre-written/src/main/java/org/openflow/types/EthType.java
+++ b/java_gen/pre-written/src/main/java/org/openflow/types/EthType.java
@@ -1,7 +1,7 @@
package org.openflow.types;
import org.jboss.netty.buffer.ChannelBuffer;
-import org.openflow.exceptions.OFParseError;
+
/**
* EtherType field representation.
@@ -110,23 +110,6 @@
return LENGTH;
}
- volatile byte[] bytesCache = null;
-
- @Override
- public byte[] getBytes() {
- if (bytesCache == null) {
- synchronized (this) {
- if (bytesCache == null) {
- bytesCache = new byte[] {
- (byte) ((rawValue >>> 8) & 0xFF),
- (byte) ((rawValue >>> 0) & 0xFF)
- };
- }
- }
- }
- return bytesCache;
- }
-
public static EthType of(int type) {
switch (type) {
case ETH_TYPE_VAL_IPv4:
@@ -243,24 +226,13 @@
public String toString() {
return Integer.toHexString(rawValue);
}
-
- public static final Serializer<EthType> SERIALIZER_V10 = new SerializerV10();
- public static final Serializer<EthType> SERIALIZER_V11 = SERIALIZER_V10;
- public static final Serializer<EthType> SERIALIZER_V12 = SERIALIZER_V10;
- public static final Serializer<EthType> SERIALIZER_V13 = SERIALIZER_V10;
-
- private static class SerializerV10 implements OFValueType.Serializer<EthType> {
-
- @Override
- public void writeTo(EthType value, ChannelBuffer c) {
- c.writeShort(value.rawValue);
- }
-
- @Override
- public EthType readFrom(ChannelBuffer c) throws OFParseError {
- return EthType.of(c.readUnsignedShort());
- }
-
+
+ public void write2Bytes(ChannelBuffer c) {
+ c.writeShort(this.rawValue);
+ }
+
+ public static EthType read2Bytes(ChannelBuffer c) {
+ return EthType.of(c.readUnsignedShort());
}
}