Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
package groovy.sql;
This class defines a wrapper for accessing a specific column in ResultSetMetaData. This allows iteration over columns using idiomatic Groovy, e.g.:
 meta.each {col ->
   println col.columnName
All ResultSetMetaData column methods taking a column index are available on a column either as a no-arg getter or via a property.

This wrapper is created by an iterator invoked for ResultSetMetaData.

John Hurst
See also:
    private static final Object[] EMPTY_OBJECT_ARRAY = new Object[0];
    private ResultSetMetaData target;
    private int index;
    public ResultSetMetaDataWrapper(ResultSetMetaData targetint index) {
        this. = target;
        this. = index;
    private Object[] getIndexedArgs(Object[] originalArgs) {
        Object[] result = new Object[originalArgs.length + 1];
        result[0] = ;
        for (int i = 0, originalArgsLength = originalArgs.lengthi < originalArgsLengthi++) {
            result[i + 1] = originalArgs[i];
        return result;
    public Object invokeMethod(String nameObject args) {
        Object[] indexedArgs = getIndexedArgs((Object[]) args);
        return InvokerHelper.invokeMethod(nameindexedArgs);
    private String getPropertyGetterName(String prop) {
        if (prop == null || prop.length() < 1) {
            throw new MissingPropertyException(prop.getClass());
        return "get" + prop.substring(0, 1).toUpperCase() + prop.substring(1);
    public Object getProperty(String property) {
        return invokeMethod(getPropertyGetterName(property), );
    public void setProperty(String propertyObject newValue) {
        throw new ReadOnlyPropertyException(property.getClass());
New to GrepCode? Check out our FAQ X