X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=third-party%2Fopenflow-codec%2Fsrc%2Fmain%2Fjava%2Forg%2Fopenflow%2Fcodec%2Fprotocol%2Finstruction%2FOFPInstructionActions.java;fp=third-party%2Fopenflow-codec%2Fsrc%2Fmain%2Fjava%2Forg%2Fopenflow%2Fcodec%2Fprotocol%2Finstruction%2FOFPInstructionActions.java;h=0000000000000000000000000000000000000000;hb=64fe0fbca1a6c2b77ad25f568d73a7eb64236d16;hp=6c2700a24063d9cc4b1752adf3fb3eca4bc40a09;hpb=8b9a3ff2bbc83941254b46b818cbbae5cc1a3a5b;p=openflowjava.git diff --git a/third-party/openflow-codec/src/main/java/org/openflow/codec/protocol/instruction/OFPInstructionActions.java b/third-party/openflow-codec/src/main/java/org/openflow/codec/protocol/instruction/OFPInstructionActions.java deleted file mode 100644 index 6c2700a2..00000000 --- a/third-party/openflow-codec/src/main/java/org/openflow/codec/protocol/instruction/OFPInstructionActions.java +++ /dev/null @@ -1,153 +0,0 @@ -package org.openflow.codec.protocol.instruction; - -import java.util.ArrayList; -import java.util.List; - -import org.openflow.codec.io.IDataBuffer; -import org.openflow.codec.protocol.action.OFPAction; -import org.openflow.codec.protocol.factory.OFPActionFactory; -import org.openflow.codec.protocol.factory.OFPActionFactoryAware; -import org.openflow.codec.util.U16; - -/** - * base class for instruction structure WRITE/APPLY/CLEAR_ACTIONS correspond to - * struct ofp_instruction_actions - * - * @author AnilGujele - * - */ -public abstract class OFPInstructionActions extends OFPInstruction implements OFPActionFactoryAware { - - private final static short MINIMUM_LENGTH = 8; - private List actions; - private OFPActionFactory actionFactory; - - /** - * constructor - */ - public OFPInstructionActions() { - actions = new ArrayList(); - this.setLength(MINIMUM_LENGTH); - - } - - /** - * read OFPInstruction from buffer - * - * @param data - */ - public void readFrom(IDataBuffer data) { - super.readFrom(data); - data.getInt(); // pad - if (null == actionFactory) { - throw new RuntimeException("OFPActionFactory is not set."); - } - int actionDataLength = U16.f(this.getLength()) - MINIMUM_LENGTH; - // read actions - actions = actionFactory.parseActions(data, actionDataLength); - - } - - /** - * write OFPInstruction to buffer - * - * @param data - */ - public void writeTo(IDataBuffer data) { - super.writeTo(data); - data.putInt(0); // pad - // write action - for (OFPAction ofAction : actions) { - ofAction.writeTo(data); - } - } - - /** - * get actions in this instruction - * - * @return - */ - public List getActions() { - return actions; - } - - /** - * set actions in this instructions. - * - * @param actions - */ - - public void setActions(List actions) { - this.actions = actions; - updateLength(); - } - - /** - * get the length of instruction actions - * - * @return - */ - private void updateLength() { - length = MINIMUM_LENGTH; - for (OFPAction ofAction : actions) { - length += ofAction.getLengthU(); - } - } - - @Override - public void setActionFactory(OFPActionFactory actionFactory) { - this.actionFactory = actionFactory; - - } - - @Override - public int hashCode() { - final int prime = 742; - int result = super.hashCode(); - result = prime * result + actions.hashCode(); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!super.equals(obj)) { - return false; - } - if (!(obj instanceof OFPInstructionActions)) { - return false; - } - OFPInstructionActions other = (OFPInstructionActions) obj; - if (!this.actions.equals(other.actions)) { - return false; - } - return true; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#clone() - */ - @Override - public OFPInstructionActions clone() throws CloneNotSupportedException { - OFPInstructionActions clone = (OFPInstructionActions) super.clone(); - clone.actions = new ArrayList(); - for (OFPAction action : this.actions) { - clone.actions.add(action.clone()); - } - - return clone; - } - - /** - * Returns a string representation of the instruction - */ - public String toString() { - return "OFPInstruction[" + "type=" + this.getOFInstructionType() + ", length=" + this.getLength() - + ", actions=" + actions.toString() + "]"; - } - -}