下面列出了org.apache.commons.lang.mutable.MutableInt#intValue ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Determine the number of unprocessed flag files in the flag directory
*
* @param fc
* @return the flag found for this ingest pool
*/
private int countFlagFileBacklog(final FlagDataTypeConfig fc) {
final MutableInt fileCounter = new MutableInt(0);
final FileFilter fileFilter = new WildcardFileFilter("*_" + fc.getIngestPool() + "_" + fc.getDataName() + "_*.flag");
final FileVisitor<java.nio.file.Path> visitor = new SimpleFileVisitor<java.nio.file.Path>() {
@Override
public FileVisitResult visitFile(java.nio.file.Path path, BasicFileAttributes attrs) throws IOException {
if (fileFilter.accept(path.toFile())) {
fileCounter.increment();
}
return super.visitFile(path, attrs);
}
};
try {
Files.walkFileTree(Paths.get(fmc.getFlagFileDirectory()), visitor);
} catch (IOException e) {
// unable to get a flag count....
log.error("Unable to get flag file count", e);
return -1;
}
return fileCounter.intValue();
}
private static long readLIBSVMMatrixFromInputStream( InputStream is, String srcInfo, MatrixBlock dest, MutableInt rowPos,
long rlen, long clen, int blen )
throws IOException
{
SparseRowVector vect = new SparseRowVector(1024);
String value = null;
int row = rowPos.intValue();
long lnnz = 0;
// Read the data
try( BufferedReader br = new BufferedReader(new InputStreamReader(is)) ) {
while( (value=br.readLine())!=null ) { //for each line
String rowStr = value.toString().trim();
lnnz += ReaderTextLIBSVM.parseLibsvmRow(rowStr, vect, (int)clen);
dest.appendRow(row, vect);
row++;
}
}
rowPos.setValue(row);
return lnnz;
}
private static FilterQuery traverseFilterQueryAndPopulateMap(FilterQueryTree tree,
Map<Integer, FilterQuery> filterQueryMap, MutableInt currentId) {
int currentNodeId = currentId.intValue();
currentId.increment();
final List<Integer> f = new ArrayList<>();
if (null != tree.getChildren()) {
for (final FilterQueryTree c : tree.getChildren()) {
final FilterQuery q = traverseFilterQueryAndPopulateMap(c, filterQueryMap, currentId);
int childNodeId = q.getId();
f.add(childNodeId);
filterQueryMap.put(childNodeId, q);
}
}
FilterQuery query = new FilterQuery();
query.setColumn(tree.getColumn());
query.setId(currentNodeId);
query.setNestedFilterQueryIds(f);
query.setOperator(tree.getOperator());
query.setValue(tree.getValue());
return query;
}
@Override
public void run() {
//let the players update smoother
int remainingUpdates = getNextUpdates();
for (Map.Entry<Player, MutableInt> entry : queue.entrySet()) {
Player player = entry.getKey();
MutableInt remainingTicks = entry.getValue();
if (remainingTicks.intValue() == 0) {
if (remainingUpdates != 0) {
//Smoother refreshing; limit the updates
plugin.getScoreboardManager().onUpdate(player);
remainingTicks.setValue(20 * Settings.getInterval());
remainingUpdates--;
}
} else {
remainingTicks.decrement();
}
}
nextGlobalUpdate--;
if (nextGlobalUpdate == 0) {
nextGlobalUpdate = 20 * Settings.getInterval();
//update globals
plugin.getReplaceManager().updateGlobals();
}
}
public void addPointsByRace(Race race, int points) {
MutableInt pointsByRace = getPointsByRace(race);
pointsByRace.add(points);
if (pointsByRace.intValue() < 0) {
pointsByRace.setValue(0);
}
}
public void addPvpKillsByRace(Race race, int points) {
MutableInt racePoints = getPvpKillsByRace(race);
racePoints.add(points);
if (racePoints.intValue() < 0) {
racePoints.setValue(0);
}
}
public void addPointsByRace(Race race, int points) {
MutableInt racePoints = getPointsByRace(race);
racePoints.add(points);
if (racePoints.intValue() < 0) {
racePoints.setValue(0);
}
}
public void addPointsByRace(Race race, int points) {
MutableInt racePoints = getPointsByRace(race);
racePoints.add(points);
if (racePoints.intValue() < 0) {
racePoints.setValue(0);
}
}
public void addPointsByRace(Race race, int points) {
MutableInt racePoints = getPointsByRace(race);
racePoints.add(points);
if (racePoints.intValue() < 0) {
racePoints.setValue(0);
}
}
public void addPvpKillsByRace(Race race, int points) {
MutableInt racePoints = getPvpKillsByRace(race);
racePoints.add(points);
if (racePoints.intValue() < 0) {
racePoints.setValue(0);
}
}
public int getCount(T key)
{
int ret = -1;
MutableInt val = map.get(key);
if (val != null) {
ret = val.intValue();
}
return ret;
}
private void decrVertexTaskCount(Priority priority, RequestPriorityStats stats, int vertexIndex) {
Integer vertexIndexInt = vertexIndex;
MutableInt taskCount = stats.vertexTaskCount.get(vertexIndexInt);
taskCount.decrement();
if (taskCount.intValue() <= 0) {
removeVertexFromRequestStats(priority, stats, vertexIndexInt);
}
}
public void addPvpKillsByRace(Race race, int points) {
MutableInt racePoints = getPvpKillsByRace(race);
racePoints.add(points);
if (racePoints.intValue() < 0) {
racePoints.setValue(0);
}
}
public void addPointsByRace(Race race, int points) {
MutableInt racePoints = getPointsByRace(race);
racePoints.add(points);
if (racePoints.intValue() < 0) {
racePoints.setValue(0);
}
}
public void addPvpKillsByRace(Race race, int points) {
MutableInt racePoints = getPvpKillsByRace(race);
racePoints.add(points);
if (racePoints.intValue() < 0) {
racePoints.setValue(0);
}
}
public void addPointsByRace(Race race, int points) {
MutableInt racePoints = getPointsByRace(race);
racePoints.add(points);
if (racePoints.intValue() < 0) {
racePoints.setValue(0);
}
}
public void addPvpKillsByRace(Race race, int points) {
MutableInt racePoints = getPvpKillsByRace(race);
racePoints.add(points);
if (racePoints.intValue() < 0) {
racePoints.setValue(0);
}
}
private boolean decrement(Map<Object, MutableInt> map, Object obj) {
MutableInt i = map.get(obj);
if(i == null) {
return false;
}
i.decrement();
if(i.intValue() == 0) {
map.remove(obj);
}
return true;
}
private void processException(Exception e, MethodInvocation invocation, MutableInt attempt) {
StringBuilder message = new StringBuilder("When invoking method ")
.append(invocation.getMethod().getDeclaringClass().getName()).append("#")
.append(invocation.getMethod().getName()).append(" caught \"").append(e.getMessage())
.append("\". Attempt #").append(attempt);
attempt.increment();
if (attempt.intValue() <= TransactionRetryInterceptor.MAX_ATTEMPTS) {
message.append(". Retrying.");
} else {
message.append(". Giving up.");
}
TransactionRetryInterceptor.log.warn(message);
}
public int getCount(T key)
{
int ret = -1;
MutableInt val = map.get(key);
if (val != null) {
ret = val.intValue();
}
return ret;
}