BUG-47 : unfinished PCEP migration to generated DTOs.
[bgpcep.git] / pcep / impl / src / main / java / org / opendaylight / protocol / pcep / impl / object / PCEPExcludeRouteObjectParser.java
index e511e2f021f2e9bcad2b9ea485c097b6cc392cce..0617e315ec50b6b46a62b9133cd61a988f3ec67c 100644 (file)
@@ -7,70 +7,63 @@
  */
 package org.opendaylight.protocol.pcep.impl.object;
 
-import java.util.Arrays;
-import java.util.BitSet;
-import java.util.List;
-
-import org.opendaylight.protocol.util.ByteArray;
-import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.PCEPDocumentedException;
-import org.opendaylight.protocol.pcep.PCEPObject;
-import org.opendaylight.protocol.pcep.impl.PCEPObjectParser;
-import org.opendaylight.protocol.pcep.impl.PCEPXROSubobjectParser;
-import org.opendaylight.protocol.pcep.object.PCEPExcludeRouteObject;
-import org.opendaylight.protocol.pcep.subobject.ExcludeRouteSubobject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ExcludeRouteObject;
 
 /**
- * Parser for {@link org.opendaylight.protocol.pcep.object.PCEPExcludeRouteObject
- * PCEPExcludeRouteObject}
+ * Parser for {@link ExcludeRouteObject}
  */
-public class PCEPExcludeRouteObjectParser implements PCEPObjectParser {
-
-       /*
-        * lengths of fields in bytes
-        */
-       public final int FLAGS_F_LENGTH = 2;
-
-       /*
-        * offsets of fields in bytes
-        */
-       public final int FLAGS_F_OFFSET = 2; // added reserved 2 bytes
-       public final int SO_F_OFFSET = this.FLAGS_F_OFFSET + this.FLAGS_F_LENGTH;
-
-       /*
-        * Flag offsets inside flags field in bits
-        */
-       public final int F_FLAG_OFFSET = 15;
-
-       @Override
-       public PCEPObject parse(byte[] bytes, boolean processed, boolean ignored) throws PCEPDeserializerException, PCEPDocumentedException {
-               if (bytes == null || bytes.length == 0)
-                       throw new IllegalArgumentException("Byte array is mandatory. Can't be null or empty.");
-
-               final BitSet flags = ByteArray.bytesToBitSet(Arrays.copyOfRange(bytes, this.FLAGS_F_OFFSET, this.FLAGS_F_LENGTH));
-
-               final List<ExcludeRouteSubobject> subobjects = PCEPXROSubobjectParser.parse(ByteArray.cutBytes(bytes, this.SO_F_OFFSET));
-               if (subobjects.isEmpty())
-                       throw new PCEPDeserializerException("Empty Exclude Route Object.");
-
-               return new PCEPExcludeRouteObject(subobjects, flags.get(this.F_FLAG_OFFSET), processed, ignored);
-       }
-
-       @Override
-       public byte[] put(PCEPObject obj) {
-               if (!(obj instanceof PCEPExcludeRouteObject))
-                       throw new IllegalArgumentException("Wrong instance of PCEPObject. Passed " + obj.getClass() + ". Needed PCEPExcludeRouteObject.");
-
-               assert !(((PCEPExcludeRouteObject) obj).getSubobjects().isEmpty()) : "Empty Exclude Route Object.";
+// FIXME: fix model, this object is not used in a message
+public final class PCEPExcludeRouteObjectParser { // extends AbstractObjectParser<ExcludeRouterBuilder> {
 
-               final byte[] subObjsBytes = PCEPXROSubobjectParser.put(((PCEPExcludeRouteObject) obj).getSubobjects());
-               final byte[] retBytes = new byte[this.SO_F_OFFSET + subObjsBytes.length];
-               final BitSet flags = new BitSet(this.FLAGS_F_LENGTH * Byte.SIZE);
-               flags.set(this.F_FLAG_OFFSET, ((PCEPExcludeRouteObject) obj).isFail());
-               ByteArray.copyWhole(ByteArray.bitSetToBytes(flags, this.FLAGS_F_LENGTH), retBytes, this.FLAGS_F_OFFSET);
-               ByteArray.copyWhole(subObjsBytes, retBytes, this.SO_F_OFFSET);
+       public static final int CLASS = 7; // FIXME: to actual value
 
-               return retBytes;
-       }
+       public static final int TYPE = 1;
 
+       // public PCEPExcludeRouteObjectParser(final HandlerRegistry registry) {
+       // super(registry);
+       // }
+       //
+       // @Override
+       // public ExcludeRouteObject parseObject(final ObjectHeader header, final byte[] bytes) throws
+       // PCEPDeserializerException,
+       // PCEPDocumentedException {
+       // if (bytes == null || bytes.length == 0)
+       // throw new IllegalArgumentException("Byte array is mandatory. Can't be null or empty.");
+       //
+       // final ExcludeRouterBuilder builder = new ExcludeRouterBuilder();
+       //
+       // builder.setIgnore(header.isIgnore());
+       // builder.setProcessingRule(header.isProcessingRule());
+       // // FIXME: add subobjects
+       // return builder.build();
+       // }
+       //
+       // @Override
+       // public void addTlv(final ExcludeRouterBuilder builder, final Tlv tlv) {
+       // // No tlvs defined
+       // }
+       //
+       // @Override
+       // public byte[] serializeObject(final Object object) {
+       // if (!(object instanceof ExcludeRouteObject))
+       // throw new IllegalArgumentException("Wrong instance of PCEPObject. Passed " + object.getClass() +
+       // ". Needed ExcludeRouteObject.");
+       //
+       // assert !(((ExcludeRouteObject) object).getSubobjects().isEmpty()) : "Empty Excluded Route Object.";
+       //
+       // // return PCEPEROSubobjectParser.put(((ExplicitRouteObject) obj).getSubobjects());
+       //
+       // // FIXME: add subobjects
+       // return null;
+       // }
+       //
+       // @Override
+       // public int getObjectType() {
+       // return TYPE;
+       // }
+       //
+       // @Override
+       // public int getObjectClass() {
+       // return CLASS;
+       // }
 }