XXX

Iterate and return for native queries. Returns a List&lt;Object&gt; or a List&lt;Object[]&gt;

@param rSet
the r set
@return the list
550588
private List iterateAndReturnNative(final ResultSet rSet) {
        final Iterator<Row> rowIter = rSet.iterator();
        final List results = new ArrayList();
        final List item = new ArrayList<>();

        final boolean isSingle = (rSet.getColumnDefinitions().size() == 1);

        while (rowIter.hasNext()) {
            final Row row = rowIter.next();

            final ColumnDefinitions columnDefs = row.getColumnDefinitions();

            final Iterator<Definition> columnDefIter = columnDefs.iterator();

            item.clear();

            while (columnDefIter.hasNext()) {
                final Definition columnDef = columnDefIter.next();

                item.add(DSClientUtilities.assign(row, null, null, columnDef.getType().getName(), null,
                    columnDef.getName(), null, null));
            }

            if (isSingle) {
                if (!item.isEmpty())
                    results.add(item.get(0));
                else
                    results.add(null);
            } else
                results.add(item.toArray(new Object[item.size()]));
        }

        return results;
    }
470454
private List<?> getResultList(Query query) {
        // TODO : use lazy fetch here?
        if (projection != null) {
            List<?> results = query.getResultList();
            List<Object> rv = new ArrayList<Object>(results.size());
            for (Object o : results) {
                if (o != null) {
                    if (!o.getClass().isArray()) {
                        o = new Object[]{o};
                    }
                    rv.add(projection.newInstance((Object[]) o));
                } else {
                    rv.add(null);
                }
            }
            return rv;
        } else {
            return query.getResultList();
        }
    }
135946
@SuppressWarnings("unchecked")
    public static <T> Set<T> jsonArrayToSet(final JSONArray jsonArray) {
        if (null == jsonArray) {
            return Collections.emptySet();
        }

        final Set<T> ret = new HashSet<T>();

        for (int i = 0; i < jsonArray.length(); i++) {
            ret.add((T) jsonArray.opt(i));
        }

        return ret;
    }
59063
protected ImageDataProvider getDataProvider (final String rset)
    {
        if (rset == null) {
            return _defaultProvider;
        }

        ImageDataProvider dprov = _providers.get(rset);
        if (dprov == null) {
            dprov = new ImageDataProvider() {
                public BufferedImage loadImage (String path)
                    throws IOException {
                    // first attempt to load the image from the specified resource set
                    try {
                        return _rmgr.getImageResource(rset, path);
                    } catch (FileNotFoundException fnfe) {
                        // fall back to trying the classpath
                        return _rmgr.getImageResource(path);
                    }
                }

                public String getIdent () {
                    return "rmgr:" + rset;
                }
            };
            _providers.put(rset, dprov);
        }

        return dprov;
    }
1311255
public static <T> Set<T> immutableSetCopy(Set<T> set) {
      if (set == null) return null;
      if (set.isEmpty()) return Collections.emptySet();
      if (set.size() == 1) return Collections.singleton(set.iterator().next());
      Set<? extends T> copy = ObjectDuplicator.duplicateSet(set);
      if (copy == null)
         // Set uses Collection copy-ctor
         copy = attemptCopyConstructor(set, Collection.class);
      if (copy == null)
         copy = new HashSet<>(set);

      return new ImmutableSetWrapper<>(copy);
   }
513111
protected function normalizeResultSet(array $resultSet)
    {
        $normalized = [];

        foreach ($resultSet as $result) {
            if (($normalizedResult = $this->normalizeResult($result)) === null) {
                continue;
            }

            $normalized[$normalizedResult] = $normalizedResult;
        }

        return array_keys($normalized);
    }
1059559
@Override
    public DataBinder process(ResultSet rset) throws Exception {
        try {
            if (rset.next()) {
                ResultSetMetaData meta = rset.getMetaData();
                int width = meta.getColumnCount();
                for (int i = 1; i <= width; ++i) {
                    Object value = rset.getObject(i);
                    if (value != null) {
                        put(Strings.toLowerCamelCase(meta.getColumnLabel(i), '_'), value.toString());
                    }
                }
            } else {
                throw new NoSuchElementException("NoSuchRow");
            }
            return this;
        } finally {
            rset.close();
        }
    }
