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


Java NumberHelper类代码示例

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


NumberHelper类属于org.openyu.commons.lang包,在下文中一共展示了NumberHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: probRandomOf

import org.openyu.commons.lang.NumberHelper; //导入依赖的package包/类
/**
 * 依機率取
 * 
 * @param values
 * @param probSum
 * @return
 */
public static <E extends ProbabilityBean> E probRandomOf(Collection<E> values, double probSum) {
	E result = null;
	if (CollectionHelper.notEmpty(values)) {
		// 計算所有機率加總
		// #issue: 每次加總會變慢
		// double sum = calcProbabilitySum(collection);
		// System.out.println("sum: "+sum);
		// 與randomOf(weightSum)的不同之處,直接用機率比對
		//
		// #fix 傳入probSum, ok
		double random = NumberHelper.randomDouble(0, probSum);
		double accu = 0d;
		//
		for (E entry : values) {
			double low = accu;
			double high = accu + entry.getProbability();
			if (random >= low && random < high) {
				result = entry;
			}
			accu = high;
		}
	}
	return result;
}
 
开发者ID:mixaceh,项目名称:openyu-commons,代码行数:32,代码来源:BeanHelper.java

示例3: 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

示例4: mockOpenCacheWithMultiThread

import org.openyu.commons.lang.NumberHelper; //导入依赖的package包/类
@Test
@BenchmarkOptions(benchmarkRounds = 1, warmupRounds = 0, concurrency = 1)
public void mockOpenCacheWithMultiThread() {
	for (int i = 0; i < 5; i++) {
		Thread thread = new Thread(new Runnable() {
			public void run() {
				try {
					mockOpenCache();
				} catch (Exception ex) {
				}
			}
		});
		thread.setName("T-" + i);
		thread.start();
		ThreadHelper.sleep(NumberHelper.randomInt(100));
	}
	//
	ThreadHelper.sleep(5 * 1000);
}
 
开发者ID:mixaceh,项目名称:openyu-commons,代码行数:20,代码来源:SoftReferenceCacheFactoryImplTest.java

示例5: mockOpenCacheWithMultiThread

import org.openyu.commons.lang.NumberHelper; //导入依赖的package包/类
@Test
@BenchmarkOptions(benchmarkRounds = 1, warmupRounds = 0, concurrency = 1)
public void mockOpenCacheWithMultiThread() throws Exception {
	for (int i = 0; i < 5; i++) {
		Thread thread = new Thread(new Runnable() {
			public void run() {
				try {
					mockOpenCache();
				} catch (Exception ex) {
				}
			}
		});
		thread.setName("T-" + i);
		thread.start();
		Thread.sleep(NumberHelper.randomInt(100));
	}
	//
	Thread.sleep(5 * 1000);
}
 
开发者ID:mixaceh,项目名称:openyu-commons,代码行数:20,代码来源:GenericCacheFactoryImplTest.java

示例6: mockGetFTPClientWithMultiThread

import org.openyu.commons.lang.NumberHelper; //导入依赖的package包/类
@Test
@BenchmarkOptions(benchmarkRounds = 1, warmupRounds = 0, concurrency = 1)
public void mockGetFTPClientWithMultiThread() throws Exception {
	for (int i = 0; i < 5; i++) {
		Thread thread = new Thread(new Runnable() {
			public void run() {
				try {
					mockGetFTPClient();
				} catch (Exception ex) {
				}
			}
		});
		thread.setName("T-" + i);
		thread.start();
		Thread.sleep(NumberHelper.randomInt(100));
	}
	//
	Thread.sleep(1 * 60 * 60 * 1000);
}
 
开发者ID:mixaceh,项目名称:openyu-commons,代码行数:20,代码来源:FtpClientConnectionFactoryImplTest.java

示例7: mockOpenSessionWithMultiThread

import org.openyu.commons.lang.NumberHelper; //导入依赖的package包/类
@Test
@BenchmarkOptions(benchmarkRounds = 1, warmupRounds = 0, concurrency = 1)
public void mockOpenSessionWithMultiThread() throws Exception {
	for (int i = 0; i < 5; i++) {
		Thread thread = new Thread(new Runnable() {
			public void run() {
				try {
					mockOpenSession();
				} catch (Exception ex) {
				}
			}
		});
		thread.setName("T-" + i);
		thread.start();
		Thread.sleep(NumberHelper.randomInt(100));
	}
	//
	Thread.sleep(1 * 60 * 60 * 1000);
}
 
开发者ID:mixaceh,项目名称:openyu-commons,代码行数:20,代码来源:FtpClientSessionFactoryImplTest.java

示例8: mockGetTableWithMultiThread

import org.openyu.commons.lang.NumberHelper; //导入依赖的package包/类
@Test
// #issue 多緒拿到同一條connection, unthread safe
public void mockGetTableWithMultiThread() throws Exception {
	for (int i = 0; i < 5; i++) {
		Thread thread = new Thread(new Runnable() {
			public void run() {
				try {
					mockGetTable();
				} catch (Exception ex) {
				}
			}
		});
		thread.setName("T-" + i);
		thread.start();
		Thread.sleep(NumberHelper.randomInt(100));
	}
	//
	Thread.sleep(1 * 60 * 60 * 1000);
}
 
开发者ID:mixaceh,项目名称:openyu-commons,代码行数:20,代码来源:HTablePoolTest.java

示例9: mockGetTableWithTablePoolWithMultiThread

