List of usage examples for java.util NoSuchElementException NoSuchElementException
public NoSuchElementException(String s)
From source file:de.tud.inf.db.sparqlytics.model.Dimension.java
/** * Returns the level with the given name. * * @param name the name of the level to be looked up * @return the level with the given name * @throws NoSuchElementException if this dimension does not contain a * level with the given name */// w ww. j a v a 2s . c o m public Level findLevel(final String name) { for (Level level : levels) { if (level.getName().equals(name)) { return level; } } throw new NoSuchElementException(name); }
From source file:de.codesourcery.asm.controlflow.AbstractBlock.java
@Override public int getFirstByteCodeInstructionNum(MethodNode method) throws NoSuchElementException { final List<Integer> sorted = new ArrayList<>(instructions); Collections.sort(sorted);//from w ww .ja v a2 s.co m for (int idx : sorted) { AbstractInsnNode instruction = method.instructions.get(idx); if (instruction.getOpcode() != -1) { return idx; } } throw new NoSuchElementException("Block contains only virtual instructions"); }
From source file:com.eviware.soapui.utils.ContainerWalker.java
public JTextComponent findTextComponent(String componentName) { JTextComponent component = (JTextComponent) Iterables.find(containedComponents, new ComponentClassAndNamePredicate(JTextComponent.class, componentName)); if (component == null) { throw new NoSuchElementException("No text component with name '" + componentName + "' found"); }// w w w. j a v a 2s . co m return component; }
From source file:com.isencia.passerelle.actor.gui.BasePasserelleQuery.java
public void setStringValue(String name, String value) throws NoSuchElementException, IllegalArgumentException { try {/*from w ww. ja va2 s .c o m*/ BeanUtils.setProperty(passerelleComponent, name, value); } catch (Exception e) { logger.error("error setting value " + name + " on property " + name + " from " + passerelleComponent, e); throw new NoSuchElementException(e.getMessage()); } }
From source file:com.octo.captcha.engine.bufferedengine.buffer.DatabaseCaptchaBuffer.java
/** * remove a captcha from the buffer corresponding to the locale * * @param locale The locale the catcha to remove * * @return a captcha correponding to the locale * * @throws NoSuchElementException if there is no captcha throw NoSuchElementException *//* www . ja va 2 s .co m*/ public Captcha removeCaptcha(Locale locale) throws NoSuchElementException { Collection col = removeCaptcha(1, locale); if (col != null && col.size() > 0) { return (Captcha) col.iterator().next(); } else { throw new NoSuchElementException("no captcha in this buffer for locale " + locale); } }
From source file:com.jameswolfeoliver.pigeon.Server.ChatServer.java
private void send(final String body, final String address, final long messageDate) { helperThread.submit(() -> {/*ww w .j a va 2 s . c om*/ try { Contact contact = ContactCacheManager.getInstance().updateNow().getContact(Long.parseLong(address)); Message message = new Message(); message.setAddress(Long.parseLong(address)); message.setContact(contact); message.setBody(escapeHtml4(body)); message.setDate(messageDate); int threadId = -1; Conversation conversation = null; try { Iterable<Integer> threadIterable = threadWrapper.find(() -> address).toBlocking().toIterable(); Iterator<Integer> threadIds = threadIterable.iterator(); while (threadIds.hasNext()) threadId = threadIds.next(); final int finalThreadId = threadId; if (finalThreadId == -1) throw new NoSuchElementException("threadId not found"); Iterable<Conversation> conversationIterable = conversationWrapper .find(() -> conversationWrapper.selectByThread(finalThreadId)).toBlocking() .toIterable(); Iterator<Conversation> conversations = conversationIterable.iterator(); while (conversations.hasNext()) conversation = conversations.next(); if (conversation == null) throw new NoSuchElementException("conversation for threadId not found"); message.setConversation(conversation); } catch (NoSuchElementException e) { Log.e(LOG_TAG, "Couldn't find conversation for address: " + address, e); } synchronized (chatWebSocket) { chatWebSocket.send(PigeonApplication.getGson().toJson(message)); } } catch (Exception e) { Log.e(LOG_TAG, "ChatWebSocket failed to send: " + body, e); } }); }
From source file:com.msopentech.odatajclient.engine.data.ODataEntitySetIterator.java
/** * {@inheritDoc }/* w w w. j ava 2 s . c o m*/ */ @Override public ODataEntity next() { if (hasNext()) { final ODataEntity res = odataClient.getBinder().getODataEntity(cached); cached = null; return res; } throw new NoSuchElementException("No entity found"); }
From source file:is.landsbokasafn.deduplicator.indexer.CrawlLogIterator.java
/** * Returns the next valid item from the crawl log. * * @return An item from the crawl log. * @throws IOException If there is an error reading the item *after* the * item to be returned from the crawl.log. * @throws NoSuchElementException If there are no more items *///w ww . j ava 2 s .c o m public CrawlDataItem next() throws IOException { if (hasNext()) { CrawlDataItem tmp = next; this.next = null; return tmp; } throw new NoSuchElementException("No more items"); }
From source file:com.github.helenusdriver.commons.collections.iterators.SnapshotIterator.java
/** * {@inheritDoc}/*from w ww .j a v a 2 s. co m*/ * * @author paouelle * * @see java.util.Iterator#next() */ @Override public T next() { if (!hasNext()) { throw new NoSuchElementException("Snapshot Iterator"); } return list.get(current++); }
From source file:com.l2jfree.gameserver.model.skills.effects.templates.EffectTemplate.java
public EffectTemplate(StatsSet set, L2Skill skill) { name = set.getString("name"); lambda = set.getDouble("val", 0); count = Math.max(1, set.getInteger("count", 1)); int time = set.getInteger("time", 1) * skill.getTimeMulti(); if (time < 0) { if (count == 1) period = (int) TimeUnit.DAYS.toSeconds(10); // 'infinite' - still in integer range, even in msec else/*from ww w .j av a 2 s . c o m*/ throw new IllegalStateException("Invalid count (> 1) for effect with infinite duration!"); } else period = Math.max(1, time); if (set.contains("abnormal")) { final String abnormal = set.getString("abnormal").toLowerCase(); abnormalEffect = AbnormalEffect.getByName(abnormal).getMask(); } else abnormalEffect = 0; if (set.contains("special")) { final String special = set.getString("special").toLowerCase(); specialEffect = SpecialEffect.getByName(special).getMask(); } else specialEffect = 0; stackTypes = set.getString("stackType", skill.generateUniqueStackType()).split(";"); stackOrder = set.getFloat("stackOrder", skill.generateStackOrder()); for (int i = 0; i < stackTypes.length; i++) stackTypes[i] = stackTypes[i].intern(); if (stackTypes.length > 1 && stackOrder != 99) throw new IllegalStateException("'stackOrder' should be 99 for merged effects!"); showIcon = set.getInteger("noicon", 0) == 0; effectPower = set.getDouble("effectPower", -1); effectType = set.getEnum("effectType", L2SkillType.class, null); if ((effectPower == -1) != (effectType == null)) throw new IllegalArgumentException("Missing effectType/effectPower for effect: " + name); triggeredSkill = TriggeredSkill.parse(set); chanceCondition = ChanceCondition.parse(set); if ("ChanceSkillTrigger".equals(name)) { if (triggeredSkill == null) throw new NoSuchElementException(name + " requires proper TriggeredSkill parameters!"); if (chanceCondition == null) throw new NoSuchElementException(name + " requires proper ChanceCondition parameters!"); } else { if (triggeredSkill != null) throw new NoSuchElementException(name + " can't have TriggeredSkill parameters!"); if (chanceCondition != null) throw new NoSuchElementException(name + " can't have ChanceCondition parameters!"); } try { final StringBuilder sb = new StringBuilder(); sb.append(IEffectMarker.class.getPackage().getName()); sb.append(".Effect"); sb.append(name); final Class<?> clazz = Class.forName(sb.toString()); _constructor = clazz.getConstructor(Env.class, EffectTemplate.class); Constructor<?> stolenConstructor = null; try { stolenConstructor = clazz.getConstructor(Env.class, L2Effect.class); } catch (NoSuchMethodException e) { } _stolenConstructor = stolenConstructor; } catch (Exception e) { throw new RuntimeException(e); } }