BUG-47 : Removed protection support. 78/1878/2
authorDana Kutenicsova <dkutenic@cisco.com>
Mon, 14 Oct 2013 14:18:33 +0000 (16:18 +0200)
committerDana Kutenicsova <dkutenic@cisco.com>
Mon, 14 Oct 2013 14:28:59 +0000 (16:28 +0200)
Change-Id: I4a2baaba8e0219843b9c10bd2533f34c5ae788b4
Signed-off-by: Dana Kutenicsova <dkutenic@cisco.com>
17 files changed:
pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/EROProtectionSubobject.java [deleted file]
pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/EROProtectionType1Subobject.java [deleted file]
pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/EROProtectionType2Subobject.java [deleted file]
pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/RROProtectionSubobject.java [deleted file]
pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/RROProtectionType1Subobject.java [deleted file]
pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/RROProtectionType2Subobject.java [deleted file]
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/PCEPEROSubobjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/PCEPRROSubobjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/EROProtectionParser.java [deleted file]
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/EROProtectionSubobjectParser.java [deleted file]
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/EROProtectionType1SubobjectParser.java [deleted file]
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/EROProtectionType2SubobjectParser.java [deleted file]
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/RROProtectionParser.java [deleted file]
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/RROProtectionSubobjectParser.java [deleted file]
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/RROProtectionType1SubobjectParser.java [deleted file]
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/RROProtectionType2SubobjectParser.java [deleted file]
pcep/impl/src/test/java/org/opendaylight/protocol/pcep/impl/PCEPSubobjectParserTest.java

