diff options
author | Marc Englund <marc.englund@itmill.com> | 2007-11-19 14:03:05 +0000 |
---|---|---|
committer | Marc Englund <marc.englund@itmill.com> | 2007-11-19 14:03:05 +0000 |
commit | f2e3722df9676436680afc0f1991e91e1696fb99 (patch) | |
tree | 6f255ff78abaf96f1e71a1f2c9ecd3b66647f4a2 /src/com/itmill/toolkit/terminal/ClassResource.java | |
parent | 93291f532db9d545cf2a8dd98e2671f27cd197b0 (diff) | |
download | vaadin-framework-f2e3722df9676436680afc0f1991e91e1696fb99.tar.gz vaadin-framework-f2e3722df9676436680afc0f1991e91e1696fb99.zip |
MASS REFORMAT.
According to http://toolkit.intra.itmill.com/trac/itmilltoolkit/wiki/CodingConventions
svn changeset:2864/svn branch:trunk
Diffstat (limited to 'src/com/itmill/toolkit/terminal/ClassResource.java')
-rw-r--r-- | src/com/itmill/toolkit/terminal/ClassResource.java | 299 |
1 files changed, 152 insertions, 147 deletions
diff --git a/src/com/itmill/toolkit/terminal/ClassResource.java b/src/com/itmill/toolkit/terminal/ClassResource.java index c53375350e..afb596f5c3 100644 --- a/src/com/itmill/toolkit/terminal/ClassResource.java +++ b/src/com/itmill/toolkit/terminal/ClassResource.java @@ -46,151 +46,156 @@ import com.itmill.toolkit.service.FileTypeResolver; */ public class ClassResource implements ApplicationResource { - /** - * Default buffer size for this stream resource. - */ - private int bufferSize = 0; - - /** - * Default cache time for this stream resource. - */ - private long cacheTime = DEFAULT_CACHETIME; - - /** - * Associated class used for indetifying the source of the resource. - */ - private Class associatedClass; - - /** - * Name of the resource is relative to the associated class. - */ - private String resourceName; - - /** - * Application used for serving the class. - */ - private Application application; - - /** - * Creates a new application resource instance. The resource id is relative - * to the location of the application class. - * - * @param resourceName - * the Unique identifier of the resource within the application. - * @param application - * the application this resource will be added to. - */ - public ClassResource(String resourceName, Application application) { - this.associatedClass = application.getClass(); - this.resourceName = resourceName; - this.application = application; - if (resourceName == null) - throw new NullPointerException(); - application.addResource(this); - } - - /** - * Creates a new application resource instance. - * - * @param associatedClass - * the class of the which the resource is associated. - * @param resourceName - * the Unique identifier of the resource within the application. - * @param application - * the application this resource will be added to. - */ - public ClassResource(Class associatedClass, String resourceName, - Application application) { - this.associatedClass = associatedClass; - this.resourceName = resourceName; - this.application = application; - if (resourceName == null || associatedClass == null) - throw new NullPointerException(); - application.addResource(this); - } - - /** - * Gets the MIME type of this resource. - * - * @see com.itmill.toolkit.terminal.Resource#getMIMEType() - */ - public String getMIMEType() { - return FileTypeResolver.getMIMEType(this.resourceName); - } - - /** - * Gets the application of this resource. - * - * @see com.itmill.toolkit.terminal.ApplicationResource#getApplication() - */ - public Application getApplication() { - return application; - } - - /** - * Gets the virtual filename for this resource. - * - * @return the file name associated to this resource. - * @see com.itmill.toolkit.terminal.ApplicationResource#getFilename() - */ - public String getFilename() { - int index = 0; - int next = 0; - while ((next = resourceName.indexOf('/', index)) > 0 - && next + 1 < resourceName.length()) - index = next + 1; - return resourceName.substring(index); - } - - /** - * Gets resource as stream. - * - * @see com.itmill.toolkit.terminal.ApplicationResource#getStream() - */ - public DownloadStream getStream() { - DownloadStream ds = new DownloadStream(associatedClass - .getResourceAsStream(resourceName), getMIMEType(), - getFilename()); - ds.setBufferSize(getBufferSize()); - ds.setCacheTime(cacheTime); - return ds; - } - - /* documented in superclass */ - public int getBufferSize() { - return bufferSize; - } - - /** - * Sets the size of the download buffer used for this resource. - * - * @param bufferSize - * the size of the buffer in bytes. - */ - public void setBufferSize(int bufferSize) { - this.bufferSize = bufferSize; - } - - /* documented in superclass */ - public long getCacheTime() { - return cacheTime; - } - - /** - * Sets the length of cache expiration time. - * - * <p> - * This gives the adapter the possibility cache streams sent to the client. - * The caching may be made in adapter or at the client if the client - * supports caching. Zero or negavive value disbales the caching of this - * stream. - * </p> - * - * @param cacheTime - * the cache time in milliseconds. - * - */ - public void setCacheTime(long cacheTime) { - this.cacheTime = cacheTime; - } + /** + * Default buffer size for this stream resource. + */ + private int bufferSize = 0; + + /** + * Default cache time for this stream resource. + */ + private long cacheTime = DEFAULT_CACHETIME; + + /** + * Associated class used for indetifying the source of the resource. + */ + private Class associatedClass; + + /** + * Name of the resource is relative to the associated class. + */ + private String resourceName; + + /** + * Application used for serving the class. + */ + private Application application; + + /** + * Creates a new application resource instance. The resource id is relative + * to the location of the application class. + * + * @param resourceName + * the Unique identifier of the resource within the + * application. + * @param application + * the application this resource will be added to. + */ + public ClassResource(String resourceName, Application application) { + associatedClass = application.getClass(); + this.resourceName = resourceName; + this.application = application; + if (resourceName == null) { + throw new NullPointerException(); + } + application.addResource(this); + } + + /** + * Creates a new application resource instance. + * + * @param associatedClass + * the class of the which the resource is associated. + * @param resourceName + * the Unique identifier of the resource within the + * application. + * @param application + * the application this resource will be added to. + */ + public ClassResource(Class associatedClass, String resourceName, + Application application) { + this.associatedClass = associatedClass; + this.resourceName = resourceName; + this.application = application; + if (resourceName == null || associatedClass == null) { + throw new NullPointerException(); + } + application.addResource(this); + } + + /** + * Gets the MIME type of this resource. + * + * @see com.itmill.toolkit.terminal.Resource#getMIMEType() + */ + public String getMIMEType() { + return FileTypeResolver.getMIMEType(resourceName); + } + + /** + * Gets the application of this resource. + * + * @see com.itmill.toolkit.terminal.ApplicationResource#getApplication() + */ + public Application getApplication() { + return application; + } + + /** + * Gets the virtual filename for this resource. + * + * @return the file name associated to this resource. + * @see com.itmill.toolkit.terminal.ApplicationResource#getFilename() + */ + public String getFilename() { + int index = 0; + int next = 0; + while ((next = resourceName.indexOf('/', index)) > 0 + && next + 1 < resourceName.length()) { + index = next + 1; + } + return resourceName.substring(index); + } + + /** + * Gets resource as stream. + * + * @see com.itmill.toolkit.terminal.ApplicationResource#getStream() + */ + public DownloadStream getStream() { + DownloadStream ds = new DownloadStream(associatedClass + .getResourceAsStream(resourceName), getMIMEType(), + getFilename()); + ds.setBufferSize(getBufferSize()); + ds.setCacheTime(cacheTime); + return ds; + } + + /* documented in superclass */ + public int getBufferSize() { + return bufferSize; + } + + /** + * Sets the size of the download buffer used for this resource. + * + * @param bufferSize + * the size of the buffer in bytes. + */ + public void setBufferSize(int bufferSize) { + this.bufferSize = bufferSize; + } + + /* documented in superclass */ + public long getCacheTime() { + return cacheTime; + } + + /** + * Sets the length of cache expiration time. + * + * <p> + * This gives the adapter the possibility cache streams sent to the client. + * The caching may be made in adapter or at the client if the client + * supports caching. Zero or negavive value disbales the caching of this + * stream. + * </p> + * + * @param cacheTime + * the cache time in milliseconds. + * + */ + public void setCacheTime(long cacheTime) { + this.cacheTime = cacheTime; + } } |