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


Java NumberHelper.toInt方法代码示例

本文整理汇总了Java中org.openyu.commons.lang.NumberHelper.toInt方法的典型用法代码示例。如果您正苦于以下问题:Java NumberHelper.toInt方法的具体用法?Java NumberHelper.toInt怎么用?Java NumberHelper.toInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.openyu.commons.lang.NumberHelper的用法示例。


在下文中一共展示了NumberHelper.toInt方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: disassembleVol

import org.openyu.commons.lang.NumberHelper; //导入方法依赖的package包/类
/**
 * 取得vol,並將已處理過的部分移除,傳回剩下尚未處理的部分
 * 
 * 原:♥1♠sys♠1331780303919♠♠
 * 
 * 取vol=1,之後會變為新的string
 * 
 * 新:sys♠1331780303919♠♠
 * 
 * @param value
 * @return
 */
protected int disassembleVol(StringBuilder value) {
	int result = 0;
	//
	int volLength = VOL_SPLITTER.length();
	if (value != null && value.length() > volLength && value.substring(0, volLength).equals(VOL_SPLITTER)) {
		int pos = value.indexOf(SPLITTER);
		if (pos > 0) {
			String vol = value.substring(volLength, pos);
			// value.delete(0, pos + SPLITTER.length());
			value.replace(0, pos + SPLITTER.length(), "");
			result = NumberHelper.toInt(vol);
		}
	}
	return result;
}
 
开发者ID:mixaceh,项目名称:openyu-commons,代码行数:28,代码来源:BaseUserTypeSupporter.java

示例2: toObject

import org.openyu.commons.lang.NumberHelper; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
protected <T> T toObject(String value, String className) {
	Object result = null;
	// 非空白才處理
	if (StringHelper.notBlank(value)) {
		if ("java.util.Locale".equals(className)) {
			result = LocaleHelper.toLocale(value);
		} else if ("java.lang.String".equals(className)) {
			result = value;
		} else if ("boolean".equals(className)
				|| "java.lang.Boolean".equals(className)) {
			result = BooleanHelper.toBoolean(value);
		} else if ("int".equals(className)
				|| "java.lang.Integer".equals(className)) {
			result = NumberHelper.toInt(value);
		} else if ("long".equals(className)
				|| "java.lang.Long".equals(className)) {
			result = NumberHelper.toLong(value);
		}
	}
	return (T) result;
}
 
开发者ID:mixaceh,项目名称:openyu-commons,代码行数:23,代码来源:BaseEditorSupporter.java

示例3: toInts

import org.openyu.commons.lang.NumberHelper; //导入方法依赖的package包/类
/**
 * 集合內元素轉成Integer
 * 
 * @param values
 * @return
 */
public static List<Serializable> toInts(List<Serializable> values) {
	List<Serializable> result = new LinkedList<Serializable>();
	if (notEmpty(values)) {
		for (Serializable entry : values) {
			Integer buff = NumberHelper.toInt(entry);
			result.add(buff);
		}
	}
	return result;
}
 
开发者ID:mixaceh,项目名称:openyu-commons,代码行数:17,代码来源:CollectionHelper.java

示例4: getIntParameterValues

import org.openyu.commons.lang.NumberHelper; //导入方法依赖的package包/类
public static int[] getIntParameterValues(Request request, String name, int defaultValue) {
	String[] paramValues = getParameterValues(request, name);
	if (paramValues == null) {
		return null;
	}
	if (paramValues.length < 1) {
		return new int[0];
	}
	int[] values = new int[paramValues.length];
	for (int i = 0; i < paramValues.length; i++) {
		values[i] = NumberHelper.toInt(paramValues[i], defaultValue);
	}
	return values;
}
 
开发者ID:mixaceh,项目名称:openyu-socklet,代码行数:15,代码来源:RequestHelper.java

示例5: buildVipTypes

import org.openyu.commons.lang.NumberHelper; //导入方法依赖的package包/类
/**
 * 內部建構用vip等級,主要來自於appConfig-op.xml
 * 
 * @return
 */
protected Map<VipType, Integer> buildVipTypes() {
	Map<VipType, Integer> result = new LinkedHashMap<VipType, Integer>();
	// 塞個0級的,0=0
	result.put(VipType._0, 0);
	//
	for (Map.Entry<String, String> entry : appVipTypes.entrySet()) {
		int intValue = NumberHelper.toInt(entry.getKey());
		VipType vipType = EnumHelper.valueOf(VipType.class, intValue);
		//
		int accuCoin = NumberHelper.toInt(entry.getValue());
		result.put(vipType, accuCoin);
	}
	return result;
}
 