diff --git a/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/EROProtectionSubobject.java b/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/EROProtectionSubobject.java
deleted file mode 100644 (file)
index d74138a..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.protocol.pcep.subobject;
-
-public abstract class EROProtectionSubobject extends ExplicitRouteSubobject {
-    public EROProtectionSubobject(boolean loose) {
-       super(loose);
-    }
-
-}
diff --git a/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/EROProtectionType1Subobject.java b/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/EROProtectionType1Subobject.java
deleted file mode 100644 (file)
index e3f5cef..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.protocol.pcep.subobject;
-
-import com.google.common.base.Objects.ToStringHelper;
-
-public class EROProtectionType1Subobject extends EROProtectionSubobject {
-
-    private final boolean secondary;
-
-    private final byte linkFlags;
-
-    /**
-     * @param secondary
-     * @param linkFlags
-     */
-    public EROProtectionType1Subobject(boolean secondary, byte linkFlags, boolean loose) {
-       super(loose);
-       this.secondary = secondary;
-       this.linkFlags = linkFlags;
-    }
-
-    /**
-     * @return the secondary
-     */
-    public boolean isSecondary() {
-       return this.secondary;
-    }
-
-    /**
-     * @return the linkFlags
-     */
-    public byte getLinkFlags() {
-       return this.linkFlags;
-    }
-
-    @Override
-    public int hashCode() {
-       final int prime = 31;
-       int result = super.hashCode();
-       result = prime * result + this.linkFlags;
-       result = prime * result + (this.secondary ? 1231 : 1237);
-       return result;
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-       if (this == obj)
-           return true;
-       if (!super.equals(obj))
-           return false;
-       if (this.getClass() != obj.getClass())
-           return false;
-       final EROProtectionType1Subobject other = (EROProtectionType1Subobject) obj;
-       if (this.linkFlags != other.linkFlags)
-           return false;
-       if (this.secondary != other.secondary)
-           return false;
-       return true;
-    }
-
-    @Override
-       protected ToStringHelper addToStringAttributes(ToStringHelper toStringHelper) {
-               toStringHelper.add("secondary", this.secondary);
-               toStringHelper.add("linkFlags", this.linkFlags);
-               return super.addToStringAttributes(toStringHelper);
-       }
-}
diff --git a/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/EROProtectionType2Subobject.java b/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/EROProtectionType2Subobject.java
deleted file mode 100644 (file)
index 4e893e1..0000000
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.protocol.pcep.subobject;
-
-import com.google.common.base.Objects.ToStringHelper;
-
-public class EROProtectionType2Subobject extends EROProtectionSubobject {
-    private final boolean secondaryLsp;
-
-    private final boolean protectionLsp;
-
-    private final boolean notification;
-
-    private final boolean operational;
-
-    private final byte lspFlags;
-
-    private final byte linkFlags;
-
-    private final boolean inPlace;
-
-    private final boolean required;
-
-    private final byte segFlags;
-
-    /**
-     * @param secondaryLsp
-     * @param protectionLsp
-     * @param notification
-     * @param operational
-     * @param lspFlags
-     * @param linkFlags
-     * @param inPlace
-     * @param required
-     * @param segFlags
-     */
-    public EROProtectionType2Subobject(boolean secondaryLsp, boolean protectionLsp, boolean notification, boolean operational, byte lspFlags, byte linkFlags,
-           boolean inPlace, boolean required, byte segFlags, boolean loose) {
-       super(loose);
-       this.secondaryLsp = secondaryLsp;
-       this.protectionLsp = protectionLsp;
-       this.notification = notification;
-       this.operational = operational;
-       this.lspFlags = lspFlags;
-       this.linkFlags = linkFlags;
-       this.inPlace = inPlace;
-       this.required = required;
-       this.segFlags = segFlags;
-    }
-
-    /**
-     * @return the secondaryLsp
-     */
-    public boolean isSecondaryLsp() {
-       return this.secondaryLsp;
-    }
-
-    /**
-     * @return the protectionLsp
-     */
-    public boolean isProtectionLsp() {
-       return this.protectionLsp;
-    }
-
-    /**
-     * @return the notification
-     */
-    public boolean isNotification() {
-       return this.notification;
-    }
-
-    /**
-     * @return the operational
-     */
-    public boolean isOperational() {
-       return this.operational;
-    }
-
-    /**
-     * @return the lspFlags
-     */
-    public byte getLspFlags() {
-       return this.lspFlags;
-    }
-
-    /**
-     * @return the linkFlags
-     */
-    public byte getLinkFlags() {
-       return this.linkFlags;
-    }
-
-    /**
-     * @return the inPlace
-     */
-    public boolean isInPlace() {
-       return this.inPlace;
-    }
-
-    /**
-     * @return the required
-     */
-    public boolean isRequired() {
-       return this.required;
-    }
-
-    /**
-     * @return the segFlags
-     */
-    public byte getSegFlags() {
-       return this.segFlags;
-    }
-
-    @Override
-    public int hashCode() {
-       final int prime = 31;
-       int result = super.hashCode();
-       result = prime * result + (this.inPlace ? 1231 : 1237);
-       result = prime * result + this.linkFlags;
-       result = prime * result + this.lspFlags;
-       result = prime * result + (this.notification ? 1231 : 1237);
-       result = prime * result + (this.operational ? 1231 : 1237);
-       result = prime * result + (this.protectionLsp ? 1231 : 1237);
-       result = prime * result + (this.required ? 1231 : 1237);
-       result = prime * result + (this.secondaryLsp ? 1231 : 1237);
-       result = prime * result + this.segFlags;
-       return result;
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-       if (this == obj)
-           return true;
-       if (!super.equals(obj))
-           return false;
-       if (this.getClass() != obj.getClass())
-           return false;
-       final EROProtectionType2Subobject other = (EROProtectionType2Subobject) obj;
-       if (this.inPlace != other.inPlace)
-           return false;
-       if (this.linkFlags != other.linkFlags)
-           return false;
-       if (this.lspFlags != other.lspFlags)
-           return false;
-       if (this.notification != other.notification)
-           return false;
-       if (this.operational != other.operational)
-           return false;
-       if (this.protectionLsp != other.protectionLsp)
-           return false;
-       if (this.required != other.required)
-           return false;
-       if (this.secondaryLsp != other.secondaryLsp)
-           return false;
-       if (this.segFlags != other.segFlags)
-           return false;
-       return true;
-    }
-
-    @Override
-       protected ToStringHelper addToStringAttributes(ToStringHelper toStringHelper) {
-               toStringHelper.add("secondaryLsp", this.secondaryLsp);
-               toStringHelper.add("protectionLsp", this.protectionLsp);
-               toStringHelper.add("notification", this.notification);
-               toStringHelper.add("operational", this.operational);
-               toStringHelper.add("lspFlags", this.lspFlags);
-               toStringHelper.add("linkFlags", this.linkFlags);
-               toStringHelper.add("inPlace", this.inPlace);
-               toStringHelper.add("required", this.required);
-               toStringHelper.add("segFlags", this.segFlags);
-               return super.addToStringAttributes(toStringHelper);
-       }
-}
diff --git a/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/RROProtectionSubobject.java b/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/RROProtectionSubobject.java
deleted file mode 100644 (file)
index 0471d36..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.protocol.pcep.subobject;
-
-public abstract class RROProtectionSubobject extends ReportedRouteSubobject {
-    public RROProtectionSubobject() {
-       super();
-    }
-
-}
diff --git a/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/RROProtectionType1Subobject.java b/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/RROProtectionType1Subobject.java
deleted file mode 100644 (file)
index 67f98d0..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.protocol.pcep.subobject;
-
-
-public class RROProtectionType1Subobject extends RROProtectionSubobject {
-
-    private final boolean secondary;
-
-    private final byte linkFlags;
-
-    /**
-     * @param secondary
-     * @param linkFlags
-     */
-    public RROProtectionType1Subobject(boolean secondary, byte linkFlags) {
-       super();
-       this.secondary = secondary;
-       this.linkFlags = linkFlags;
-    }
-
-    /**
-     * @return the secondary
-     */
-    public boolean isSecondary() {
-       return this.secondary;
-    }
-
-    /**
-     * @return the linkFlags
-     */
-    public byte getLinkFlags() {
-       return this.linkFlags;
-    }
-
-    @Override
-    public int hashCode() {
-       final int prime = 31;
-       int result = 1;
-       result = prime * result + this.linkFlags;
-       result = prime * result + (this.secondary ? 1231 : 1237);
-       return result;
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-       if (this == obj)
-           return true;
-       if (obj == null)
-           return false;
-       if (this.getClass() != obj.getClass())
-           return false;
-       final RROProtectionType1Subobject other = (RROProtectionType1Subobject) obj;
-       if (this.linkFlags != other.linkFlags)
-           return false;
-       if (this.secondary != other.secondary)
-           return false;
-       return true;
-    }
-
-    @Override
-    public String toString() {
-       final StringBuilder builder = new StringBuilder();
-       builder.append("ProtectionType1Subobject [secondary=");
-       builder.append(this.secondary);
-       builder.append(", linkFlags=");
-       builder.append(this.linkFlags);
-       builder.append("]");
-       return builder.toString();
-    }
-
-}
diff --git a/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/RROProtectionType2Subobject.java b/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/RROProtectionType2Subobject.java
deleted file mode 100644 (file)
index d617f4c..0000000
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.protocol.pcep.subobject;
-
-public class RROProtectionType2Subobject extends RROProtectionSubobject {
-    private final boolean secondaryLsp;
-
-    private final boolean protectionLsp;
-
-    private final boolean notification;
-
-    private final boolean operational;
-
-    private final byte lspFlags;
-
-    private final byte linkFlags;
-
-    private final boolean inPlace;
-
-    private final boolean required;
-
-    private final byte segFlags;
-
-    /**
-     * @param secondaryLsp
-     * @param protectionLsp
-     * @param notification
-     * @param operational
-     * @param lspFlags
-     * @param linkFlags
-     * @param inPlace
-     * @param required
-     * @param segFlags
-     */
-    public RROProtectionType2Subobject(boolean secondaryLsp, boolean protectionLsp, boolean notification, boolean operational, byte lspFlags, byte linkFlags,
-           boolean inPlace, boolean required, byte segFlags) {
-       super();
-       this.secondaryLsp = secondaryLsp;
-       this.protectionLsp = protectionLsp;
-       this.notification = notification;
-       this.operational = operational;
-       this.lspFlags = lspFlags;
-       this.linkFlags = linkFlags;
-       this.inPlace = inPlace;
-       this.required = required;
-       this.segFlags = segFlags;
-    }
-
-    /**
-     * @return the secondaryLsp
-     */
-    public boolean isSecondaryLsp() {
-       return this.secondaryLsp;
-    }
-
-    /**
-     * @return the protectionLsp
-     */
-    public boolean isProtectionLsp() {
-       return this.protectionLsp;
-    }
-
-    /**
-     * @return the notification
-     */
-    public boolean isNotification() {
-       return this.notification;
-    }
-
-    /**
-     * @return the operational
-     */
-    public boolean isOperational() {
-       return this.operational;
-    }
-
-    /**
-     * @return the lspFlags
-     */
-    public byte getLspFlags() {
-       return this.lspFlags;
-    }
-
-    /**
-     * @return the linkFlags
-     */
-    public byte getLinkFlags() {
-       return this.linkFlags;
-    }
-
-    /**
-     * @return the inPlace
-     */
-    public boolean isInPlace() {
-       return this.inPlace;
-    }
-
-    /**
-     * @return the required
-     */
-    public boolean isRequired() {
-       return this.required;
-    }
-
-    /**
-     * @return the segFlags
-     */
-    public byte getSegFlags() {
-       return this.segFlags;
-    }
-
-    @Override
-    public int hashCode() {
-       final int prime = 31;
-       int result = 1;
-       result = prime * result + (this.inPlace ? 1231 : 1237);
-       result = prime * result + this.linkFlags;
-       result = prime * result + this.lspFlags;
-       result = prime * result + (this.notification ? 1231 : 1237);
-       result = prime * result + (this.operational ? 1231 : 1237);
-       result = prime * result + (this.protectionLsp ? 1231 : 1237);
-       result = prime * result + (this.required ? 1231 : 1237);
-       result = prime * result + (this.secondaryLsp ? 1231 : 1237);
-       result = prime * result + this.segFlags;
-       return result;
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-       if (this == obj)
-           return true;
-       if (obj == null)
-           return false;
-       if (this.getClass() != obj.getClass())
-           return false;
-       final RROProtectionType2Subobject other = (RROProtectionType2Subobject) obj;
-       if (this.inPlace != other.inPlace)
-           return false;
-       if (this.linkFlags != other.linkFlags)
-           return false;
-       if (this.lspFlags != other.lspFlags)
-           return false;
-       if (this.notification != other.notification)
-           return false;
-       if (this.operational != other.operational)
-           return false;
-       if (this.protectionLsp != other.protectionLsp)
-           return false;
-       if (this.required != other.required)
-           return false;
-       if (this.secondaryLsp != other.secondaryLsp)
-           return false;
-       if (this.segFlags != other.segFlags)
-           return false;
-       return true;
-    }
-
-    @Override
-    public String toString() {
-       final StringBuilder builder = new StringBuilder();
-       builder.append("ProtectionType1Subobject [secondaryLsp=");
-       builder.append(this.secondaryLsp);
-       builder.append(", protectionLsp=");
-       builder.append(this.protectionLsp);
-       builder.append(", notification=");
-       builder.append(this.notification);
-       builder.append(", operational=");
-       builder.append(this.operational);
-       builder.append(", lspFlags=");
-       builder.append(this.lspFlags);
-       builder.append(", linkFlags=");
-       builder.append(this.linkFlags);
-       builder.append(", inPlace=");
-       builder.append(this.inPlace);
-       builder.append(", required=");
-       builder.append(this.required);
-       builder.append(", segFlags=");
-       builder.append(this.segFlags);
-       builder.append("]");
-       return builder.toString();
-    }
-
-}
index 721cd98628c2bba8c536e7d9b5214c1a72e5159f..d110b23840b0cc62267c64dd9cda02d5e24a1272 100644 (file)
@@ -17,7 +17,6 @@ import org.opendaylight.protocol.pcep.impl.subobject.EROExplicitExclusionRouteSu
 import org.opendaylight.protocol.pcep.impl.subobject.EROLabelSubobjectParser;
 import org.opendaylight.protocol.pcep.impl.subobject.EROPathKeyWith128PCEIDSubobjectParser;
 import org.opendaylight.protocol.pcep.impl.subobject.EROPathKeyWith32PCEIDSubobjectParser;