628841
@SuppressWarnings("unchecked")
    public static List<Integer> getAt(int[] array, Collection indices) {
        return primitiveArrayGet(array, indices);
    }
681457
Index getIndexForColumns(OrderedIntHashSet set) {

        int   maxMatchCount = 0;
        Index selected      = null;

        if (set.isEmpty()) {
            return null;
        }

        for (int i = 0, count = indexList.length; i < count; i++) {
            Index currentindex = getIndex(i);
            int[] indexcols    = currentindex.getColumns();
            int   matchCount   = set.getOrderedMatchCount(indexcols);

            if (matchCount == 0) {
                continue;
            }

            if (matchCount == indexcols.length) {
                return currentindex;
            }

            if (matchCount > maxMatchCount) {
                maxMatchCount = matchCount;
                selected      = currentindex;
            }
        }

        if (selected != null) {
            return selected;
        }

        switch (tableType) {

            case TableBase.SYSTEM_SUBQUERY :
            case TableBase.SYSTEM_TABLE :
            case TableBase.VIEW_TABLE :
            case TableBase.TEMP_TABLE : {
                selected = createIndexForColumns(set.toArray());
            }
        }

        return selected;
    }
251458
public List<RDN> rdns() {
        List<RDN> list = rdnList;
        if (list == null) {
            list = Collections.unmodifiableList(Arrays.asList(names));
            rdnList = list;
        }
        return list;
    }
568494
private QueryParameters convertResultSetNextLine(ResultSet rs) throws SQLException {
        QueryParameters result = null;

        if (rs.next() == true) {
            result = convertResultSetCurrentLine(rs);
        }

        return result;
    }
1340111
public function process(SearchResultSet $resultSet)
    {
        if (!$resultSet instanceof SearchResultSet) {
            return $resultSet;
        }

        $resultSet = $this->parseSpellCheckingResponseIntoObjects($resultSet);
        $resultSet = $this->parseSortingIntoObjects($resultSet);

        // here we can reconstitute other domain objects from the solr response
        $resultSet = $this->parseFacetsIntoObjects($resultSet);

        return $resultSet;
    }
633794
public static List<IterableResult<?>> getIterableResults(Result r) {
    if(r instanceof IterableResult<?>) {
      List<IterableResult<?>> irs = new ArrayList<>(1);
      irs.add((IterableResult<?>) r);
      return irs;
    }
    if(r instanceof HierarchicalResult) {
      return filterResults(((HierarchicalResult) r).getHierarchy(), r, IterableResult.class);
    }
    return Collections.emptyList();
  }
1300454
public static Type fromExceptionSet(ExceptionSet exceptionSet) throws ClassNotFoundException {
        Type commonSupertype = exceptionSet.getCommonSupertype();
        if (commonSupertype.getType() != Const.T_OBJECT) {
            return commonSupertype;
        }

        ObjectType exceptionSupertype = (ObjectType) commonSupertype;

        String className = exceptionSupertype.getClassName();
        if ("java.lang.Throwable".equals(className)) {
            return exceptionSupertype;
        }
        return new ExceptionObjectType(className, exceptionSet);
    }
196121
private IEntityLock instanceFromResultSet(java.sql.ResultSet rs)
            throws SQLException, LockingException {
        Integer entityTypeID = rs.getInt(1);
        Class entityType = EntityTypesLocator.getEntityTypes().getEntityTypeFromID(entityTypeID);
        String key = rs.getString(2);
        int lockType = rs.getInt(3);
        Timestamp ts = rs.getTimestamp(4);
        String lockOwner = rs.getString(5);

        return newInstance(entityType, key, lockType, ts, lockOwner);
    }
415318
public List<CDKRMap> bitSetToRMap(BitSet set) {
        List<CDKRMap> rMapList = new ArrayList<CDKRMap>();

        for (int x = set.nextSetBit(0); x >= 0; x = set.nextSetBit(x + 1)) {
            CDKRNode xNode = getGraph().get(x);
            rMapList.add(xNode.getRMap());
        }
        return rMapList;
    }
943417
public static List<String> getLabels(Set dataSet) {
        char[] c = getLabelsArray(dataSet);
        List<String> l = new ArrayList<>(c.length);
        for (char c2 : c) {
            l.add(String.valueOf(c2));
        }
        return l;
    }