Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 1 | package net.floodlightcontroller.util; |
| 2 | |
Pavlin Radoslavov | ad008e0 | 2013-02-21 18:42:42 -0800 | [diff] [blame] | 3 | import net.floodlightcontroller.util.serializers.FlowEntryErrorStateSerializer; |
| 4 | |
| 5 | import org.codehaus.jackson.annotate.JsonProperty; |
| 6 | import org.codehaus.jackson.map.annotate.JsonSerialize; |
| 7 | |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 8 | /** |
| 9 | * The class representing the Flow Entry error state. |
| 10 | */ |
Pavlin Radoslavov | ad008e0 | 2013-02-21 18:42:42 -0800 | [diff] [blame] | 11 | @JsonSerialize(using=FlowEntryErrorStateSerializer.class) |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 12 | public class FlowEntryErrorState { |
| 13 | private short type; // The error type (e.g., see OF-1.3.1 spec, pp. 95) |
| 14 | private short code; // The error code (e.g., see OF-1.3.1 spec, pp. 95) |
| 15 | |
| 16 | /** |
| 17 | * Default constructor. |
| 18 | */ |
| 19 | public FlowEntryErrorState() { |
| 20 | this.type = 0; |
| 21 | this.code = 0; |
| 22 | } |
| 23 | |
| 24 | /** |
| 25 | * Constructor for a given error type and code. |
| 26 | * |
| 27 | * @param type the error type to use. |
| 28 | * @param code the error code to use. |
| 29 | */ |
| 30 | public FlowEntryErrorState(short type, short code) { |
| 31 | this.type = type; |
| 32 | this.code = code; |
| 33 | } |
| 34 | |
| 35 | /** |
| 36 | * Get the error type. |
| 37 | * |
| 38 | * @return the error type. |
| 39 | */ |
| 40 | public short type() { return type; } |
| 41 | |
| 42 | /** |
| 43 | * Get the error code. |
| 44 | * |
| 45 | * @return the error code. |
| 46 | */ |
| 47 | public short code() { return code; } |
| 48 | |
| 49 | /** |
| 50 | * Set the values of the error type and code. |
| 51 | * |
| 52 | * @param type the error type to use. |
| 53 | * @param code the error code to use. |
| 54 | */ |
| 55 | public void setValue(short type, short code) { |
| 56 | this.type = type; |
| 57 | this.code = code; |
| 58 | } |
| 59 | |
| 60 | /** |
| 61 | * Convert the error type and code to a string. |
| 62 | * |
Pavlin Radoslavov | ad008e0 | 2013-02-21 18:42:42 -0800 | [diff] [blame] | 63 | * The string has the following form: |
Pavlin Radoslavov | a10a9a8 | 2013-02-22 11:47:54 -0800 | [diff] [blame] | 64 | * [type=1 code=2] |
Pavlin Radoslavov | ad008e0 | 2013-02-21 18:42:42 -0800 | [diff] [blame] | 65 | * |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 66 | * @return the error type and code as a string. |
| 67 | */ |
| 68 | @Override |
| 69 | public String toString() { |
Pavlin Radoslavov | a10a9a8 | 2013-02-22 11:47:54 -0800 | [diff] [blame] | 70 | String ret = "[type=" + this.type + " code=" + code + "]"; |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 71 | return ret; |
| 72 | } |
| 73 | } |