-import org.opendaylight.protocol.pcep.impl.subobject.EROProtectionSubobjectParser;
 import org.opendaylight.protocol.pcep.impl.subobject.EROUnnumberedInterfaceSubobjectParser;
 import org.opendaylight.protocol.pcep.subobject.EROAsNumberSubobject;
 import org.opendaylight.protocol.pcep.subobject.EROExplicitExclusionRouteSubobject;
@@ -25,7 +24,6 @@ import org.opendaylight.protocol.pcep.subobject.EROIPPrefixSubobject;
 import org.opendaylight.protocol.pcep.subobject.EROLabelSubobject;
 import org.opendaylight.protocol.pcep.subobject.EROPathKeyWith128PCEIDSubobject;
 import org.opendaylight.protocol.pcep.subobject.EROPathKeyWith32PCEIDSubobject;
-import org.opendaylight.protocol.pcep.subobject.EROProtectionSubobject;
 import org.opendaylight.protocol.pcep.subobject.EROUnnumberedInterfaceSubobject;
 import org.opendaylight.protocol.pcep.subobject.ExplicitRouteSubobject;
 import org.opendaylight.protocol.util.ByteArray;
@@ -168,9 +166,6 @@ public class PCEPEROSubobjectParser {
                } else if (objToSerialize instanceof EROPathKeyWith128PCEIDSubobject) {
                        typeIndicator = PCEPSubobjectType.PK_128.getIndicator();
                        soContentsBytes = EROPathKeyWith128PCEIDSubobjectParser.put((EROPathKeyWith128PCEIDSubobject) objToSerialize);
-               } else if (objToSerialize instanceof EROProtectionSubobject) {
-                       typeIndicator = PCEPSubobjectType.PROTECTION.getIndicator();
-                       soContentsBytes = EROProtectionSubobjectParser.put((EROProtectionSubobject) objToSerialize);
                } else
                        throw new IllegalArgumentException("Unknown instance of PCEPSubobject. Passed: " + objToSerialize.getClass() + ".");
 
@@ -206,8 +201,6 @@ public class PCEPEROSubobjectParser {
                        return EROPathKeyWith32PCEIDSubobjectParser.parse(soContentsBytes, loose_flag);
                case PK_128:
                        return EROPathKeyWith128PCEIDSubobjectParser.parse(soContentsBytes, loose_flag);
-               case PROTECTION:
-                       return EROProtectionSubobjectParser.parse(soContentsBytes, loose_flag);
                default:
                        throw new PCEPDeserializerException("Unknown Subobject type. Passed: " + type + ".");
                }
index 395717920fea6b80a307f33d3b547790e3402225..154cc14e16b282b320cf9004910a130923aede4f 100644 (file)
@@ -10,10 +10,6 @@ package org.opendaylight.protocol.pcep.impl;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.protocol.concepts.IPv4Prefix;
 import org.opendaylight.protocol.concepts.IPv6Prefix;
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
@@ -23,182 +19,182 @@ import org.opendaylight.protocol.pcep.impl.subobject.RROIPv6AddressSubobjectPars
 import org.opendaylight.protocol.pcep.impl.subobject.RROLabelSubobjectParser;
 import org.opendaylight.protocol.pcep.impl.subobject.RROPathKeyWith128PCEIDSubobjectParser;
 import org.opendaylight.protocol.pcep.impl.subobject.RROPathKeyWith32PCEIDSubobjectParser;
-import org.opendaylight.protocol.pcep.impl.subobject.RROProtectionSubobjectParser;
 import org.opendaylight.protocol.pcep.impl.subobject.RROUnnumberedInterfaceSubobjectParser;
 import org.opendaylight.protocol.pcep.subobject.RROAttributesSubobject;
 import org.opendaylight.protocol.pcep.subobject.RROIPAddressSubobject;
 import org.opendaylight.protocol.pcep.subobject.RROLabelSubobject;
 import org.opendaylight.protocol.pcep.subobject.RROPathKeyWith128PCEIDSubobject;
 import org.opendaylight.protocol.pcep.subobject.RROPathKeyWith32PCEIDSubobject;
-import org.opendaylight.protocol.pcep.subobject.RROProtectionSubobject;
 import org.opendaylight.protocol.pcep.subobject.RROUnnumberedInterfaceSubobject;
 import org.opendaylight.protocol.pcep.subobject.ReportedRouteSubobject;
