001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. The ASF licenses this file to You
004: * under the Apache License, Version 2.0 (the "License"); you may not
005: * use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License. For additional information regarding
015: * copyright in this work, please see the NOTICE file in the top level
016: * directory of this distribution.
017: */
018:
019: package org.apache.roller.pojos;
020:
021: import java.io.InputStream;
022:
023: /**
024: * Represents a static resource file uploaded to a weblog.
025: *
026: * The main reason for having this interface is so that we can provide a layer
027: * of abstraction between how Roller uses uploaded resource files and how those
028: * files are physically being managed by the underlying code.
029: */
030: public interface WeblogResource {
031:
032: /**
033: * The weblog this resource is attached to.
034: *
035: * @returns The weblog object owning this resource.
036: */
037: public WebsiteData getWeblog();
038:
039: /**
040: * The name of this resource.
041: * i.e. "some.jpg"
042: *
043: * @returns The short name for the resource.
044: */
045: public String getName();
046:
047: /**
048: * The path to this resource, relative to the weblog's uploads area.
049: * i.e. "images/some.jpg"
050: *
051: * @returns The path to the resource, relative to the weblog's uploads area.
052: */
053: public String getPath();
054:
055: /**
056: * The last-modified time for this resource.
057: *
058: * @returns The last time the resource changed, as a long value.
059: */
060: public long getLastModified();
061:
062: /**
063: * The length of this resource, in bytes.
064: *
065: * @returns The length of the resource in bytes.
066: */
067: public long getLength();
068:
069: /**
070: * Does this resource represent a directory? True if yes, False otherwise.
071: *
072: * @returns True if the resource is a directory, False otherwise.
073: */
074: public boolean isDirectory();
075:
076: /**
077: * Does this resource represent a file? True if yes, False otherwise.
078: *
079: * @returns True if the resource is a file, False otherwise.
080: */
081: public boolean isFile();
082:
083: /**
084: * List child resources if this resource represents a directory.
085: *
086: * The children returned by this method should only be actual files. No
087: * directories should be returned by this method.
088: *
089: * @returns null if resource is not a directory, otherwise a WeblogResource[].
090: */
091: public WeblogResource[] getChildren();
092:
093: /**
094: * The web url where the resource can be accessed, optionally absolute.
095: *
096: * @param absolute should the url be absolute or not?
097: *
098: * @returns a String representing the web url to this resource.
099: */
100: public String getURL(boolean absolute);
101:
102: /**
103: * An InputStream that the resource can be read from.
104: *
105: * @returns an InputStream for the resource.
106: */
107: public InputStream getInputStream();
108:
109: }
|