/*
* Created on Feb 9, 2005
*
*/
package com.sun.portal.wireless.htmlconversion;
import java.util.HashMap;
import com.sun.portal.wireless.htmlconversion.processors.*;
/**
* Singleton class holding a registry mapping TagProcessor implementations to the
* corresponding HTML tag.
*
* @author ashwin.mathew@sun.com
*/
public class TagProcessorRegistry
{
private static TagProcessorRegistry instance = new TagProcessorRegistry();
private HashMap processorMap = new HashMap();
/**
* Private constructor for singleton, used to register all TagProcessor
* implementations.
*/
private TagProcessorRegistry()
{
registerTagProcessor(new AmlTextTagProcessor());
registerTagProcessor(new AmlDocumentTitleTagProcessor());
registerTagProcessor(new AmlBrTagProcessor());
registerTagProcessor(new AmlListTagProcessor());
registerTagProcessor(new AmlOrderedListTagProcessor());
registerTagProcessor(new AmlListItemTagProcessor());
registerTagProcessor(new AmlDocumentTagProcessor());
registerTagProcessor(new AmlPageTagProcessor());
registerTagProcessor(new AmlLinkTagProcessor());
registerTagProcessor(new AmlFormTagProcessor());
registerTagProcessor(new HtmlInputTagProcessor());
registerTagProcessor(new AmlInputTagProcessor());
registerTagProcessor(new AmlFormSubmitTagProcessor());
registerTagProcessor(new AmlFormResetTagProcessor());
registerTagProcessor(new AmlCheckBoxTagProcessor());
registerTagProcessor(new AmlChoiceTagProcessor());
registerTagProcessor(new AmlOptionTagProcessor());
registerTagProcessor(new HtmlRadioTagProcessor());
registerTagProcessor(new AmlTextAreaTagProcessor());
registerTagProcessor(new HtmlButtonTagProcessor());
registerTagProcessor(new AmlTableTagProcessor());
registerTagProcessor(new AmlTableRowTagProcessor());
registerTagProcessor(new AmlTableColTagProcessor());
registerTagProcessor(new HtmlIgnoreTagProcessor());
registerTagProcessor(new AmlImageTagProcessor());
registerTagProcessor(new HtmlBaseTagProcessor());
}
public static TagProcessorRegistry getInstance()
{
return instance;
}
/**
* Returns the processor for the named tag - it's assumed that all tag names
* are lower case.
* @param tag
* @return
*/
public TagProcessor getProcessor(String tag)
{
return (TagProcessor) processorMap.get(tag);
}
/**
* Registers a tag processor, mapping it to all the tags in it's
* supported tags list.
* @param processor
*/
public void registerTagProcessor(TagProcessor processor)
{
// First add all the HTML tags
String[] supportedTags = processor.getSupportedTags();
for (int i=0; i<supportedTags.length; i++)
{
processorMap.put(supportedTags[i], processor);
}
// Also add the AML tag name
String amlTag = processor.getAmlTag();
if (amlTag != null)
{
processorMap.put(amlTag, processor);
}
}
}
|