source: gli/branches/rtl-gli/src/org/greenstone/gatherer/cdm/SuperCollection.java@ 18368

Last change on this file since 18368 was 12641, checked in by mdewsnip, 18 years ago

Changed all access to the static strings through CollectionConfiguration to directly use StaticStrings.

  • Property svn:keywords set to Author Date Id Revision
File size: 2.7 KB
Line 
1/**
2 *#########################################################################
3 *
4 * A component of the Gatherer application, part of the Greenstone digital
5 * library suite from the New Zealand Digital Library Project at the
6 * University of Waikato, New Zealand.
7 *
8 * Author: John Thompson, Greenstone Digital Library, University of Waikato
9 *
10 * Copyright (C) 1999 New Zealand Digital Library Project
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17* This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 *########################################################################
26 */
27package org.greenstone.gatherer.cdm;
28
29import org.greenstone.gatherer.util.StaticStrings;
30import org.w3c.dom.Element;
31
32
33public class SuperCollection
34 implements DOMProxyListEntry {
35
36 private Element element;
37 private String name;
38
39 public SuperCollection() {
40 element = null;
41 name = null;
42 }
43
44 public SuperCollection(Element element) {
45 this.element = element;
46 name = null;
47 }
48
49 public int compareTo(Object other) {
50 return this.getName().compareTo(other.toString());
51 }
52
53 public DOMProxyListEntry create(Element element) {
54 return new SuperCollection(element);
55 }
56
57 public boolean equals(Object other) {
58 return (compareTo(other) == 0);
59 }
60
61 public Element getElement() {
62 return element;
63 }
64
65 public String getName() {
66 if(name == null && element != null) {
67 name = element.getAttribute(StaticStrings.NAME_ATTRIBUTE);
68 }
69 return name;
70 }
71
72 public boolean isAssigned() {
73 return (element != null && element.getAttribute(StaticStrings.ASSIGNED_ATTRIBUTE).equals(StaticStrings.TRUE_STR));
74 }
75
76 public void setAssigned(boolean assigned) {
77 if(element != null) {
78 element.setAttribute(StaticStrings.ASSIGNED_ATTRIBUTE, (assigned ? StaticStrings.TRUE_STR : StaticStrings.FALSE_STR));
79 }
80 }
81
82 public void setElement(Element element) {
83 this.element = element;
84 name = null;
85 }
86
87 public void setName(String name) {
88 this.name = name;
89 if(element != null) {
90 element.setAttribute(StaticStrings.NAME_ATTRIBUTE, name);
91 }
92 }
93
94 public String toString() {
95 return getName();
96 }
97}
Note: See TracBrowser for help on using the repository browser.