Changeset 12641 for trunk/gli/src/org/greenstone/gatherer/cdm/Index.java
- Timestamp:
- 2006-09-01T11:38:53+12:00 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/cdm/Index.java
r12304 r12641 43 43 implements Comparable, DOMProxyListEntry { 44 44 /** An values of items in the index level enumeration. */ 45 static protected final String LEVEL[] = { CollectionConfiguration.DOCUMENT_STR, CollectionConfiguration.SECTION_STR, CollectionConfiguration.PARAGRAPH_STR};45 static protected final String LEVEL[] = {StaticStrings.DOCUMENT_STR, StaticStrings.SECTION_STR, StaticStrings.PARAGRAPH_STR}; 46 46 47 47 private ArrayList sources = null; … … 67 67 // Create a new element 68 68 Document document = CollectionDesignManager.collect_config.document; 69 this.element = document.createElement( CollectionConfiguration.INDEX_ELEMENT);69 this.element = document.createElement(StaticStrings.INDEX_ELEMENT); 70 70 // For each source add a content element 71 71 int size = sources.size(); 72 72 for(int i = 0; i < size; i++) { 73 Element content_element = document.createElement( CollectionConfiguration.CONTENT_ELEMENT);73 Element content_element = document.createElement(StaticStrings.CONTENT_ELEMENT); 74 74 Object source_object = sources.get(i); 75 75 if (source_object instanceof MetadataElement) { 76 76 // System.err.println("Constructing new Index with MetadataElement source..."); 77 content_element.setAttribute( CollectionConfiguration.NAME_ATTRIBUTE, ((MetadataElement) source_object).getFullName());77 content_element.setAttribute(StaticStrings.NAME_ATTRIBUTE, ((MetadataElement) source_object).getFullName()); 78 78 } 79 79 else { 80 80 // System.err.println("Constructing new Index with String source..."); 81 content_element.setAttribute( CollectionConfiguration.NAME_ATTRIBUTE, source_object.toString());81 content_element.setAttribute(StaticStrings.NAME_ATTRIBUTE, source_object.toString()); 82 82 } 83 83 element.appendChild(content_element); … … 91 91 this(sources); 92 92 this.level = level; 93 element.setAttribute( CollectionConfiguration.LEVEL_ATTRIBUTE, LEVEL[level]);93 element.setAttribute(StaticStrings.LEVEL_ATTRIBUTE, LEVEL[level]); 94 94 } 95 95 … … 101 101 } 102 102 } 103 element.setAttribute( CollectionConfiguration.LEVEL_ATTRIBUTE, LEVEL[this.level]);103 element.setAttribute(StaticStrings.LEVEL_ATTRIBUTE, LEVEL[this.level]); 104 104 } 105 105 … … 138 138 public int getLevel() { 139 139 if(level == -1 && element != null) { 140 String level_str = element.getAttribute( CollectionConfiguration.LEVEL_ATTRIBUTE);140 String level_str = element.getAttribute(StaticStrings.LEVEL_ATTRIBUTE); 141 141 for(int i = 0; level == -1 && i < LEVEL.length; i++) { 142 142 if(level_str.equals(LEVEL[i])) { … … 197 197 if(sources == null) { 198 198 sources = new ArrayList(); 199 NodeList content_elements = element.getElementsByTagName( CollectionConfiguration.CONTENT_ELEMENT);199 NodeList content_elements = element.getElementsByTagName(StaticStrings.CONTENT_ELEMENT); 200 200 int content_elements_length = content_elements.getLength(); 201 201 for(int i = 0; i < content_elements_length; i++) { 202 202 Element content_element = (Element) content_elements.item(i); 203 String metadata_element_name_full = (String) content_element.getAttribute( CollectionConfiguration.NAME_ATTRIBUTE);203 String metadata_element_name_full = (String) content_element.getAttribute(StaticStrings.NAME_ATTRIBUTE); 204 204 MetadataElement metadata_element = MetadataTools.getMetadataElementWithName(metadata_element_name_full); 205 205 if (metadata_element != null) { … … 216 216 217 217 public boolean isAssigned() { 218 return (element != null && !element.getAttribute( CollectionConfiguration.ASSIGNED_ATTRIBUTE).equals(CollectionConfiguration.FALSE_STR));218 return (element != null && !element.getAttribute(StaticStrings.ASSIGNED_ATTRIBUTE).equals(StaticStrings.FALSE_STR)); 219 219 } 220 220 221 221 public void setAssigned(boolean assigned) { 222 222 if(element != null) { 223 element.setAttribute( CollectionConfiguration.ASSIGNED_ATTRIBUTE, (assigned ? CollectionConfiguration.TRUE_STR : CollectionConfiguration.FALSE_STR));223 element.setAttribute(StaticStrings.ASSIGNED_ATTRIBUTE, (assigned ? StaticStrings.TRUE_STR : StaticStrings.FALSE_STR)); 224 224 } 225 225 } … … 237 237 public void setLevel(int new_level) { 238 238 // System.err.println("SetLevel(" + new_level + ")"); 239 if(element != null && element.getNodeName().equals( CollectionConfiguration.INDEX_DEFAULT_ELEMENT)) {239 if(element != null && element.getNodeName().equals(StaticStrings.INDEX_DEFAULT_ELEMENT)) { 240 240 if (0 <= new_level && new_level < 3) { 241 element.setAttribute( CollectionConfiguration.LEVEL_ATTRIBUTE, LEVEL[new_level]);241 element.setAttribute(StaticStrings.LEVEL_ATTRIBUTE, LEVEL[new_level]); 242 242 } else { 243 element.setAttribute( CollectionConfiguration.LEVEL_ATTRIBUTE, "");243 element.setAttribute(StaticStrings.LEVEL_ATTRIBUTE, ""); 244 244 } 245 245 this.id = null; // Regenerate ID. … … 255 255 */ 256 256 public void setSources(ArrayList sources) { 257 if(element != null && element.getNodeName().equals( CollectionConfiguration.INDEX_DEFAULT_ELEMENT)) {257 if(element != null && element.getNodeName().equals(StaticStrings.INDEX_DEFAULT_ELEMENT)) { 258 258 // Erase old sources 259 259 XMLTools.clear(element); … … 261 261 int size = sources.size(); 262 262 for(int i = 0; i < size; i++) { 263 Element content_element = element.getOwnerDocument().createElement( CollectionConfiguration.CONTENT_ELEMENT);263 Element content_element = element.getOwnerDocument().createElement(StaticStrings.CONTENT_ELEMENT); 264 264 Object source_object = sources.get(i); 265 265 if (source_object instanceof MetadataElement) { 266 266 String name = ((MetadataElement) source_object).getFullName(); 267 content_element.setAttribute( CollectionConfiguration.NAME_ATTRIBUTE, name);267 content_element.setAttribute(StaticStrings.NAME_ATTRIBUTE, name); 268 268 name = null; 269 269 } 270 270 else { 271 271 //DebugStream.println("Found String as source: " + source_object.toString()); 272 content_element.setAttribute( CollectionConfiguration.NAME_ATTRIBUTE, source_object.toString());272 content_element.setAttribute(StaticStrings.NAME_ATTRIBUTE, source_object.toString()); 273 273 } 274 274 source_object = null;
Note:
See TracChangeset
for help on using the changeset viewer.