当前位置: 首页>>代码示例>>Java>>正文


Java InetAddressValidator类代码示例

本文整理汇总了Java中org.apache.commons.validator.routines.InetAddressValidator的典型用法代码示例。如果您正苦于以下问题:Java InetAddressValidator类的具体用法?Java InetAddressValidator怎么用?Java InetAddressValidator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


InetAddressValidator类属于org.apache.commons.validator.routines包,在下文中一共展示了InetAddressValidator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isValidIpAddress

import org.apache.commons.validator.routines.InetAddressValidator; //导入依赖的package包/类
private boolean isValidIpAddress(String serverIP) {
	InetAddressValidator validator = new InetAddressValidator();
	return (validator.isValidInet4Address(serverIP) /*
													 * || validator.
													 * isValidInet6Address
													 * (serverIP)
													 */);
}
 
开发者ID:LittleSnake42,项目名称:java-irc,代码行数:9,代码来源:MessageControler.java

示例2: connectButtonActionPerformed

import org.apache.commons.validator.routines.InetAddressValidator; //导入依赖的package包/类
/**
 * Lancia la connessione
 */
private void connectButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_connectButtonActionPerformed
    if (!InetAddressValidator.getInstance().isValid(this.ipField.getText()) || Integer.parseInt(portField.getText()) > 65535)
        JOptionPane.showMessageDialog(this, "Indirizzo ip non valido", "Errore", JOptionPane.ERROR_MESSAGE);
    else {
        try {
            socket = new Socket();
            String ip = ipField.getText();
            int port = Integer.parseInt(portField.getText());
            socket.connect(new InetSocketAddress(ip, port), 10000);
            connectionLabel.setText("Connesso!");
            nickname = nicknameField.getText();
            //in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
            //out = new PrintStream(socket.getOutputStream(), true);
            Client client = new Client(socket, nickname);
            Thread clientThread = new Thread(client);
            clientThread.start();
            dispose();
        } catch (IOException ex) {
            connectionLabel.setText("Errore di connessione");
        }  
    }
}
 
开发者ID:IngSW-unipv,项目名称:Progetto-J,代码行数:26,代码来源:LoginFrame.java

示例3: isValidInetAddress

import org.apache.commons.validator.routines.InetAddressValidator; //导入依赖的package包/类
public static boolean isValidInetAddress(final String address) {
    if (StringUtils.isEmptyOrWhitespaceOnly(address)) {
        return false;
    }
    if (InetAddressValidator.getInstance().isValid(address)) {
        return true;
    }

    return false;
}
 
开发者ID:CanadianRepublican,项目名称:DDNS_Server,代码行数:11,代码来源:DynServlet.java

示例4: validateState

