1 26 27 29 package de.nava.informa.impl.basic; 30 31 import java.net.URL ; 32 import java.util.Date ; 33 import java.util.Properties ; 34 35 import org.apache.commons.logging.Log; 36 import org.apache.commons.logging.LogFactory; 37 38 import org.jdom.Element; 39 40 import de.nava.informa.core.CategoryIF; 41 import de.nava.informa.core.ChannelBuilderException; 42 import de.nava.informa.core.ChannelBuilderIF; 43 import de.nava.informa.core.ChannelGroupIF; 44 import de.nava.informa.core.ChannelIF; 45 import de.nava.informa.core.CloudIF; 46 import de.nava.informa.core.ImageIF; 47 import de.nava.informa.core.ItemEnclosureIF; 48 import de.nava.informa.core.ItemGuidIF; 49 import de.nava.informa.core.ItemIF; 50 import de.nava.informa.core.ItemSourceIF; 51 import de.nava.informa.core.TextInputIF; 52 53 59 public class ChannelBuilder implements ChannelBuilderIF { 60 61 private static Log logger = LogFactory.getLog(ChannelBuilder.class); 62 63 public ChannelBuilder() { 64 logger.debug("New channel builder for the in-memory backend"); 65 } 66 67 71 public void init(Properties props) throws ChannelBuilderException { 72 logger.debug("Initialising channel builder for in-memory backend"); 73 } 74 75 public ChannelGroupIF createChannelGroup(String title) { 76 return new ChannelGroup(title); 77 } 78 79 public ChannelIF createChannel(String title) { 80 return new Channel(title); 81 } 82 83 public ChannelIF createChannel(Element channelElement, String title) { 84 return new Channel(channelElement, title); 85 } 86 87 public ItemIF createItem(ChannelIF channel, String title, String description, 88 URL link) { 89 return createItem(null, channel, title, description, link); 90 } 91 92 public ItemIF createItem(Element itemElement, ChannelIF channel, String title, String description, 93 URL link) { 94 ItemIF item = new Item(itemElement, channel, title, description, link); 95 if (channel != null) { 96 channel.addItem(item); 97 } 98 return item; 99 } 100 101 106 public ItemIF createItem(ChannelIF chan, ItemIF oldItem) 107 { 108 return createItem(null, chan, oldItem.getTitle(), oldItem.getDescription(), oldItem.getLink()); 109 } 110 111 public ImageIF createImage(String title, URL location, URL link) { 112 return new Image(title, location, link); 113 } 114 115 public TextInputIF createTextInput(String title, String description, String name, URL link) { 116 return new TextInput(title, description, name, link); 117 } 118 119 public CloudIF createCloud(String domain, int port, String path, String registerProcedure, String protocol) { 120 logger.info("ChannelBuilder is creating a Basic Cloud"); 121 return new Cloud(domain, port, path, registerProcedure, protocol); 122 } 123 124 public ItemSourceIF createItemSource(ItemIF item, String name, String location, Date timestamp) { 125 return new ItemSource(item, name, location, timestamp); 126 } 127 128 public ItemEnclosureIF createItemEnclosure(ItemIF item, URL location, String type, int length) { 129 return new ItemEnclosure(item, location, type, length); 130 } 131 132 public ItemGuidIF createItemGuid(ItemIF item, String location, boolean permaLink) { 133 return new ItemGuid(item, location, permaLink); 134 } 135 136 public CategoryIF createCategory(CategoryIF parent, String title) { 137 CategoryIF cat = new Category(title); 138 if (parent != null) { 139 parent.addChild(cat); 140 } 141 return cat; 142 } 143 144 149 public void close() throws ChannelBuilderException { 150 logger.debug("Closing channel builder for in-memory backend"); 151 } 152 153 public void beginTransaction() throws ChannelBuilderException 154 { 155 logger.debug("No-op beginTransaction for in-memory backend"); 156 } 157 158 public void endTransaction() throws ChannelBuilderException 159 { 160 logger.debug("No-op endTransaction for in-memory backend"); 161 } 162 163 public void update(Object obj) 164 { 165 logger.debug("No-op update for in-memory backend"); 166 } 167 } 168 | Popular Tags |