Wraps a DB collection in a JacksonDBCollection

@param dbCollection The DB collection to wrap
@param type         The type of objects to deserialise to
@return The wrapped collection
557545
public static <T> JacksonDBCollection<T, Object> wrap(DBCollection dbCollection, Class<T> type) {
        return new JacksonDBCollection<T, Object>(dbCollection, DEFAULT_OBJECT_MAPPER.constructType(type),
                DEFAULT_OBJECT_MAPPER.constructType(Object.class), DEFAULT_OBJECT_MAPPER, null);
    }
914076
public <R, RK> List<R> fetch(Collection<DBRef<R, RK>> collection) {
        return fetch(collection, null);
    }
194438
public static Collection toCollection(String input, Class<?> collectionClass, Class<?> genericClass,
            String mediaType)
    {

        try
        {
            if (MediaType.APPLICATION_XML.equals(mediaType))
            {
                Collection c = (Collection) collectionClass.newInstance();
                if (input.startsWith("<?xml"))
                {
                    input = input.substring(input.indexOf(">") + 1, input.length());
                }

                input = input.replaceAll("<" + genericClass.getSimpleName().toLowerCase() + "s>", "");

                while (!input.equals(""))
                {
                    int i = input.indexOf("</" + genericClass.getSimpleName().toLowerCase() + ">");
                    String s = input.substring(0, i + 3 + genericClass.getSimpleName().length());
                    input = input.substring(i + 3 + genericClass.getSimpleName().length(), input.length());
                    Object o = JAXBUtils.toObject(StreamUtils.toInputStream(s), genericClass, mediaType);
                    c.add(o);
                }
                return c;

            }
            else if (MediaType.APPLICATION_JSON.equals(mediaType))
            {
                
                    return  JAXBUtils.mapper.readValue(input, JAXBUtils.mapper.getTypeFactory()
                                        .constructCollectionType((Class<? extends Collection>) collectionClass, genericClass));
               
                
            }
            return null;
        }
        catch (InstantiationException e)
        {
            log.error("Error during translation, Caused by:" + e.getMessage() + ", returning null");
            return null;
        }
        catch (IllegalAccessException e)
        {
            log.error("Error during translation, Caused by:" + e.getMessage() + ", returning null");
            return null;
        } catch (JsonParseException e) {
            log.error("Error during translation, Caused by:" + e.getMessage() + ", returning null");
            return null;
        } catch (JsonMappingException e) {
            log.error("Error during translation, Caused by:" + e.getMessage() + ", returning null");
            return null;
        } catch (IOException e) {
            log.error("Error during translation, Caused by:" + e.getMessage() + ", returning null");
            return null;
        }
    }
199937
public static MongoCollection<Document> createCollection(MongoDatabase db,
            String collectionName, CreateCollectionOptions options) {
        db.createCollection(collectionName, options);
        return db.getCollection(collectionName);
    }
1072621
public static <T, J extends Convertable<T>> ArrayList<T> convert(Collection<J> collection) {
        if (collection == null) {
            return null;
        }

        ArrayList<T> list = new ArrayList<>(collection.size());

        for (J json : collection) {
            try {
                T item = json == null ? null : json.convert();
                if (item != null) {
                    list.add(item);
                }
            } catch (ParseException e) {
                Log.e("ConvertUtils", "Error converting item (" + json.getClass().getSimpleName()
                        + ") : " + e.getMessage());
            }
        }

        return list;
    }
620675
public static <T> List<T> convertCollectionToList(final Collection<T> collection) {

        if(List.class.isAssignableFrom(collection.getClass())) {
            return (List<T>)collection;
        }

        return new ArrayList<>(collection);

    }
1262225
@Override
    public DBCursor cursor(DBCollection dbCollection) {
        return dbCollection.find(query, fieldsToRetrieve).setDecoderFactory(decoderFactory);
    }
540653
@Override
	public <E> String serializeCollection(Collection<E> collection, Class<E> objectClazz) {
		if (collection == null)
			return null;

		SegmentedStringWriter source = new SegmentedStringWriter(buffer.get());
		try (SerializerWrapper serializer = createSerializer(source)) {
			mapperFor(objectClazz).serializeCollection(this, serializer, collection);
		} catch (Exception e) {
			e.printStackTrace();
			throw new KriptonRuntimeException(e);
		}
		return source.getAndClear();
	}
277207
@Deprecated
    public Class<?> getClassFromCollection(final String collection) {
        final Set<MappedClass> mcs = mappedClassesByCollection.get(collection);
        if (mcs == null || mcs.isEmpty()) {
            throw new MappingException(format("The collection '%s' is not mapped to a java class.", collection));
        }
        if (mcs.size() > 1) {
            if (LOG.isInfoEnabled()) {
                LOG.info(format("Found more than one class mapped to collection '%s'%s", collection, mcs));
            }
        }
        return mcs.iterator().next().getClazz();
    }
