net.sf.mmm.content.parser.impl.xml
Class ContentParserXml

java.lang.Object
  extended by net.sf.mmm.util.component.base.AbstractComponent
      extended by net.sf.mmm.util.component.base.AbstractLoggableComponent
          extended by net.sf.mmm.content.parser.base.AbstractContentParser
              extended by net.sf.mmm.content.parser.impl.xml.ContentParserXml
All Implemented Interfaces:
ContentParser

@Singleton
@Named
public class ContentParserXml
extends AbstractContentParser

This is the implementation of the ContentParser interface for XML documents (content with the mimetype "text/xml").
It does NOT use a standard XML parser such as SAX or StAX to be fault tolerant. Still it supports XML encoding declarations, entities, CDATA sections, etc. Features like XInclude or entity-includes are (intentionally) NOT supported.

Author:
Joerg Hohwiller (hohwille at users.sourceforge.net)

Field Summary
static String KEY_EXTENSION
          The default extension.
static String KEY_MIMETYPE
          The mimetype.
private  net.sf.mmm.util.xml.api.XmlUtil xmlUtil
           
 
Fields inherited from interface net.sf.mmm.content.parser.api.ContentParser
VARIABLE_NAME_CREATOR, VARIABLE_NAME_KEYWORDS, VARIABLE_NAME_LANGUAGE, VARIABLE_NAME_TEXT, VARIABLE_NAME_TITLE
 
Constructor Summary
ContentParserXml()
          The constructor.
 
Method Summary
protected  void doInitialize()
          
 String[] getAlternativeKeyArray()
          
 String getExtension()
          
 String getMimetype()
          
 String[] getSecondaryKeyArray()
          
protected  net.sf.mmm.util.xml.api.XmlUtil getXmlUtil()
           
 void parse(BufferedReader bufferedReader, ContentParserOptions options, net.sf.mmm.util.context.api.MutableGenericContext context, StringBuilder textBuffer)
          This method parses the content of the given bufferedReader and appends the textual content to the textBuffer.
 void parse(InputStream inputStream, long filesize, ContentParserOptions options, net.sf.mmm.util.context.api.MutableGenericContext context)
          
 void setXmlUtil(net.sf.mmm.util.xml.api.XmlUtil xmlUtil)
           
 
Methods inherited from class net.sf.mmm.content.parser.base.AbstractContentParser
getPrimaryKeys, getSecondaryKeys, parse, parse, setGenericContextFactory
 
Methods inherited from class net.sf.mmm.util.component.base.AbstractLoggableComponent
getLogger, setLogger
 
Methods inherited from class net.sf.mmm.util.component.base.AbstractComponent
doInitialized, getInitializationState, initialize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

KEY_MIMETYPE

public static final String KEY_MIMETYPE
The mimetype.

See Also:
Constant Field Values

KEY_EXTENSION

public static final String KEY_EXTENSION
The default extension.

See Also:
Constant Field Values

xmlUtil

private net.sf.mmm.util.xml.api.XmlUtil xmlUtil
See Also:
getXmlUtil()
Constructor Detail

ContentParserXml

public ContentParserXml()
The constructor.

Method Detail

doInitialize

protected void doInitialize()

Overrides:
doInitialize in class AbstractContentParser

getXmlUtil

protected net.sf.mmm.util.xml.api.XmlUtil getXmlUtil()
Returns:
the xmlUtil

setXmlUtil

@Inject
public void setXmlUtil(net.sf.mmm.util.xml.api.XmlUtil xmlUtil)
Parameters:
xmlUtil - is the xmlUtil to set

getExtension

public String getExtension()


getMimetype

public String getMimetype()


getAlternativeKeyArray

public String[] getAlternativeKeyArray()

Overrides:
getAlternativeKeyArray in class AbstractContentParser

getSecondaryKeyArray

public String[] getSecondaryKeyArray()

Overrides:
getSecondaryKeyArray in class AbstractContentParser

parse

public void parse(InputStream inputStream,
                  long filesize,
                  ContentParserOptions options,
                  net.sf.mmm.util.context.api.MutableGenericContext context)
           throws Exception

Specified by:
parse in class AbstractContentParser
Throws:
Exception

parse

public void parse(BufferedReader bufferedReader,
                  ContentParserOptions options,
                  net.sf.mmm.util.context.api.MutableGenericContext context,
                  StringBuilder textBuffer)
           throws Exception
This method parses the content of the given bufferedReader and appends the textual content to the textBuffer. Additional metadata can directly be set in the given properties.

Parameters:
bufferedReader - is where to read the content from.
options - are the ContentParserOptions.
context - is where the metadata is collected.
textBuffer - is the buffer where the textual content should be appended to.
Throws:
Exception - if something goes wrong.


Copyright © 2001-2010 mmm-Team. All Rights Reserved.