Example usage for com.mongodb DBCursor hasNext

List of usage examples for com.mongodb DBCursor hasNext

Introduction

In this page you can find the example usage for com.mongodb DBCursor hasNext.

Prototype

@Override
public boolean hasNext() 

Source Link

Document

Checks if there is another object available.

Usage

From source file:bd.DPersona.java

@Override
public Object buscar_id(String id_find) {
    ArrayList datos = new ArrayList();
    CPersona x = new CPersona();
    conecion con = new conecion(table);
    BasicDBObject id = new BasicDBObject("_id", new ObjectId(id_find));
    DBCursor cursor = con.get_colletion().find(id);

    try {//from  w  ww.j a  v a 2s  . c  o m
        while (cursor.hasNext()) {
            x = new CPersona();
            x.set_datos((HashMap) cursor.next().toMap());
            datos.add(x);
        }
    } finally {
        cursor.close();
    }
    con.end();
    if (datos.size() == 0)
        return null;
    return datos.get(0);
}

From source file:bd.DPersona.java

@Override
public ArrayList listar(String clave, String valor) {
    ArrayList datos = new ArrayList();
    CPersona x = new CPersona();
    conecion con = new conecion(table);
    BasicDBObject id = new BasicDBObject(clave, valor);
    DBCursor cursor = con.get_colletion().find(id);

    try {//from w  w  w  . j  a v a2s . co  m
        while (cursor.hasNext()) {
            x = new CPersona();
            x.set_datos((HashMap) cursor.next().toMap());
            datos.add(x);
        }
    } finally {
        cursor.close();
    }
    con.end();

    return datos;
}

From source file:bd.DPersona.java

@Override
public ArrayList listar(HashMap map) {
    ArrayList datos = new ArrayList();
    CPersona x = new CPersona();
    conecion con = new conecion(table);
    BasicDBObject id = new BasicDBObject(map);
    DBCursor cursor = con.get_colletion().find(id);

    try {//  w  w  w . ja  v  a 2  s .com
        while (cursor.hasNext()) {
            x = new CPersona();
            x.set_datos((HashMap) cursor.next().toMap());
            datos.add(x);
        }
    } finally {
        cursor.close();
    }
    con.end();

    return datos;
}

From source file:bd.DSession.java

@Override
public ArrayList listar() {
    ArrayList datos = new ArrayList();
    CSession x = new CSession();
    conecion con = new conecion(table);
    DBCursor cursor = con.get_colletion().find();
    try {/*from w  w  w.  j av a  2s .  c o  m*/
        while (cursor.hasNext()) {
            x = new CSession();
            BasicDBObject agg = (BasicDBObject) cursor.next();
            x.set_datos((HashMap) agg.toMap());
            x.setId((String) agg.getString("_id"));
            datos.add(x);
        }
    } finally {
        cursor.close();
    }
    con.end();
    return datos;
}

From source file:bd.DSession.java

@Override
public Object buscar_id(String id_find) {
    ArrayList datos = new ArrayList();
    CSession x = new CSession();
    conecion con = new conecion(table);
    System.out.println(id_find + "warrennnnn");
    BasicDBObject id = new BasicDBObject("_id", new ObjectId(id_find));
    DBCursor cursor = con.get_colletion().find(id);

    try {/* w  w w .j av a 2s  . c o m*/
        while (cursor.hasNext()) {
            x = new CSession();
            x.set_datos((HashMap) cursor.next().toMap());
            datos.add(x);
        }
    } finally {
        cursor.close();
    }
    con.end();
    if (datos.size() == 0)
        return null;
    return datos.get(0);
}

From source file:bd.DSession.java

@Override
public ArrayList listar(String clave, String valor) {
    ArrayList datos = new ArrayList();
    CSession x = new CSession();
    conecion con = new conecion(table);
    BasicDBObject id = new BasicDBObject(clave, valor);
    DBCursor cursor = con.get_colletion().find(id);

    try {//ww w.  j av a2s  .c  o m
        while (cursor.hasNext()) {
            x = new CSession();
            x.set_datos((HashMap) cursor.next().toMap());
            datos.add(x);
        }
    } finally {
        cursor.close();
    }
    con.end();

    return datos;
}

From source file:bd.DSession.java

@Override
public ArrayList listar(HashMap map) {
    ArrayList datos = new ArrayList();
    CSession x = new CSession();
    conecion con = new conecion(table);
    BasicDBObject id = new BasicDBObject(map);
    DBCursor cursor = con.get_colletion().find(id);

    try {/*from w  w w.  ja  v a 2  s.  c o  m*/
        while (cursor.hasNext()) {
            x = new CSession();
            x.set_datos((HashMap) cursor.next().toMap());
            datos.add(x);
        }
    } finally {
        cursor.close();
    }
    con.end();

    return datos;
}

From source file:bd.DVenta.java

@Override
public ArrayList listar() {
    ArrayList datos = new ArrayList();
    CVenta x = new CVenta();
    conecion con = new conecion(table);
    DBCursor cursor = con.get_colletion().find();
    try {/*w  ww. ja v  a2 s  .c o m*/
        while (cursor.hasNext()) {
            x = new CVenta();
            BasicDBObject agg = (BasicDBObject) cursor.next();
            x.set_datos((HashMap) agg.toMap());
            x.setId((String) agg.getString("_id"));
            datos.add(x);
        }
    } finally {
        cursor.close();
    }
    con.end();
    return datos;
}

From source file:bd.DVenta.java

@Override
public Object buscar_id(String id_find) {
    ArrayList datos = new ArrayList();
    CVenta x = new CVenta();
    conecion con = new conecion(table);
    BasicDBObject id = new BasicDBObject("_id", new ObjectId(id_find));
    DBCursor cursor = con.get_colletion().find(id);

    try {/*from  w  w w  .  j a  v a  2 s .c  o m*/
        while (cursor.hasNext()) {
            x = new CVenta();
            x.set_datos((HashMap) cursor.next().toMap());
            datos.add(x);
        }
    } finally {
        cursor.close();
    }
    con.end();
    if (datos.size() == 0)
        return null;
    return datos.get(0);
}

From source file:bd.DVenta.java

@Override
public ArrayList listar(String clave, String valor) {
    ArrayList datos = new ArrayList();
    CVenta x = new CVenta();
    conecion con = new conecion(table);
    BasicDBObject id = new BasicDBObject(clave, valor);
    DBCursor cursor = con.get_colletion().find(id);

    try {/*from w w w . j  av  a2 s  . co  m*/
        while (cursor.hasNext()) {
            x = new CVenta();
            x.set_datos((HashMap) cursor.next().toMap());
            datos.add(x);
        }
    } finally {
        cursor.close();
    }
    con.end();

    return datos;
}