Example usage for java.util List get

List of usage examples for java.util List get

Introduction

In this page you can find the example usage for java.util List get.

Prototype

E get(int index);

Source Link

Document

Returns the element at the specified position in this list.

Usage

From source file:Main.java

public static void main(String[] args) throws Exception {
    String xml = "<?xml version='1.0' encoding='UTF-8'?>" + "<Employees>"
            + "  <Employee emplid='1' type='admin'>" + "    <firstname/>" + "    <lastname>A</lastname>"
            + "    <age>30</age>" + "    <email>j@s.com</email>" + "  </Employee>"
            + "  <Employee emplid='2' type='admin'>" + "    <firstname>S</firstname>"
            + "    <lastname>H</lastname>" + "    <age>32</age>" + "    <email>s@h.com</email>"
            + "  </Employee>" + "</Employees>";
    List<String> ids = Arrays.asList("1", "2");
    for (int i = 0; i < ids.size(); i++) {
        String employeeId = ids.get(i);
        String xpath = "/Employees/Employee[@emplid='" + employeeId + "']/firstname";
        XPath xPath = XPathFactory.newInstance().newXPath();
        String employeeFirstName = xPath.evaluate(xpath, new InputSource(new StringReader(xml)));
        if (employeeFirstName == "") {
            System.out.println("Employee " + employeeId + " has no first name.");
        } else {//from   ww w  .j  ava  2 s .com
            System.out.println("Employee " + employeeId + "'s first name is " + employeeFirstName);
        }
    }
}

From source file:net.awl.edoc.pdfa.font.CFFTest.java

/**
 * @param args/*from  w w w.j a  va 2  s.c om*/
 */
public static void main(String[] args) throws Exception {
    FileInputStream fis = new FileInputStream("/home/eric/UneCFFType0.cff0");
    // FileInputStream fis = new FileInputStream("/home/eric/UneCFFType2.cff2");
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    IOUtils.copyLarge(fis, bos);

    CFFParser cp = new CFFParser();
    List<CFFFont> lf = cp.parse(bos.toByteArray());

    CFFFontROS font = (CFFFontROS) lf.get(0);
    System.out.println("CharstringType : " + font.getProperty("CharstringType"));

    int CID = 85;
    int fdAIndex = font.getFdSelect().getFd(CID);
    Map<String, Object> fd = font.getFontDict().get(fdAIndex);
    Map<String, Object> pd = font.getPrivDict().get(fdAIndex);
    for (Mapping m : font.getMappings()) {
        if (m.getSID() == CID) {
            // List<Object> l1 = new
            // Type1CharStringParser().parse(font.getCharStringsDict().get(m.getName()));
            List<Object> l2 = new Type2CharStringParser().parse(m.getBytes());
            System.err.println("");
        }
    }
    System.out.println("");
}

From source file:Main.java

public static void main(String[] args) {
    String data = "<root><row><column name='username' length='6'>admin</column>"
            + "<column name='password' length='1'>p</column></row><row>"
            + "<column name='username' length='6'>j</column>"
            + "<column name='password' length='8'>q</column></row></root>";

    SAXBuilder builder = new SAXBuilder();
    Document document = builder.build(new ByteArrayInputStream(data.getBytes()));

    Element root = document.getRootElement();

    List rows = root.getChildren("row");
    for (int i = 0; i < rows.size(); i++) {
        Element row = (Element) rows.get(i);
        List columns = row.getChildren("column");
        for (int j = 0; j < columns.size(); j++) {
            Element column = (Element) columns.get(j);
            String name = column.getAttribute("name").getValue();
            String value = column.getText();
            int length = column.getAttribute("length").getIntValue();

            System.out.println("name = " + name);
            System.out.println("value = " + value);
            System.out.println("length = " + length);
        }/*from   www  .  j  a va2 s .  com*/
    }
}

From source file:com.khartec.waltz.jobs.UserAgentInfoHarness.java

public static void main(String[] args) {

    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    UserAgentInfoDao userLoginDao = ctx.getBean(UserAgentInfoDao.class);
    DSLContext dsl = ctx.getBean(DSLContext.class);

    List<UserAgentInfo> infos = userLoginDao.findLoginsForUser("admin", 10);
    System.out.println(infos);//from  ww  w .  j  a v a  2  s.co  m

    userLoginDao.save(infos.get(0));
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    List drivers = Collections.list(DriverManager.getDrivers());
    for (int i = 0; i < drivers.size(); i++) {
        Driver driver = (Driver) drivers.get(i);

        String name = driver.getClass().getName();
        System.out.println(name);

        int majorVersion = driver.getMajorVersion();
        System.out.println(majorVersion);
        int minorVersion = driver.getMinorVersion();
        System.out.println(minorVersion);
        boolean isJdbcCompliant = driver.jdbcCompliant();
        System.out.println(isJdbcCompliant);
    }/*from  w  w w  . j a v  a2  s  . co  m*/
}

