/** * Gets elements depending on the format specified. * * @param format The format specification of the elements to be returned. * @return a List of all elements in MetaDB with the specified format. */ public List<Element> getElementList(String format) { List<Element> elementList = new ArrayList<Element>(); Connection conn = Conn.initialize(); if (conn != null) { try { PreparedStatement getElementListQuery = conn.prepareStatement(GET_ELEMENT_LIST_BY_FORMAT); getElementListQuery.setString(1, format); ResultSet getElementListQueryResult = getElementListQuery.executeQuery(); while (getElementListQueryResult.next()) elementList.add( new Element( getElementListQueryResult.getString(Global.ELEMENT), getElementListQueryResult.getString(Global.ELEMENT_FORMAT))); getElementListQueryResult.close(); getElementListQuery.close(); conn.close(); } catch (Exception e) { MetaDbHelper.logEvent(e); } } return elementList; }
/** * Returns all the elements in the database. * * @return a List of all elements in MetaDB. */ public static ArrayList<String> getElementList() { ArrayList<String> elementList = new ArrayList<String>(); Connection conn = Conn.initialize(); if (conn != null) { try { PreparedStatement getElementListQuery = conn.prepareStatement(GET_ELEMENT_LIST); ResultSet getElementListQueryResult = getElementListQuery.executeQuery(); while (getElementListQueryResult.next()) elementList.add(getElementListQueryResult.getString(Global.ELEMENT)); getElementListQueryResult.close(); getElementListQuery.close(); conn.close(); } catch (Exception e) { MetaDbHelper.logEvent(e); } } return elementList; }