1 package org.kuali.ole.handler;
2
3 import com.thoughtworks.xstream.XStream;
4 import org.kuali.ole.bo.explain.*;
5 import org.kuali.ole.converters.*;
6
7
8
9
10
11
12
13
14 public class OleSRUExplainOperationHandler {
15
16
17
18
19
20
21 public String toXML(OleSRUExplainResponse oleSRUExplainResponse) {
22
23 StringBuffer stringBuffer = new StringBuffer();
24 stringBuffer.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
25 stringBuffer.append("\n");
26 XStream xStream = new XStream();
27 xStream.alias("sru:explainResponse", OleSRUExplainResponse.class);
28 xStream.aliasField("sru:version", OleSRUExplainResponse.class, "version");
29 xStream.aliasField("sru:record", OleSRUExplainResponse.class, "record");
30 xStream.aliasField("sru:recordPacking", OleSRUExplainRecord.class, "recordPacking");
31 xStream.aliasField("sru:recordSchema", OleSRUExplainRecord.class, "recordSchema");
32 xStream.aliasField("sru:recordData", OleSRUExplainRecord.class, "recordData");
33 xStream.aliasField("zr:explain", OleSRUExplainRecordData.class, "explain");
34 xStream.aliasField("zr:serverInfo", OleSRUExplainOperation.class, "serverInfo");
35 xStream.aliasField("zr:databaseInfo", OleSRUExplainOperation.class, "databaseInfo");
36 xStream.aliasField("zr:indexInfo", OleSRUExplainOperation.class, "indexInfo");
37 xStream.aliasField("zr:schemaInfo", OleSRUExplainOperation.class, "schemaInfo");
38 xStream.aliasField("zr:configInfo", OleSRUExplainOperation.class, "configInfo");
39 xStream.aliasField("zr:host", OleSRUExplainServerInfo.class, "host");
40 xStream.aliasField("zr:port", OleSRUExplainServerInfo.class, "port");
41 xStream.aliasField("zr:database", OleSRUExplainServerInfo.class, "database");
42
43 xStream.aliasField("zr:index", OleSRUExplainIndexInfo.class, "index");
44 xStream.aliasField("zr:set", OleSRUExplainIndexInfo.class, "set");
45 xStream.aliasField("zr:map", OleSRUExplainIndex.class, "indexMap");
46 xStream.aliasField("zr:name", OleSRUExplainIndexMap.class, "name");
47 xStream.aliasField("zr:schema", OleSRUExplainSchemaInfo.class, "schema");
48 xStream.aliasField("zr:title", OleSRUExplainSchema.class, "title");
49 xStream.aliasField("zr:default", OleSRUExplainConfigurationInfo.class, "defaultValue");
50 xStream.aliasField("zr:setting", OleSRUExplainConfigurationInfo.class, "setting");
51 xStream.aliasField("zr:supports", OleSRUExplainConfigurationInfo.class, "supports");
52 xStream.registerConverter(new OleSRUExplainServerInfoConverter());
53 xStream.registerConverter(new OleSRUExplainDatabaseInfoConverter());
54 xStream.registerConverter(new OleSRUExplainIndexInfoConverter());
55 xStream.registerConverter(new OleSRUExplainSchemaInfoConverter());
56 xStream.registerConverter(new OleSRUExplainIndexMapNameConverter());
57 xStream.registerConverter(new OleSRUExplainConfigInfoSupportConverter());
58 xStream.registerConverter(new OleSRUExplainConfigInfoSettingConverter());
59 xStream.registerConverter(new OleSRUExplainConfigInfoDefaultConverter());
60 String xml = xStream.toXML(oleSRUExplainResponse);
61 xml=xml.replaceAll("<sru:explainResponse>","<sru:explainResponse xmlns:sru=\"http://www.loc.gov/zing/srw/\">");
62 xml=xml.replaceAll("<zr:explain>"," <zr:explain xmlns:zr=\"http://explain.z3950.org/dtd/2.1/\">");
63 stringBuffer.append(xml);
64 return stringBuffer.toString();
65 }
66
67
68
69 }