From source file:FileExtensionsDemo.java

public static void main(String[] args) {
    ScriptEngineManager manager = new ScriptEngineManager();
    List<ScriptEngineFactory> factories = manager.getEngineFactories();
    for (ScriptEngineFactory factory : factories) {
        List<String> ext = factory.getExtensions();
        for (int i = 0; i < ext.size(); i++) {
            System.out.printf("Supported file extension: " + (String) ext.get(i) + "\n");
        }/*from ww w .jav a  2s  . co  m*/
    }
}

From source file:org.seasar.dao.spring.example.Employee2DaoClient.java

public static void main(final String[] args) {
    final BeanFactoryLocator locator = ContextSingletonBeanFactoryLocator.getInstance();
    final BeanFactoryReference ref = locator.useBeanFactory("context");
    final ApplicationContext context = (ApplicationContext) ref.getFactory();
    try {/*from  w  w w.j  av  a  2  s  .co m*/
        final Employee2Dao dao = (Employee2Dao) context.getBean("employee2Dao");
        final List employees = dao.getEmployees("CO");
        for (int i = 0; i < employees.size(); ++i) {
            System.out.println(employees.get(i));
        }
        final Employee employee = dao.getEmployee(7788);
        System.out.println(employee);
    } finally {
        ref.release();
    }

}

From source file:RegisteredNameDemo.java

public static void main(String[] args) {
    ScriptEngineManager manager = new ScriptEngineManager();
    List<ScriptEngineFactory> factories = manager.getEngineFactories();
    for (ScriptEngineFactory factory : factories) {
        List<String> regNames = factory.getNames();
        for (int i = 0; i < regNames.size(); i++) {
            System.out.printf("Registered name " + i + " " + (String) regNames.get(i) + "\n");
        }//from w w w .  j  a v  a 2  s.co m
    }
}

From source file:com.apress.prospringintegration.springenterprise.stocks.runner.MainHibernateEntityManager.java

public static void main(String[] args) {
    GenericApplicationContext context = new AnnotationConfigApplicationContext(
            "com.apress.prospringintegration.springenterprise.stocks.dao.jpaandentitymanagers");

    StockDao stockDao = context.getBean("jpaStockDao", StockDao.class);
    Stock stock = new Stock("ORAC", "JPAMAIN0001", "QQQQ", 120.0f, 1100, Calendar.getInstance().getTime());
    stockDao.insert(stock);/*from  ww w  .j a v a 2 s  .c  om*/

    List<Stock> stocks = stockDao.findAvailableStockBySymbol("ORAC");

    if (stocks != null && stocks.size() > 0) {
        stock = stocks.get(0);
        System.out.println("Stock Symbol :" + stock.getSymbol());
        System.out.println("Inventory Code :" + stock.getInventoryCode());
        System.out.println("purchased price:" + stock.getSharePrice());
        System.out.println("Exchange ID:" + stock.getExchangeId());
        System.out.println("Quantity Available :" + stock.getQuantityAvailable());
    }
}

From source file:com.apress.prospringintegration.springenterprise.stocks.runner.MainHibernateJPA.java

public static void main(String[] args) {
    GenericApplicationContext context = new AnnotationConfigApplicationContext(
            "com.apress.prospringintegration.springenterprise.stocks.dao.jpa");

    StockDao stockDao = context.getBean("jpaStockDao", StockDao.class);
    Stock stock = new Stock("ORAC", "JPAMAIN0001", "QQQQ", 120.0f, 1100, Calendar.getInstance().getTime());
    stockDao.insert(stock);/*  w  w  w.j a v a2 s .c om*/

    List<Stock> stocks = stockDao.findAvailableStockBySymbol("ORAC");

    if (stocks != null && stocks.size() > 0) {
        stock = stocks.get(0);
        System.out.println("Stock Symbol :" + stock.getSymbol());
        System.out.println("Inventory Code :" + stock.getInventoryCode());
        System.out.println("purchased price:" + stock.getSharePrice());
        System.out.println("Exchange ID:" + stock.getExchangeId());
        System.out.println("Quantity Available :" + stock.getQuantityAvailable());
    }
}