+import org.opendaylight.protocol.util.ByteArray;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Parser for {@link org.opendaylight.protocol.pcep.PCEPSubobject PCEPSubobject}
  */
 public class PCEPRROSubobjectParser {
 
-    private static final Logger logger = LoggerFactory.getLogger(PCEPRROSubobjectParser.class);
+       private static final Logger logger = LoggerFactory.getLogger(PCEPRROSubobjectParser.class);
 
-    /**
-     * Type identifier for {@link org.opendaylight.protocol.pcep.PCEPSubobject
-     * PCEPSubobject}
-     */
-    public enum PCEPSubobjectType {
-       IPv4_PREFIX(1), IPv6_PREFIX(2), LABEL(3), UNNUMBERED_INTERFACE_ID(4), ATTRIBUTES(5), PROTECTION(37), PK_32(64), PK_128(65);
+       /**
+        * Type identifier for {@link org.opendaylight.protocol.pcep.PCEPSubobject PCEPSubobject}
+        */
+       public enum PCEPSubobjectType {
+               IPv4_PREFIX(1), IPv6_PREFIX(2), LABEL(3), UNNUMBERED_INTERFACE_ID(4), ATTRIBUTES(5), PROTECTION(37), PK_32(64), PK_128(65);
 
-       private final int indicator;
+               private final int indicator;
 
-       PCEPSubobjectType(final int indicator) {
-           this.indicator = indicator;
-       }
+               PCEPSubobjectType(final int indicator) {
+                       this.indicator = indicator;
+               }
 
-       public int getIndicator() {
-           return this.indicator;
-       }
+               public int getIndicator() {
+                       return this.indicator;
+               }
 
-       public static PCEPSubobjectType getFromInt(final int type) throws PCEPDeserializerException {
+               public static PCEPSubobjectType getFromInt(final int type) throws PCEPDeserializerException {
 
-           for (final PCEPSubobjectType type_e : PCEPSubobjectType.values()) {
-               if (type_e.getIndicator() == type)
-                   return type_e;
-           }
+                       for (final PCEPSubobjectType type_e : PCEPSubobjectType.values()) {
+                               if (type_e.getIndicator() == type)
+                                       return type_e;
+                       }
 
-           throw new PCEPDeserializerException("Unknown Subobject type. Passed: " + type + "; Known: " + PCEPSubobjectType.values() + ".");
-       }
+                       throw new PCEPDeserializerException("Unknown Subobject type. Passed: " + type + "; Known: " + PCEPSubobjectType.values() + ".");
+               }
        }
 
-    /*
-     * Fields lengths in Bytes
-     */
-    public static final int TYPE_F_LENGTH = 1;
-    public static final int LENGTH_F_LENGTH = 1;
+       /*
+        * Fields lengths in Bytes
+        */
+       public static final int TYPE_F_LENGTH = 1;
+       public static final int LENGTH_F_LENGTH = 1;
+
+       /*
+        * Fields offsets in Bytes
+        */
+       public static final int TYPE_F_OFFSET = 0;
+       public static final int LENGTH_F_OFFSET = TYPE_F_OFFSET + TYPE_F_LENGTH;
+       public static final int SO_CONTENTS_OFFSET = LENGTH_F_OFFSET + LENGTH_F_LENGTH;
 
-    /*
-     * Fields offsets in Bytes
-     */
-    public static final int TYPE_F_OFFSET = 0;
-    public static final int LENGTH_F_OFFSET = TYPE_F_OFFSET + TYPE_F_LENGTH;
-    public static final int SO_CONTENTS_OFFSET = LENGTH_F_OFFSET + LENGTH_F_LENGTH;
+       public static List<ReportedRouteSubobject> parse(final byte[] bytes) throws PCEPDeserializerException {
+               if (bytes == null)
+                       throw new IllegalArgumentException("Byte array is mandatory.");
 
-    public static List<ReportedRouteSubobject> parse(final byte[] bytes) throws PCEPDeserializerException {
-       if (bytes == null)
-           throw new IllegalArgumentException("Byte array is mandatory.");
+               final List<ReportedRouteSubobject> subobjsList = new ArrayList<ReportedRouteSubobject>();
+               PCEPSubobjectType type;
+               byte[] soContentsBytes;
+               int length;
+               int offset = 0;
 
-       final List<ReportedRouteSubobject> subobjsList = new ArrayList<ReportedRouteSubobject>();
-       PCEPSubobjectType type;
-       byte[] soContentsBytes;
-       int length;
-       int offset = 0;
+               while (offset < bytes.length) {
+                       length = ByteArray.bytesToInt(ByteArray.subByte(bytes, offset + LENGTH_F_OFFSET, LENGTH_F_LENGTH));
 
-       while (offset < bytes.length) {
-           length = ByteArray.bytesToInt(ByteArray.subByte(bytes, offset + LENGTH_F_OFFSET, LENGTH_F_LENGTH));
+                       type = PCEPSubobjectType.getFromInt(bytes[offset + TYPE_F_OFFSET] & 0xff);
 
-           type = PCEPSubobjectType.getFromInt(bytes[offset + TYPE_F_OFFSET] & 0xff);
+                       if (length > bytes.length - offset)
+                               throw new PCEPDeserializerException("Wrong length specified. Passed: " + length + "; Expected: <= "
+                                               + (bytes.length - offset));
 
-           if (length > bytes.length - offset)
-               throw new PCEPDeserializerException("Wrong length specified. Passed: " + length + "; Expected: <= " + (bytes.length - offset));
+                       soContentsBytes = new byte[length - SO_CONTENTS_OFFSET];
+                       System.arraycopy(bytes, offset + SO_CONTENTS_OFFSET, soContentsBytes, 0, length - SO_CONTENTS_OFFSET);
 
-           soContentsBytes = new byte[length - SO_CONTENTS_OFFSET];
-           System.arraycopy(bytes, offset + SO_CONTENTS_OFFSET, soContentsBytes, 0, length - SO_CONTENTS_OFFSET);
+                       logger.trace("Attempt to parse subobject from bytes: {}", ByteArray.bytesToHexString(soContentsBytes));
+                       final ReportedRouteSubobject subObj = parseSpecificSubobject(type, soContentsBytes);
+                       logger.trace("Subobject was parsed. {}", subObj);
 
-           logger.trace("Attempt to parse subobject from bytes: {}", ByteArray.bytesToHexString(soContentsBytes));
-           final ReportedRouteSubobject subObj = parseSpecificSubobject(type, soContentsBytes);
-           logger.trace("Subobject was parsed. {}", subObj);
+                       subobjsList.add(subObj);
 
-           subobjsList.add(subObj);
+                       offset += length;
+               }
 
-           offset += length;
+               return subobjsList;
        }
 
-       return subobjsList;
-    }
+       public static byte[] put(final List<ReportedRouteSubobject> objsToSerialize) {
+               final List<byte[]> bytesList = new ArrayList<byte[]>(objsToSerialize.size());
 
-    public static byte[] put(final List<ReportedRouteSubobject> objsToSerialize) {
-       final List<byte[]> bytesList = new ArrayList<byte[]>(objsToSerialize.size());
+               int length = 0;
+               for (final ReportedRouteSubobject obj : objsToSerialize) {
+                       final byte[] bytes = put(obj);
+                       length += bytes.length;
+                       bytesList.add(bytes);
+               }
 
-       int length = 0;
-       for (final ReportedRouteSubobject obj : objsToSerialize) {
-           final byte[] bytes = put(obj);
-           length += bytes.length;
-           bytesList.add(bytes);
-       }
+               final byte[] retBytes = new byte[length];
+
+               int offset = 0;
+               for (final byte[] bytes : bytesList) {
+                       System.arraycopy(bytes, 0, retBytes, offset, bytes.length);
+                       offset += bytes.length;
+               }
 
-       final byte[] retBytes = new byte[length];
+               return retBytes;
+       }
 
-       int offset = 0;
-       for (final byte[] bytes : bytesList) {
-           System.arraycopy(bytes, 0, retBytes, offset, bytes.length);
-           offset += bytes.length;
+       public static byte[] put(final ReportedRouteSubobject objToSerialize) {
+               int typeIndicator = 0;
+
+               final byte[] soContentsBytes;
+
+               if (objToSerialize instanceof RROIPAddressSubobject<?>
+                               && ((RROIPAddressSubobject<?>) objToSerialize).getPrefix() instanceof IPv4Prefix) {
+                       typeIndicator = PCEPSubobjectType.IPv4_PREFIX.getIndicator();
+                       soContentsBytes = RROIPv4AddressSubobjectParser.put(objToSerialize);
+               } else if (objToSerialize instanceof RROIPAddressSubobject<?>
+                               && ((RROIPAddressSubobject<?>) objToSerialize).getPrefix() instanceof IPv6Prefix) {
+                       typeIndicator = PCEPSubobjectType.IPv6_PREFIX.getIndicator();
+                       soContentsBytes = RROIPv6AddressSubobjectParser.put(objToSerialize);
+               } else if (objToSerialize instanceof RROUnnumberedInterfaceSubobject) {
+                       typeIndicator = PCEPSubobjectType.UNNUMBERED_INTERFACE_ID.getIndicator();
+                       soContentsBytes = RROUnnumberedInterfaceSubobjectParser.put(objToSerialize);
+               } else if (objToSerialize instanceof RROLabelSubobject) {
+                       typeIndicator = PCEPSubobjectType.LABEL.getIndicator();
+                       soContentsBytes = RROLabelSubobjectParser.put((RROLabelSubobject) objToSerialize);
+               } else if (objToSerialize instanceof RROPathKeyWith32PCEIDSubobject) {
+                       typeIndicator = PCEPSubobjectType.PK_32.getIndicator();
+                       soContentsBytes = RROPathKeyWith32PCEIDSubobjectParser.put((RROPathKeyWith32PCEIDSubobject) objToSerialize);
+               } else if (objToSerialize instanceof RROPathKeyWith128PCEIDSubobject) {
+                       typeIndicator = PCEPSubobjectType.PK_128.getIndicator();
+                       soContentsBytes = RROPathKeyWith128PCEIDSubobjectParser.put((RROPathKeyWith128PCEIDSubobject) objToSerialize);
+               } else if (objToSerialize instanceof RROAttributesSubobject) {
+                       typeIndicator = PCEPSubobjectType.ATTRIBUTES.getIndicator();
+                       soContentsBytes = RROAttributesSubobjectParser.put((RROAttributesSubobject) objToSerialize);
+               } else
+                       throw new IllegalArgumentException("Unknown instance of PCEPSubobject. Passed: " + objToSerialize.getClass() + ".");
+
+               final byte[] bytes = new byte[SO_CONTENTS_OFFSET + soContentsBytes.length];
+
+               bytes[TYPE_F_OFFSET] = ByteArray.cutBytes(ByteArray.intToBytes(typeIndicator), (Integer.SIZE / 8) - TYPE_F_LENGTH)[0];
+               bytes[LENGTH_F_OFFSET] = ByteArray.cutBytes(ByteArray.intToBytes(soContentsBytes.length + SO_CONTENTS_OFFSET), (Integer.SIZE / 8)
+                               - LENGTH_F_LENGTH)[0];
+
+               System.arraycopy(soContentsBytes, 0, bytes, SO_CONTENTS_OFFSET, soContentsBytes.length);
+
+               return bytes;
        }
 
-       return retBytes;
-    }
-
-    public static byte[] put(final ReportedRouteSubobject objToSerialize) {
-       int typeIndicator = 0;
-
-       final byte[] soContentsBytes;
-
-       if (objToSerialize instanceof RROIPAddressSubobject<?> && ((RROIPAddressSubobject<?>) objToSerialize).getPrefix() instanceof IPv4Prefix) {
-           typeIndicator = PCEPSubobjectType.IPv4_PREFIX.getIndicator();
-           soContentsBytes = RROIPv4AddressSubobjectParser.put(objToSerialize);
-       } else if (objToSerialize instanceof RROIPAddressSubobject<?> && ((RROIPAddressSubobject<?>) objToSerialize).getPrefix() instanceof IPv6Prefix) {
-           typeIndicator = PCEPSubobjectType.IPv6_PREFIX.getIndicator();
-           soContentsBytes = RROIPv6AddressSubobjectParser.put(objToSerialize);
-       } else if (objToSerialize instanceof RROUnnumberedInterfaceSubobject) {
-           typeIndicator = PCEPSubobjectType.UNNUMBERED_INTERFACE_ID.getIndicator();
-           soContentsBytes = RROUnnumberedInterfaceSubobjectParser.put(objToSerialize);
-       } else if (objToSerialize instanceof RROLabelSubobject) {
-           typeIndicator = PCEPSubobjectType.LABEL.getIndicator();
-           soContentsBytes = RROLabelSubobjectParser.put((RROLabelSubobject) objToSerialize);
-       } else if (objToSerialize instanceof RROProtectionSubobject) {
-           typeIndicator = PCEPSubobjectType.PROTECTION.getIndicator();
-           soContentsBytes = RROProtectionSubobjectParser.put((RROProtectionSubobject) objToSerialize);
-       } else if (objToSerialize instanceof RROPathKeyWith32PCEIDSubobject) {
-           typeIndicator = PCEPSubobjectType.PK_32.getIndicator();
-           soContentsBytes = RROPathKeyWith32PCEIDSubobjectParser.put((RROPathKeyWith32PCEIDSubobject) objToSerialize);
-       } else if (objToSerialize instanceof RROPathKeyWith128PCEIDSubobject) {
-           typeIndicator = PCEPSubobjectType.PK_128.getIndicator();
-           soContentsBytes = RROPathKeyWith128PCEIDSubobjectParser.put((RROPathKeyWith128PCEIDSubobject) objToSerialize);
-       } else if (objToSerialize instanceof RROAttributesSubobject) {
-           typeIndicator = PCEPSubobjectType.ATTRIBUTES.getIndicator();
-           soContentsBytes = RROAttributesSubobjectParser.put((RROAttributesSubobject) objToSerialize);
-       } else
-           throw new IllegalArgumentException("Unknown instance of PCEPSubobject. Passed: " + objToSerialize.getClass() + ".");
-
-       final byte[] bytes = new byte[SO_CONTENTS_OFFSET + soContentsBytes.length];
-
-       bytes[TYPE_F_OFFSET] = ByteArray.cutBytes(ByteArray.intToBytes(typeIndicator), (Integer.SIZE / 8) - TYPE_F_LENGTH)[0];
-       bytes[LENGTH_F_OFFSET] = ByteArray.cutBytes(ByteArray.intToBytes(soContentsBytes.length + SO_CONTENTS_OFFSET), (Integer.SIZE / 8) - LENGTH_F_LENGTH)[0];
-
-       System.arraycopy(soContentsBytes, 0, bytes, SO_CONTENTS_OFFSET, soContentsBytes.length);
-
-       return bytes;
-    }
-
-    private static ReportedRouteSubobject parseSpecificSubobject(final PCEPSubobjectType type, final byte[] soContentsBytes) throws PCEPDeserializerException {
-
-       switch (type) {
-           case IPv4_PREFIX:
-               return RROIPv4AddressSubobjectParser.parse(soContentsBytes);
-           case IPv6_PREFIX:
-               return RROIPv6AddressSubobjectParser.parse(soContentsBytes);
-           case UNNUMBERED_INTERFACE_ID:
-               return RROUnnumberedInterfaceSubobjectParser.parse(soContentsBytes);
-           case LABEL:
-               return RROLabelSubobjectParser.parse(soContentsBytes);
-           case PROTECTION:
-               return RROProtectionSubobjectParser.parse(soContentsBytes);
-           case PK_32:
-               return RROPathKeyWith32PCEIDSubobjectParser.parse(soContentsBytes);
-           case PK_128:
-               return RROPathKeyWith128PCEIDSubobjectParser.parse(soContentsBytes);
-           case ATTRIBUTES:
-               return RROAttributesSubobjectParser.parse(soContentsBytes);
-           default:
-               throw new PCEPDeserializerException("Unknown Subobject type. Passed: " + type + ".");
+       private static ReportedRouteSubobject parseSpecificSubobject(final PCEPSubobjectType type, final byte[] soContentsBytes)
+                       throws PCEPDeserializerException {
+
+               switch (type) {
+               case IPv4_PREFIX:
+                       return RROIPv4AddressSubobjectParser.parse(soContentsBytes);
+               case IPv6_PREFIX:
+                       return RROIPv6AddressSubobjectParser.parse(soContentsBytes);
+               case UNNUMBERED_INTERFACE_ID:
+                       return RROUnnumberedInterfaceSubobjectParser.parse(soContentsBytes);
+               case LABEL:
+                       return RROLabelSubobjectParser.parse(soContentsBytes);
+               case PK_32:
+                       return RROPathKeyWith32PCEIDSubobjectParser.parse(soContentsBytes);
+               case PK_128:
+                       return RROPathKeyWith128PCEIDSubobjectParser.parse(soContentsBytes);
+               case ATTRIBUTES:
+                       return RROAttributesSubobjectParser.parse(soContentsBytes);
+               default:
+                       throw new PCEPDeserializerException("Unknown Subobject type. Passed: " + type + ".");
+               }
        }
-    }
 }
diff --git a/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/EROProtectionParser.java b/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/EROProtectionParser.java
deleted file mode 100644 (file)
index 1b0c8d9..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.protocol.pcep.impl.subobject;
-
-import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.subobject.EROProtectionSubobject;
-
-public interface EROProtectionParser {
-
-    EROProtectionSubobject parse(byte[] cutBytes, boolean loose) throws PCEPDeserializerException;
-
-    byte[] put(EROProtectionSubobject objToSerialize);
-
-}
diff --git a/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/EROProtectionSubobjectParser.java b/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/EROProtectionSubobjectParser.java
deleted file mode 100644 (file)
index 8cb8bbf..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.protocol.pcep.impl.subobject;
-
-import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.impl.Util.BiParsersMap;
-import org.opendaylight.protocol.pcep.subobject.EROProtectionSubobject;
-import org.opendaylight.protocol.pcep.subobject.EROProtectionType1Subobject;
-import org.opendaylight.protocol.pcep.subobject.EROProtectionType2Subobject;
-import org.opendaylight.protocol.util.ByteArray;
-
-public class EROProtectionSubobjectParser {
-
-    public static final int RES_F_LENGTH = 1;
-
-    public static final int C_TYPE_F_LENGTH = 1;
-
-    public static final int RES_F_OFFSET = 0;
-
-    public static final int C_TYPE_F_OFFSET = RES_F_OFFSET + RES_F_LENGTH;
-
-    public static final int HEADER_LENGTH = C_TYPE_F_OFFSET + C_TYPE_F_LENGTH;
-
-    public static final int U_FLAG_OFFSET = 0;
-
-    private static class MapOfParsers extends BiParsersMap<Class<? extends EROProtectionSubobject>, Integer, EROProtectionParser> {
-       private final static MapOfParsers instance = new MapOfParsers();
-
-       private MapOfParsers() {
-           this.fillInMap();
-       }
-
-       private void fillInMap() {
-           this.put(EROProtectionType1Subobject.class, 1, new EROProtectionType1SubobjectParser());
-           this.put(EROProtectionType2Subobject.class, 2, new EROProtectionType2SubobjectParser());
-       }
-
-       public static MapOfParsers getInstance() {
-           return instance;
-       }
-    }
-
-    public static EROProtectionSubobject parse(byte[] soContentsBytes, boolean loose) throws PCEPDeserializerException {
-       if (soContentsBytes == null || soContentsBytes.length == 0)
-           throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
-       if (soContentsBytes.length < HEADER_LENGTH)
-           throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + soContentsBytes.length + "; Expected: >" + HEADER_LENGTH + ".");
-
-       final int c_type = soContentsBytes[C_TYPE_F_OFFSET] & 0xFF;
-
-       final EROProtectionParser parser = MapOfParsers.getInstance().getValueFromKeyValue(c_type);
-
-       if (parser == null) {
-           throw new PCEPDeserializerException("Unknown C-TYPE for ero protection subobject. Passed: " + c_type);
-       }
-
-       return parser.parse(ByteArray.cutBytes(soContentsBytes, HEADER_LENGTH), loose);
-    }
-
-    public static byte[] put(EROProtectionSubobject objToSerialize) {
-       final Integer c_type = MapOfParsers.getInstance().getKeyValueFromKey(objToSerialize.getClass());
-       final EROProtectionParser parser = MapOfParsers.getInstance().getValueFromKeyValue(c_type);
-
-       if (c_type == null || parser == null)
-           throw new IllegalArgumentException("Unknown EROProtectionSubobject instance. Passed " + objToSerialize.getClass());
-
-       final byte[] protBytes = parser.put(objToSerialize);
-
-       final byte[] retBytes = new byte[protBytes.length + HEADER_LENGTH];
-
-       System.arraycopy(protBytes, 0, retBytes, HEADER_LENGTH, protBytes.length);
-
-       retBytes[C_TYPE_F_OFFSET] = (byte) c_type.intValue();
-
-       return retBytes;
-    }
-}
diff --git a/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/EROProtectionType1SubobjectParser.java b/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/EROProtectionType1SubobjectParser.java
deleted file mode 100644 (file)
index f9326a0..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.protocol.pcep.impl.subobject;
-
-import java.util.Arrays;
-import java.util.BitSet;
-
-import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.subobject.EROProtectionSubobject;
-import org.opendaylight.protocol.pcep.subobject.EROProtectionType1Subobject;
-import org.opendaylight.protocol.util.ByteArray;
-
-public class EROProtectionType1SubobjectParser implements EROProtectionParser {
-
-    public static final int RES_F_LENGTH = 4;
-
-    public static final int RES_F_OFFSET = 0;
-
-    public static final int CONTENT_LENGTH = RES_F_OFFSET + RES_F_LENGTH;
-
-    /*
-     * offsets of flags inside reserved field
-     */
-    public static final int S_FLAG_OFFSET = 0;
-
-    @Override
-    public EROProtectionSubobject parse(byte[] cutBytes, boolean loose) throws PCEPDeserializerException {
-       if (cutBytes == null || cutBytes.length == 0)
-           throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
-       if (cutBytes.length < CONTENT_LENGTH)
-           throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + cutBytes.length + "; Expected: >" + CONTENT_LENGTH + ".");
-
-       final BitSet reserved = ByteArray.bytesToBitSet(Arrays.copyOfRange(cutBytes, RES_F_OFFSET, RES_F_LENGTH));
-
-       final byte linkFlags = (byte) (cutBytes[3] & 0x3F);
-
-       return new EROProtectionType1Subobject(reserved.get(S_FLAG_OFFSET), linkFlags, loose);
-    }
-
-    @Override
-    public byte[] put(EROProtectionSubobject objToSerialize) {
-       if (!(objToSerialize instanceof EROProtectionType1Subobject))
-           throw new IllegalArgumentException("Unknown EROProtectionSubobject instance. Passed " + objToSerialize.getClass()
-                   + ". Needed EROProtectionType1Subobject.");
-
-       final byte[] retBytes = new byte[CONTENT_LENGTH];
-
-       final BitSet reserved = new BitSet();
-       reserved.set(S_FLAG_OFFSET, ((EROProtectionType1Subobject) objToSerialize).isSecondary());
-       System.arraycopy(ByteArray.bitSetToBytes(reserved, RES_F_LENGTH), 0, retBytes, RES_F_OFFSET, RES_F_LENGTH);
-
-       retBytes[3] |= ((EROProtectionType1Subobject) objToSerialize).getLinkFlags() & 0x3F;
-
-       return retBytes;
-    }
-
-}
diff --git a/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/EROProtectionType2SubobjectParser.java b/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/EROProtectionType2SubobjectParser.java
deleted file mode 100644 (file)
index 33e034c..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.protocol.pcep.impl.subobject;
-
-import java.util.Arrays;
-import java.util.BitSet;
-
-import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.subobject.EROProtectionSubobject;
-import org.opendaylight.protocol.pcep.subobject.EROProtectionType2Subobject;
-import org.opendaylight.protocol.util.ByteArray;
-
-public class EROProtectionType2SubobjectParser implements EROProtectionParser {
-
-    public static final int RES_F_LENGTH = 8;
-
-    public static final int RES_F_OFFSET = 0;
-
-    public static final int CONTENT_LENGTH = RES_F_OFFSET + RES_F_LENGTH;
-
-    /*
-     * offsets of flags inside reserved field
-     */
-    public static final int S_FLAG_OFFSET = 0;
-    public static final int P_FLAG_OFFSET = 1;
-    public static final int N_FLAG_OFFSET = 2;
-    public static final int O_FLAG_OFFSET = 3;
-
-    public static final int I_FLAG_OFFSET = 32;
-    public static final int R_FLAG_OFFSET = 33;
-
-    @Override
-    public EROProtectionSubobject parse(byte[] cutBytes, boolean loose) throws PCEPDeserializerException {
-       if (cutBytes == null || cutBytes.length == 0)
-           throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
-       if (cutBytes.length < CONTENT_LENGTH)
-           throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + cutBytes.length + "; Expected: >" + CONTENT_LENGTH + ".");
-
-       final BitSet reserved = ByteArray.bytesToBitSet(Arrays.copyOfRange(cutBytes, RES_F_OFFSET, RES_F_LENGTH));
-
-       final byte linkFlags = (byte) (cutBytes[3] & 0x3F);
-       final byte lspFlags = (byte) (cutBytes[1] & 0x3F);
-       final byte segFlags = (byte) (cutBytes[5] & 0x3F);
-
-       return new EROProtectionType2Subobject(reserved.get(S_FLAG_OFFSET), reserved.get(P_FLAG_OFFSET), reserved.get(N_FLAG_OFFSET),
-               reserved.get(N_FLAG_OFFSET), lspFlags, linkFlags, reserved.get(I_FLAG_OFFSET), reserved.get(R_FLAG_OFFSET), segFlags, loose);
-    }
-
-    @Override
-    public byte[] put(EROProtectionSubobject objToSerialize) {
-       if (!(objToSerialize instanceof EROProtectionType2Subobject))
-           throw new IllegalArgumentException("Unknown EROProtectionSubobject instance. Passed " + objToSerialize.getClass()
-                   + ". Needed EROProtectionType2Subobject.");
-
-       final byte[] retBytes = new byte[CONTENT_LENGTH];
-
-       final BitSet reserved = new BitSet();
-       reserved.set(S_FLAG_OFFSET, ((EROProtectionType2Subobject) objToSerialize).isSecondaryLsp());
-       reserved.set(P_FLAG_OFFSET, ((EROProtectionType2Subobject) objToSerialize).isProtectionLsp());
-       reserved.set(N_FLAG_OFFSET, ((EROProtectionType2Subobject) objToSerialize).isNotification());
-       reserved.set(O_FLAG_OFFSET, ((EROProtectionType2Subobject) objToSerialize).isOperational());
-       reserved.set(I_FLAG_OFFSET, ((EROProtectionType2Subobject) objToSerialize).isInPlace());
-       reserved.set(R_FLAG_OFFSET, ((EROProtectionType2Subobject) objToSerialize).isRequired());
-       System.arraycopy(ByteArray.bitSetToBytes(reserved, RES_F_LENGTH), 0, retBytes, RES_F_OFFSET, RES_F_LENGTH);
-
-       retBytes[3] |= ((EROProtectionType2Subobject) objToSerialize).getLinkFlags() & 0x3F;
-       retBytes[1] |= ((EROProtectionType2Subobject) objToSerialize).getLspFlags() & 0x3F;
-       retBytes[5] |= ((EROProtectionType2Subobject) objToSerialize).getSegFlags() & 0x3F;
-
-       return retBytes;
-    }
-
-}
diff --git a/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/RROProtectionParser.java b/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/RROProtectionParser.java
deleted file mode 100644 (file)
index 643a929..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.protocol.pcep.impl.subobject;
-
-import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.subobject.RROProtectionSubobject;
-
-public interface RROProtectionParser {
-
-    RROProtectionSubobject parse(byte[] cutBytes) throws PCEPDeserializerException;
-
-    byte[] put(RROProtectionSubobject objToSerialize);
-
-}
diff --git a/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/RROProtectionSubobjectParser.java b/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/RROProtectionSubobjectParser.java
deleted file mode 100644 (file)
index 7de1a93..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.protocol.pcep.impl.subobject;
-
-import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.impl.Util.BiParsersMap;
-import org.opendaylight.protocol.pcep.subobject.RROProtectionSubobject;
-import org.opendaylight.protocol.pcep.subobject.RROProtectionType1Subobject;
-import org.opendaylight.protocol.pcep.subobject.RROProtectionType2Subobject;
-import org.opendaylight.protocol.util.ByteArray;
-
-public class RROProtectionSubobjectParser {
-
-    public static final int RES_F_LENGTH = 1;
-
-    public static final int C_TYPE_F_LENGTH = 1;
-
-    public static final int RES_F_OFFSET = 0;
-
-    public static final int C_TYPE_F_OFFSET = RES_F_OFFSET + RES_F_LENGTH;
-
-    public static final int HEADER_LENGTH = C_TYPE_F_OFFSET + C_TYPE_F_LENGTH;
-
-    public static final int U_FLAG_OFFSET = 0;
-
-    private static class MapOfParsers extends BiParsersMap<Class<? extends RROProtectionSubobject>, Integer, RROProtectionParser> {
-       private final static MapOfParsers instance = new MapOfParsers();
-
-       private MapOfParsers() {
-           this.fillInMap();
-       }
-
-       private void fillInMap() {
-           this.put(RROProtectionType1Subobject.class, 1, new RROProtectionType1SubobjectParser());
-           this.put(RROProtectionType2Subobject.class, 2, new RROProtectionType2SubobjectParser());
-       }
-
-       public static MapOfParsers getInstance() {
-           return instance;
-       }
-    }
-
-    public static RROProtectionSubobject parse(byte[] soContentsBytes) throws PCEPDeserializerException {
-       if (soContentsBytes == null || soContentsBytes.length == 0)
-           throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
-       if (soContentsBytes.length < HEADER_LENGTH)
-           throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + soContentsBytes.length + "; Expected: >" + HEADER_LENGTH + ".");
-
-       final int c_type = soContentsBytes[C_TYPE_F_OFFSET] & 0xFF;
-
-       final RROProtectionParser parser = MapOfParsers.getInstance().getValueFromKeyValue(c_type);
-
-       if (parser == null) {
-           throw new PCEPDeserializerException("Unknown C-TYPE for ero protection subobject. Passed: " + c_type);
-       }
-
-       return parser.parse(ByteArray.cutBytes(soContentsBytes, HEADER_LENGTH));
-    }
-
-    public static byte[] put(RROProtectionSubobject objToSerialize) {
-       final Integer c_type = MapOfParsers.getInstance().getKeyValueFromKey(objToSerialize.getClass());
-       final RROProtectionParser parser = MapOfParsers.getInstance().getValueFromKeyValue(c_type);
-
-       if (c_type == null || parser == null)
-           throw new IllegalArgumentException("Unknown EROProtectionSubobject instance. Passed " + objToSerialize.getClass());
-
-       final byte[] protBytes = parser.put(objToSerialize);
-
-       final byte[] retBytes = new byte[protBytes.length + HEADER_LENGTH];
-
-       System.arraycopy(protBytes, 0, retBytes, HEADER_LENGTH, protBytes.length);
-
-       retBytes[C_TYPE_F_OFFSET] = (byte) c_type.intValue();
-
-       return retBytes;
-    }
-}
diff --git a/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/RROProtectionType1SubobjectParser.java b/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/RROProtectionType1SubobjectParser.java
deleted file mode 100644 (file)
index f7629ba..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.protocol.pcep.impl.subobject;
-
-import java.util.Arrays;
-import java.util.BitSet;
-
-import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.subobject.RROProtectionSubobject;
-import org.opendaylight.protocol.pcep.subobject.RROProtectionType1Subobject;
-import org.opendaylight.protocol.util.ByteArray;
-
-public class RROProtectionType1SubobjectParser implements RROProtectionParser {
-
-    public static final int RES_F_LENGTH = 4;
-
-    public static final int RES_F_OFFSET = 0;
-
-    public static final int CONTENT_LENGTH = RES_F_OFFSET + RES_F_LENGTH;
-
-    /*
-     * offsets of flags inside reserved field
-     */
-    public static final int S_FLAG_OFFSET = 0;
-
-    @Override
-    public RROProtectionSubobject parse(byte[] cutBytes) throws PCEPDeserializerException {
-       if (cutBytes == null || cutBytes.length == 0)
-           throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
-       if (cutBytes.length < CONTENT_LENGTH)
-           throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + cutBytes.length + "; Expected: >" + CONTENT_LENGTH + ".");
-
-       final BitSet reserved = ByteArray.bytesToBitSet(Arrays.copyOfRange(cutBytes, RES_F_OFFSET, RES_F_LENGTH));
-
-       final byte linkFlags = (byte) (cutBytes[3] & 0x3F);
-
-       return new RROProtectionType1Subobject(reserved.get(S_FLAG_OFFSET), linkFlags);
-    }
-
-    @Override
-    public byte[] put(RROProtectionSubobject objToSerialize) {
-       if (!(objToSerialize instanceof RROProtectionType1Subobject))
-           throw new IllegalArgumentException("Unknown RROProtectionSubobject instance. Passed " + objToSerialize.getClass()
-                   + ". Needed RROProtectionType1Subobject.");
-
-       final byte[] retBytes = new byte[CONTENT_LENGTH];
-
-       final BitSet reserved = new BitSet();
-       reserved.set(S_FLAG_OFFSET, ((RROProtectionType1Subobject) objToSerialize).isSecondary());
-       System.arraycopy(ByteArray.bitSetToBytes(reserved, RES_F_LENGTH), 0, retBytes, RES_F_OFFSET, RES_F_LENGTH);
-
-       retBytes[3] |= ((RROProtectionType1Subobject) objToSerialize).getLinkFlags() & 0x3F;
-
-       return retBytes;
-    }
-
-}
diff --git a/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/RROProtectionType2SubobjectParser.java b/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/RROProtectionType2SubobjectParser.java
deleted file mode 100644 (file)
index 8aeaf68..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.protocol.pcep.impl.subobject;
-
-import java.util.Arrays;
-import java.util.BitSet;
-
-import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.subobject.RROProtectionSubobject;
-import org.opendaylight.protocol.pcep.subobject.RROProtectionType2Subobject;
-import org.opendaylight.protocol.util.ByteArray;
-
-public class RROProtectionType2SubobjectParser implements RROProtectionParser {
-
-    public static final int RES_F_LENGTH = 8;
-
-    public static final int RES_F_OFFSET = 0;
-
-    public static final int CONTENT_LENGTH = RES_F_OFFSET + RES_F_LENGTH;
-
-    /*
-     * offsets of flags inside reserved field
-     */
-    public static final int S_FLAG_OFFSET = 0;
-    public static final int P_FLAG_OFFSET = 1;
-    public static final int N_FLAG_OFFSET = 2;
-    public static final int O_FLAG_OFFSET = 3;
-
-    public static final int I_FLAG_OFFSET = 32;
-    public static final int R_FLAG_OFFSET = 33;
-
-    @Override
-    public RROProtectionSubobject parse(byte[] cutBytes) throws PCEPDeserializerException {
-       if (cutBytes == null || cutBytes.length == 0)
-           throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
-       if (cutBytes.length < CONTENT_LENGTH)
-           throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + cutBytes.length + "; Expected: >" + CONTENT_LENGTH + ".");
-
-       final BitSet reserved = ByteArray.bytesToBitSet(Arrays.copyOfRange(cutBytes, RES_F_OFFSET, RES_F_LENGTH));
-
-       final byte linkFlags = (byte) (cutBytes[3] & 0x3F);
-       final byte lspFlags = (byte) (cutBytes[1] & 0x3F);
-       final byte segFlags = (byte) (cutBytes[5] & 0x3F);
-
-       return new RROProtectionType2Subobject(reserved.get(S_FLAG_OFFSET), reserved.get(P_FLAG_OFFSET), reserved.get(N_FLAG_OFFSET),
-               reserved.get(N_FLAG_OFFSET), lspFlags, linkFlags, reserved.get(I_FLAG_OFFSET), reserved.get(R_FLAG_OFFSET), segFlags);
-    }
-
-    @Override
-    public byte[] put(RROProtectionSubobject objToSerialize) {
-       if (!(objToSerialize instanceof RROProtectionType2Subobject))
-           throw new IllegalArgumentException("Unknown RROProtectionSubobject instance. Passed " + objToSerialize.getClass()
-                   + ". Needed RROProtectionType2Subobject.");
-
-       final byte[] retBytes = new byte[CONTENT_LENGTH];
-
-       final BitSet reserved = new BitSet();
-       reserved.set(S_FLAG_OFFSET, ((RROProtectionType2Subobject) objToSerialize).isSecondaryLsp());
-       reserved.set(P_FLAG_OFFSET, ((RROProtectionType2Subobject) objToSerialize).isProtectionLsp());
-       reserved.set(N_FLAG_OFFSET, ((RROProtectionType2Subobject) objToSerialize).isNotification());
-       reserved.set(O_FLAG_OFFSET, ((RROProtectionType2Subobject) objToSerialize).isOperational());
-       reserved.set(I_FLAG_OFFSET, ((RROProtectionType2Subobject) objToSerialize).isInPlace());
-       reserved.set(R_FLAG_OFFSET, ((RROProtectionType2Subobject) objToSerialize).isRequired());
-       System.arraycopy(ByteArray.bitSetToBytes(reserved, RES_F_LENGTH), 0, retBytes, RES_F_OFFSET, RES_F_LENGTH);
-
-       retBytes[3] |= ((RROProtectionType2Subobject) objToSerialize).getLinkFlags() & 0x3F;
-       retBytes[1] |= ((RROProtectionType2Subobject) objToSerialize).getLspFlags() & 0x3F;
-       retBytes[5] |= ((RROProtectionType2Subobject) objToSerialize).getSegFlags() & 0x3F;
-
-       return retBytes;
-    }
-
-}
index 0a89b438b99ef83e5888aeeb276065cf438296ac..7c399a3d4a9148d60f84e2e5d9193c3188fe93b4 100644 (file)
@@ -29,8 +29,6 @@ import org.opendaylight.protocol.pcep.subobject.EROExplicitExclusionRouteSubobje
 import org.opendaylight.protocol.pcep.subobject.EROGeneralizedLabelSubobject;
 import org.opendaylight.protocol.pcep.subobject.EROPathKeyWith128PCEIDSubobject;
 import org.opendaylight.protocol.pcep.subobject.EROPathKeyWith32PCEIDSubobject;
