001: // You can redistribute this software and/or modify it under the terms of
002: // the Ozone Library License version 1 published by ozone-db.org.
003: //
004: // The original code and portions created by SMB are
005: // Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
006: //
007: // $Id: XMLCollectionImpl.java,v 1.1 2001/12/18 11:03:24 per_nyfelt Exp $
008:
009: package org.ozoneDB.xml.core;
010:
011: import java.util.Map;
012: import java.util.HashMap;
013: import java.util.Set;
014: import java.util.HashSet;
015: import java.util.Iterator;
016:
017: import org.ozoneDB.OzoneInterface;
018: import org.ozoneDB.ExternalDatabase;
019: import org.ozoneDB.OzoneObject;
020: import org.ozoneDB.OzoneProxy;
021: import org.ozoneDB.xml.util.XMLContainer;
022:
023: import org.xmldb.api.base.Resource;
024: import org.xmldb.api.modules.XMLResource;
025: import org.ozoneDB.xml.cli.resources.XMLResourceImpl;
026: import org.ozoneDB.xml.cli.CollectionImpl;
027: import org.xmldb.api.base.Collection;
028:
029: /**
030: *
031: * @author <a href="http://www.smb-tec.com">SMB</a>
032: * @version $Revision: 1.1 $
033: */
034: public class XMLCollectionImpl extends OzoneObject implements
035: XMLCollection {
036:
037: //
038: // data
039: //
040: // XML documents in this collection, String as key, XMLContainer as value
041: private Set xmlDocuments = null;
042: private Map childCollections = null;
043: private XMLCollection parentCollection = null;
044: private String collectionName = null;
045: // the database this object resides in
046: private OzoneInterface db = null;
047:
048: public XMLCollectionImpl() {
049: // the id's for the XML documents in this collection
050: xmlDocuments = new HashSet();
051: // child collections
052: childCollections = new HashMap();
053: }
054:
055: /**
056: */
057: public XMLCollection getParentCollection() {
058: return parentCollection;
059: }
060:
061: /**
062: * Added to support parent-child collections
063: */
064: public void setParentCollection(XMLCollection parentCollection) {
065: this .parentCollection = parentCollection;
066: }
067:
068: /**
069: */
070: public String getName() {
071: return collectionName;
072: }
073:
074: /**
075: */
076: public void setName(String name) {
077: collectionName = name;
078: }
079:
080: /**
081: */
082: public int getChildCollectionCount() {
083: return childCollections.size();
084: }
085:
086: /**
087: */
088: public synchronized String[] listChildCollections() {
089: return (String[]) childCollections.keySet().toArray(
090: new String[childCollections.keySet().size()]);
091: }
092:
093: /**
094: */
095: public XMLCollection getChildCollection(String name) {
096: return (XMLCollection) childCollections.get(name);
097: }
098:
099: public int getResourceCount() {
100: return xmlDocuments.size();
101: }
102:
103: public Set getResources() {
104: return xmlDocuments;
105: }
106:
107: public boolean hasResource(String id) {
108: return xmlDocuments.contains(id);
109: }
110:
111: public void addResource(String id) {
112: System.out
113: .println("XMLCollectionImpl.addResource() - Adding container to Set");
114: xmlDocuments.add(id);
115: }
116:
117: public void storeResource(String id, Resource res) {
118: db = super .database();
119: System.out
120: .println("XMLCOllectionImpl.storeResource() - Dont know what to do here");
121: }
122:
123: /**
124: * Added to support parent-child collections
125: */
126: public void setChildCollection(String childName,
127: XMLCollection childCollection) {
128: childCollections.put(childName, childCollection);
129: }
130: }
|