org.alfresco.repo.content.transform
Class PoiHssfContentTransformer

java.lang.Object
  extended by org.alfresco.repo.content.transform.ContentTransformerHelper
      extended by org.alfresco.repo.content.transform.AbstractContentTransformer2
          extended by org.alfresco.repo.content.transform.PoiHssfContentTransformer
All Implemented Interfaces:
ContentWorker, ContentTransformer

public class PoiHssfContentTransformer
extends AbstractContentTransformer2

Makes use of the POI library to perform conversions from Excel spreadsheets to text (comma separated).

While most text extraction from spreadsheets only extract the first sheet of the workbook, the method used here extracts the text from all the sheets. This is more useful, especially when it comes to indexing spreadsheets.

In the case where there is only one sheet in the document, the results will be exactly the same as most extractors. Where there are multiple sheets, the results will differ, but meaningful reimporting of the text document is not possible anyway.


Field Summary
static java.lang.String WRONG_FORMAT_MESSAGE_ID
          Error message to delegate to NodeInfoBean
 
Constructor Summary
PoiHssfContentTransformer()
           
 
Method Summary
 boolean isTransformable(java.lang.String sourceMimetype, java.lang.String targetMimetype, TransformationOptions options)
          Currently the only transformation performed is that of text extraction from XLS documents.
 void transformInternal(ContentReader reader, ContentWriter writer, TransformationOptions options)
          Method to be implemented by subclasses wishing to make use of the common infrastructural code provided by this class.
static void writeString(java.io.OutputStream os, java.lang.String encoding, java.lang.String value, boolean isData)
          Writes the given data to the stream using the encoding specified.
 
Methods inherited from class org.alfresco.repo.content.transform.AbstractContentTransformer2
checkTransformable, getTransformationTime, recordTime, register, setRegistry, toString, transform, transform, transform
 
Methods inherited from class org.alfresco.repo.content.transform.ContentTransformerHelper
getMimetype, getMimetypeService, isExplicitTransformation, setExplicitTransformations, setMimetypeService
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.alfresco.repo.content.transform.ContentTransformer
isExplicitTransformation
 

Field Detail

WRONG_FORMAT_MESSAGE_ID

public static final java.lang.String WRONG_FORMAT_MESSAGE_ID
Error message to delegate to NodeInfoBean

See Also:
Constant Field Values
Constructor Detail

PoiHssfContentTransformer

public PoiHssfContentTransformer()
Method Detail

isTransformable

public boolean isTransformable(java.lang.String sourceMimetype,
                               java.lang.String targetMimetype,
                               TransformationOptions options)
Currently the only transformation performed is that of text extraction from XLS documents.

Parameters:
sourceMimetype - the source mimetype
options - the transformation options
Returns:
boolean true if this content transformer can satify the mimetypes and options specified, false otherwise

transformInternal

public void transformInternal(ContentReader reader,
                              ContentWriter writer,
                              TransformationOptions options)
                       throws java.lang.Exception
Description copied from class: AbstractContentTransformer2
Method to be implemented by subclasses wishing to make use of the common infrastructural code provided by this class.

Specified by:
transformInternal in class AbstractContentTransformer2
Parameters:
reader - the source of the content to transform
writer - the target to which to write the transformed content
options - a map of options to use when performing the transformation. The map will never be null.
Throws:
java.lang.Exception - exceptions will be handled by this class - subclasses can throw anything

writeString

public static void writeString(java.io.OutputStream os,
                               java.lang.String encoding,
                               java.lang.String value,
                               boolean isData)
                        throws java.lang.Exception
Writes the given data to the stream using the encoding specified. If the encoding is not given, the default String to byte[] conversion will be used.

The given data string will be escaped appropriately.

Parameters:
os - the stream to write to
encoding - the encoding to use, or null if the default encoding is acceptable
value - the string to write
isData - true if the value represents a human-readable string, false if the value represents formatting characters, separating characters, etc.
Throws:
java.lang.Exception


Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.