01: /*
02: * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com>
03: * Distributed under the terms of either:
04: * - the common development and distribution license (CDDL), v1.0; or
05: * - the GNU Lesser General Public License, v2.1 or later
06: * $Id: SiteModel.java 3634 2007-01-08 21:42:24Z gbevin $
07: */
08: package com.uwyn.rife.gui.model;
09:
10: import java.util.Collection;
11:
12: import com.uwyn.rife.gui.model.exceptions.GuiModelException;
13: import com.uwyn.rife.gui.model.exceptions.SiteElementAlreadyPresentException;
14:
15: public class SiteModel extends ParticleModel {
16: public SiteModel() {
17: super ();
18: }
19:
20: public void addElement(ElementModel element)
21: throws GuiModelException {
22: if (null == element)
23: throw new IllegalArgumentException("element can't be null.");
24:
25: try {
26: addChild(element);
27: } catch (GuiModelException e) {
28: throw new SiteElementAlreadyPresentException(e);
29: }
30:
31: assert getChildren().contains(element);
32: }
33:
34: public Collection<ElementModel> getElements() {
35: Collection<ElementModel> result = getChildren(ElementModel.class);
36:
37: assert result != null;
38:
39: return result;
40: }
41:
42: public int countElements() {
43: int result = countChildren(ElementModel.class);
44:
45: assert result >= 0;
46:
47: return result;
48: }
49: }
|