开发者ID:mixaceh,项目名称:openyu-mix,代码行数:20,代码来源:VipCollector.java

示例6: toObject

import org.openyu.commons.lang.NumberHelper; //导入方法依赖的package包/类
/**
 * disassemble常用
 * 
 * @param value
 * @param clazz
 * @return
 */
@SuppressWarnings("unchecked")
protected <T> T toObject(String value, Class<T> clazz) {
	Object result = null;
	// 非空白才處理
	if (StringHelper.notBlank(value)) {
		if (String.class == clazz) {
			result = value;
		}
		// date,calendar
		else if (Date.class == clazz || Calendar.class == clazz) {
			// 用long
			long time = NumberHelper.toLong(value);
			result = new Date(time);
		} else if (Locale.class == clazz) {
			result = LocaleHelper.toLocale(value);
		}
		// boolean
		else if (boolean.class == clazz || Boolean.class == clazz) {
			result = BooleanHelper.toBoolean(value);
		}
		// char
		else if (char.class == clazz || Character.class == clazz) {
			result = CharHelper.toChar(value);
		}
		// number
		else if (byte.class == clazz || Byte.class == clazz) {
			result = NumberHelper.toByte(value);
		} else if (short.class == clazz || Short.class == clazz) {
			result = NumberHelper.toShort(value);
		} else if (int.class == clazz || Integer.class == clazz) {
			result = NumberHelper.toInt(value);
		} else if (long.class == clazz || Long.class == clazz) {
			result = NumberHelper.toLong(value);
		} else if (float.class == clazz || Float.class == clazz) {
			result = NumberHelper.toFloat(value);
		} else if (double.class == clazz || Double.class == clazz) {
			result = NumberHelper.toDouble(value);
		}
	}
	return (T) result;
}
 
开发者ID:mixaceh,项目名称:openyu-commons,代码行数:49,代码来源:BaseUserTypeSupporter.java

示例7: bufferSize

import org.openyu.commons.lang.NumberHelper; //导入方法依赖的package包/类
public static int bufferSize(Object value) {
	AssertHelper.notNull(value, "The Value must not be null");
	//
	long sizeOf = MemoryHelper.sizeOf(value);
	return NumberHelper.toInt(sizeOf + 64);
}
 
开发者ID:mixaceh,项目名称:openyu-commons,代码行数:7,代码来源:SerializeHelper.java

示例8: startRelationServers

import org.openyu.commons.lang.NumberHelper; //导入方法依赖的package包/类
/**
 * 提供給內部連線
 */
protected void startRelationServers() throws Exception {
	// ------------------------------------------------
	// relationServers, 127.0.0.1:3300, 127.0.0.1:3301
	// ------------------------------------------------
	// 內部不用加密
	for (String ipPort : relationServers) {
		if (StringHelper.isEmpty(ipPort)) {
			continue;
		}
		//
		String[] buff = ipPort.split(":");
		// [0]=ip
		// [1]=port
		if (buff.length == 2) {
			ServerServiceImpl serverService = new ServerServiceImpl(ipPort, true);
			//
			serverService.setApplicationContext(applicationContext);
			serverService.setBeanFactory(beanFactory);
			serverService.setResourceLoader(resourceLoader);
			//
			serverService.setThreadService(threadService);
			serverService.setMessageService(messageService);
			serverService.setProtocolService(protocolService);
			serverService.setAuthKeyService(authKeyService);
			serverService.setAcceptorServiceImpl(this);
			serverService.setContextServiceImpl(contextServiceImpl);
			//
			serverService.setIp(buff[0]);
			int port = NumberHelper.toInt(buff[1]);
			serverService.setPort(port);
			//
			int maxCounter = (int) NumberHelper.divide(maxClient, relationServers.size());
			serverService.setMaxClient(maxCounter);
			serverService.setModuleTypeClass(moduleTypeClass);
			serverService.setMessageTypeClass(messageTypeClass);
			//
			serverService.start();
		} else {
			LOGGER.error(
					"[" + id + "]" + " Wrong [" + ipPort + "] format, ex: [127.0.0.1:3300] or [localhost:3300]");
		}
	}
}
 
开发者ID:mixaceh,项目名称:openyu-socklet,代码行数:47,代码来源:AcceptorServiceImpl.java

示例9: startClientServers

import org.openyu.commons.lang.NumberHelper; //导入方法依赖的package包/类
/**
 * 提供給外部連線
 */