-import org.opendaylight.protocol.pcep.subobject.EROProtectionType1Subobject;
-import org.opendaylight.protocol.pcep.subobject.EROProtectionType2Subobject;
 import org.opendaylight.protocol.pcep.subobject.EROType1LabelSubobject;
 import org.opendaylight.protocol.pcep.subobject.EROWavebandSwitchingLabelSubobject;
 import org.opendaylight.protocol.pcep.subobject.ExcludeRouteSubobject;
@@ -40,8 +38,6 @@ import org.opendaylight.protocol.pcep.subobject.RROGeneralizedLabelSubobject;
 import org.opendaylight.protocol.pcep.subobject.RROIPAddressSubobject;
 import org.opendaylight.protocol.pcep.subobject.RROPathKeyWith128PCEIDSubobject;
 import org.opendaylight.protocol.pcep.subobject.RROPathKeyWith32PCEIDSubobject;
-import org.opendaylight.protocol.pcep.subobject.RROProtectionType1Subobject;
-import org.opendaylight.protocol.pcep.subobject.RROProtectionType2Subobject;
 import org.opendaylight.protocol.pcep.subobject.RROType1LabelSubobject;
 import org.opendaylight.protocol.pcep.subobject.RROWavebandSwitchingLabelSubobject;
 import org.opendaylight.protocol.pcep.subobject.ReportedRouteSubobject;
