本文整理汇总了Java中java.util.NoSuchElementException类的典型用法代码示例。如果您正苦于以下问题:Java NoSuchElementException类的具体用法?Java NoSuchElementException怎么用?Java NoSuchElementException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NoSuchElementException类属于java.util包,在下文中一共展示了NoSuchElementException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: next
import java.util.NoSuchElementException; //导入依赖的package包/类
public Object next() {
if (hasNext()) {
removed = false;
if (counter != 0) {
last = current;
current = current.next;
}
counter++;
return current.data;
}
throw new NoSuchElementException();
}
示例2: getVisitId
import java.util.NoSuchElementException; //导入依赖的package包/类
private Long getVisitId(String visitToken) throws Exception {
Long visitId = null;
if (!CommonUtil.isEmptyString(visitToken)) {
if (!visitIdMap.containsKey(visitToken)) {
try {
visitId = visitDao.findByTrialTitleToken(context.getEntityId(), null, visitToken).iterator().next().getId();
} catch (NoSuchElementException e) {
VisitOutVO visitVO = createVisit(visitToken);
visitId = visitVO.getId();
jobOutput.println("visit '" + visitVO.getUniqueName() + "' created");
}
visitIdMap.put(visitToken, visitId);
} else {
visitId = visitIdMap.get(visitToken);
}
}
return visitId;
}
示例3: getLoadAvg
import java.util.NoSuchElementException; //导入依赖的package包/类
private static void getLoadAvg(double[] doubles) {
InputStreamReader isr = null;
BufferedReader br = null;
try {
isr = new InputStreamReader(new FileInputStream("/proc/loadavg"));
br = new BufferedReader(isr, 512);
String line = br.readLine();
if (line == null) {
return;
}
st.setString(line);
doubles[LinuxSystemStats.loadAverage1DOUBLE] = st.nextTokenAsDouble();
doubles[LinuxSystemStats.loadAverage5DOUBLE] = st.nextTokenAsDouble();
doubles[LinuxSystemStats.loadAverage15DOUBLE] = st.nextTokenAsDouble();
} catch (NoSuchElementException nsee) {
} catch (IOException ioe) {
} finally {
st.releaseResources();
if (br != null)
try {
br.close();
} catch (IOException ignore) {
}
}
}
示例4: next
import java.util.NoSuchElementException; //导入依赖的package包/类
public E next() {
final Node<E> pred = nextNode;
if (pred == null) throw new NoSuchElementException();
// assert nextItem != null;
lastRet = pred;
E item = null;
for (Node<E> p = succ(pred), q;; p = q) {
if (p == null || (item = p.item) != null) {
nextNode = p;
E x = nextItem;
nextItem = item;
return x;
}
// unlink deleted nodes
if ((q = succ(p)) != null)
NEXT.compareAndSet(pred, p, q);
}
}
示例5: addAll
import java.util.NoSuchElementException; //导入依赖的package包/类
public boolean addAll(Enumeration<String> comps) throws InvalidNameException {
boolean added = false;
while (comps.hasMoreElements()) {
try {
String comp = comps.nextElement();
if (size() > 0 && syntaxDirection == FLAT) {
throw new InvalidNameException(
"A flat name can only have a single component");
}
components.addElement(comp);
added = true;
} catch (NoSuchElementException e) {
break; // "comps" has shrunk.
}
}
return added;
}
示例6: getHandleIterator
import java.util.NoSuchElementException; //导入依赖的package包/类
public static CoprocessIterator<Long> getHandleIterator(TiDAGRequest req,
List<RegionTask> regionTasks,
TiSession session) {
return new DAGIterator<Long>(
req.buildScan(true),
regionTasks,
session,
SchemaInfer.create(req),
req.getPushDownType()
) {
@Override
public Long next() {
if (hasNext()) {
return rowReader.readRow(handleTypes).getLong(0);
} else {
throw new NoSuchElementException();
}
}
};
}
示例7: next
import java.util.NoSuchElementException; //导入依赖的package包/类
@Override
public IPosition next() {
if (!hasNext()) {
throw new NoSuchElementException();
}
if (model.getSleep()>0) {
try {
Thread.sleep(model.getSleep());
if (countSleeps) sleepCount++;
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new RuntimeException(e);
}
}
Scalar<Double> point = new Scalar<>(model.getName(), count, model.getValue());
count++;
return point;
}
示例8: elements
import java.util.NoSuchElementException; //导入依赖的package包/类
/**
* Returns an enumeration of the components of this vector. The
* returned <tt>Enumeration</tt> object will generate all items in
* this vector. The first item generated is the item at index <tt>0</tt>,
* then the item at index <tt>1</tt>, and so on.
*
* @return an enumeration of the components of this vector.
* @see Enumeration
* @see java.util.Iterator
*/
public Enumeration<SimEvent> elements() {
return new Enumeration<SimEvent>() {
int count = start;
public boolean hasMoreElements() {
return count < size;
}
public SimEvent nextElement() {
synchronized (CircularEventQueue.this) {
if (count < size) {
return data[count++];
}
}
throw new NoSuchElementException("Vector Enumeration");
}
};
}
示例9: parseEdgeMetadata
import java.util.NoSuchElementException; //导入依赖的package包/类
/**
* Parses the metadata of a link (edge) to an {@link EdgeMetadata} object.
*
* @param gfa string containing the contents of the GFA file
* @param byteOffset the byte offset where the edge should be located
* @return an {@link EdgeMetadata} object containing a link's metadata
* @throws MetadataParseException if the GFA file or given line is invalid
*/
public EdgeMetadata parseEdgeMetadata(final GfaFile gfa, final long byteOffset) throws MetadataParseException {
final String line = getLine(gfa.getRandomAccessFile(), byteOffset);
validateLine(line, "L", byteOffset);
final StringTokenizer st = initializeStringTokenizer(line, byteOffset);
try {
st.nextToken();
st.nextToken();
final String fromOrient = st.nextToken();
st.nextToken();
final String toOrient = st.nextToken();
final String overlap = st.nextToken();
return new EdgeMetadata(fromOrient, toOrient, overlap);
} catch (final NoSuchElementException e) {
throw new MetadataParseException("Not enough parameters for link at position " + byteOffset, e);
}
}
示例10: invokeMethod
import java.util.NoSuchElementException; //导入依赖的package包/类
private Object invokeMethod(Object moduleInstance, Map<String, Map<String, Object>> argsDescription)
throws NoSuchMethodException, SecurityException, ClassNotFoundException, IllegalAccessException,
IllegalArgumentException, InvocationTargetException, APICallException {
if (moduleInstance == null) {
throw new NoSuchElementException();
}
Method m = fetchMethod(moduleInstance.getClass());
if (m == null) {
throw new NoSuchMethodException();
}
Object[] args = fetchArgsValues(argsDescription);
return (args == null) ? m.invoke(moduleInstance) : m.invoke(moduleInstance, args);
}
示例11: getNumber
import java.util.NoSuchElementException; //导入依赖的package包/类
/**
* This method returns the value of the named double data read from the Telemetry class. If the named data does
* not exist, it is created and assigned the given default value. Then it is sent to the Driver Station.
*
* @param key specifies the name associated with the double data.
* @param defaultValue specifies the default value if it does not exist.
* @return double data value.
*/
public double getNumber(String key, double defaultValue)
{
final String funcName = "getNumber";
double value;
if (debugEnabled)
{
dbgTrace.traceEnter(funcName, TrcDbgTrace.TraceLevel.API, "key=%s,defValue=%f", key, defaultValue);
}
try
{
value = getNumber(key);
}
catch (NoSuchElementException e)
{
putNumber(key, defaultValue);
value = defaultValue;
}
if (debugEnabled)
{
dbgTrace.traceExit(funcName, TrcDbgTrace.TraceLevel.API, "=%f", value);
}
return value;
}
示例12: next
import java.util.NoSuchElementException; //导入依赖的package包/类
@Override
public T next()
{
if (hasNext()) {
T ret = (T)view.get(position);
lastPosition = position;
position++;
return ret;
}
throw new NoSuchElementException();
}
示例13: next
import java.util.NoSuchElementException; //导入依赖的package包/类
@Override
public E next() {
if (!hasNext()) {
throw new NoSuchElementException();
}
element = elements[index++];
return element;
}
示例14: testSpanTwoRanges
import java.util.NoSuchElementException; //导入依赖的package包/类
public void testSpanTwoRanges() {
for (Range<Integer> range1 : RANGES) {
for (Range<Integer> range2 : RANGES) {
RangeMap<Integer, Integer> rangeMap = TreeRangeMap.create();
rangeMap.put(range1, 1);
rangeMap.put(range2, 2);
Range<Integer> expected;
if (range1.isEmpty()) {
if (range2.isEmpty()) {
expected = null;
} else {
expected = range2;
}
} else {
if (range2.isEmpty()) {
expected = range1;
} else {
expected = range1.span(range2);
}
}
try {
assertEquals(expected, rangeMap.span());
assertNotNull(expected);
} catch (NoSuchElementException e) {
assertNull(expected);
}
}
}
}
示例15: testOptionalMapOnEmpty
import java.util.NoSuchElementException; //导入依赖的package包/类
@Test
public void testOptionalMapOnEmpty() {
Optional<String> emptyName = Optional.empty(); // or Optional.ofNullable(null);
Optional<String> emptyUpperName = emptyName.map(String::toUpperCase);
assertThat(emptyUpperName.isPresent()).isFalse();
try {
assertThat(emptyUpperName.get()).isEqualTo("FRED");
fail("found a value on an empty Optional");
} catch (NoSuchElementException e) {
// ignore
}
}