01: /*
02: * Copyright 2001-2006 C:1 Financial Services GmbH
03: *
04: * This software is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License Version 2.1, as published by the Free Software Foundation.
07: *
08: * This software is distributed in the hope that it will be useful,
09: * but WITHOUT ANY WARRANTY; without even the implied warranty of
10: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11: * Lesser General Public License for more details.
12: *
13: * You should have received a copy of the GNU Lesser General Public
14: * License along with this library; if not, write to the Free Software
15: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
16: */
17:
18: package de.finix.contelligent.xml.export;
19:
20: import java.io.BufferedWriter;
21: import java.io.IOException;
22: import java.io.Writer;
23: import java.util.Set;
24:
25: import de.finix.contelligent.Component;
26: import de.finix.contelligent.ComponentNotFoundException;
27: import de.finix.contelligent.core.security.AccessControlList;
28:
29: public class ComponentXMLWriter {
30: private Writer writer;
31:
32: private ComponentXMLPolicy policy;
33:
34: public ComponentXMLWriter(Writer writer, ComponentXMLPolicy policy) {
35: if (writer instanceof BufferedWriter) {
36: this .writer = writer;
37: } else {
38: this .writer = new BufferedWriter(writer);
39: }
40: this .policy = policy;
41: }
42:
43: public Set write(Component component) throws IOException,
44: ComponentNotFoundException {
45: policy.writeXMLHeader(writer);
46: Set files = policy.writeComponent(component, writer);
47: policy.writeXMLFooter(writer);
48: writer.flush();
49: return files;
50: }
51:
52: public void write(AccessControlList acl) throws IOException,
53: ComponentNotFoundException {
54: policy.writeACL(acl, writer);
55: writer.flush();
56: }
57:
58: public void flush() throws IOException {
59: writer.flush();
60: }
61:
62: public void close() throws IOException {
63: writer.close();
64: }
65: }
|