source: trunk/gli/src/org/greenstone/gatherer/cdm/SuperCollection.java@ 4932

Last change on this file since 4932 was 4932, checked in by jmt12, 21 years ago

Major CDM rewrite so it uses DOM.

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