01: //WebOnSwing - Web Application Framework
02: //Copyright (C) 2003 Fernando Damian Petrola
03: //
04: //This library is free software; you can redistribute it and/or
05: //modify it under the terms of the GNU Lesser General Public
06: //License as published by the Free Software Foundation; either
07: //version 2.1 of the License, or (at your option) any later version.
08: //
09: //This library is distributed in the hope that it will be useful,
10: //but WITHOUT ANY WARRANTY; without even the implied warranty of
11: //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: //Lesser General Public License for more details.
13: //
14: //You should have received a copy of the GNU Lesser General Public
15: //License along with this library; if not, write to the Free Software
16: //Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17:
18: package net.ar.webonswing.managers.script;
19:
20: import java.util.*;
21:
22: /**
23: * Maneja la inclusiones y codigo suelto de scritps y estilos, permitiendo variar en la subclases el formato
24: * de las operaciones de inclusion.
25: *
26: * @author Fernando Damian Petrola
27: */
28: public abstract class CodeAndIncludeContributionContainer {
29: protected Set theIncludes = new HashSet();
30: protected StringBuffer theCode = new StringBuffer();
31: protected Set uniqueCode = new HashSet();
32:
33: public void addInclude(String anIncludePath) {
34: theIncludes.add(anIncludePath);
35: }
36:
37: public void addCode(String aCode) {
38: theCode.append(aCode);
39: }
40:
41: public void addCodeOnce(String aCode) {
42: if (!uniqueCode.contains(aCode)) {
43: theCode.append(aCode);
44: uniqueCode.add(aCode);
45: }
46: }
47:
48: public String getIncludesCode() {
49: StringBuffer theResult = new StringBuffer();
50:
51: for (Iterator i = theIncludes.iterator(); i.hasNext();)
52: theResult.append(getIncludeOperation((String) i.next()));
53:
54: return theResult.toString();
55: }
56:
57: protected abstract String getIncludeOperation(String anIncludedPath);
58:
59: public StringBuffer getCode() {
60: return theCode;
61: }
62:
63: public void setCode(StringBuffer aBuffer) {
64: theCode = aBuffer;
65: }
66: }
|