Java Code Examples for java.util.concurrent.atomic.AtomicLong.longValue()

The following are Jave code examples for showing how to use longValue() of the java.util.concurrent.atomic.AtomicLong class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: incubator-netbeans   File: Stamps.java   View Source Code Vote up 6 votes
private static boolean highestStampForDir(File file, AtomicReference<File> newestFile, AtomicLong result, AtomicInteger crc) {
    if (file.getName().equals(".nbattrs")) { // NOI18N
        return true;
    }

    File[] children = file.listFiles();
    if (children == null) {
        if (crc != null) {
            crc.addAndGet(file.getName().length());
        }
        long time = file.lastModified();
        if (time > result.longValue()) {
            newestFile.set(file);
            result.set(time);
        }
        return false;
    }
    
    for (File f : children) {
        highestStampForDir(f, newestFile, result, crc);
    }
    return true;
}
 
Example 2
Project: incubator-netbeans   File: ExpandFolderTest.java   View Source Code Vote up 6 votes
private void iterateTests(TestResult result, StringBuffer times, TestSuite suite, AtomicLong min, AtomicLong max) {
    Enumeration en = suite.tests();
    while (en.hasMoreElements()) {
        Test t = (Test)en.nextElement();
        if (t instanceof Callable) {
            try {
                Long v = (Long)((Callable) t).call();
                long time = v.longValue();
                if (time < min.longValue()) {
                    min.set(time);
                }
                if (time > max.longValue()) {
                    max.set(time);
                }
                // append(t.toString()).append(" value: ")
                times.append("Run: ").append(v).append('\n');
            } catch (Exception ex) {
                result.addError(this, ex);
            }
        }
        if (t instanceof TestSuite) {
            iterateTests(result, times, (TestSuite)t, min, max);
        }
    }
}
 
Example 3
Project: incubator-netbeans   File: ExpandFolderTest.java   View Source Code Vote up 5 votes
@Override
public void run(TestResult result) {
    result.startTest(this);
    StringBuffer times = new StringBuffer("\n");
    AtomicLong min = new AtomicLong(Long.MAX_VALUE);
    AtomicLong max = new AtomicLong(Long.MIN_VALUE);
    iterateTests(result, times, suite, min, max);
    
    System.err.println(times.toString());
    
    if (max.longValue() > 3 * min.longValue()) {
        result.addFailure(this, new AssertionFailedError(times.toString()));
    }
    result.endTest(this);
}
 
Example 4
Project: incubator-netbeans   File: CssIndexer.java   View Source Code Vote up 5 votes
public static long getImportsHashCodeForRoots(Collection<FileObject> roots) {
    long hash = 5;
    for(FileObject root : roots) {
        AtomicLong rootHash = computedImportsHashCodes.get(root);
        if(rootHash != null) {
            hash = hash * 51 + rootHash.longValue();
        }
    }
    return hash;
}
 
Example 5
Project: QLExpress   File: QLPattern.java   View Source Code Vote up 5 votes
public static QLMatchResult findMatchStatement(INodeTypeManager aManager,QLPatternNode pattern ,List<? extends IDataNode> nodes,int point) throws Exception{
	AtomicLong maxMatchPoint = new AtomicLong();
	QLMatchResult result = findMatchStatementWithAddRoot(aManager,pattern,nodes,point,true,maxMatchPoint);
	if(result == null || result.matchs.size() == 0){
		throw new Exception("程序错误,不满足语法规范,没有匹配到合适的语法,最大匹配致[0:" + (maxMatchPoint.longValue()-1) +"]");
	}else if(result != null && result.matchs.size() != 1){
		throw new Exception("程序错误,不满足语法规范,必须有一个根节点:" + pattern + ",最大匹配致[0:" + (maxMatchPoint.longValue()-1) +"]");
	}
	return result;
}
 
Example 6
Project: wamp2spring   File: IdGenerator.java   View Source Code Vote up 3 votes
/**
 * Creates new linear identification number from the provided parameter.
 * <p>
 * Used for session scope and router scope ids
 *
 * @param longValue start address of the identification number. Next number will be
 * this value plus 1
 * @return new id
 */
public static long newLinearId(AtomicLong longValue) {
	long candiateId = longValue.incrementAndGet();
	if (candiateId > IdGenerator.MAX) {
		longValue.set(1L);
		candiateId = longValue.longValue();
	}
	return candiateId;
}