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 | */
|
---|
27 | package org.greenstone.gatherer.cdm;
|
---|
28 |
|
---|
29 | /**************************************************************************************
|
---|
30 | * Written: 02/07/03
|
---|
31 | * Revised:
|
---|
32 | **************************************************************************************/
|
---|
33 | import org.w3c.dom.Element;
|
---|
34 |
|
---|
35 | public class SuperCollection
|
---|
36 | implements DOMProxyListEntry {
|
---|
37 |
|
---|
38 | private Element element;
|
---|
39 | private String name;
|
---|
40 |
|
---|
41 | public SuperCollection() {
|
---|
42 | element = null;
|
---|
43 | name = null;
|
---|
44 | }
|
---|
45 |
|
---|
46 | public SuperCollection(Element element) {
|
---|
47 | this.element = element;
|
---|
48 | name = null;
|
---|
49 | }
|
---|
50 |
|
---|
51 | public int compareTo(Object other) {
|
---|
52 | return this.getName().compareTo(other.toString());
|
---|
53 | }
|
---|
54 |
|
---|
55 | public DOMProxyListEntry create(Element element) {
|
---|
56 | return new SuperCollection(element);
|
---|
57 | }
|
---|
58 |
|
---|
59 | public boolean equals(Object other) {
|
---|
60 | return (compareTo(other) == 0);
|
---|
61 | }
|
---|
62 |
|
---|
63 | public Element getElement() {
|
---|
64 | return element;
|
---|
65 | }
|
---|
66 |
|
---|
67 | public String getName() {
|
---|
68 | if(name == null && element != null) {
|
---|
69 | name = element.getAttribute(CollectionConfiguration.NAME_ATTRIBUTE);
|
---|
70 | }
|
---|
71 | return name;
|
---|
72 | }
|
---|
73 |
|
---|
74 | public boolean isAssigned() {
|
---|
75 | return (element != null && element.getAttribute(CollectionConfiguration.ASSIGNED_ATTRIBUTE).equals(CollectionConfiguration.TRUE_STR));
|
---|
76 | }
|
---|
77 |
|
---|
78 | public void setAssigned(boolean assigned) {
|
---|
79 | if(element != null) {
|
---|
80 | element.setAttribute(CollectionConfiguration.ASSIGNED_ATTRIBUTE, (assigned ? CollectionConfiguration.TRUE_STR : CollectionConfiguration.FALSE_STR));
|
---|
81 | }
|
---|
82 | }
|
---|
83 |
|
---|
84 | public void setElement(Element element) {
|
---|
85 | this.element = element;
|
---|
86 | name = null;
|
---|
87 | }
|
---|
88 |
|
---|
89 | public void setName(String name) {
|
---|
90 | this.name = name;
|
---|
91 | if(element != null) {
|
---|
92 | element.setAttribute(CollectionConfiguration.NAME_ATTRIBUTE, name);
|
---|
93 | }
|
---|
94 | }
|
---|
95 |
|
---|
96 | public String toString() {
|
---|
97 | return getName();
|
---|
98 | }
|
---|
99 | }
|
---|