import org.openyu.commons.lang.NumberHelper; //导入依赖的package包/类
@Test
// #issue 多緒拿到同一條connection, unthread safe
public void mockGetTableWithTablePoolWithMultiThread() throws Exception {
	for (int i = 0; i < 5; i++) {
		Thread thread = new Thread(new Runnable() {
			public void run() {
				try {
					mockGetTableByTablePool();
				} catch (Exception ex) {
				}
			}
		});
		thread.setName("T-" + i);
		thread.start();
		Thread.sleep(NumberHelper.randomInt(100));
	}
	//
	Thread.sleep(1 * 60 * 60 * 1000);
}
 
开发者ID:mixaceh,项目名称:openyu-commons,代码行数:20,代码来源:HTablePoolTest.java

示例10: mockGetTransportWithMultiThread

import org.openyu.commons.lang.NumberHelper; //导入依赖的package包/类
@Test
public void mockGetTransportWithMultiThread() throws Exception {
	// PRD blocking: 450-480
	// PRD noblocking: 330-350

	// DEV blocking: 430-450
	// 127.0.0.1 blocking: 2000
	for (int i = 0; i < 5; i++) {
		Thread thread = new Thread(new Runnable() {
			public void run() {
				try {
					mockGetTransport();
				} catch (Exception ex) {
				}
			}
		});
		thread.setName("T-" + i);
		thread.start();
		Thread.sleep(NumberHelper.randomInt(100));
	}
	//
	Thread.sleep(1 * 60 * 60 * 1000);
}
 
开发者ID:mixaceh,项目名称:openyu-commons,代码行数:24,代码来源:HtDataSourceImplTest.java

示例11: mockOpenSessionWithMultiThread

import org.openyu.commons.lang.NumberHelper; //导入依赖的package包/类
@Test
public void mockOpenSessionWithMultiThread() throws Exception {
	// PRD blocking: 450-480
	// PRD noblocking: 330-350

	// DEV blocking: 430-450
	// 127.0.0.1 blocking: 2000
	for (int i = 0; i < 5; i++) {
		Thread thread = new Thread(new Runnable() {
			public void run() {
				try {
					mockOpenSession();
				} catch (Exception ex) {
				}
			}
		});
		thread.setName("T-" + i);
		thread.start();
		Thread.sleep(NumberHelper.randomInt(100));
	}
	//
	Thread.sleep(1 * 60 * 60 * 1000);
}
 
开发者ID:mixaceh,项目名称:openyu-commons,代码行数:24,代码来源:HtSessionFactoryImplTest.java

示例12: mockFilterUpdateWithMultiThread

import org.openyu.commons.lang.NumberHelper; //导入依赖的package包/类
@Test
public void mockFilterUpdateWithMultiThread() throws Exception {
	// blocking: 450-480
	// noblocking: 590-600
	for (int i = 0; i < 600; i++) {
		Thread thread = new Thread(new Runnable() {
			public void run() {
				try {
					mockFilterUpdate();
				} catch (Exception ex) {
				}
			}
		});
		thread.setName("T-" + i);
		thread.start();
		Thread.sleep(NumberHelper.randomInt(100));
	}
	//
	Thread.sleep(1 * 60 * 60 * 1000);
}
 
开发者ID:mixaceh,项目名称:openyu-commons,代码行数:21,代码来源:HBaseThriftDMLTest.java

示例13: mockGetHConnectionWithMultiThread

import org.openyu.commons.lang.NumberHelper; //导入依赖的package包/类
@Test
public void mockGetHConnectionWithMultiThread() throws Exception {
	for (int i = 0; i < 5; i++) {
		Thread thread = new Thread(new Runnable() {
			public void run() {
				try {
					mockGetHConnection();
				} catch (Exception ex) {
				}
			}
		});
		thread.setName("T-" + i);
		thread.start();
		Thread.sleep(NumberHelper.randomInt(100));
	}
	//
	Thread.sleep(1 * 60 * 60 * 1000);
}
 
开发者ID:mixaceh,项目名称:openyu-commons,代码行数:19,代码来源:HzDataSourceImplTest.java

示例14: mockOpenSessionWithMultiThread

import org.openyu.commons.lang.NumberHelper; //导入依赖的package包/类
@Test
public void mockOpenSessionWithMultiThread() throws Exception {
	for (int i = 0; i < 5; i++) {
		Thread thread = new Thread(new Runnable() {
			public void run() {
				try {
					mockOpenSession();
				} catch (Exception ex) {
				}
			}
		});
		thread.setName("T-" + i);
		thread.start();
		Thread.sleep(NumberHelper.randomInt(100));
	}
	//
	Thread.sleep(1 * 60 * 60 * 1000);
}
 
开发者ID:mixaceh,项目名称:openyu-commons,代码行数:19,代码来源:HzSessionFactoryImplTest.java

示例15: run

import org.openyu.commons.lang.NumberHelper; //导入依赖的package包/类
public void run()
{
	System.out.println("thread[" + Thread.currentThread().getId() + "] " + " start");
	Integer result = null;
	try
	{
		//				while (result == null)
		//				{
		int randomInt = NumberHelper.randomInt(0, 1000000);
		result = Helper.createInteger(randomInt + "a");
		//				}
	}
	catch (Exception ex)
	{
		ex.printStackTrace();
	}

	System.out.println("thread[" + Thread.currentThread().getId() + "] finish. result="
			+ result);
}
 
开发者ID:mixaceh,项目名称:openyu-commons,代码行数:21,代码来源:MapCacheImplTest.java


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