01: /*
02: * Copyright 2005-2006 The Kuali Foundation.
03: *
04: *
05: * Licensed under the Educational Community License, Version 1.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * http://www.opensource.org/licenses/ecl1.php
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package edu.iu.uis.eden.batch;
18:
19: import java.io.File;
20: import java.io.IOException;
21: import java.util.Collection;
22: import java.util.Iterator;
23: import java.util.LinkedList;
24: import java.util.List;
25:
26: /**
27: * In someway allows muliple xml documents to be pushed into the xml loading
28: * 'pipeline'.
29: *
30: * @author ahamid
31: */
32: public class CompositeXmlDocCollection implements XmlDocCollection {
33: protected Collection collections;
34:
35: public CompositeXmlDocCollection(Collection xmlDocCollections) {
36: collections = xmlDocCollections;
37: }
38:
39: public File getFile() {
40: return null;
41: }
42:
43: public List getXmlDocs() {
44: List docs = new LinkedList();
45: Iterator collectionIt = collections.iterator();
46: while (collectionIt.hasNext()) {
47: XmlDocCollection coll = (XmlDocCollection) collectionIt
48: .next();
49: docs.addAll(coll.getXmlDocs());
50: }
51: return docs;
52: }
53:
54: public void close() throws IOException {
55: Iterator collectionIt = collections.iterator();
56: while (collectionIt.hasNext()) {
57: XmlDocCollection coll = (XmlDocCollection) collectionIt
58: .next();
59: coll.close();
60: }
61: }
62:
63: public String toString() {
64: StringBuffer sb = new StringBuffer(
65: "[CompositeXmlDocCollection: ");
66: Iterator collectionIt = collections.iterator();
67: while (collectionIt.hasNext()) {
68: XmlDocCollection coll = (XmlDocCollection) collectionIt
69: .next();
70: sb.append(coll.toString() + ", ");
71: }
72: if (collections.size() > 0) {
73: sb.setLength(sb.length() - 2);
74: }
75: sb.append("]");
76: return sb.toString();
77: }
78: }
|