List of usage examples for java.util NoSuchElementException NoSuchElementException
public NoSuchElementException(String s)
From source file:com.orange.mmp.api.ws.jsonrpc.SimpleJSONSerializer.java
/** * Replace getClassFromHint from super class to avoid using class hint * @param o a JSONObject or JSONArray object to get the Class type * @return the Class found, or null if the passed in Object is null * * @throws UnmarshallException if javaClass was not found *///from w w w . ja v a 2 s .com @SuppressWarnings("unchecked") private Class getClass(Object o) throws UnmarshallException { if (o == null) { return null; } if (o instanceof JSONArray) { JSONArray arr = (JSONArray) o; if (arr.length() == 0) { // throw new UnmarshallException("no type for empty array"); try { return Class.forName("[L" + Integer.class.getName() + ";"); } catch (ClassNotFoundException e) { // XXX Warning: if this block doesn't fit, just throw the following exception // This block is used by SynchronizeAPI, when an empty blocks list is provided throw new UnmarshallException("no type for empty array"); } } Class compClazz; try { compClazz = getClass(arr.get(0)); int arrayLgth = arr.length(); for (int index = 0; index < arrayLgth; index++) { if (!getClass(arr.get(index)).isAssignableFrom(compClazz)) { return java.util.List.class; } } } catch (JSONException e) { throw (NoSuchElementException) new NoSuchElementException(e.getMessage()).initCause(e); } try { if (compClazz.isArray()) { return Class.forName("[" + compClazz.getName()); } return Class.forName("[L" + compClazz.getName() + ";"); } catch (ClassNotFoundException e) { throw new UnmarshallException("problem getting array type"); } } return o.getClass(); }
From source file:com.sampas.socbs.core.data.arcsde.impl.ArcSDEPooledConnection.java
public synchronized SeTable getTable(final String tableName) throws DataSourceException { checkActive();/* w ww. jav a2s.co m*/ if (!cachedTables.containsKey(tableName)) { try { cacheLayers(); } catch (SeException e) { throw new DataSourceException("Can't obtain table " + tableName, e); } } SeTable seLayer = (SeTable) cachedTables.get(tableName); if (seLayer == null) { throw new NoSuchElementException("Table '" + tableName + "' not found"); } return seLayer; }
From source file:jef.tools.Assert.java
/** * ?// www. j a va 2s .c o m * @param value * @param array * @param msg */ public static <T> void isInArray(T value, T[] array, String msg) { if (!ArrayUtils.contains(array, value)) { throw new NoSuchElementException(msg); } }
From source file:forge.limited.BoosterDraft.java
protected boolean generateProduct() { switch (this.draftFormat) { case Full: // Draft from all cards in Forge final Supplier<List<PaperCard>> s = new UnOpenedProduct(SealedProduct.Template.genericBooster); for (int i = 0; i < 3; i++) { this.product.add(s); }/*from w ww . j ava 2 s .co m*/ IBoosterDraft.LAND_SET_CODE[0] = CardEdition.Predicates .getRandomSetWithAllBasicLands(FModel.getMagicDb().getEditions()); break; case Block: // Draft from cards by block or set case FantasyBlock: final List<CardBlock> blocks = new ArrayList<>(); final IStorage<CardBlock> storage = this.draftFormat == LimitedPoolType.Block ? FModel.getBlocks() : FModel.getFantasyBlocks(); for (final CardBlock b : storage) { if (b.getCntBoostersDraft() > 0) { blocks.add(b); } } final CardBlock block = SGuiChoose.oneOrNone("Choose Block", blocks); if (block == null) { return false; } final List<CardEdition> cardSets = block.getSets(); if (cardSets.isEmpty()) { SOptionPane.showErrorDialog(block.toString() + " does not contain any set combinations."); return false; } final Stack<String> sets = new Stack<>(); for (int k = cardSets.size() - 1; k >= 0; k--) { sets.add(cardSets.get(k).getCode()); } for (final String setCode : block.getMetaSetNames()) { if (block.getMetaSet(setCode).isDraftable()) { sets.push(setCode); // to the beginning } } final int nPacks = block.getCntBoostersDraft(); if (sets.size() > 1) { final Object p = SGuiChoose.oneOrNone("Choose Set Combination", getSetCombos(sets)); if (p == null) { return false; } final String[] pp = p.toString().split("/"); for (int i = 0; i < nPacks; i++) { this.product.add(block.getBooster(pp[i])); } } else { final IUnOpenedProduct product1 = block.getBooster(sets.get(0)); for (int i = 0; i < nPacks; i++) { this.product.add(product1); } } IBoosterDraft.LAND_SET_CODE[0] = block.getLandSet(); break; case Custom: final List<CustomLimited> myDrafts = loadCustomDrafts(); if (myDrafts.isEmpty()) { SOptionPane.showMessageDialog("No custom draft files found."); } else { final CustomLimited customDraft = SGuiChoose.oneOrNone("Choose Custom Draft", myDrafts); if (customDraft == null) { return false; } this.setupCustomDraft(customDraft); } break; default: throw new NoSuchElementException("Draft for mode " + this.draftFormat + " has not been set up!"); } this.pack = this.get8BoosterPack(); return true; }
From source file:com.impetus.client.cassandra.query.ResultIterator.java
@Override public E next() { if (current != null && checkOnEmptyResult() && current.equals(results.get(results.size() - 1))) { hasNext();/* ww w . ja va 2 s. c o m*/ } if (scrollComplete) { throw new NoSuchElementException("Nothing to scroll further for:" + entityMetadata.getEntityClazz()); } E lastFetchedEntity = getEntity(results.get(results.size() - 1)); start = lastFetchedEntity != null ? idValueInByteArr() : null; current = getEntity(results.get(results.size() - 1)); return current; }
From source file:eu.crisis_economics.configuration.FromFileConfigurationContext.java
IntegerPrimitiveExpression hasPrimitiveIntegerValueExpression(String literalName) { if (!knownIntegerPrimitiveDefinitions.containsKey(literalName)) throw new NoSuchElementException( "'" + literalName + "' does not have a primitive" + "integer definition."); return knownIntegerPrimitiveDefinitions.get(literalName); }
From source file:jef.tools.Assert.java
/** * ?/*from w w w. j a va2 s. com*/ * @param value * @param array */ public static <T> void isInArray(T value, T[] array) { if (!ArrayUtils.contains(array, value)) { throw new NoSuchElementException("Not found: " + value); } }
From source file:com.github.helenusdriver.commons.collections.iterators.CombinationIterator.java
/** * {@inheritDoc}// ww w.j a v a2 s .c o m * * @author paouelle * * @see java.util.Iterator#next() */ @Override public List<T> next() { if (!hasNext()) { throw new NoSuchElementException("CombinationIterator"); } this.hasNext = false; return Arrays.asList(current); }
From source file:com.devicehive.service.NetworkService.java
@Transactional public NetworkVO update(@NotNull Long networkId, NetworkUpdate networkUpdate) { NetworkVO existing = networkDao.find(networkId); if (existing == null) { throw new NoSuchElementException(String.format(Messages.NETWORK_NOT_FOUND, networkId)); }/* w w w. jav a2 s .c om*/ if (networkUpdate.getKey() != null) { existing.setKey(networkUpdate.getKey().orElse(null)); } if (networkUpdate.getName() != null) { existing.setName(networkUpdate.getName().orElse(null)); } if (networkUpdate.getDescription() != null) { existing.setDescription(networkUpdate.getDescription().orElse(null)); } hiveValidator.validate(existing); return networkDao.merge(existing); }
From source file:jef.tools.Assert.java
/** * ?s/*from ww w .ja v a 2s.c o m*/ * @param value * @param array */ public static void isInArray(int value, int[] array) { if (!ArrayUtils.contains(array, value)) { throw new NoSuchElementException("Not Found: " + value); } }