org.weborganic.bastille.util
Class WebBundle

java.lang.Object
  extended by org.weborganic.bastille.util.WebBundle

public final class WebBundle
extends Object

A bundle of files to serve.

Since:
0.6.0

Nested Class Summary
static class WebBundle.Type
          The type of bundling required.
 
Constructor Summary
WebBundle(String name, List<File> files, boolean minimized)
          Creates a new bundles of files.
 
Method Summary
 void addImport(File f)
          Adds a file to consider as an import.
 void clearImport()
          Clears the list of imported files.
 List<File> files()
          Returns the list of files to bundle.
 String getETag(boolean refresh)
          Returns the etag for that bundle.
 String getFileName()
          Returns the filename of this bundle.
 String id()
          Returns an ID for that bundle based on the names list of files.
static String id(List<File> files)
          Returns an ID for this bundle.
 boolean isCSSMinimizable()
           
 boolean isFresh()
          Calculates whether the bundles is still fresh by comparing the etag.
 boolean isMinimized()
          Indicates whether the web bundle is minimized.
 String name()
          Returns the name of this bundle.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WebBundle

public WebBundle(String name,
                 List<File> files,
                 boolean minimized)
Creates a new bundles of files.

Parameters:
name - The name of the bundle.
files - The files to bundle.
minimized - Whether the files are minimized.
Method Detail

name

public String name()
Returns the name of this bundle.

Returns:
the name of this bundle.

files

public List<File> files()
Returns the list of files to bundle.

Returns:
the list of files to bundle.

id

public String id()
Returns an ID for that bundle based on the names list of files.

The ID of the bundle remain constant.

Returns:
an ID for that bundle based on the list of files.

clearImport

public void clearImport()
Clears the list of imported files.


addImport

public void addImport(File f)
Adds a file to consider as an import.

Parameters:
f - the file to import.

getETag

public String getETag(boolean refresh)
Returns the etag for that bundle.

The etag changes when any of the file changes.

Parameters:
refresh - true to calculate the etag; false otherwise.
Returns:
the etag for that bundle.

isFresh

public boolean isFresh()
Calculates whether the bundles is still fresh by comparing the etag.

Returns:
true if still fresh; false otherwise.

isMinimized

public boolean isMinimized()
Indicates whether the web bundle is minimized.

Returns:
true if minimized; false otherwise.

isCSSMinimizable

public boolean isCSSMinimizable()
Returns:
true if it can be safely minimized; false otherwise.

getFileName

public String getFileName()
Returns the filename of this bundle.

The filename is: [name]-[isodate]-[etag-suffix].[extension].

Or [name]-[isodate]-[etag-suffix].min.[extension] if minimized.

Returns:
the filename of this bundle.

id

public static String id(List<File> files)
Returns an ID for this bundle.

Parameters:
files - the files included in the bundle.
Returns:
An ID based on the hash value of the concatenation.