protected void startClientServers() throws Exception {
	// ------------------------------------------------
	// clientServers, 127.0.0.1:10300, 127.0.0.1:10301
	// ------------------------------------------------
	if (clientServers == null || clientServers.isEmpty()) {
		LOGGER.warn("[" + id + "]" + " ClientServer is null, not been started");
		return;
	}

	// ------------------------------------------------
	// clientServers, localhost:2100
	// ------------------------------------------------
	// 外部,可選加密通訊
	for (String ipPort : clientServers) {
		if (StringHelper.isEmpty(ipPort)) {
			continue;
		}
		//
		String[] buff = ipPort.split(":");
		// [0]=ip
		// [1]=port
		if (buff.length == 2) {
			ServerServiceImpl serverService = new ServerServiceImpl(ipPort, false);
			//
			serverService.setApplicationContext(applicationContext);
			serverService.setBeanFactory(beanFactory);
			serverService.setResourceLoader(resourceLoader);
			//
			serverService.setThreadService(threadService);
			serverService.setMessageService(messageService);
			serverService.setProtocolService(protocolService);
			serverService.setAuthKeyService(authKeyService);
			serverService.setAcceptorServiceImpl(this);
			serverService.setContextServiceImpl(contextServiceImpl);
			//
			serverService.setIp(buff[0]);
			int port = NumberHelper.toInt(buff[1]);
			serverService.setPort(port);
			//
			int maxCounter = (int) NumberHelper.divide(maxClient, relationServers.size());
			serverService.setMaxClient(maxCounter);
			serverService.setModuleTypeClass(moduleTypeClass);
			serverService.setMessageTypeClass(messageTypeClass);
			//
			serverService.start();
		} else {
			LOGGER.error(
					"[" + id + "]" + " Wrong [" + ipPort + "] format, ex: [localhost:2000] or [127.0.0.1:2000]");
		}
	}
}
 
开发者ID:mixaceh,项目名称:openyu-socklet,代码行数:55,代码来源:AcceptorServiceImpl.java

示例10: getIntParameter

import org.openyu.commons.lang.NumberHelper; //导入方法依赖的package包/类
public static int getIntParameter(Request request, String name, int defaultValue) {
	String value = getParameter(request, name);
	return NumberHelper.toInt(value, defaultValue);
}
 
开发者ID:mixaceh,项目名称:openyu-socklet,代码行数:5,代码来源:RequestHelper.java

示例11: getIntAttribute

import org.openyu.commons.lang.NumberHelper; //导入方法依赖的package包/类
public static int getIntAttribute(Request request, String name, int defaultValue) {
	String value = (String) getAttribute(request, name);
	return NumberHelper.toInt(value, defaultValue);
}
 
开发者ID:mixaceh,项目名称:openyu-socklet,代码行数:5,代码来源:RequestHelper.java

示例12: getIntAttribute

import org.openyu.commons.lang.NumberHelper; //导入方法依赖的package包/类
public static int getIntAttribute(Session session, String name, int defaultValue) {
	return NumberHelper.toInt(getStringAttribute(session, name), defaultValue);
}
 
开发者ID:mixaceh,项目名称:openyu-socklet,代码行数:4,代码来源:SessionHelper.java

示例13: getIntInitParameter

import org.openyu.commons.lang.NumberHelper; //导入方法依赖的package包/类
public static int getIntInitParameter(ListenerConfig config, String name, int defaultValue) {
	String value = getInitParameter(config, name);
	return NumberHelper.toInt(value, defaultValue);
}
 
开发者ID:mixaceh,项目名称:openyu-socklet,代码行数:5,代码来源:ListenerConfigHelper.java

示例14: kryoWriteClass

import org.openyu.commons.lang.NumberHelper; //导入方法依赖的package包/类
/**
 * kryo 序列化
 * 
 * 也會把class資訊一同序列化
 * 
 * object -> byte[]
 * 
 * @param kryo
 * @param value
 * @return
 */
public static byte[] kryoWriteClass(Kryo kryo, Object value) {
	AssertHelper.notNull(kryo, "The Kryo must not be null");
	AssertHelper.notNull(value, "The Value must not be null");
	//
	double sizeOf = MemoryHelper.sizeOf(value);
	AssertHelper.isTrue(sizeOf > 0, "The SizeOf must be greater than zero");
	//
	int bufferSize = NumberHelper.toInt(sizeOf) + 128;
	return kryoWriteClass(kryo, value, bufferSize);
}
 
开发者ID:mixaceh,项目名称:openyu-commons,代码行数:22,代码来源:SerializeHelper.java


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