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: package de.schlund.pfixcore.editor2.core.dom;
020:
021: import java.util.Collection;
022:
023: import org.w3c.dom.Document;
024:
025: /**
026: * Stores several IncludeParts
027: *
028: * @author Sebastian Marsching <sebastian.marsching@1und1.de>
029: */
030: public interface IncludeFile extends Comparable<IncludeFile> {
031: /**
032: * Returns path and filename of this IncludeFile (relative to docroot)
033: *
034: * @return Path to this IncludeFile
035: */
036: String getPath();
037:
038: /**
039: * Returns IncludePart stored in this IncludeFile identified by name
040: *
041: * @param name
042: * Name of the IncludePart to return
043: * @return IncludePart object corresponding to <code>name</code> or
044: * <code>null</code> if no IncludePart for this name can be found
045: * within this IncludeFile
046: */
047: IncludePart getPart(String name);
048:
049: /**
050: * Creates a new IncludePart. The part is not actually created in the file,
051: * but only in memory. Changes on the filesystem are first made, when
052: * content is assigned to the part. If there is already a part with the
053: * specified name, the existing part is returned.
054: *
055: * @param name
056: * Name of the part
057: * @return IncludePart object representing the new IncludePart
058: */
059: IncludePart createPart(String name);
060:
061: /**
062: * Returns true if there is a part with the specified name, whereas this
063: * does not necessarily mean, that this part is also already stored on
064: * filesystem.
065: *
066: * @param name
067: * Name of the part to look for
068: * @return <code>true</code> true if the part is existing,
069: * <code>false</code> otherwise.
070: */
071: boolean hasPart(String name);
072:
073: /**
074: * Returns all parts which are stored in this IncludeFile.
075: *
076: * @return Iterator iterating over all parts stored in this file
077: */
078: Collection<IncludePart> getParts();
079:
080: /**
081: * Returns a DOM Document representing the content of this IncludeFile. If
082: * this IncludeFile is not yet existing on filesystem, <code>null</code>
083: * is returned. This call equals to {@link #getContentXML(boolean)} with
084: * <code>forceUpdate</code> set to <code>false</code>.
085: *
086: * @return DOM Document with content of this IncludeFile or
087: * <code>null</code> if file is not yet existing.
088: */
089: Document getContentXML();
090:
091: /**
092: * Returns a DOM Document representing the content of this IncludeFile. If
093: * this IncludeFile is not yet existing on filesystem, <code>null</code>
094: * is returned.
095: *
096: * @param forceUpdate
097: * if set to <code>true</code>, the content will be read from
098: * the filesystem, otherwise the cache might be used
099: * @return DOM Document with content of this IncludeFile or
100: * <code>null</code> if file is not yet existing.
101: */
102: Document getContentXML(boolean forceUpdate);
103:
104: /**
105: * Returns a number that is incremented each time a changed version of this
106: * file is loaded. Please note that this serial is not persistent through
107: * restarts of the application.
108: *
109: * @return Number identifying the current version
110: */
111: long getSerial();
112: }
|