1 22 23 24 package org.xquark.xquery.metadata; 25 26 import java.util.*; 27 28 import org.xml.sax.SAXException ; 29 import org.xquark.xquery.metadata.resolver.CollectionMetadata; 30 import org.xquark.xquery.metadata.resolver.SourceMetadata; 31 32 36 public class MetaWrapper implements SourceMetadata{ 37 38 private static final String RCSRevision = "$Revision: 1.1 $"; 42 private static final String RCSName = "$Name: $"; 43 private HashMap metacollections = null; 47 private String sourcename = null; 48 private MetaDataImpl metadata = null ; 49 50 51 52 60 public MetaWrapper(MetaDataImpl metadata) { 61 initMetaCollections(); 62 this.metadata = metadata; 63 } 64 65 public MetaWrapper(MetaDataImpl metadata, MetaWrapper oldwrapper) { 67 this.metadata = metadata; 68 initMetaCollections(); 69 HashMap hm = oldwrapper.getMetaCollections () ; 70 for (Iterator it = hm.values ().iterator () ; it.hasNext () ; ) 71 { 72 MetaCollection col = (MetaCollection) it.next () ; 73 MetaCollection newmetacol = new MetaCollection (metadata, col) ; 74 addMetaCollection (newmetacol) ; 75 } 76 } 77 78 79 85 public void addMetaCollection(MetaCollection metacollection) { 86 if (metacollection == null) { 88 System.err.println("metacollection null") ; 89 return; 90 } 91 String key = metacollection.getCollectionName(); 93 if (key == null) { 95 System.err.println("incorrect key name") ; 96 return; 97 } 98 if (metacollections == null) { 100 initMetaCollections(); 101 } 102 if (metacollections.get(key) != null) { 104 return; 105 } 106 metacollections.put(key, metacollection); 108 } 109 110 111 114 public void initMetaCollections() { 115 metacollections = new HashMap(); 116 } 117 118 119 122 public String getSourceName() { 123 return sourcename; 124 } 125 126 127 130 public void setSourceName(String sourcename) { 131 this.sourcename = sourcename; 132 } 133 134 135 136 137 public Collection getCollectionsMetadata() { 138 if (metacollections == null) return null; 139 return metacollections.values(); 140 } 141 142 143 146 public HashMap getSchemaTrees() throws SAXException { 147 HashMap collections = new HashMap(); 148 Iterator it = metacollections.entrySet().iterator(); 149 while (it.hasNext()) { 150 Map.Entry entry = (Map.Entry)it.next(); 151 MetaCollection col = (MetaCollection)entry.getValue(); 152 if (col.getXTree() != null) collections.put((String )entry.getKey(),col.getXTree()); 153 } 154 return collections; 155 } 156 157 public MetaCollection getMetaCollection(String colName) { 158 if (metacollections == null) return null; 159 return (MetaCollection)metacollections.get(colName); 160 } 168 169 public HashMap getMetaCollections() { 170 return metacollections ; 171 } 172 173 public MetaDataImpl getMetaData() { 174 return metadata ; 175 } 176 177 public CollectionMetadata getCollectionMetadata(String colname) { 178 if (metacollections == null) return null; 179 return (CollectionMetadata)metacollections.get(colname.toUpperCase()); 180 } 181 182 public boolean isCaseSensitive() { return false; } 183 184 public boolean isStrict() { return false; } 185 186 public List getCollectionsName () 187 { 188 if (metacollections == null) return null; 189 List al = new ArrayList () ; 190 al.addAll(metacollections.keySet()); 191 201 return al ; 202 203 } 204 211 protected void finalize() 212 throws Throwable { 213 214 } 215 } 216 | Popular Tags |