001: /*
002: * This file is part of PFIXCORE.
003: *
004: * PFIXCORE is free software; you can redistribute it and/or modify
005: * it under the terms of the GNU Lesser General Public License as published by
006: * the Free Software Foundation; either version 2 of the License, or
007: * (at your option) any later version.
008: *
009: * PFIXCORE is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
012: * GNU Lesser General Public License for more details.
013: *
014: * You should have received a copy of the GNU Lesser General Public License
015: * along with PFIXCORE; if not, write to the Free Software
016: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
017: *
018: */
019:
020: package de.schlund.pfixxml.targets;
021:
022: import java.util.Iterator;
023: import java.util.TreeMap;
024: import java.util.TreeSet;
025:
026: import de.schlund.pfixxml.resources.DocrootResource;
027:
028: /**
029: * AuxDependencyFactory.java
030: *
031: *
032: * Created: Fri Jul 13 13:31:32 2001
033: *
034: *
035: */
036:
037: public class AuxDependencyFactory {
038: private static AuxDependencyFactory instance = new AuxDependencyFactory();
039: private TreeMap<String, AuxDependencyInclude> includeparts = new TreeMap<String, AuxDependencyInclude>();
040: private TreeMap<String, AuxDependencyImage> images = new TreeMap<String, AuxDependencyImage>();
041: private TreeMap<String, AuxDependencyFile> files = new TreeMap<String, AuxDependencyFile>();
042: private TreeMap<String, AuxDependencyTarget> targets = new TreeMap<String, AuxDependencyTarget>();
043:
044: private AuxDependencyFactory() {
045: }
046:
047: private AuxDependency root = new AbstractAuxDependency() {
048:
049: public DependencyType getType() {
050: return DependencyType.ROOT;
051: }
052:
053: public String toString() {
054: return "[AUX/" + getType() + "]";
055: }
056:
057: public long getModTime() {
058: return 0;
059: }
060:
061: };
062:
063: public static AuxDependencyFactory getInstance() {
064: return instance;
065: }
066:
067: public synchronized AuxDependency getAuxDependencyRoot() {
068: return root;
069: }
070:
071: public synchronized AuxDependencyInclude getAuxDependencyInclude(
072: DocrootResource path, String part, String theme) {
073: String key = DependencyType.TEXT.getTag() + "@"
074: + path.toString() + "@" + part + "@" + theme;
075: AuxDependencyInclude ret = includeparts.get(key);
076: if (ret == null) {
077: ret = new AuxDependencyInclude(path, part, theme);
078: includeparts.put(key, ret);
079: }
080: return ret;
081: }
082:
083: public synchronized AuxDependencyImage getAuxDependencyImage(
084: DocrootResource path) {
085: String key = path.toString();
086: AuxDependencyImage ret = (AuxDependencyImage) images.get(key);
087: if (ret == null) {
088: ret = new AuxDependencyImage(path);
089: images.put(key, ret);
090: }
091: return ret;
092: }
093:
094: public synchronized AuxDependencyFile getAuxDependencyFile(
095: DocrootResource path) {
096: String key = path.toString();
097: AuxDependencyFile ret = (AuxDependencyFile) files.get(key);
098: if (ret == null) {
099: ret = new AuxDependencyFile(path);
100: files.put(key, ret);
101: }
102: return ret;
103: }
104:
105: public synchronized AuxDependencyTarget getAuxDependencyTarget(
106: TargetGenerator tgen, String targetkey) {
107: String key = tgen.getConfigPath().toString() + ":" + targetkey;
108: AuxDependencyTarget ret = (AuxDependencyTarget) targets
109: .get(key);
110: if (ret == null) {
111: ret = new AuxDependencyTarget(tgen, targetkey);
112: targets.put(key, ret);
113: }
114: return ret;
115: }
116:
117: public synchronized TreeSet<AuxDependency> getAllAuxDependencies() {
118: TreeSet<AuxDependency> retval = new TreeSet<AuxDependency>();
119:
120: for (Iterator<AuxDependencyInclude> i = includeparts.values()
121: .iterator(); i.hasNext();) {
122: AuxDependency aux = i.next();
123: retval.add(aux);
124: }
125:
126: for (Iterator<AuxDependencyImage> i = images.values()
127: .iterator(); i.hasNext();) {
128: AuxDependency aux = i.next();
129: retval.add(aux);
130: }
131:
132: for (Iterator<AuxDependencyFile> i = files.values().iterator(); i
133: .hasNext();) {
134: AuxDependency aux = i.next();
135: retval.add(aux);
136: }
137:
138: for (Iterator<AuxDependencyTarget> i = targets.values()
139: .iterator(); i.hasNext();) {
140: AuxDependency aux = i.next();
141: retval.add(aux);
142: }
143:
144: return retval;
145: }
146:
147: public void reset() {
148: includeparts = new TreeMap<String, AuxDependencyInclude>();
149: images = new TreeMap<String, AuxDependencyImage>();
150: files = new TreeMap<String, AuxDependencyFile>();
151: targets = new TreeMap<String, AuxDependencyTarget>();
152: }
153:
154: }// AuxDependencyFactory
|