001: //=============================================================================
002: //=== Copyright (C) 2001-2007 Food and Agriculture Organization of the
003: //=== United Nations (FAO-UN), United Nations World Food Programme (WFP)
004: //=== and United Nations Environment Programme (UNEP)
005: //===
006: //=== This program is free software; you can redistribute it and/or modify
007: //=== it under the terms of the GNU General Public License as published by
008: //=== the Free Software Foundation; either version 2 of the License, or (at
009: //=== your option) any later version.
010: //===
011: //=== This program is distributed in the hope that it will be useful, but
012: //=== WITHOUT ANY WARRANTY; without even the implied warranty of
013: //=== MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: //=== General Public License for more details.
015: //===
016: //=== You should have received a copy of the GNU General Public License
017: //=== along with this program; if not, write to the Free Software
018: //=== Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
019: //===
020: //=== Contact: Jeroen Ticheler - FAO - Viale delle Terme di Caracalla 2,
021: //=== Rome - Italy. email: geonetwork@osgeo.org
022: //==============================================================================
023:
024: package org.fao.oaipmh.responses;
025:
026: import java.util.ArrayList;
027: import java.util.Iterator;
028: import java.util.List;
029: import org.fao.oaipmh.OaiPmh;
030: import org.fao.oaipmh.util.Lib;
031: import org.jdom.Element;
032:
033: //=============================================================================
034:
035: public class SetInfo {
036: //---------------------------------------------------------------------------
037: //---
038: //--- Constructor
039: //---
040: //---------------------------------------------------------------------------
041:
042: public SetInfo() {
043: }
044:
045: //---------------------------------------------------------------------------
046:
047: public SetInfo(String spec, String name) {
048: this .spec = spec;
049: this .name = name;
050: }
051:
052: //---------------------------------------------------------------------------
053:
054: public SetInfo(Element set) {
055: build(set);
056: }
057:
058: //---------------------------------------------------------------------------
059: //---
060: //--- API methods
061: //---
062: //---------------------------------------------------------------------------
063:
064: public String getSpec() {
065: return spec;
066: }
067:
068: public String getName() {
069: return name;
070: }
071:
072: //---------------------------------------------------------------------------
073:
074: public Iterator<Element> getDescriptions() {
075: return descriptions.iterator();
076: }
077:
078: //---------------------------------------------------------------------------
079:
080: public Element toXml() {
081: Element set = new Element("set", OaiPmh.Namespaces.OAI_PMH);
082:
083: Lib.add(set, "setSpec", spec);
084: Lib.add(set, "setName", name);
085:
086: for (Element descr : descriptions)
087: set.addContent((Element) descr.clone());
088:
089: return set;
090: }
091:
092: //---------------------------------------------------------------------------
093: //---
094: //--- Private methods
095: //---
096: //---------------------------------------------------------------------------
097:
098: private void build(Element set) {
099: spec = set.getChildText("setSpec", OaiPmh.Namespaces.OAI_PMH);
100: name = set.getChildText("setName", OaiPmh.Namespaces.OAI_PMH);
101:
102: //--- add description information
103:
104: for (Object o : set.getChildren("setDescription",
105: OaiPmh.Namespaces.OAI_PMH))
106: descriptions.add((Element) o);
107: }
108:
109: //---------------------------------------------------------------------------
110: //---
111: //--- Variables
112: //---
113: //---------------------------------------------------------------------------
114:
115: private String spec;
116: private String name;
117:
118: private List<Element> descriptions = new ArrayList<Element>();
119: }
120:
121: //=============================================================================
|