001: /*
002: * Helma License Notice
003: *
004: * The contents of this file are subject to the Helma License
005: * Version 2.0 (the "License"). You may not use this file except in
006: * compliance with the License. A copy of the License is available at
007: * http://adele.helma.org/download/helma/license.txt
008: *
009: * Copyright 1998-2003 Helma Software. All Rights Reserved.
010: *
011: * $RCSfile$
012: * $Author: root $
013: * $Revision: 8604 $
014: * $Date: 2007-09-28 15:16:38 +0200 (Fre, 28 Sep 2007) $
015: */
016:
017: package helma.framework.repository;
018:
019: import java.io.InputStream;
020: import java.io.IOException;
021: import java.net.URL;
022:
023: /**
024: * Resource represents a pointer to some kind of information (code, skin, ...)
025: * from which the content can be fetched
026: */
027: public interface Resource {
028:
029: /**
030: * Returns the date the resource was last modified
031: * @return last modified date
032: */
033: public long lastModified();
034:
035: /**
036: * Checks wether this resource actually (still) exists
037: * @return true if the resource exists
038: */
039: public boolean exists();
040:
041: /**
042: * Returns the lengh of the resource's content
043: * @return content length
044: * @throws IOException I/O related problem
045: */
046: public long getLength() throws IOException;
047:
048: /**
049: * Returns an input stream to the content of the resource
050: * @return content input stream
051: * @throws IOException I/O related problem
052: */
053: public InputStream getInputStream() throws IOException;
054:
055: /**
056: * Returns the content of the resource in a given encoding
057: * @param encoding the character encoding
058: * @return content
059: * @throws IOException I/O related problem
060: */
061: public String getContent(String encoding) throws IOException;
062:
063: /**
064: * Returns the content of the resource
065: * @return content
066: * @throws IOException I/O related problem
067: */
068: public String getContent() throws IOException;
069:
070: /**
071: * Returns the name of the resource; does not include the name of the
072: * repository the resource was fetched from
073: * @return name of the resource
074: */
075: public String getName();
076:
077: /**
078: * Returns the short name of the resource which is its name exclusive file
079: * ending if it exists
080: * @return short name of the resource
081: */
082: public String getShortName();
083:
084: /**
085: * Returns the short name of the resource with the file extension
086: * (everything following the last dot character) cut off.
087: * @return the file name without the file extension
088: */
089: public String getBaseName();
090:
091: /**
092: * Returns an url to the resource if the repository of this resource is
093: * able to provide urls
094: * @return url to the resource
095: * @throws UnsupportedOperationException if resource does not support URL schema
096: */
097: public URL getUrl() throws UnsupportedOperationException;
098:
099: /**
100: * Get a Resource this Resource is overloading
101: * @return the overloaded resource
102: */
103: public Resource getOverloadedResource();
104:
105: /**
106: * Method for registering a Resource this Resource is overloading
107: * @param res the overloaded resource
108: */
109: public void setOverloadedResource(Resource res);
110:
111: /**
112: * Returns the repository the resource does belong to
113: * @return upper repository
114: */
115: public Repository getRepository();
116:
117: }
|