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


Java InvalidAddressException类代码示例

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


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

示例1: matchSubnet

import org.apache.tajo.common.exception.InvalidAddressException; //导入依赖的package包/类
/**
 * This function will be provided as UDF later.
 * @param addr
 * @return
 * @throws InvalidAddressException
 */
public boolean matchSubnet(String addr) throws InvalidAddressException {
	int maskIndex;
	if ((maskIndex=addr.indexOf('/')) != -1) {
		IPv4 other = new IPv4(addr.substring(0, maskIndex));
		int maskLen = Integer.valueOf(addr.substring(maskIndex+1));
		IPv4 subnetMask = IPv4.getSubnetMask(maskLen);
		if (this.and(subnetMask).equals(other.and(subnetMask))) {
			return true;
		} else {
			return false;
		}
	} else {
		throw new InvalidAddressException();
	}
}
 
开发者ID:apache,项目名称:incubator-tajo,代码行数:22,代码来源:IPv4.java

示例2: matchSubnet

import org.apache.tajo.common.exception.InvalidAddressException; //导入依赖的package包/类
/**
 * This function will be provided as UDF later.
 * @param addr
 * @return
 * @throws InvalidAddressException
 */
public boolean matchSubnet(String addr) throws InvalidAddressException {
	int maskIndex;
	if ((maskIndex=addr.indexOf('/')) != -1) {
		IPv4 other = new IPv4(addr.substring(0, maskIndex));
		int maskLen = Integer.parseInt(addr.substring(maskIndex+1));
		IPv4 subnetMask = IPv4.getSubnetMask(maskLen);
		if (this.and(subnetMask).equals(other.and(subnetMask))) {
			return true;
		} else {
			return false;
		}
	} else {
		throw new InvalidAddressException();
	}
}
 
开发者ID:gruter,项目名称:tajo-cdh,代码行数:22,代码来源:IPv4.java

示例3: set

import org.apache.tajo.common.exception.InvalidAddressException; //导入依赖的package包/类
public void set(String ipAddress) throws InvalidAddressException {
	StringTokenizer tokenizer = new StringTokenizer(ipAddress);
	String token;
	for (int i = 0; i < 4; i++) {
		token = tokenizer.nextToken(".");
		if (token == null) {
			throw new InvalidAddressException();
		} else if (Integer.valueOf(token) < 0 || Integer.valueOf(token) > 255) {
			throw new InvalidAddressException();
		}
		//			ipBytes[i] = Short.valueOf(token).byteValue();
		this.ipBytes[i] = (byte)(((Integer.valueOf(token) << 24) >> 24) & 0xFF);
	}
}
 
开发者ID:apache,项目名称:incubator-tajo,代码行数:15,代码来源:IPv4.java

示例4: testSet

import org.apache.tajo.common.exception.InvalidAddressException; //导入依赖的package包/类
@Test
public final void testSet() throws InvalidAddressException {
	IPv4 ip = null;
  ip = new IPv4("255.255.255.255");
	byte[] b = new byte[4];
	for (int i = 0; i < 4; i++) {
		b[i] = (byte)0xFF;
	}
	IPv4 ip2 = new IPv4(b);
	assertEquals(ip, ip2);
}
 
开发者ID:apache,项目名称:incubator-tajo,代码行数:12,代码来源:TestIPv4.java

示例5: testEqual

import org.apache.tajo.common.exception.InvalidAddressException; //导入依赖的package包/类
@Test
public final void testEqual() throws InvalidAddressException {
	IPv4 ip1 = new IPv4("163.152.23.1");
	IPv4 ip2 = new IPv4("163.152.23.2");
	IPv4 ip3 = new IPv4("163.152.23.1");
	assertTrue(ip1.equals(ip3));
	assertFalse(ip1.equals(ip2));
	IPv4 ip4 = new IPv4("255.255.0.0");
	assertFalse(ip1.equals(ip4));
}
 
开发者ID:apache,项目名称:incubator-tajo,代码行数:11,代码来源:TestIPv4.java

示例6: testAnd

import org.apache.tajo.common.exception.InvalidAddressException; //导入依赖的package包/类
@Test
public final void testAnd() throws InvalidAddressException {
	IPv4 ip1 = new IPv4("163.152.23.223");
	IPv4 ip2 = new IPv4("255.255.255.0");
	IPv4 ip3 = new IPv4("255.0.0.0");
	assertEquals(new IPv4("163.152.23.0"), ip1.and(ip2));
	assertFalse(ip1.and(ip2).equals(new IPv4("163.152.0.0")));
	assertTrue(ip1.and(ip3).equals(new IPv4("163.0.0.0")));
}
 
开发者ID:apache,项目名称:incubator-tajo,代码行数:10,代码来源:TestIPv4.java

示例7: testCompareTo

import org.apache.tajo.common.exception.InvalidAddressException; //导入依赖的package包/类
@Test
public final void testCompareTo() throws InvalidAddressException {
	IPv4 ip1 = new IPv4("163.152.23.1");
	IPv4 ip2 = new IPv4("163.152.23.2");
	IPv4 ip3 = new IPv4("177.234.123.12");
	IPv4 ip4 = new IPv4("177.234.123.12");
	assertTrue(ip1.compareTo(ip2) == -1);
	assertTrue(ip2.compareTo(ip1) == 1);
	assertTrue(ip3.compareTo(ip1) == 1);
	assertFalse(ip3.compareTo(ip2) != 1);
	assertTrue(ip4.compareTo(ip3) == 0);
}
 
开发者ID:apache,项目名称:incubator-tajo,代码行数:13,代码来源:TestIPv4.java

示例8: set

import org.apache.tajo.common.exception.InvalidAddressException; //导入依赖的package包/类
public void set(String ipAddress) throws InvalidAddressException {
	StringTokenizer tokenizer = new StringTokenizer(ipAddress);
	String token;
	for (int i = 0; i < 4; i++) {
		token = tokenizer.nextToken(".");
		if (token == null) {
			throw new InvalidAddressException();
		} else if (Integer.parseInt(token) < 0 || Integer.parseInt(token) > 255) {
			throw new InvalidAddressException();
		}
		//			ipBytes[i] = Short.valueOf(token).byteValue();
		this.ipBytes[i] = (byte)(((Integer.parseInt(token) << 24) >> 24) & 0xFF);
	}
}
 
开发者ID:gruter,项目名称:tajo-cdh,代码行数:15,代码来源:IPv4.java

示例9: IPv4

import org.apache.tajo.common.exception.InvalidAddressException; //导入依赖的package包/类
public IPv4(String ipAddress) throws InvalidAddressException {
	this.ipBytes = new byte[4];
	this.set(ipAddress);
}
 
开发者ID:apache,项目名称:incubator-tajo,代码行数:5,代码来源:IPv4.java

示例10: testMatchSubnet

import org.apache.tajo.common.exception.InvalidAddressException; //导入依赖的package包/类
@Test
public final void testMatchSubnet() throws InvalidAddressException {
	IPv4 ip1 = new IPv4("163.152.23.223");
	assertTrue(ip1.matchSubnet("163.152.23.0/1"));
	assertFalse(ip1.matchSubnet("163.152.23.0/28"));
}
 
开发者ID:apache,项目名称:incubator-tajo,代码行数:7,代码来源:TestIPv4.java


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