fnug.resource
Class AbstractAggregatedResource

java.lang.Object
  extended by fnug.resource.AbstractResource
      extended by fnug.resource.AbstractAggregatedResource
All Implemented Interfaces:
AggregatedResource, HasLastModifiedBytes, Resource
Direct Known Subclasses:
DefaultResourceCollection

public abstract class AbstractAggregatedResource
extends AbstractResource
implements AggregatedResource

Abstract superclass for aggregated resources.

Author:
Martin Algesten

Nested Class Summary
 
Nested classes/interfaces inherited from class fnug.resource.AbstractResource
AbstractResource.Entry
 
Field Summary
 
Fields inherited from class fnug.resource.AbstractResource
CONTENT_TYPE_TEXT_CSS, CONTENT_TYPE_TEXT_JAVASCRIPT
 
Constructor Summary
protected AbstractAggregatedResource(Bundle owner, String path)
          Constructs setting necessary fields.
 
Method Summary
protected abstract  byte[] buildAggregate()
          Must be implemented in subclasses to build the aggregated bytes.
 boolean checkModified()
          Calls Resource.checkModified() on all the underlying resources in AggregatedResource.getAggregates() and AggregatedResource.getDependencies().
 List<String> findRequiresTags()
          Always throws UnsupportedOperationException.
protected  AbstractResource.Entry readEntry()
          Implements the abstract readEntry(), and uses readLastModified() and buildAggregate() to build the AbstractResource.Entry .
protected  long readLastModified()
          Loops over AggregatedResource.getAggregates() and AggregatedResource.getDependencies() to find the most recent last modified date.
 
Methods inherited from class fnug.resource.AbstractResource
contentTypeForPath, ensureReadEntry, getBasePath, getBytes, getContentType, getFullPath, getLastModified, getPath, isCss, isJs, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface fnug.resource.AggregatedResource
getAggregates, getBasePath, getDependencies
 
Methods inherited from interface fnug.resource.Resource
getBytes, getContentType, getFullPath, getLastModified, getPath, isCss, isJs
 

Constructor Detail

AbstractAggregatedResource

protected AbstractAggregatedResource(Bundle owner,
                                     String path)
Constructs setting necessary fields.

Parameters:
owner - The bundle owning this aggregated resource.
path - The path of the resource. See AbstractResource.getPath().
Method Detail

readEntry

protected final AbstractResource.Entry readEntry()
Implements the abstract readEntry(), and uses readLastModified() and buildAggregate() to build the AbstractResource.Entry .

Specified by:
readEntry in class AbstractResource
Returns:
the bytes and last modified date.

buildAggregate

protected abstract byte[] buildAggregate()
Must be implemented in subclasses to build the aggregated bytes.

Returns:
the aggregated bytes, built from AggregatedResource.getAggregates().

readLastModified

protected long readLastModified()
Loops over AggregatedResource.getAggregates() and AggregatedResource.getDependencies() to find the most recent last modified date.

Specified by:
readLastModified in class AbstractResource
Returns:
the most recent last modified date.

checkModified

public boolean checkModified()
Calls Resource.checkModified() on all the underlying resources in AggregatedResource.getAggregates() and AggregatedResource.getDependencies(). After that calls super class checkModified() which may trigger a rebuild of the aggregate (via readEntry(), buildAggregate())

Specified by:
checkModified in interface Resource
Overrides:
checkModified in class AbstractResource
Returns:
true if any of the resources were found to be newer.

findRequiresTags

public List<String> findRequiresTags()
Always throws UnsupportedOperationException.

Specified by:
findRequiresTags in interface Resource
Returns:
The list of parsed resources found in the file.


Copyright © 2012. All Rights Reserved.