當前位置: 首頁>>代碼示例>>Java>>正文


Java PcepLabelRangeObject類代碼示例

本文整理匯總了Java中org.onosproject.pcepio.protocol.PcepLabelRangeObject的典型用法代碼示例。如果您正苦於以下問題:Java PcepLabelRangeObject類的具體用法?Java PcepLabelRangeObject怎麽用?Java PcepLabelRangeObject使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


PcepLabelRangeObject類屬於org.onosproject.pcepio.protocol包,在下文中一共展示了PcepLabelRangeObject類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: read

import org.onosproject.pcepio.protocol.PcepLabelRangeObject; //導入依賴的package包/類
/**
 * Reads from the channel buffer and returns object of  PcepLabelRangeObject.
 *
 * @param cb of type channel buffer
 * @return object of  PcepLabelRangeObject
 * @throws PcepParseException when fails to read from channel buffer
 */
public static PcepLabelRangeObject read(ChannelBuffer cb) throws PcepParseException {

    PcepObjectHeader labelRangeObjHeader;
    byte labelType;
    int rangeSize;
    int labelBase;

    LinkedList<PcepValueType> llOptionalTlv = new LinkedList<>();

    labelRangeObjHeader = PcepObjectHeader.read(cb);

    //take only LabelRangeObject buffer.
    ChannelBuffer tempCb = cb.readBytes(labelRangeObjHeader.getObjLen() - MINIMUM_COMMON_HEADER_LENGTH);
    int temp = 0;
    temp = tempCb.readInt();
    rangeSize = temp & 0x00FFFFFF;
    labelType = (byte) (temp >> 24);
    labelBase = tempCb.readInt();
    llOptionalTlv = parseOptionalTlv(tempCb);
    return new PcepLabelRangeObjectVer1(labelRangeObjHeader, labelType, rangeSize, labelBase, llOptionalTlv);
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:29,代碼來源:PcepLabelRangeObjectVer1.java

示例2: build

import org.onosproject.pcepio.protocol.PcepLabelRangeObject; //導入依賴的package包/類
@Override
public PcepLabelRangeObject build() throws PcepParseException {
    PcepObjectHeader labelRangeObjHeader = this.bIsHeaderSet ? this.labelRangeObjHeader
            : DEFAULT_LABELRANGE_OBJECT_HEADER;

    if (!this.bIsLabelType) {
        throw new PcepParseException("LabelType NOT Set while building label range object.");
    }

    if (!this.bIsRangeSize) {
        throw new PcepParseException("RangeSize NOT Set while building label range object.");
    }

    if (!this.bIsLabelBase) {
        throw new PcepParseException("LabelBase NOT Set while building label range object.");
    }

    if (bIsPFlagSet) {
        labelRangeObjHeader.setPFlag(bPFlag);
    }

    if (bIsIFlagSet) {
        labelRangeObjHeader.setIFlag(bIFlag);
    }
    return new PcepLabelRangeObjectVer1(labelRangeObjHeader, this.labelType, this.rangeSize, this.labelBase,
            this.llOptionalTlv);
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:28,代碼來源:PcepLabelRangeObjectVer1.java

示例3: read

import org.onosproject.pcepio.protocol.PcepLabelRangeObject; //導入依賴的package包/類
/**
 * Reads channel buffer and returns object of PcepLabelRange.
 *
 * @param cb of type channel buffer.
 * @return object of PcepLabelRange
 * @throws PcepParseException when fails to read from channel buffer
 */
public static PcepLabelRange read(ChannelBuffer cb) throws PcepParseException {

    //parse and store SRP mandatory object
    PcepSrpObject srpObj = null;
    srpObj = PcepSrpObjectVer1.read(cb);
    if (srpObj == null) {
        throw new PcepParseException("Exception while parsing srp object");
    }

    LinkedList<PcepLabelRangeObject> llLabelRangeList = new LinkedList<>();
    boolean bFoundLabelRangeObj = false;
    while (0 < cb.readableBytes()) {
        //parse and store <labelrange-list>
        PcepLabelRangeObject lrObj;
        lrObj = PcepLabelRangeObjectVer1.read(cb);
        if (lrObj == null) {
            throw new PcepParseException("Exception while parsing label range object");
        } else {
            llLabelRangeList.add(lrObj);
            bFoundLabelRangeObj = true;
        }
    }

    if (!bFoundLabelRangeObj) {
        throw new PcepParseException("At least one LABEL-RANGE MUST be present.");
    }
    return new PcepLabelRangeVer1(srpObj, llLabelRangeList);
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:36,代碼來源:PcepLabelRangeVer1.java

示例4: write

import org.onosproject.pcepio.protocol.PcepLabelRangeObject; //導入依賴的package包/類
@Override
public int write(ChannelBuffer cb) throws PcepParseException {
    //write Object header
    int objStartIndex = cb.writerIndex();

    //write <SRP>
    int objLenIndex = srpObject.write(cb);

    if (objLenIndex <= 0) {
        throw new PcepParseException("bjectLength is " + objLenIndex);
    }

    //write <labelrange-list>
    ListIterator<PcepLabelRangeObject> listIterator = llLabelRangeList.listIterator();
    while (listIterator.hasNext()) {
        listIterator.next().write(cb);
    }

    //Update object length now
    int length = cb.writerIndex() - objStartIndex;
    // As per RFC the length of object should be
    // multiples of 4
    int pad = length % 4;
    if (pad != 0) {
        pad = 4 - pad;
        for (int i = 0; i < pad; i++) {
            cb.writeByte((byte) 0);
        }
        length = length + pad;
    }
    cb.setShort(objLenIndex, (short) length);
    return length;
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:34,代碼來源:PcepLabelRangeVer1.java

示例5: buildPcepLabelRangeObject

import org.onosproject.pcepio.protocol.PcepLabelRangeObject; //導入依賴的package包/類
@Override
public PcepLabelRangeObject.Builder buildPcepLabelRangeObject() {
    return new PcepLabelRangeObjectVer1.Builder();
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:5,代碼來源:PcepFactoryVer1.java

示例6: getLabelRangeList

import org.onosproject.pcepio.protocol.PcepLabelRangeObject; //導入依賴的package包/類
@Override
public LinkedList<PcepLabelRangeObject> getLabelRangeList() {
    return llLabelRangeList;
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:5,代碼來源:PcepLabelRangeVer1.java

示例7: setLabelRangeList

import org.onosproject.pcepio.protocol.PcepLabelRangeObject; //導入依賴的package包/類
@Override
public void setLabelRangeList(LinkedList<PcepLabelRangeObject> ll) {
    this.llLabelRangeList = ll;
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:5,代碼來源:PcepLabelRangeVer1.java

示例8: PcepLabelRangeVer1

import org.onosproject.pcepio.protocol.PcepLabelRangeObject; //導入依賴的package包/類
/**
 * Constructor to initialize objects.
 *
 * @param srpObj PCEP Srp object.
 * @param llLabelRangeList list of PcepLabelRangeObject.
 */
PcepLabelRangeVer1(PcepSrpObject srpObj, LinkedList<PcepLabelRangeObject> llLabelRangeList) {
    this.srpObject = srpObj;
    this.llLabelRangeList = llLabelRangeList;
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:11,代碼來源:PcepLabelRangeVer1.java


注:本文中的org.onosproject.pcepio.protocol.PcepLabelRangeObject類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。