org.apache.cocoon.components.source.impl
Class AbstractImageSourceInspector

java.lang.Object
  extended by org.apache.avalon.framework.logger.AbstractLogEnabled
      extended by org.apache.cocoon.components.source.impl.AbstractImageSourceInspector
All Implemented Interfaces:
Component, LogEnabled, SourceInspector
Direct Known Subclasses:
GIFSourceInspector, JPEGSourceInspector

public abstract class AbstractImageSourceInspector
extends AbstractLogEnabled
implements SourceInspector

Abstract base class for inspectors that can calculate the size of an image of a particular type.

Author:
Unico Hommes

Field Summary
static String IMAGE_HEIGHT_PROPERTY_NAME
          height property name.
static String IMAGE_WIDTH_PROPERTY_NAME
          width property name.
static String PROPERTY_NS
          The namespace uri of the properties exposed by this SourceInspector.
 
Fields inherited from interface org.apache.cocoon.components.source.SourceInspector
ROLE
 
Constructor Summary
AbstractImageSourceInspector()
           
 
Method Summary
 String[] getHandledPropertyTypes()
           
protected abstract  int[] getImageSize(Source source)
          Calculate the width and the height of the image represented by source.
 SourceProperty[] getSourceProperties(Source source)
          Gets all the SourceProperties associated with the given Source.
 SourceProperty getSourceProperty(Source source, String namespace, String name)
          Gets the SourceProperty associated with the given Source identified by the requested namespace and name.
 SourceValidity getValidity(Source source)
          Returns NOPValidity
 boolean handlesProperty(String namespace, String name)
          Check whether this inspector handles properties of the given kind.
protected abstract  boolean isImageFileType(Source source)
          Inspects the input stream to verify this is in fact a file of the type that this inspector handles.
protected abstract  boolean isImageMimeType(Source source)
          Checks whether the mime mapping yields the type this inspector handles.
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROPERTY_NS

public static final String PROPERTY_NS
The namespace uri of the properties exposed by this SourceInspector.

The value is http://apache.org/cocoon/inspector/image/1.0.

See Also:
Constant Field Values

IMAGE_WIDTH_PROPERTY_NAME

public static final String IMAGE_WIDTH_PROPERTY_NAME
width property name.

See Also:
Constant Field Values

IMAGE_HEIGHT_PROPERTY_NAME

public static final String IMAGE_HEIGHT_PROPERTY_NAME
height property name.

See Also:
Constant Field Values
Constructor Detail

AbstractImageSourceInspector

public AbstractImageSourceInspector()
Method Detail

getSourceProperty

public final SourceProperty getSourceProperty(Source source,
                                              String namespace,
                                              String name)
                                       throws SourceException
Description copied from interface: SourceInspector
Gets the SourceProperty associated with the given Source identified by the requested namespace and name.

Specified by:
getSourceProperty in interface SourceInspector
Parameters:
source - the source for which to compute the property
namespace - the namespace of the property
name - the name of the property
Returns:
the SourceProperty associated with the Source, null if the inspector does not provide this property.
Throws:
SourceException

getSourceProperties

public final SourceProperty[] getSourceProperties(Source source)
                                           throws SourceException
Description copied from interface: SourceInspector
Gets all the SourceProperties associated with the given Source.

Specified by:
getSourceProperties in interface SourceInspector
Parameters:
source - the Source for wich to compute the property.
Returns:
the collection of all SourceProperties that could be computed by this SourceInspector.
Throws:
SourceException

getHandledPropertyTypes

public final String[] getHandledPropertyTypes()

handlesProperty

public final boolean handlesProperty(String namespace,
                                     String name)
Check whether this inspector handles properties of the given kind.

Specified by:
handlesProperty in interface SourceInspector
Parameters:
namespace - the namespace of the property
name - the name of the property
Returns:
true if this inspector handles properties of the given type else false.

getValidity

public SourceValidity getValidity(Source source)
Returns NOPValidity

Specified by:
getValidity in interface SourceInspector
Parameters:
source - the Source for which to calculate the validity its properties, null if the source properties are not cacheable.

isImageMimeType

protected abstract boolean isImageMimeType(Source source)
Checks whether the mime mapping yields the type this inspector handles.

Parameters:
source - the Source to test

isImageFileType

protected abstract boolean isImageFileType(Source source)
                                    throws SourceException
Inspects the input stream to verify this is in fact a file of the type that this inspector handles.

Parameters:
source - the Source to test
Throws:
SourceException

getImageSize

protected abstract int[] getImageSize(Source source)
                               throws SourceException
Calculate the width and the height of the image represented by source.

Parameters:
source - the Source to inspect.
Returns:
array carrying the calculated width parameter in its 0 index, the height under index 1.
Throws:
SourceException


Copyright © 1999-2010 The Apache Software Foundation. All Rights Reserved.