|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.any23.extractor.microdata.MicrodataParser
public class MicrodataParser
This class provides utility methods for handling Microdata nodes contained within a DOM document.
| Field Summary | |
|---|---|
static Set<String> |
HREF_TAGS
List of tags providing the href property. |
static String |
ITEMPROP_ATTRIBUTE
|
static String |
ITEMSCOPE_ATTRIBUTE
|
static Set<String> |
SRC_TAGS
List of tags providing the src property. |
| Constructor Summary | |
|---|---|
MicrodataParser(Document document)
|
|
| Method Summary | |
|---|---|
ItemProp[] |
deferProperties(String... refs)
Given a document and a list of itemprop names this method will return such itemprops. |
org.apache.any23.extractor.microdata.MicrodataParser.ErrorMode |
getErrorMode()
|
MicrodataParserException[] |
getErrors()
|
static List<Node> |
getItemPropNodes(Node node)
Returns all the itemProps detected within the given root node. |
List<ItemProp> |
getItemProps(Node node,
boolean skipRoot)
Returns all the itemprops for the given itemscope node. |
ItemScope |
getItemScope(Node node)
Returns the ItemScope instance described within the specified node. |
static List<Node> |
getItemScopeNodes(Node node)
Returns all the itemScopes detected within the given root node. |
static MicrodataParserReport |
getMicrodata(Document document)
Returns all the Microdata items detected within the given document,
works in full report mode. |
static MicrodataParserReport |
getMicrodata(Document document,
org.apache.any23.extractor.microdata.MicrodataParser.ErrorMode errorMode)
Returns all the Microdata items detected within the given document. |
static void |
getMicrodataAsJSON(Document document,
PrintStream ps)
Returns a JSON containing the list of all extracted Microdata, as described at Microdata JSON Specification. |
ItemPropValue |
getPropertyValue(Node node)
Reads the value of a itemprop node. |
static List<Node> |
getTopLevelItemScopeNodes(Node node)
Returns only the itemScopes that are top level items. |
static boolean |
isItemProp(Node node)
Check whether a node is an itemProp. |
static boolean |
isItemScope(Node node)
Check whether a node is an itemScope. |
void |
setErrorMode(org.apache.any23.extractor.microdata.MicrodataParser.ErrorMode errorMode)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String ITEMSCOPE_ATTRIBUTE
public static final String ITEMPROP_ATTRIBUTE
public static final Set<String> SRC_TAGS
src property.
public static final Set<String> HREF_TAGS
href property.
| Constructor Detail |
|---|
public MicrodataParser(Document document)
| Method Detail |
|---|
public static List<Node> getItemScopeNodes(Node node)
node - root node to search in.
public static boolean isItemScope(Node node)
node - node to check.
true if the node is an itemScope., false otherwise.public static List<Node> getItemPropNodes(Node node)
node - root node to search in.
public static boolean isItemProp(Node node)
node - node to check.
true if the node is an itemProp., false otherwise.public static List<Node> getTopLevelItemScopeNodes(Node node)
node - root node to search in.
public static MicrodataParserReport getMicrodata(Document document,
org.apache.any23.extractor.microdata.MicrodataParser.ErrorMode errorMode)
throws MicrodataParserException
document.
document - document to be processed.errorMode - error management policy.
MicrodataParserException - if errorMode == ErrorMode#StopAtFirstError
and an error occurs.public static MicrodataParserReport getMicrodata(Document document)
document,
works in full report mode.
document - document to be processed.
public static void getMicrodataAsJSON(Document document,
PrintStream ps)
document - document to be processed.ps - public void setErrorMode(org.apache.any23.extractor.microdata.MicrodataParser.ErrorMode errorMode)
public org.apache.any23.extractor.microdata.MicrodataParser.ErrorMode getErrorMode()
public MicrodataParserException[] getErrors()
public ItemPropValue getPropertyValue(Node node)
throws MicrodataParserException
node - itemprop node.
node.
MicrodataParserException - if an error occurs while extracting a nested item scope.
public List<ItemProp> getItemProps(Node node,
boolean skipRoot)
throws MicrodataParserException
node - node representing the itemscope>skipRoot - if true the given root node
will be not read as a property, even if it contains the itemprop attribute.
- Returns:
- the list of itemprops detected within the given itemscope.
- Throws:
MicrodataParserException - if an error occurs while retrieving an property value.
public ItemProp[] deferProperties(String... refs)
throws MicrodataParserException
refs - list of references.
MicrodataParserException - if a loop is detected or a property name is missing.
public ItemScope getItemScope(Node node)
throws MicrodataParserException
ItemScope instance described within the specified node.
node - node describing an itemscope.
MicrodataParserException - if an error occurs while dereferencing properties.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||