001 package market; 002 003 import data.CatalogItem; 004 import data.ooimpl.CatalogImpl; 005 006 /** 007 * A CatalogImpl, where the CIArticles of the market are stored. The market's offer, and therefore 008 * this catalog, never changes. 009 */ 010 public class CArticleCatalog extends CatalogImpl { 011 012 /** 013 * ID for serialization. 014 */ 015 private static final long serialVersionUID = 7115018608362610522L; 016 017 /** 018 * @param name the ID of the CArticleCatalog 019 */ 020 public CArticleCatalog(String name) { 021 super(name); 022 } 023 024 /** 025 * Adds a CatalogItem to the catalog. Used as a shortcut for <code>add(item, null)</code>. 026 * @param item the CatalogItem to be added. 027 */ 028 public void add(CatalogItem item) { 029 add(item, null); 030 } 031 032 /** 033 * Removes a CatalogItem from the catalog. Used as a shortcut for <code>remove(name, null)</code> 034 * including the try-catch-block. 035 * @param name the name of the CatalogItem to be removed. 036 */ 037 public void remove(String name) { 038 try { 039 remove(name, null); 040 } 041 catch (Exception e) { 042 System.err.println(e.getMessage()); 043 } 044 } 045 046 /** 047 * Gets a CatalogItem by its name. Used as a shortcut for <code>get(name, null)</code> 048 * including the try-catch-block. 049 * 050 * @param name the name of the searched CatalogItem. 051 * @return the searched CatalogItem if found, otherwise <code>null</code>. 052 */ 053 public CIArticle get(String name) { 054 try { 055 return (CIArticle)get(name, null, false); 056 } 057 catch (Exception e) { 058 System.err.println(e.getMessage()); 059 return null; 060 } 061 } 062 }