Source Code Cross Referenced for IdentifyResponse.java in  » GIS » geonetwork » org » fao » oaipmh » responses » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » GIS » geonetwork » org.fao.oaipmh.responses 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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.geonet.util.ISODate;
029:        import org.fao.oaipmh.OaiPmh;
030:        import org.fao.oaipmh.requests.IdentifyRequest;
031:        import org.jdom.Element;
032:
033:        //=============================================================================
034:
035:        public class IdentifyResponse extends AbstractResponse {
036:            //---------------------------------------------------------------------------
037:            //---
038:            //--- Constructor
039:            //---
040:            //---------------------------------------------------------------------------
041:
042:            public IdentifyResponse() {
043:            }
044:
045:            //---------------------------------------------------------------------------
046:
047:            public IdentifyResponse(Element response) {
048:                super (response);
049:                build(response);
050:            }
051:
052:            //---------------------------------------------------------------------------
053:            //---
054:            //--- API methods
055:            //---
056:            //---------------------------------------------------------------------------
057:
058:            public String getRepositoryName() {
059:                return reposName;
060:            }
061:
062:            public String getBaseUrl() {
063:                return baseURL;
064:            }
065:
066:            public ISODate getEarliestDateStamp() {
067:                return earlDateStamp;
068:            }
069:
070:            public DeletedRecord getDeletedRecord() {
071:                return deletedRecord;
072:            }
073:
074:            public Granularity getGranularity() {
075:                return granularity;
076:            }
077:
078:            //---------------------------------------------------------------------------
079:
080:            public void setRepositoryName(String name) {
081:                reposName = name;
082:            }
083:
084:            //---------------------------------------------------------------------------
085:
086:            public void setBaseUrl(String url) {
087:                baseURL = url;
088:            }
089:
090:            //---------------------------------------------------------------------------
091:
092:            public void setEarliestDateStamp(ISODate dateStamp) {
093:                earlDateStamp = dateStamp;
094:            }
095:
096:            //---------------------------------------------------------------------------
097:
098:            public void setDeletedRecord(DeletedRecord dr) {
099:                deletedRecord = dr;
100:            }
101:
102:            //---------------------------------------------------------------------------
103:
104:            public void setGranularity(Granularity g) {
105:                granularity = g;
106:            }
107:
108:            //---------------------------------------------------------------------------
109:
110:            public void clearAdminEmails() {
111:                adminEmails.clear();
112:            }
113:
114:            //---------------------------------------------------------------------------
115:
116:            public void addAdminEmail(String email) {
117:                adminEmails.add(email);
118:            }
119:
120:            //---------------------------------------------------------------------------
121:
122:            public Element toXml() {
123:                Element root = new Element(IdentifyRequest.VERB,
124:                        OaiPmh.Namespaces.OAI_PMH);
125:
126:                add(root, "repositoryName", reposName);
127:                add(root, "baseURL", baseURL);
128:                add(root, "protocolVersion", "2.0");
129:
130:                for (String email : adminEmails)
131:                    add(root, "adminEmail", email);
132:
133:                add(root, "earliestDatestamp", earlDateStamp + "Z");
134:                add(root, "deletedRecord", deletedRecord.toString());
135:                add(root, "granularity", granularity.toString());
136:
137:                for (String compression : compressions)
138:                    add(root, "compression", compression);
139:
140:                for (Element descr : descriptions)
141:                    root.addContent((Element) descr.clone());
142:
143:                return root;
144:            }
145:
146:            //---------------------------------------------------------------------------
147:            //---
148:            //--- Private methods
149:            //---
150:            //---------------------------------------------------------------------------
151:
152:            private void build(Element response) {
153:                Element ident = response.getChild("Identify",
154:                        OaiPmh.Namespaces.OAI_PMH);
155:
156:                reposName = ident.getChildText("repositoryName",
157:                        OaiPmh.Namespaces.OAI_PMH);
158:                baseURL = ident.getChildText("baseURL",
159:                        OaiPmh.Namespaces.OAI_PMH);
160:
161:                //--- store earliest datestamp
162:
163:                String eds = ident.getChildText("earliestDatestamp",
164:                        OaiPmh.Namespaces.OAI_PMH);
165:                earlDateStamp = new ISODate(eds);
166:
167:                //--- add admin emails
168:
169:                for (Object o : ident.getChildren("adminEmail",
170:                        OaiPmh.Namespaces.OAI_PMH)) {
171:                    Element email = (Element) o;
172:                    adminEmails.add(email.getText());
173:                }
174:
175:                //--- handle granularity
176:
177:                String gran = ident.getChildText("granularity",
178:                        OaiPmh.Namespaces.OAI_PMH);
179:                granularity = Granularity.parse(gran);
180:
181:                //--- handle deleted record
182:
183:                String delRec = ident.getChildText("deletedRecord",
184:                        OaiPmh.Namespaces.OAI_PMH);
185:                deletedRecord = DeletedRecord.parse(delRec);
186:
187:                //--- add compressions
188:
189:                for (Object o : ident.getChildren("compression",
190:                        OaiPmh.Namespaces.OAI_PMH)) {
191:                    Element comp = (Element) o;
192:                    compressions.add(comp.getText());
193:                }
194:
195:                //--- add descriptions
196:
197:                for (Object o : ident.getChildren("description",
198:                        OaiPmh.Namespaces.OAI_PMH))
199:                    descriptions.add((Element) o);
200:            }
201:
202:            //---------------------------------------------------------------------------
203:            //---
204:            //--- Variables
205:            //---
206:            //---------------------------------------------------------------------------
207:
208:            private String reposName;
209:            private String baseURL;
210:
211:            private ISODate earlDateStamp;
212:            private DeletedRecord deletedRecord;
213:            private Granularity granularity;
214:
215:            private List<String> adminEmails = new ArrayList<String>();
216:            private List<String> compressions = new ArrayList<String>();
217:            private List<Element> descriptions = new ArrayList<Element>();
218:
219:            //---------------------------------------------------------------------------
220:            //---
221:            //--- Enumerations
222:            //---
223:            //---------------------------------------------------------------------------
224:
225:            //---------------------------------------------------------------------------
226:            //--- Granularity
227:            //---------------------------------------------------------------------------
228:
229:            public enum Granularity {
230:                SHORT("YYYY-MM-DD"), LONG("YYYY-MM-DDThh:mm:ssZ");
231:
232:                //------------------------------------------------------------------------
233:
234:                private Granularity(String type) {
235:                    this .type = type;
236:                }
237:
238:                //------------------------------------------------------------------------
239:
240:                public String toString() {
241:                    return type;
242:                }
243:
244:                //------------------------------------------------------------------------
245:
246:                public static Granularity parse(String type) {
247:                    if (type.equals(SHORT.toString()))
248:                        return SHORT;
249:                    if (type.equals(LONG.toString()))
250:                        return LONG;
251:
252:                    throw new RuntimeException("Unknown granularity type : "
253:                            + type);
254:                }
255:
256:                //------------------------------------------------------------------------
257:
258:                private String type;
259:            }
260:
261:            //---------------------------------------------------------------------------
262:            //--- DeletedRecord
263:            //---------------------------------------------------------------------------
264:
265:            public enum DeletedRecord {
266:                NO("no"), PERSISTENT("persistent"), TRANSIENT("transient");
267:
268:                //------------------------------------------------------------------------
269:
270:                private DeletedRecord(String type) {
271:                    this .type = type;
272:                }
273:
274:                //------------------------------------------------------------------------
275:
276:                public String toString() {
277:                    return type;
278:                }
279:
280:                //------------------------------------------------------------------------
281:
282:                public static DeletedRecord parse(String type) {
283:                    if (type.equals(NO.toString()))
284:                        return NO;
285:                    if (type.equals(PERSISTENT.toString()))
286:                        return PERSISTENT;
287:                    if (type.equals(TRANSIENT.toString()))
288:                        return TRANSIENT;
289:
290:                    throw new RuntimeException("Unknown deleted record type : "
291:                            + type);
292:                }
293:
294:                //------------------------------------------------------------------------
295:
296:                private String type;
297:            }
298:        }
299:
300:        //=============================================================================
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.