Search in sources :

Example 46 with NoSuchElementException

use of java.util.NoSuchElementException in project voltdb by VoltDB.

the class TransferSQLText method parseFileForTables.

void parseFileForTables() throws DataAccessPointException {
    StringTokenizer Tokenizer;
    if (WTextRead == null) {
        try {
            WTextRead = new BufferedReader(new FileReader(sFileName));
        } catch (IOException e) {
            throw new DataAccessPointException(e.getMessage());
        }
    }
    String currentLine = "";
    String Token = "";
    String name = "";
    TransferTable relatedTable = null;
    try {
        while ((currentLine = WTextRead.readLine()) != null) {
            currentLine = currentLine.trim() + ";";
            Tokenizer = new StringTokenizer(currentLine);
            try {
                Token = Tokenizer.nextToken();
            } catch (NoSuchElementException NSE) {
                continue;
            }
            if (Token == null) {
                continue;
            }
            if (!Token.toUpperCase().equals("CREATE")) {
                continue;
            }
            Token = Tokenizer.nextToken().toUpperCase();
            if (Token.equals("TABLE") || Token.equals("VIEW")) {
                try {
                    name = Tokenizer.nextToken(" (;");
                    relatedTable = new TransferTable(this, name, "", Token, tracer);
                    relatedTable.Stmts.bCreate = false;
                    relatedTable.Stmts.bDelete = false;
                    relatedTable.Stmts.bDrop = false;
                    relatedTable.Stmts.bCreateIndex = false;
                    relatedTable.Stmts.bDropIndex = false;
                    relatedTable.Stmts.bInsert = false;
                    relatedTable.Stmts.bAlter = false;
                    DbStmts.put(relatedTable.Stmts.sSourceTable, relatedTable);
                } catch (NoSuchElementException NSE) {
                    continue;
                }
            }
        }
    } catch (Exception IOe) {
        throw new DataAccessPointException(IOe.getMessage());
    }
}
Also used : StringTokenizer(java.util.StringTokenizer) BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader) IOException(java.io.IOException) NoSuchElementException(java.util.NoSuchElementException) SQLException(java.sql.SQLException) IOException(java.io.IOException) NoSuchElementException(java.util.NoSuchElementException)

Example 47 with NoSuchElementException

use of java.util.NoSuchElementException in project voltdb by VoltDB.

the class TransferSQLText method getData.

TransferResultSet getData(String statement) throws DataAccessPointException {
    StringTokenizer Tokenizer;
    String tableName = "";
    try {
        Tokenizer = new StringTokenizer(statement);
        while (!Tokenizer.nextToken().toUpperCase().equals("FROM")) {
            ;
        }
        tableName = Tokenizer.nextToken(" ;");
    } catch (NoSuchElementException NSE) {
        throw new DataAccessPointException("Table name not found in statement: " + statement);
    }
    if (WTextRead != null) {
        try {
            WTextRead.close();
            WTextRead = null;
        } catch (IOException e) {
        }
    }
    return (this.parseFileForData(tableName));
}
Also used : StringTokenizer(java.util.StringTokenizer) IOException(java.io.IOException) NoSuchElementException(java.util.NoSuchElementException)

Example 48 with NoSuchElementException

use of java.util.NoSuchElementException in project Railcraft by Railcraft.

the class LinkageManager method linkIterator.

public Iterable<EntityMinecart> linkIterator(final EntityMinecart start, final LinkType type) {
    return () -> new Iterator<EntityMinecart>() {

        private final LinkageManager lm = LinkageManager.instance();

        private EntityMinecart last;

        private EntityMinecart current = start;

        @Override
        public boolean hasNext() {
            if (last == null) {
                EntityMinecart next = lm.getLinkedCart(current, type);
                return next != null;
            }
            EntityMinecart next = lm.getLinkedCartA(current);
            if (next != null && next != last)
                return true;
            next = lm.getLinkedCartB(current);
            return next != null && next != last;
        }

        @Override
        public EntityMinecart next() {
            if (last == null) {
                EntityMinecart next = lm.getLinkedCart(current, type);
                if (next == null)
                    throw new NoSuchElementException();
                last = current;
                current = next;
                return current;
            }
            EntityMinecart next = lm.getLinkedCartA(current);
            if (next != null && next != last) {
                last = current;
                current = next;
                return current;
            }
            next = lm.getLinkedCartB(current);
            if (next != null && next != last) {
                last = current;
                current = next;
                return current;
            }
            throw new NoSuchElementException();
        }

        @Override
        public void remove() {
            throw new UnsupportedOperationException("Removal not supported.");
        }
    };
}
Also used : Iterator(java.util.Iterator) EntityMinecart(net.minecraft.entity.item.EntityMinecart) ILinkageManager(mods.railcraft.api.carts.ILinkageManager) NoSuchElementException(java.util.NoSuchElementException)

