net.grcomputing.opencms.search.lucene
Class ExtensionMapping

java.lang.Object
  |
  +--net.grcomputing.opencms.search.lucene.ExtensionMapping

public class ExtensionMapping
extends java.lang.Object

This class maps extensions to Lucene search document factories (e.g. implementations of I_DocumentFactory).

Extensions are used by the indexer to determine what document factory ought to be used to index the content of particular resources. Normally, extensions are only checked for content of type "plain", not Pages or JSPs.

I have tried to set suitable default values, such as a default document factory of net.grcomputing.opencms.search.lucene.BodylessDocument.

Author:
Matt Butcher mbutcher@grcomputing.net
See Also:
http://grcomputing.net

Constructor Summary
ExtensionMapping(java.lang.String docFac, java.lang.String name)
          Creates a new Extension Mapping with an empty list of extensions.
 
Method Summary
 boolean addExtension(java.lang.String ext)
          Adds an extension.
 I_DocumentFactory getDocumentFactory()
          Returns an instance of the appropriate DocumentFactory.
 java.lang.String getDocumentFactoryName()
          Gets the class name for the document factory.
 java.lang.String getName()
          Gets the name of this extension map.
 boolean handlesExtension(java.lang.String ext)
          Returns true if this ExtensionMapping handles the given extension.
 boolean removeExtension(java.lang.String ext)
          Removes an extension from the list of extensions.
 void setName(java.lang.String name)
          Sets the name of this extension map.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExtensionMapping

public ExtensionMapping(java.lang.String docFac,
                        java.lang.String name)
Creates a new Extension Mapping with an empty list of extensions.

Method Detail

addExtension

public boolean addExtension(java.lang.String ext)
Adds an extension. Extensions should be of type ".xxx". If the dot is not present, it will be prepended. There is no limit on the characters, however, the underlying filesystems might have problems with non-ASCII letters. NOTE: using additional dots in the extension may also cause problems with the underlying implementation of OpenCMS. The extension ".tar.gz" will likely be rendered ".gz" by OpenCMS. Therefore, it would not match the class to handle .tar.gz files here.

Returns:
true if extension was added, false if not (which means the extension is already there.

removeExtension

public boolean removeExtension(java.lang.String ext)
Removes an extension from the list of extensions. If the extension doesn't exist in the list, the return will be false. Otherwise, true.

Returns:
true if extension was removed, false if no match was found.

handlesExtension

public boolean handlesExtension(java.lang.String ext)
Returns true if this ExtensionMapping handles the given extension. When this is true, it means that the DocumentFactory encapsulated in this ExtensionMap can be applied to files with the given extension.

Returns:
true if this ExtensionMapping handles the given extension. False otherwise.

setName

public void setName(java.lang.String name)
Sets the name of this extension map. Mainly, names are used for debug information. it's a good idea to set this.


getName

public java.lang.String getName()
Gets the name of this extension map.

Returns:
String name

getDocumentFactoryName

public java.lang.String getDocumentFactoryName()
Gets the class name for the document factory.

Returns:
String name

getDocumentFactory

public I_DocumentFactory getDocumentFactory()
                                     throws CmsException
Returns an instance of the appropriate DocumentFactory.

Returns:
An implementation of an I_DocumentFactory
Throws:
CmsException - if it can't load the class.


Copyright © 2003 Matt Butcher of Global Resources for Computing. Reporoduction and modification of this documents are allowed as in accordance with the GPL v2. Refer to COPYING.txt for information on acceptible use