129842
function (cb) {
          if (opts.dropCollection) {
            db.listCollections({name: collectionName})
              .toArray(function (err, items) {
                if (err) return cb(err)
                if (items.length) return coll.drop(cb)
                cb()
              })
          } else cb()
        }
1226636
private static String getCollectionInnerType(Class<?> type) {
        CQL3Type.Native nativeType = MAP_JAVA_TYPE_TO_CQL_TYPE.get(type);
        return nativeType.name().toLowerCase();
    }
168769
public static String createTypeCollectionId(Collection<? extends Type> types) {
        StringBuilder builder = new StringBuilder();
        List<? extends Type> sortedTypes = new ArrayList<Type>(types);
        Collections.sort(sortedTypes, TypeComparator.INSTANCE);
        builder.append("[");
        for (Iterator<? extends Type> iterator = sortedTypes.iterator(); iterator.hasNext();) {
            builder.append(createTypeId(iterator.next()));
            if (iterator.hasNext()) {
                builder.append(",");
            }
        }
        builder.append("]");
        return builder.toString();
    }
330279
public static Collection toCollection( JSONArray jsonArray, JsonConfig jsonConfig ) {
      Collection collection = null;
      Class collectionType = jsonConfig.getCollectionType();

      if( collectionType.isInterface() ){
         if( collectionType.equals( List.class ) ){
            collection = new ArrayList();
         }else if( collectionType.equals( Set.class ) ){
            collection = new HashSet();
         }else{
            throw new JSONException( "unknown interface: " + collectionType );
         }
      }else{
         try{
            collection = (Collection) collectionType.newInstance();
         }catch( InstantiationException e ){
            throw new JSONException( e );
         }catch( IllegalAccessException e ){
            throw new JSONException( e );
         }
      }

      Class objectClass = jsonConfig.getRootClass();
      Map classMap = jsonConfig.getClassMap();

      int size = jsonArray.size();
      for( int i = 0; i < size; i++ ){
         Object value = jsonArray.get( i );

         if( JSONUtils.isNull( value ) ){
            collection.add( null );
         }else{
            Class type = value.getClass();
            if( JSONArray.class.isAssignableFrom( value.getClass() ) ){
               collection.add( toCollection( (JSONArray) value, jsonConfig ) );
            }else if( String.class.isAssignableFrom( type )
                  || Boolean.class.isAssignableFrom( type ) || JSONUtils.isNumber( type )
                  || Character.class.isAssignableFrom( type )
                  || JSONFunction.class.isAssignableFrom( type ) ){
               if( objectClass != null && !objectClass.isAssignableFrom( type ) ){
                  value = JSONUtils.getMorpherRegistry()
                     .morph( objectClass, value );
               }
               collection.add( value );
            }else{
               if( objectClass != null ){
                  JsonConfig jsc = jsonConfig.copy();
                  jsc.setRootClass( objectClass );
                  jsc.setClassMap( classMap );
                  collection.add( JSONObject.toBean( (JSONObject) value, jsc ) );
               }else{
                  collection.add( JSONObject.toBean( (JSONObject) value ) );
               }
            }
         }
      }

      return collection;
   }
222869
@When("^I execute a query '(.+?)' of type '(json|string)' in mongo '(.+?)' database using collection '(.+?)' with:$")
    public void sendQueryOfType(String query, String type, String database, String collection, DataTable modifications) throws Exception {
        try {
            commonspec.setResultsType("mongo");
            String retrievedData = commonspec.retrieveData(query, type);
            String modifiedData = commonspec.modifyData(retrievedData, type, modifications);
            commonspec.getMongoDBClient().connectToMongoDBDataBase(database);
            DBCollection dbCollection = commonspec.getMongoDBClient().getMongoDBCollection(collection);
            DBObject dbObject = (DBObject) JSON.parse(modifiedData);
            DBCursor cursor = dbCollection.find(dbObject);
            commonspec.setMongoResults(cursor);
        } catch (Exception e) {
            commonspec.getExceptions().add(e);
        }
    }
1150844
public Collection<String> wrap(Collection<String> fields){
		if(CollectionUtil.isEmpty(fields)) {
			return fields;
		}
		
		return Arrays.asList(wrap(fields.toArray(new String[fields.size()])));
	}
480582
public function allCollections($wrap = false)
    {
        $collections = $this->database->listCollections();

        if (! $wrap) {
            return $collections;
        }

        return array_map(
            function ($collection) {
                return new Collection($collection);
            },
            $collections
        );
    }
743965
public static Function<Object, Collection<?>> COLLECTION(final Class<? extends Collection> collectionType) {
      return as(new CollectionConverterImpl<>(collectionType, null));
   }