Example 49 with NoSuchElementException

use of java.util.NoSuchElementException in project pcgen by PCGen.

the class EnvironmentModel method update.

/**
	 * Update the model
	 */
public void update() {
    VectorTable table;
    ReadXML reader;
    //$NON-NLS-1$
    File f = new File(dir, "environments.xml");
    this.removeAllElements();
    if (!f.exists()) {
        // TODO Make it so that the view also indicate that the file is missing.
        //$NON-NLS-1$
        Logging.errorPrintLocalised("in_plugin_encounter_error_missing", f);
        return;
    }
    reader = new ReadXML(f);
    table = reader.getTable();
    //$NON-NLS-1$
    this.addElement(LanguageBundle.getString("in_plugin_encounter_generic"));
    for (int x = 1; x < table.size(); x++) {
        try {
            this.addElement(((Vector) table.get(x)).firstElement());
        } catch (NoSuchElementException e) {
            break;
        }
    }
}
Also used : VectorTable(gmgen.io.VectorTable) File(java.io.File) NoSuchElementException(java.util.NoSuchElementException) ReadXML(gmgen.io.ReadXML)

Example 50 with NoSuchElementException

use of java.util.NoSuchElementException in project opennms by OpenNMS.

the class ResponseHandlingUtils method getMatchingIndex.

private static int getMatchingIndex(Expression exp, ListMultimap<String, String> valuesByName, int depth) throws NoSuchElementException {
    // Build the context with values from all the attributes at the current depth
    final StandardEvaluationContext context = new StandardEvaluationContext();
    int maxDepth = 0;
    for (String name : valuesByName.keySet()) {
        List<String> values = valuesByName.get(name);
        // Keep track of the largest depth
        maxDepth = Math.max(maxDepth, values.size());
        // Skip the variable if there are no values are the current depth
        if (values.size() < depth + 1) {
            continue;
        }
        // Store the value for the current depth in the context
        context.setVariable(name, values.get(depth));
    }
    // Evaluate our expression
    try {
        if (exp.getValue(context, Boolean.class)) {
            return depth;
        }
    } catch (Exception e) {
        LOG.error("Failed to evaluate expression {}. Msg: {}", exp.getExpressionString(), e.getMessage());
        throw new NoSuchElementException();
    }
    if (maxDepth > depth) {
        // Recurse
        return getMatchingIndex(exp, valuesByName, depth + 1);
    }
    throw new NoSuchElementException();
}
Also used : StandardEvaluationContext(org.springframework.expression.spel.support.StandardEvaluationContext) NoSuchElementException(java.util.NoSuchElementException) NoSuchElementException(java.util.NoSuchElementException)

Aggregations

NoSuchElementException (java.util.NoSuchElementException)1629 Iterator (java.util.Iterator)234 ArrayList (java.util.ArrayList)138 IOException (java.io.IOException)137 Test (org.junit.Test)95 StringTokenizer (java.util.StringTokenizer)88 Scanner (java.util.Scanner)86 Map (java.util.Map)56 List (java.util.List)54 File (java.io.File)51 HashMap (java.util.HashMap)47 InputMismatchException (java.util.InputMismatchException)47 LinkedList (java.util.LinkedList)32 HashSet (java.util.HashSet)31 Set (java.util.Set)29 CorruptDataException (com.ibm.j9ddr.CorruptDataException)28 Locale (java.util.Locale)27 Collection (java.util.Collection)26 BufferedReader (java.io.BufferedReader)24 Enumeration (java.util.Enumeration)24