final String description = "search string"; final Iterable<Item> filtered = FluentIterable.from(unfiltered) .filter(new Predicate<Item>() { @Override public boolean apply(final Item input) { return input.getDescription().contains(desciption); } });
public static Predicate<Item> filterDescription(final String desciption){ return new Predicate<Item>() { @Override public boolean apply(Item input) { return input.getDescription() != null && input.getDescription().contains(desciption); } }; }
for (Item x : favourites) { if(description.equals(x.getDescription())) { return x; return null;
ArrayList<Item> favourites; public Item finditem(String description) { for (Item x : favourites) if(description.equals(x.getDescription())) return x; return null; }
Iterator<Item> i = items.iterator(); while (i.hasNext()) { Item items = i.next(); if (items.getDescription() != null && items.getDescription().equals(description)) { i.remove(); System.out.print("Item removed!"); return; } }
public static void write(Map<Integer, Item> items, Map<Integer, Store> stores, List<Stock> stocks) { System.out.println(); System.out.println("Inventory Report"); System.out.println("----------------"); for(Stock stock : stocks) { // <-- for all Stocks Store store = stores.get(stock.getStoreID()); // <-- get Store Item item = items.get(stock.getItemSKU()); // <-- get Item System.out.println(item.getDescription() + "is from store" + store.getId() + "in" + store.getCity() + "and costs" + item.getPrice()); } }
public MyAdapter(Context context, ArrayList<Item> itemsArrayList) { super(context, R.layout.row, itemsArrayList); this.context = context; Map<String,String> this.map = new Hashmap<String,String>(); for(Item i : itemsArrayList){ this.map.put(i.getTitle(),i.getDescription()); } this.itemsArrayList = itemsArrayList;//not needed }
public void removeItem(String description) { Iterator<Item> i = items.iterator(); while (i.hasNext()) { Item items = i.next(); if (items.getDescription().equals(description)) { i.remove(); System.out.print("Item removed!"); return; } } }
/** * remove item */ public void removeItem(String description) { Iterator<Item> i = items.iterator(); //ok, so the variable items is probably a class field Item items = i.next(); //...we just overwrote our class field items with the first item from iter... if items.getDescription().equals(description) { //we don't have parenthesis around our if statement...? i.remove(); //ok, we removed the item because it was equal } else { System.out.println("Invalid item description"); //it wasn't equal, so we say we got an invalid description } //aaaand apparently we are done. We only checked the first item in "items" System.out.println("Item removed!"); //this is outside of the if statement, so we will print this every time }
protected void populateItem(Item item, Element eItem, int index) { super.populateItem(item,eItem, index); Description description = item.getDescription(); if (description!=null) { eItem.addContent(generateSimpleElement("description",description.getValue())); } if (item.getModule(getContentNamespace().getURI()) == null && item.getContent() != null) { Element elem = new Element("encoded", getContentNamespace()); elem.addContent(item.getContent().getValue()); eItem.addContent(elem); } }
protected void populateItem(Item item, Element eItem, int index) { super.populateItem(item,eItem, index); Description description = item.getDescription(); if (description!=null) { eItem.addContent(generateSimpleElement("description",description.getValue())); } if (item.getModule(getContentNamespace().getURI()) == null && item.getContent() != null) { Element elem = new Element("encoded", getContentNamespace()); elem.addContent(item.getContent().getValue()); eItem.addContent(elem); } }
protected void populateItem(Item item, Element eItem, int index) { super.populateItem(item,eItem, index); Description description = item.getDescription(); if (description!=null && description.getType()!=null) { Element eDescription = eItem.getChild("description",getFeedNamespace()); eDescription.setAttribute(new Attribute("type",description.getType())); } eItem.removeChild("expirationDate",getFeedNamespace()); }
protected void populateItem(Item item, Element eItem, int index) { super.populateItem(item,eItem, index); Description description = item.getDescription(); if (description!=null && description.getType()!=null) { Element eDescription = eItem.getChild("description",getFeedNamespace()); eDescription.setAttribute(new Attribute("type",description.getType())); } eItem.removeChild("expirationDate",getFeedNamespace()); }
protected void populateItem(Item item, Element eItem, int index) { super.populateItem(item,eItem, index); Description description = item.getDescription(); if (description!=null && description.getType()!=null) { Element eDescription = eItem.getChild("description",getFeedNamespace()); eDescription.setAttribute(new Attribute("type",description.getType())); } eItem.removeChild("expirationDate",getFeedNamespace()); }
protected SyndEntry createSyndEntry(Item item, boolean preserveWireItem) { SyndEntry syndEntry = super.createSyndEntry(item, preserveWireItem); Description desc = item.getDescription(); if (desc!=null) { SyndContent descContent = new SyndContentImpl(); descContent.setType(desc.getType()); descContent.setValue(desc.getValue()); syndEntry.setDescription(descContent); } Content cont = item.getContent(); if (cont!=null) { SyndContent contContent = new SyndContentImpl(); contContent.setType(cont.getType()); contContent.setValue(cont.getValue()); List contents = new ArrayList(); contents.add(contContent); syndEntry.setContents(contents); } return syndEntry; }
protected void populateItem(Item item, Element eItem, int index) { super.populateItem(item,eItem, index); Description description = item.getDescription(); if (description!=null && description.getType()!=null) { Element eDescription = eItem.getChild("description",getFeedNamespace()); eDescription.setAttribute(new Attribute("type",description.getType())); } eItem.removeChild("expirationDate",getFeedNamespace()); }
protected void populateItem(Item item, Element eItem, int index) { super.populateItem(item, eItem, index); Description description = item.getDescription(); if (description != null) { eItem.addContent(generateSimpleElement("description", description.getValue())); } if ((item.getModule(getContentNamespace().getURI()) == null) && (item.getContent() != null)) { Element elem = new Element("encoded", getContentNamespace()); elem.addContent(item.getContent().getValue()); eItem.addContent(elem); } } }
protected void populateItem(Item item, Element eItem, int index) { super.populateItem(item, eItem, index); Description description = item.getDescription(); if (description != null) { eItem.addContent(generateSimpleElement("description", description.getValue())); } if ((item.getModule(getContentNamespace().getURI()) == null) && (item.getContent() != null)) { Element elem = new Element("encoded", getContentNamespace()); elem.addContent(item.getContent().getValue()); eItem.addContent(elem); } } }
protected Item parseItem(Element rssRoot,Element eItem) { Item item = super.parseItem(rssRoot,eItem); Element e = eItem.getChild("pubDate",getRSSNamespace()); if (e!=null) { item.setPubDate(DateParser.parseDate(e.getText())); } e = eItem.getChild("expirationDate",getRSSNamespace()); if (e!=null) { item.setExpirationDate(DateParser.parseDate(e.getText())); } e = eItem.getChild("description",getRSSNamespace()); if (e!=null) { String type = e.getAttributeValue("type"); if (type!=null) { item.getDescription().setType(type); } } return item; }
protected void populateItem(Item item, Element eItem, int index) { super.populateItem(item,eItem, index); String link = item.getLink(); String uri = item.getUri(); if (uri != null) { eItem.setAttribute("about", uri, getRDFNamespace()); } else if (link != null) { eItem.setAttribute("about", link, getRDFNamespace()); } Description description = item.getDescription(); if (description!=null) { eItem.addContent(generateSimpleElement("description", description.getValue())); } if (item.getModule(getContentNamespace().getURI()) == null && item.getContent() != null) { Element elem = new Element("encoded", getContentNamespace()); elem.addContent(item.getContent().getValue()); eItem.addContent(elem); } }