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


Java Ipv4Range.parse方法代碼示例

本文整理匯總了Java中net.ripe.commons.ip.Ipv4Range.parse方法的典型用法代碼示例。如果您正苦於以下問題:Java Ipv4Range.parse方法的具體用法?Java Ipv4Range.parse怎麽用?Java Ipv4Range.parse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.ripe.commons.ip.Ipv4Range的用法示例。


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

示例1: transferInIpv4Block

import net.ripe.commons.ip.Ipv4Range; //導入方法依賴的package包/類
@Transactional
public void transferInIpv4Block(final String range) {
    final AuthoritativeResource resources = resourceDataDao.load(source);

    final Iterable<Ipv4Range> overlaps = containsOrOverlaps(resources, range);
    if (isEmpty(overlaps)) {
        authoritativeResourceDao.create(source, formatIpv4Resource(range));
    } else {
        final Ipv4Range ipv4Range = Ipv4Range.parse(range);

        for (Ipv4Range overlap : overlaps) {
            if (overlap.contains(ipv4Range)) {
                // found parent which completely overlaps range, no need to create a new one
                break;
            } else {
                for (Ipv4Range nonOverlap : ipv4Range.exclude(overlap)) {
                    // create new entry for non-overlapping range
                    authoritativeResourceDao.create(source, nonOverlap.toStringInRangeNotation());
                }
            }
        }
    }
}
 
開發者ID:RIPE-NCC,項目名稱:whois,代碼行數:24,代碼來源:AuthoritativeResourceService.java

示例2: doTransfer

import net.ripe.commons.ip.Ipv4Range; //導入方法依賴的package包/類
@Override
public List<ActionRequest> doTransfer(final Transfer<Ipv4Range> transfer, final Optional<RpslObject> precedingObject, final RpslObject originalObject, final Optional<RpslObject> followingObject) {
    final List<ActionRequest> requests = Lists.newArrayList();

    final Ipv4Range originalRange = Ipv4Range.parse(originalObject.getKey().toString());
    final List<Ipv4Range> whatIsLeft = originalRange.exclude(transfer.getResource());

    final List<RpslAttribute> originalObjectAttributes = originalObject.getAttributes();

    for (Ipv4Range range : whatIsLeft) {
        final RpslObjectBuilder whatIsLeftRpslObjectBuilder = new RpslObjectBuilder(Lists.newArrayList(originalObjectAttributes));

        for (RpslAttribute rpslAttribute : originalObjectAttributes) {
            if (rpslAttribute.getType() == AttributeType.INETNUM) {
                final RpslAttribute newRange = new RpslAttribute(AttributeType.INETNUM, formatInetnum(range));
                whatIsLeftRpslObjectBuilder.replaceAttribute(rpslAttribute, newRange);
            }
        }

        requests.add(new ActionRequest(whatIsLeftRpslObjectBuilder.get(), Action.CREATE));
    }

    return doNextTransferStep(transfer, precedingObject, originalObject, followingObject, requests);
}
 
開發者ID:RIPE-NCC,項目名稱:whois,代碼行數:25,代碼來源:CreatePlaceholderForWhatIsLeftStage.java

示例3: shouldMergeWithObject

import net.ripe.commons.ip.Ipv4Range; //導入方法依賴的package包/類
private boolean shouldMergeWithObject(final Optional<RpslObject> rpslObject, final Ipv4Range resource) {
    if (!rpslObject.isPresent()) {
        return false;
    }

    final Ipv4Range rangeObject = Ipv4Range.parse(rpslObject.get().getKey().toString());
    if (!rangeObject.isConsecutive(resource)) {
        return false;
    }

    final Ipv4Range mergedRange = resource.merge(rangeObject);

    final Ipv4 startLowerBoundForPrefix = mergedRange.start().lowerBoundForPrefix(8);
    final Ipv4 endLowerBoundForPrefix = mergedRange.end().lowerBoundForPrefix(8);

    return startLowerBoundForPrefix.equals(endLowerBoundForPrefix);
}
 
開發者ID:RIPE-NCC,項目名稱:whois,代碼行數:18,代碼來源:CreatePlaceholderForInetnumStage.java

