Search in sources :

Example 1 with ObjectParser

use of org.opendaylight.protocol.pcep.spi.ObjectParser in project bgpcep by opendaylight.

the class SimpleObjectRegistry method parseObject.

@Override
public Object parseObject(final int objectClass, final int objectType, final ObjectHeader header, final ByteBuf buffer) throws PCEPDeserializerException {
    Preconditions.checkArgument(objectType >= 0 && objectType <= Values.UNSIGNED_SHORT_MAX_VALUE);
    final ObjectParser parser = this.handlers.getParser(createKey(objectClass, objectType));
    if (parser == null) {
        if (!header.isProcessingRule()) {
            return null;
        }
        for (int type = 1; type <= MAX_OBJECT_TYPE; type++) {
            final ObjectParser objParser = this.handlers.getParser(createKey(objectClass, type));
            if (objParser != null) {
                return new UnknownObject(PCEPErrors.UNRECOGNIZED_OBJ_TYPE);
            }
        }
        return new UnknownObject(PCEPErrors.UNRECOGNIZED_OBJ_CLASS);
    }
    return parser.parseObject(header, buffer);
}
Also used : ObjectParser(org.opendaylight.protocol.pcep.spi.ObjectParser) UnknownObject(org.opendaylight.protocol.pcep.spi.UnknownObject)

Aggregations

ObjectParser (org.opendaylight.protocol.pcep.spi.ObjectParser)1 UnknownObject (org.opendaylight.protocol.pcep.spi.UnknownObject)1