use of java.util.Iterator in project groovy-core by groovy.
the class GroovyResultSetExtension method add.
/**
* Adds a new row to the result set
*
* @param values a map containing the mappings for column names and values
* @throws java.sql.SQLException if something goes wrong
* @see ResultSet#insertRow()
* @see ResultSet#updateObject(java.lang.String, java.lang.Object)
* @see ResultSet#moveToInsertRow()
*/
public void add(Map values) throws SQLException {
getResultSet().moveToInsertRow();
for (Iterator iter = values.entrySet().iterator(); iter.hasNext(); ) {
Map.Entry entry = (Map.Entry) iter.next();
getResultSet().updateObject(entry.getKey().toString(), entry.getValue());
}
getResultSet().insertRow();
}
use of java.util.Iterator in project groovy-core by groovy.
the class GroovyRowResult method getAt.
/**
* Retrieve the value of the property by its index.
* A negative index will count backwards from the last column.
*
* @param index is the number of the column to look at
* @return the value of the property
*/
public Object getAt(int index) {
try {
// a negative index will count backwards from the last column.
if (index < 0)
index += result.size();
Iterator it = result.values().iterator();
int i = 0;
Object obj = null;
while ((obj == null) && (it.hasNext())) {
if (i == index)
obj = it.next();
else
it.next();
i++;
}
return obj;
} catch (Exception e) {
throw new MissingPropertyException(Integer.toString(index), GroovyRowResult.class, e);
}
}
use of java.util.Iterator in project groovy-core by groovy.
the class SwingGroovyMethods method buildRowData.
private static Object[] buildRowData(DefaultTableModel delegate, Object row) {
int cols = delegate.getColumnCount();
Object[] rowData = new Object[cols];
int i = 0;
for (Iterator it = DefaultGroovyMethods.iterator(row); it.hasNext() && i < cols; ) {
rowData[i++] = it.next();
}
return rowData;
}
use of java.util.Iterator in project groovy-core by groovy.
the class TableLayoutRow method addCell.
/**
* Adds a new cell to this row
* @param tag the td element
*/
public void addCell(groovy.swing.impl.TableLayoutCell tag) {
int gridx = 0;
for (Iterator iter = cells.iterator(); iter.hasNext(); ) {
groovy.swing.impl.TableLayoutCell cell = (groovy.swing.impl.TableLayoutCell) iter.next();
gridx += cell.getColspan();
}
tag.getConstraints().gridx = gridx;
cells.add(tag);
}
use of java.util.Iterator in project groovy-core by groovy.
the class Attributes method text.
public String text() {
final StringBuilder sb = new StringBuilder();
final Iterator iter = iterator();
while (iter.hasNext()) {
sb.append(iter.next());
}
return sb.toString();
}
Aggregations