1 26 27 29 package de.nava.informa.impl.basic; 30 31 import de.nava.informa.core.ChannelGroupIF; 32 import de.nava.informa.core.ChannelIF; 33 34 import java.util.Collection ; 35 import java.util.ArrayList ; 36 import java.util.Iterator ; 37 import java.util.List ; 38 39 44 public class ChannelGroup implements ChannelGroupIF, 45 java.io.Serializable { 46 47 private long id; 48 private String title; 49 private Collection channels; 50 private ChannelGroupIF parent; 51 private List children; 52 53 public ChannelGroup() { 54 this("[Unknown title]"); 55 } 56 57 public ChannelGroup(String title) { 58 this(IdGenerator.getInstance().getId(), null, title); 59 } 60 61 public ChannelGroup(long id, String title) { 62 this(id, null, title); 63 } 64 65 public ChannelGroup(long id, ChannelGroupIF parent, String title) { 66 this.id = id; 67 this.title = title; 68 this.channels = new ArrayList (); 69 this.parent = parent; 70 this.children = new ArrayList (); 71 } 72 73 77 public long getId() { 78 return id; 79 } 80 81 public void setId(long id) { 82 this.id = id; 83 } 84 85 public String getTitle() { 86 return title; 87 } 88 89 public void setTitle(String title) { 90 this.title = title; 91 } 92 93 public void add(ChannelIF channel) { 94 channels.add(channel); 95 } 96 97 public void remove(ChannelIF channel) { 98 channels.remove(channel); 99 } 100 101 public Collection getAll() { 102 return channels; 103 } 104 105 public ChannelIF getById(long id) { 106 Iterator it = channels.iterator(); 107 while (it.hasNext()) { 108 ChannelIF channel = (ChannelIF) it.next(); 109 if (channel.getId() == id) { 110 return channel; 111 } 112 } 113 return null; 114 } 115 116 public ChannelGroupIF getParent() { 117 return parent; 118 } 119 120 public void setParent(ChannelGroupIF parent) { 121 this.parent = parent; 122 } 123 124 public Collection getChildren() { 125 return children; 126 } 127 128 public void addChild(ChannelGroupIF child) { 129 children.add(child); 130 child.setParent(this); 131 } 132 133 public void removeChild(ChannelGroupIF child) { 134 children.remove(child); 135 } 136 137 141 public String toString() { 142 return "[ChannelGroup (" + id + ")]"; 143 } 144 145 } 146 | Popular Tags |