1 26 27 29 package de.nava.informa.impl.hibernate; 30 31 import de.nava.informa.core.ChannelGroupIF; 32 import de.nava.informa.core.ChannelIF; 33 34 import java.util.ArrayList ; 35 import java.util.Collection ; 36 import java.util.HashSet ; 37 import java.util.Iterator ; 38 import java.util.Set ; 39 40 48 public class ChannelGroup implements ChannelGroupIF, java.io.Serializable { 49 50 private int id = -1; 51 private String title; 52 private ChannelGroupIF parent; 53 54 private Set channels; 55 private Collection children; 56 57 public ChannelGroup() { 58 this("Unnamed channel group"); 59 } 60 61 public ChannelGroup(String title) { 62 this(null, title); 63 } 64 65 public ChannelGroup(ChannelGroupIF parent, String title) { 66 this.title = title; 67 this.channels = new HashSet (); 68 this.parent = parent; 69 this.children = new ArrayList (); 70 } 71 72 76 85 public int getIntId() { 86 return id; 87 } 88 89 public void setIntId(int anId) { 90 this.id = anId; 91 } 92 93 public long getId() { 94 return id; 95 } 96 97 public void setId(long longid) { 98 this.id = (int) longid; 99 } 100 101 108 public String getTitle() { 109 return title; 110 } 111 112 public void setTitle(String aTitle) { 113 this.title = aTitle; 114 } 115 116 129 public Set getChannels() { 130 return channels; 131 } 132 133 public void setChannels(Set aChannels) { 134 this.channels = aChannels; 135 } 136 137 public void add(ChannelIF channel) { 138 channels.add(channel); 139 } 140 141 public void remove(ChannelIF channel) { 142 channels.remove(channel); 143 } 144 145 public Collection getAll() { 146 return getChannels(); 147 } 148 149 public ChannelIF getById(long channelId) { 150 Iterator it = getChannels().iterator(); 151 while (it.hasNext()) { 152 ChannelIF channel = (ChannelIF) it.next(); 153 if (channel.getId() == channelId) { 154 return channel; 155 } 156 } 157 return null; 158 } 159 160 167 public ChannelGroupIF getParent() { 168 return parent; 169 } 170 171 public void setParent(ChannelGroupIF group) { 172 this.parent = group; 173 } 174 175 186 public Collection getChildren() { 187 return children; 188 } 189 190 public void setChildren(Collection aChildren) { 191 this.children = aChildren; 192 } 193 194 public void addChild(ChannelGroupIF child) { 195 getChildren().add(child); 196 child.setParent(this); 197 } 198 199 public void removeChild(ChannelGroupIF child) { 200 getChildren().remove(child); 201 } 202 203 207 212 public String toString() { 213 return "[Hibernate ChannelGroup \"" + getTitle() + "\"(id=" + id + ")]"; 214 } 215 } 216 | Popular Tags |