Package services

Examples of services.Item


        try {
            Statement statement = connection.createStatement();
            ResultSet results = statement.executeQuery("select * from Cart");
            List<Entry<String, Item>> entries = new ArrayList<Entry<String, Item>>();
            while (results.next()) {
                Item item = new Item(results.getString("name"), results.getString("price"));
                entries.add(new Entry<String, Item>(results.getString("id"), item));
            }
            return entries.toArray(new Entry[entries.size()]);
        } catch (SQLException e) {
            throw new ServiceRuntimeException(e);
View Full Code Here


    public Item get(String key) throws NotFoundException {
        try {
            Statement statement = connection.createStatement();
            ResultSet results = statement.executeQuery("select * from Cart where id = '" + key + "'");
            if (results.next()) {
                return new Item(results.getString("name"), results.getString("price"));
            } else {
                throw new NotFoundException(key);
            }
        } catch (SQLException e) {
            throw new ServiceRuntimeException(e);
View Full Code Here

        try {
            Statement statement = connection.createStatement();
            ResultSet results = statement.executeQuery("select * from Cart where " + queryString);
            List<Entry<String, Item>> entries = new ArrayList<Entry<String, Item>>();
            while (results.next()) {
                Item item = new Item(results.getString("name"), results.getString("price"));
                entries.add(new Entry<String, Item>(results.getString("id"), item));
            }
            return entries.toArray(new Entry[entries.size()]);
        } catch (SQLException e) {
            throw new ServiceRuntimeException(e);
View Full Code Here

    public String getTotal() {
        Entry<String, Item>[] entries = getAll();
        double total = 0;
        String currencySymbol = "";
        if (entries.length > 0) {
            Item item = entries[0].getData();
            currencySymbol = item.getPrice().substring(0, 1);
        }
        for (Entry<String, Item> entry : entries) {
            Item item = entry.getData();
            total += Double.valueOf(item.getPrice().substring(1));
        }
        return currencySymbol + total;
    }
View Full Code Here

        try {
            Statement statement = connection.createStatement();
            ResultSet results = statement.executeQuery("select * from Cart");
            List<Entry<String, Item>> entries = new ArrayList<Entry<String, Item>>();
            while (results.next()) {
                Item item = new Item(results.getString("name"), results.getString("price"));
                entries.add(new Entry<String, Item>(results.getString("id"), item));
            }
            return entries.toArray(new Entry[entries.size()]);
        } catch (SQLException e) {
            throw new ServiceRuntimeException(e);
View Full Code Here

    public Item get(String key) throws NotFoundException {
        try {
            Statement statement = connection.createStatement();
            ResultSet results = statement.executeQuery("select * from Cart where id = '" + key + "'");
            if (results.next()) {
                return new Item(results.getString("name"), results.getString("price"));
            } else {
                throw new NotFoundException(key);
            }
        } catch (SQLException e) {
            throw new ServiceRuntimeException(e);
View Full Code Here

        try {
            Statement statement = connection.createStatement();
            ResultSet results = statement.executeQuery("select * from Cart where " + queryString);
            List<Entry<String, Item>> entries = new ArrayList<Entry<String, Item>>();
            while (results.next()) {
                Item item = new Item(results.getString("name"), results.getString("price"));
                entries.add(new Entry<String, Item>(results.getString("id"), item));
            }
            return entries.toArray(new Entry[entries.size()]);
        } catch (SQLException e) {
            throw new ServiceRuntimeException(e);
View Full Code Here

    public String getTotal() {
        Entry<String, Item>[] entries = getAll();
        double total = 0;
        String currencySymbol = "";
        if (entries.length > 0) {
            Item item = entries[0].getData();
            currencySymbol = item.getPrice().substring(0, 1);
        }
        for (Entry<String, Item> entry : entries) {
            Item item = entry.getData();
            total += Double.valueOf(item.getPrice().substring(1));
        }
        return currencySymbol + total;
    }
View Full Code Here

        } catch (RemoteException e) {
            throw new ServiceRuntimeException(e);
        }
        Item[] items = new Item[vegetables.length];
        for (int i = 0; i < vegetables.length; i++) {
            items[i] = new Item(vegetables[i].getName(), vegetables[i].getPrice());
        }
        return items;
    }
View Full Code Here

        Item[] catalog = new Item[fruits.length + vegetables.length];
        int i =0;
        for (Item item: fruits) {
            double price = Double.valueOf(item.getPrice().substring(1))
            price = currencyConverter.getConversion("USD", currencyCode, price);
            catalog[i++] = new Item(item.getName(), currencySymbol + price);
        }
       
        for (Item item: vegetables) {
            double price = Double.valueOf(item.getPrice().substring(1))
            price = currencyConverter.getConversion("USD", currencyCode, price);
            catalog[i++] = new Item(item.getName(), currencySymbol + price);
        }
       
        return catalog;
    }
View Full Code Here

TOP

Related Classes of services.Item

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.