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.List;
028: import org.fao.oaipmh.OaiPmh;
029: import org.fao.oaipmh.requests.ListMetadataFormatsRequest;
030: import org.jdom.Element;
031:
032: //=============================================================================
033:
034: public class ListMetadataFormatsResponse extends AbstractResponse {
035: //---------------------------------------------------------------------------
036: //---
037: //--- Constructor
038: //---
039: //---------------------------------------------------------------------------
040:
041: public ListMetadataFormatsResponse() {
042: }
043:
044: //---------------------------------------------------------------------------
045:
046: public ListMetadataFormatsResponse(Element response) {
047: super (response);
048: build(response);
049: }
050:
051: //---------------------------------------------------------------------------
052: //---
053: //--- API methods
054: //---
055: //---------------------------------------------------------------------------
056:
057: public Iterable<MetadataFormat> getFormats() {
058: return formats;
059: }
060:
061: //---------------------------------------------------------------------------
062:
063: public void clearFormats() {
064: formats.clear();
065: }
066:
067: //---------------------------------------------------------------------------
068:
069: public void addFormat(MetadataFormat mf) {
070: formats.add(mf);
071: }
072:
073: //---------------------------------------------------------------------------
074:
075: public Element toXml() {
076: Element root = new Element(ListMetadataFormatsRequest.VERB,
077: OaiPmh.Namespaces.OAI_PMH);
078:
079: for (MetadataFormat mf : formats)
080: root.addContent(mf.toXml());
081:
082: return root;
083: }
084:
085: //---------------------------------------------------------------------------
086: //---
087: //--- Private methods
088: //---
089: //---------------------------------------------------------------------------
090:
091: private void build(Element response) {
092: Element listMdFor = response.getChild("ListMetadataFormats",
093: OaiPmh.Namespaces.OAI_PMH);
094:
095: List mdFormats = listMdFor.getChildren("metadataFormat",
096: OaiPmh.Namespaces.OAI_PMH);
097:
098: for (Object o : mdFormats)
099: formats.add(new MetadataFormat((Element) o));
100: }
101:
102: //---------------------------------------------------------------------------
103: //---
104: //--- Variables
105: //---
106: //---------------------------------------------------------------------------
107:
108: private List<MetadataFormat> formats = new ArrayList<MetadataFormat>();
109: }
110:
111: //=============================================================================
|