KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ozoneDB > xml > core > XMLCollectionImpl


1 // You can redistribute this software and/or modify it under the terms of
2
// the Ozone Library License version 1 published by ozone-db.org.
3
//
4
// The original code and portions created by SMB are
5
// Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
6
//
7
// $Id: XMLCollectionImpl.java,v 1.2 2003/11/20 23:18:42 per_nyfelt Exp $
8

9 package org.ozoneDB.xml.core;
10
11 import java.util.Map JavaDoc;
12 import java.util.HashMap JavaDoc;
13 import java.util.Set JavaDoc;
14 import java.util.HashSet JavaDoc;
15
16 import org.ozoneDB.OzoneObject;
17
18 import org.xmldb.api.base.Resource;
19
20 /**
21  *
22  * @author <a HREF="http://www.smb-tec.com">SMB</a>
23  * @version $Revision: 1.2 $
24  */

25 public class XMLCollectionImpl extends OzoneObject
26                                implements XMLCollection {
27
28     //
29
// data
30
//
31
// XML documents in this collection, String as key, XMLContainer as value
32
private Set JavaDoc xmlDocuments = null;
33     private Map JavaDoc childCollections = null;
34     private XMLCollection parentCollection = null;
35     private String JavaDoc collectionName = null;
36
37     public XMLCollectionImpl() {
38         // the id's for the XML documents in this collection
39
xmlDocuments = new HashSet JavaDoc();
40         // child collections
41
childCollections = new HashMap JavaDoc();
42     }
43
44     /**
45     */

46     public XMLCollection getParentCollection() {
47         return parentCollection;
48     }
49
50     /**
51      * Added to support parent-child collections
52      */

53     public void setParentCollection(XMLCollection parentCollection) {
54         this.parentCollection = parentCollection;
55     }
56
57     /**
58     */

59     public String JavaDoc getName() {
60         return collectionName;
61     }
62
63     /**
64     */

65     public void setName(String JavaDoc name) {
66         collectionName = name;
67     }
68
69     /**
70     */

71     public int getChildCollectionCount() {
72         return childCollections.size();
73     }
74
75     /**
76     */

77     public synchronized String JavaDoc[] listChildCollections() {
78         return (String JavaDoc[]) childCollections.keySet().toArray( new String JavaDoc[childCollections.keySet().size()] );
79     }
80
81     /**
82     */

83     public XMLCollection getChildCollection( String JavaDoc name ) {
84         return (XMLCollection)childCollections.get(name);
85     }
86
87     public int getResourceCount() {
88         return xmlDocuments.size();
89     }
90
91     public Set JavaDoc getResources() {
92         return xmlDocuments;
93     }
94
95     public boolean hasResource(String JavaDoc id) {
96         return xmlDocuments.contains(id);
97     }
98
99     public void addResource(String JavaDoc id) {
100         System.out.println("XMLCollectionImpl.addResource() - Adding container to Set");
101         xmlDocuments.add(id);
102     }
103
104     public void storeResource( String JavaDoc id, Resource res ) {
105         System.out.println("XMLCOllectionImpl.storeResource() - Dont know what to do here");
106     }
107
108     /**
109      * Added to support parent-child collections
110      */

111     public void setChildCollection(String JavaDoc childName, XMLCollection childCollection) {
112         childCollections.put(childName,childCollection);
113     }
114 }
115
Popular Tags