當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。