2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.protocol.pcep.spi;
10 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ObjectHeader;
11 import org.opendaylight.yangtools.yang.binding.DataContainer;
14 * Header parser for {@link org.opendaylight.protocol.pcep.PCEPObject PCEPObject}
16 public class ObjectHeaderImpl implements ObjectHeader {
19 * Common object header fields lengths in bytes
21 public final static int OC_F_LENGTH = 1;
22 public final static int OT_FLAGS_MF_LENGTH = 1; // multi-field
23 public final static int OBJ_LENGTH_F_LENGTH = 2;
26 * size of fields inside of multi-filed in bits
28 public final static int OT_SF_LENGTH = 4;
29 public final static int FLAGS_SF_LENGTH = 4;
32 * offsets of fields inside of multi-field in bits
34 public final static int OT_SF_OFFSET = 0;
35 public final static int FLAGS_SF_OFFSET = OT_SF_OFFSET + OT_SF_LENGTH;
38 * flags offsets inside multi-filed
40 public final static int P_FLAG_OFFSET = 6;
41 public final static int I_FLAG_OFFSET = 7;
44 * Common object header fields offsets in bytes;
46 public final static int OC_F_OFFSET = 0;
47 public final static int OT_FLAGS_MF_OFFSET = OC_F_OFFSET + OC_F_LENGTH;
48 public final static int OBJ_LENGTH_F_OFFSET = OT_FLAGS_MF_OFFSET + OT_FLAGS_MF_LENGTH;
49 public final static int OBJ_BODY_OFFSET = OBJ_LENGTH_F_OFFSET + OBJ_LENGTH_F_LENGTH;
52 * Common object header length in bytes
54 public final static int COMMON_OBJECT_HEADER_LENGTH = (OC_F_LENGTH + OT_FLAGS_MF_LENGTH + OBJ_LENGTH_F_LENGTH);
56 public final boolean processed;
57 public final boolean ignored;
59 public ObjectHeaderImpl(final boolean processed, final boolean ignore) {
60 this.processed = processed;
61 this.ignored = ignore;
66 public Class<? extends DataContainer> getImplementedInterface() {
67 return ObjectHeader.class;
71 public Boolean isIgnore() {
76 public Boolean isProcessingRule() {
77 return this.processed;
81 public String toString() {
82 final StringBuilder builder = new StringBuilder();
83 builder.append("ObjectHeader [objClass=");
84 builder.append(", processed=");
85 builder.append(this.processed);
86 builder.append(", ignored=");
87 builder.append(this.ignored);
89 return builder.toString();
93 public int hashCode() {
96 result = prime * result + (this.ignored ? 1231 : 1237);
97 result = prime * result + (this.processed ? 1231 : 1237);
102 public boolean equals(final Object obj) {
107 if (this.getClass() != obj.getClass())
109 final ObjectHeaderImpl other = (ObjectHeaderImpl) obj;
110 if (this.ignored != other.ignored)
112 if (this.processed != other.processed)