import org.apache.commons.validator.routines.InetAddressValidator; //导入依赖的package包/类
private void validateState(NetworkInterfaceDescription state) {
    if (state.assignment == null) {
        state.assignment = IpAssignment.DYNAMIC;
    }

    Utils.validateState(getStateDescription(), state);

    if (state.address != null) {
        if (state.assignment != IpAssignment.STATIC) {
            throw new IllegalArgumentException(
                    "IP can be reserved only when assignment is STATIC");
        }
        if (!InetAddressValidator.getInstance().isValidInet4Address(
                state.address)) {
            throw new IllegalArgumentException("IP address is invalid");
        }

    }
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:20,代码来源:NetworkInterfaceDescriptionService.java

示例5: isValid

import org.apache.commons.validator.routines.InetAddressValidator; //导入依赖的package包/类
@Override
public boolean isValid(String value, ConstraintValidatorContext context) {
    if (value == null) {
        return false;
    }
    return InetAddressValidator
            .getInstance()
            .isValidInet4Address(value);
}
 
开发者ID:nomemory,项目名称:java-bean-validation-extension,代码行数:10,代码来源:IPv4Validator.java

示例6: isValid

import org.apache.commons.validator.routines.InetAddressValidator; //导入依赖的package包/类
@Override
public boolean isValid(String value, ConstraintValidatorContext context) {
    if (value == null) {
        return false;
    }
    return InetAddressValidator
            .getInstance()
            .isValidInet6Address(value);
}
 
开发者ID:nomemory,项目名称:java-bean-validation-extension,代码行数:10,代码来源:IPv6Validator.java

示例7: replaceUrlParams

import org.apache.commons.validator.routines.InetAddressValidator; //导入依赖的package包/类
public void replaceUrlParams(UrlParams urlParams) {
    if (url.contains(RedirectorConstants.HOST_PLACEHOLDER) && urlParams.getIPProtocolVersion() != null) {
        // TODO: move to separate place
        if (urlParams.getIPProtocolVersion() == IpProtocolVersion.IPV6.getVersion() && StringUtils.isNotBlank(serverIpV6)) {
            if (InetAddressValidator.getInstance().isValidInet6Address(serverIpV6)) {
                url = url.replace(RedirectorConstants.HOST_PLACEHOLDER, "[" + serverIpV6 + "]");
            } else {
                url = url.replace(RedirectorConstants.HOST_PLACEHOLDER, serverIpV6);
            }
            address = serverIpV6;
            ipProtocolVersion = IpProtocolVersion.IPV6.getVersion();
        } else if (StringUtils.isNotBlank(serverIp)) {
            url = url.replace(RedirectorConstants.HOST_PLACEHOLDER, serverIp);
            ipProtocolVersion = IpProtocolVersion.IPV4.getVersion();;
        }
    }

    if (urlParams.getPort() != null) {
        port = urlParams.getPort();
        url = url.replace(RedirectorConstants.PORT_PLACEHOLDER, urlParams.getPort().toString());
    }

    if (urlParams.getProtocol() != null) {
        protocol = urlParams.getProtocol();
        url = url.replace(RedirectorConstants.PROTOCOL_PLACEHOLDER, urlParams.getProtocol());
    }

    if (urlParams.getUrn() != null) {
        urn = urlParams.getUrn();
        url = url.replace(RedirectorConstants.URN_PLACEHOLDER, urlParams.getUrn());
    }

    if (urlParams.getAppliedRulesNames() != null) {
        appliedUrlRules = urlParams.getAppliedRulesNames();
    }
}
 
开发者ID:Comcast,项目名称:redirector,代码行数:37,代码来源:InstanceInfo.java

示例8: isValidInetAddress

import org.apache.commons.validator.routines.InetAddressValidator; //导入依赖的package包/类
public static boolean isValidInetAddress(final String address) {
    if (StringUtils.isEmptyOrWhitespaceOnly(address)) {
        return false;
    }
    if (InetAddressValidator.getInstance().isValid(address)) {
        return true;
    }
        return false;
}
 
开发者ID:CanadianRepublican,项目名称:DDNS_Server,代码行数:10,代码来源:UpdateServlet.java

示例9: doSubStageValidateComputeHostState

import org.apache.commons.validator.routines.InetAddressValidator; //导入依赖的package包/类
private void doSubStageValidateComputeHostState(
        ProvisionComputeTaskState updatedState) {
    // we need to make sure the boot/power services not only properly
    // patched
    // our sub tasks but also patched the compute host with the IP address
    // and other
    // runtime data

    sendRequest(Operation
            .createGet(this, updatedState.computeLink)
            .setCompletion((o, e) -> {
                if (e != null) {
                    // the compute host is co-located so it is unexpected
                    // that it failed the GET
                    logWarning(() -> String.format("GET to %s failed: %s", o.getUri(),
                            Utils.toString(e)));
                    failTask(e);
                    return;
                }
                ComputeService.ComputeState chs = o
                        .getBody(ComputeService.ComputeState.class);
                try {
                    if (!updatedState.isMockRequest) {
                        InetAddressValidator.getInstance()
                                .isValidInet4Address(chs.address);
                    }
                    sendSelfPatch(TaskStage.FINISHED,
                            ProvisionComputeTaskState.SubStage.DONE, null);
                } catch (Throwable ex) {
                    failTask(ex);
                }
            }));
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:34,代码来源:ProvisionComputeTaskService.java

示例10: validateState

import org.apache.commons.validator.routines.InetAddressValidator; //导入依赖的package包/类
private void validateState(NetworkInterfaceState state) {
    Utils.validateState(getStateDescription(), state);

    if (state.address != null) {
        if (!InetAddressValidator.getInstance().isValidInet4Address(
                state.address)) {
            throw new IllegalArgumentException("IP address is invalid");
        }
    }

    if (state.networkLink == null && state.subnetLink == null) {
        throw new IllegalArgumentException(
                "Either subnetLink or networkLink must be set");
    }
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:16,代码来源:NetworkInterfaceService.java

示例11: isValidIPAddress

import org.apache.commons.validator.routines.InetAddressValidator; //导入依赖的package包/类
/**
 * Method to validate an IP address
 *
 * @param ipAddress IP address to be validated
 * @param ipVersion IPv4 or IPv6
 */
public static boolean isValidIPAddress(String ipAddress, IPVersion ipVersion) {
    if (StringUtil.isNullOrEmpty(ipAddress)) {
        throw new LocalizableValidationException("IP address must be specified",
                "subnet.range.ip.must.be.specified");
    }
    switch (ipVersion) {
    case IPv6:
        return InetAddressValidator.getInstance().isValidInet6Address(ipAddress);
    case IPv4:
    default:
        return InetAddressValidator.getInstance().isValidInet4Address(ipAddress);
    }
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:20,代码来源:SubnetValidator.java

示例12: isValidIp4

import org.apache.commons.validator.routines.InetAddressValidator; //导入依赖的package包/类
public static boolean isValidIp4(final String ip) {
    if (ip == null) {
        return false;
    }

    final InetAddressValidator validator = InetAddressValidator.getInstance();
    return validator.isValidInet4Address(ip);
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:9,代码来源:NetUtils.java

示例13: isValidIp6

import org.apache.commons.validator.routines.InetAddressValidator; //导入依赖的package包/类
public static boolean isValidIp6(final String ip) {
    if (ip == null) {
        return false;
    }

    final InetAddressValidator validator = InetAddressValidator.getInstance();
    return validator.isValidInet6Address(ip);
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:9,代码来源:NetUtils.java

示例14: validateKaaHost

import org.apache.commons.validator.routines.InetAddressValidator; //导入依赖的package包/类
@Override
public void validateKaaHost(String host) throws SandboxServiceException {
    if (host == null || host.length() == 0) {
        throw new SandboxServiceException("Kaa host field can not be empty!");
    } else if (!InetAddressValidator.getInstance().isValid(host) &&
            !DomainValidator.getInstance(true).isValid(host)) {
        throw new SandboxServiceException("Invalid hostname/ip address format!");
    }
}
 
开发者ID:kaaproject,项目名称:sandbox-frame,代码行数:10,代码来源:SandboxServiceImpl.java

示例15: isValidNonBlankValue

import org.apache.commons.validator.routines.InetAddressValidator; //导入依赖的package包/类
@Override
public boolean isValidNonBlankValue(String value, ConstraintValidatorContext context) {
    switch (type) {
        case IP_V4:
            return InetAddressValidator.getInstance().isValidInet4Address(value);
        case IP_V6:
            return InetAddressValidator.getInstance().isValidInet6Address(value);
        default:
            return InetAddressValidator.getInstance().isValid(value);
    }
}
 
开发者ID:britter,项目名称:bean-validators,代码行数:12,代码来源:IPConstraintValidator.java


注:本文中的org.apache.commons.validator.routines.InetAddressValidator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。