01: /*
02: * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com>
03: * Distributed under the terms of either:
04: * - the common development and distribution license (CDDL), v1.0; or
05: * - the GNU Lesser General Public License, v2.1 or later
06: * $Id: XhtmlContentLoaderBackend.java 3634 2007-01-08 21:42:24Z gbevin $
07: */
08: package com.uwyn.rife.cmf.loader;
09:
10: import com.uwyn.rife.cmf.dam.exceptions.ContentManagerException;
11: import java.util.Set;
12:
13: /**
14: * This is an abstract class that should be implemented by all xhtml content
15: * loader back-ends.
16: * <p>The {@link #load(Object, boolean, Set) load} method simply checks the
17: * type of the data and delegates the handling to typed methods that should be
18: * implemented by the back-ends.
19: *
20: * @author Geert Bevin (gbevin[remove] at uwyn dot com)
21: * @version $Revision: 3634 $
22: * @since 1.0
23: */
24: public abstract class XhtmlContentLoaderBackend implements
25: ContentLoaderBackend<String> {
26: /**
27: * Loads the data from a string
28: *
29: * @param data the raw data that has to be loaded
30: * @param fragment <code>true</code> if the raw data is a fragment; or
31: * <p><code>false</code> if the raw data is a complete document or file
32: * @param errors a set to which possible error messages will be added
33: * @return an instance of the xhtml as a <code>String</code>; or
34: * <p><code>null</code> if the raw data couldn't be loaded
35: */
36: protected abstract String loadFromString(String data,
37: boolean fragment, Set<String> errors)
38: throws ContentManagerException;
39:
40: public String load(Object data, boolean fragment, Set<String> errors)
41: throws ContentManagerException {
42: if (data instanceof String) {
43: return loadFromString((String) data, fragment, errors);
44: }
45:
46: return null;
47: }
48: }
|