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.impl.subobject;
10 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
11 import org.opendaylight.protocol.pcep.subobject.RROGeneralizedLabelSubobject;
12 import org.opendaylight.protocol.pcep.subobject.RROLabelSubobject;
14 public class RROGeneralizedLabelSubobjectParser implements RROLabelParser {
17 public RROLabelSubobject parse(byte[] cutBytes, boolean upStream) throws PCEPDeserializerException {
18 if (cutBytes == null || cutBytes.length == 0)
19 throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
21 return new RROGeneralizedLabelSubobject(cutBytes, upStream);
25 public byte[] put(RROLabelSubobject objToSerialize) {
26 if (!(objToSerialize instanceof RROGeneralizedLabelSubobject))
27 throw new IllegalArgumentException("Unknown RROLabelSubobject instance. Passed " + objToSerialize.getClass()
28 + ". Needed RROGeneralizedLabelSubobject.");
29 final byte[] retBytes = ((RROGeneralizedLabelSubobject) objToSerialize).getLabel();