KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > outerj > daisy > repository > commonimpl > DocumentCollectionsImpl


1 /*
2  * Copyright 2004 Outerthought bvba and Schaubroeck nv
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.outerj.daisy.repository.commonimpl;
17
18 import java.util.ArrayList JavaDoc;
19
20 import org.outerj.daisy.repository.DocumentCollection;
21 import org.outerj.daisy.repository.DocumentCollections;
22 import org.outerx.daisy.x10.CollectionsDocument;
23 import org.outerx.daisy.x10.CollectionDocument;
24
25 /**
26  * implementation class of Collections
27  */

28 public class DocumentCollectionsImpl implements DocumentCollections{
29     private final DocumentCollection[] collections;
30     
31     public DocumentCollectionsImpl (DocumentCollection[] collections) {
32         this.collections = collections;
33     }
34
35     public DocumentCollection[] getArray() {
36         return collections;
37     }
38
39     public CollectionsDocument getXml() {
40         CollectionsDocument collectionsDocument = CollectionsDocument.Factory.newInstance();
41         CollectionsDocument.Collections collectionsXml = collectionsDocument.addNewCollections();
42         
43         ArrayList JavaDoc collectionList = new ArrayList JavaDoc();
44         for (int i = 0; i < collections.length; i++) {
45             collectionList.add(collections[i].getXml().getCollection());
46         }
47         
48         collectionsXml.setCollectionArray((CollectionDocument.Collection[])collectionList.toArray(new CollectionDocument.Collection[collectionList.size()]));
49     
50         return collectionsDocument;
51     }
52 }
53
Popular Tags