Interface ContentParser
-
@ProviderType public interface ContentParser
AContentParser
parses Sling resource trees from a file. Implementations have to be thread-safe. A consumer requiring aContentParser
reference should filter based on theSERVICE_PROPERTY_CONTENT_TYPE
in order to get a content type specific parser.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
SERVICE_PROPERTY_CONTENT_TYPE
OSGi service registration property indicating the content type thisContentParser
supports.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
parse(ContentHandler contentHandler, java.io.InputStream inputStream, ParserOptions parserOptions)
Parse content in a "stream-based" way.
-
-
-
Field Detail
-
SERVICE_PROPERTY_CONTENT_TYPE
static final java.lang.String SERVICE_PROPERTY_CONTENT_TYPE
OSGi service registration property indicating the content type thisContentParser
supports. The simplest way to retrieve aContentParser
for a certain content type is to apply a filter on the service reference:@Reference(target = "(" + ContentParser.SERVICE_PROPERTY_CONTENT_TYPE + "=" + _value_ + ")") private ContentParser parser;
If multiple services are registered for the same content type, the above code snippet will provide you with the service implementation with the highest ranking. However, if a certain implementation is needed, an additional filter can be added:@Reference(target = "(&(" + ContentParser.SERVICE_PROPERTY_CONTENT_TYPE + "=" + _value_ + ")(component.name=" + _class_name_ + "))") private ContentParser parser;
- See Also:
- Constant Field Values
-
-
Method Detail
-
parse
void parse(ContentHandler contentHandler, java.io.InputStream inputStream, ParserOptions parserOptions) throws java.io.IOException
Parse content in a "stream-based" way. Each resource that is found in the content is reported to theContentHandler
.- Parameters:
contentHandler
- content handler that accepts the parsed contentinputStream
- stream with serialized contentparserOptions
- parser options, providing different settings for handling the serialized content- Throws:
java.io.IOException
- when an I/O or parsing error occurs
-
-