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());
}
}
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));
}
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.");
}
};
}
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;
}
}
}
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();
}
Aggregations