content-parser/impl-opendoc/src/main/java/net/sf/mmm/content/parser/impl/opendoc/AbstractContentParserOpenDoc.java
/**
   * This method parses the content of the document.
   * 
   * @param inputStream is the {@link InputStream} where to read the metadata
   *        from.
   * @param options are the {@link ContentParserOptions}
   * @param context is the {@link MutableGenericContext} where the extracted
   *        metadata from the parsed <code>inputStream</code> will be
   *        {@link MutableGenericContext#setVariable(String, Object) added} to.
   * @param buffer is the {@link StringBuilder} where to append the text.
   * @throws Exception if the operation fails for arbitrary reasons.
   */
This method parses the content of the document.

@param inputStream is the  InputStream where to read the metadata
from.
@param options are the  ContentParserOptions
@param context is the  MutableGenericContext where the extracted
metadata from the parsed inputStream will be
MutableGenericContext#setVariable(String, Object) added to.
@param buffer is the  StringBuilder where to append the text.
@throws Exception if the operation fails for arbitrary reasons.
This method parses the content of the document . @param inputStream is the InputStream where to read the metadata from . @param options are the ContentParserOptions @param context is the MutableGenericContext where the extracted metadata from the parsed inputStream will be MutableGenericContext#setVariable ( String Object ) added to . @param buffer is the StringBuilder where to append the text . @throws Exception if the operation fails for arbitrary reasons .
protected void parseContent(InputStream inputStream, ContentParserOptions options,
      MutableGenericContext context, StringBuilder buffer) throws Exception {
    int maxChars = options.getMaximumBufferSize() / 2;
    XMLStreamReader streamReader = XMLInputFactory.newInstance().createXMLStreamReader(inputStream);
    int type;
    String tag = "";
    do {
      type = streamReader.next();
      if (type == XMLStreamConstants.START_ELEMENT) {
        tag = streamReader.getLocalName();
      } else if ((type == XMLStreamConstants.CHARACTERS) || (type == XMLStreamConstants.CDATA)) {
        if (TEXT_TAGS.contains(tag)) {
          String text = streamReader.getText();
          buffer.append(text);
          if (buffer.length() > maxChars) {
            break;
          }
        }
      }
    } while (type != XMLStreamConstants.END_DOCUMENT);
    streamReader.close();
    context.setVariable(VARIABLE_NAME_TEXT, buffer.toString());
  }
protected void parseContent ( InputStream inputStream , ContentParserOptions options , MutableGenericContext context , StringBuilder buffer ) throws Exception { int maxChars = options . getMaximumBufferSize ( ) / 2 ; XMLStreamReader streamReader = XMLInputFactory . newInstance ( ) . createXMLStreamReader ( inputStream ) ; int type ; String tag = "" ; do { type = streamReader . next ( ) ; if ( type == XMLStreamConstants . START_ELEMENT ) { tag = streamReader . getLocalName ( ) ; } else if ( ( type == XMLStreamConstants . CHARACTERS ) || ( type == XMLStreamConstants . CDATA ) ) { if ( TEXT_TAGS . contains ( tag ) ) { String text = streamReader . getText ( ) ; buffer . append ( text ) ; if ( buffer . length ( ) > maxChars ) { break ; } } } } while ( type != XMLStreamConstants . END_DOCUMENT ) ; streamReader . close ( ) ; context . setVariable ( VARIABLE_NAME_TEXT , buffer . toString ( ) ) ; }
This method parses the content of the document.
This method parses the content of the document .