示例4: merge

import net.ripe.commons.ip.Ipv4Range; //導入方法依賴的package包/類
private List<ActionRequest> merge(final RpslObject precedingObject, final RpslObject followingObject, final Ipv4Range resource) {
    final List<ActionRequest> requests = Lists.newArrayList();

    Preconditions.checkArgument(precedingObject != null);
    Preconditions.checkArgument(followingObject != null);
    Preconditions.checkArgument(resource != null);

    final Ipv4Range precedingRange = Ipv4Range.parse(precedingObject.getKey().toString());
    final Ipv4Range followingRange = Ipv4Range.parse(followingObject.getKey().toString());

    final Ipv4Range mergedRange = precedingRange.merge(resource).merge(followingRange);

    final RpslObject inetnum = RpslObject.parse(String.format(TEMPLATE, mergedRange.toStringInRangeNotation(), source));

    requests.add(new ActionRequest(precedingObject, Action.DELETE));
    requests.add(new ActionRequest(followingObject, Action.DELETE));
    requests.add(new ActionRequest(inetnum, Action.CREATE));

    return requests;
}
 
開發者ID:RIPE-NCC,項目名稱:whois,代碼行數:21,代碼來源:CreatePlaceholderForInetnumStage.java

示例5: containsOrOverlaps

import net.ripe.commons.ip.Ipv4Range; //導入方法依賴的package包/類
private Iterable<Ipv4Range> containsOrOverlaps(final AuthoritativeResource resources, final String range) {
    final Ipv4Range ipv4Range = Ipv4Range.parse(range);
    return Iterables.filter(extractIpv4Resources(resources), new Predicate<Ipv4Range>() {
        @Override
        public boolean apply(final Ipv4Range input) {
            return input.contains(ipv4Range) || input.overlaps(ipv4Range);
        }
    });
}
 
開發者ID:RIPE-NCC,項目名稱:whois,代碼行數:10,代碼來源:AuthoritativeResourceService.java

示例6: planOutgoingTransfer

import net.ripe.commons.ip.Ipv4Range; //導入方法依賴的package包/類
private List<ActionRequest> planOutgoingTransfer(final String inetnum) {
    final List<ActionRequest> requests = Lists.newArrayList();

    final Collection<RpslObject> searchResults = searchInetnumObject(inetnum, QueryFlag.ALL_LESS);
    validateSearchResults(inetnum, searchResults);
    final RpslObject matchingObject = Iterables.getLast(searchResults);

    if (InetnumTransfer.isNonRipeResource(matchingObject)) {
        // no transfer tasks to be performed
        LOGGER.warn("Inetnum {} is already non-RIPE", inetnum);
    } else {
        final Ipv4Range range = Ipv4Range.parse(inetnum);
        if (isExactMatch(range, matchingObject)) {
            throw new BadRequestException(inetnum + " is an exact match and cannot be transferred out");
        }

        final Optional<RpslObject> preceding = getPrecedingRpslObject(range);
        final Optional<RpslObject> following = getFollowingRpslObject(range);

        final Transfer transfer = InetnumTransfer.buildOutgoing(inetnum);
        requests.addAll(transferOutPipeline.doTransfer(transfer, preceding, matchingObject, following));
    }

    logSteps(requests);

    return requests;
}
 
開發者ID:RIPE-NCC,項目名稱:whois,代碼行數:28,代碼來源:InetnumTransfersLogic.java

示例7: buildOutgoing

import net.ripe.commons.ip.Ipv4Range; //導入方法依賴的package包/類
public static Transfer buildOutgoing(final String inetnum) {
    return new InetnumTransfer(Ipv4Range.parse(inetnum), false);
}
 
開發者ID:RIPE-NCC,項目名稱:whois,代碼行數:4,代碼來源:InetnumTransfer.java

示例8: buildIncoming

import net.ripe.commons.ip.Ipv4Range; //導入方法依賴的package包/類
public static Transfer buildIncoming(final String inetnum) {
    return new InetnumTransfer(Ipv4Range.parse(inetnum), true);
}
 
開發者ID:RIPE-NCC,項目名稱:whois,代碼行數:4,代碼來源:InetnumTransfer.java


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