@@ -112,8 +108,6 @@ public class PCEPSubobjectParserTest {
                objsToTest.add(new EROType1LabelSubobject(0x12345648L, false, true));
                objsToTest.add(new EROGeneralizedLabelSubobject(new byte[] { (byte) 0x12, (byte) 0x00, (byte) 0x25, (byte) 0xFF }, true, true));
                objsToTest.add(new EROWavebandSwitchingLabelSubobject(0x12345678L, 0x87654321L, 0xFFFFFFFFL, false, false));
-               objsToTest.add(new EROProtectionType1Subobject(true, (byte) 0x05, true));
-               objsToTest.add(new EROProtectionType2Subobject(true, false, true, true, (byte) 0x06, (byte) 0x3f, true, false, (byte) 0x00, false));
                objsToTest.add(new EROPathKeyWith32PCEIDSubobject(0x1235, new byte[] { (byte) 0x00, (byte) 0x55, (byte) 0xFF, (byte) 0xF1 }, true));
                objsToTest.add(new EROPathKeyWith128PCEIDSubobject(0x5432, new byte[] { (byte) 0x00, (byte) 0x55, (byte) 0xFF, (byte) 0xF1,
                                (byte) 0x00, (byte) 0x55, (byte) 0xFF, (byte) 0xF1, (byte) 0x00, (byte) 0x55, (byte) 0xFF, (byte) 0xF1, (byte) 0x00,
@@ -132,8 +126,6 @@ public class PCEPSubobjectParserTest {
                objsToTest.add(new RROType1LabelSubobject(0x12345648L, false));
                objsToTest.add(new RROGeneralizedLabelSubobject(new byte[] { (byte) 0x12, (byte) 0x00, (byte) 0x25, (byte) 0xFF }, true));
                objsToTest.add(new RROWavebandSwitchingLabelSubobject(0x12345678L, 0x87654321L, 0xFFFFFFFFL, false));
-               objsToTest.add(new RROProtectionType1Subobject(true, (byte) 0x05));
-               objsToTest.add(new RROProtectionType2Subobject(true, false, true, true, (byte) 0x06, (byte) 0x3f, true, false, (byte) 0x00));
                objsToTest.add(new RROPathKeyWith32PCEIDSubobject(0x1235, new byte[] { (byte) 0x00, (byte) 0x55, (byte) 0xFF, (byte) 0xF1 }));
                objsToTest.add(new RROPathKeyWith128PCEIDSubobject(0x5432, new byte[] { (byte) 0x00, (byte) 0x55, (byte) 0xFF, (byte) 0xF1,
                                (byte) 0x00, (byte) 0x55, (byte) 0xFF, (byte) 0xF1, (byte) 0x00, (byte) 0x55, (byte) 0xFF, (byte) 0xF1, (byte) 0x00,