public class SyndEntryDocumentSource extends Object implements SyndEntrySource
XWikiDocument
instance.Modifier and Type | Class and Description |
---|---|
static class |
SyndEntryDocumentSource.PropertySelector
Utility class for selecting a property from a XWiki object.
|
Modifier and Type | Field and Description |
---|---|
static String |
CONTENT_LENGTH |
static String |
CONTENT_TYPE |
static Map<String,Object> |
DEFAULT_PARAMS |
static String |
FIELD_AUTHOR |
static String |
FIELD_CATEGORIES |
static String |
FIELD_CONTRIBUTORS |
static String |
FIELD_DESCRIPTION |
static String |
FIELD_LINK |
static String |
FIELD_PUBLISHED_DATE |
static String |
FIELD_TITLE |
static String |
FIELD_UPDATED_DATE |
static String |
FIELD_URI |
protected static org.slf4j.Logger |
LOGGER |
static Properties |
TIDY_FEED_CONFIG |
static Properties |
TIDY_HTML_CONFIG |
protected static TidyMessageLogger |
TIDY_LOGGER |
static Properties |
TIDY_XML_CONFIG |
Constructor and Description |
---|
SyndEntryDocumentSource() |
SyndEntryDocumentSource(Map<String,Object> params)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
protected Document |
castDocument(Object obj,
XWikiContext context)
Casts the given object to a
Document instance. |
protected String |
getAuthor(Document doc,
Map<String,Object> params,
XWikiContext context) |
protected List<com.sun.syndication.feed.synd.SyndCategory> |
getCategories(Document doc,
Map<String,Object> params,
XWikiContext context) |
protected List<String> |
getContributors(Document doc,
Map<String,Object> params,
XWikiContext context) |
protected Date |
getDateValue(String mapping,
Document doc,
XWikiContext context)
Retrieves the value of a date property.
|
protected String |
getDefaultAuthor(Document doc,
Map<String,Object> params,
XWikiContext context) |
protected List<com.sun.syndication.feed.synd.SyndCategory> |
getDefaultCategories(Document doc,
Map<String,Object> params,
XWikiContext context) |
protected List<String> |
getDefaultContributors(Document doc,
Map<String,Object> params,
XWikiContext context) |
protected String |
getDefaultDescription(Document doc,
Map<String,Object> params,
XWikiContext context) |
protected String |
getDefaultLink(Document doc,
Map<String,Object> params,
XWikiContext context) |
protected Map<String,Object> |
getDefaultParams()
Strategy class parameters
|
protected Date |
getDefaultPublishedDate(Document doc,
Map<String,Object> params,
XWikiContext context) |
protected String |
getDefaultTitle(Document doc,
Map<String,Object> params,
XWikiContext context) |
protected Date |
getDefaultUpdateDate(Document doc,
Map<String,Object> params,
XWikiContext context) |
protected String |
getDefaultURI(Document doc,
Map<String,Object> params,
XWikiContext context) |
protected com.sun.syndication.feed.synd.SyndContent |
getDescription(Document doc,
Map<String,Object> params,
XWikiContext context) |
static String |
getHTMLPreview(String htmlFragment,
int previewLength)
Extracts the first characters of the given HTML fragment, up to the given length limit, adding only characters in
HTML text nodes.
|
protected String |
getLink(Document doc,
Map<String,Object> params,
XWikiContext context) |
protected List<Object> |
getListValue(String mapping,
Document doc,
XWikiContext context)
Retrieves the value of a list property.
|
Map<String,Object> |
getParams() |
static String |
getPlainPreview(String plainText,
int previewLength)
Extracts the first characters of the given text, up to the last space within the given length limit.
|
protected Date |
getPublishedDate(Document doc,
Map<String,Object> params,
XWikiContext context) |
protected String |
getStringValue(String mapping,
Document doc,
XWikiContext context)
Retrieves the value of a string property.
|
protected com.sun.syndication.feed.synd.SyndContent |
getSyndContent(String type,
String value)
Creates a new
SyndContent instance for the given content type and value. |
protected String |
getTitle(Document doc,
Map<String,Object> params,
XWikiContext context) |
protected Date |
getUpdateDate(Document doc,
Map<String,Object> params,
XWikiContext context) |
protected String |
getURI(Document doc,
Map<String,Object> params,
XWikiContext context) |
static String |
getXMLPreview(String xmlFragment,
int previewLength)
Extracts the first characters of the given XML fragment, up to the given length limit, adding only characters in
XML text nodes.
|
static int |
innerTextLength(Node node)
Computes the sum of lengths of all the text nodes within the given DOM sub-tree
|
protected boolean |
isVelocityCode(String mapping)
Distinguishes between mapping to a property and mapping to a velocity code.
|
protected Map<String,Object> |
joinParams(Map<String,Object> base,
Map<String,Object> extra) |
protected Date |
parseDate(String mapping,
Document doc,
XWikiContext context)
Converts the given velocity string to a
Date instance. |
protected List<Object> |
parseList(String mapping,
Document doc,
XWikiContext context)
Converts the given velocity code to a
List instance. |
protected String |
parseString(String mapping,
Document doc,
XWikiContext context) |
void |
setParams(Map<String,Object> params)
Sets instance parameters.
|
void |
source(com.sun.syndication.feed.synd.SyndEntry entry,
Object obj,
Map<String,Object> params,
XWikiContext context)
Overwrites the current values of the given feed entry with new ones computed from the specified source object.
|
void |
sourceDocument(com.sun.syndication.feed.synd.SyndEntry entry,
Document doc,
Map<String,Object> params,
XWikiContext context)
Overwrites the current values of the given feed entry with new ones computed from the specified source document.
|
static Document |
tidy(String xmlFragment,
Properties config)
Cleans up the given XML fragment using the specified configuration.
|
protected static final org.slf4j.Logger LOGGER
protected static final TidyMessageLogger TIDY_LOGGER
public static final String CONTENT_TYPE
public static final String CONTENT_LENGTH
public static final Properties TIDY_FEED_CONFIG
public static final Properties TIDY_XML_CONFIG
public static final Properties TIDY_HTML_CONFIG
public static final String FIELD_URI
public static final String FIELD_LINK
public static final String FIELD_TITLE
public static final String FIELD_DESCRIPTION
public static final String FIELD_CATEGORIES
public static final String FIELD_PUBLISHED_DATE
public static final String FIELD_UPDATED_DATE
public static final String FIELD_AUTHOR
public static final String FIELD_CONTRIBUTORS
public SyndEntryDocumentSource()
public SyndEntryDocumentSource(Map<String,Object> params)
DEFAULT_PARAMS
.params
- parameters only for this instancepublic void setParams(Map<String,Object> params)
DEFAULT_PARAMS
params
- instance parameterspublic void source(com.sun.syndication.feed.synd.SyndEntry entry, Object obj, Map<String,Object> params, XWikiContext context) throws XWikiException
SyndEntrySource
source
in interface SyndEntrySource
entry
- the feed entry whose fields are going to be overwrittenobj
- the source for the new values to be set on the fields of the feed entryparams
- parameters to adjust the computation. Each concrete strategy may define its own (key, value) pairscontext
- the XWiki contextXWikiException
public void sourceDocument(com.sun.syndication.feed.synd.SyndEntry entry, Document doc, Map<String,Object> params, XWikiContext context) throws XWikiException
entry
- the feed entry whose fields are going to be overwrittendoc
- the source for the new values to be set on the fields of the feed entryparams
- parameters to adjust the computation. Each concrete strategy may define its own (key, value) pairscontext
- the XWiki contextXWikiException
protected String getDefaultURI(Document doc, Map<String,Object> params, XWikiContext context) throws XWikiException
XWikiException
protected String getURI(Document doc, Map<String,Object> params, XWikiContext context) throws XWikiException
XWikiException
protected String getDefaultLink(Document doc, Map<String,Object> params, XWikiContext context) throws XWikiException
XWikiException
protected String getLink(Document doc, Map<String,Object> params, XWikiContext context) throws XWikiException
XWikiException
protected String getDefaultTitle(Document doc, Map<String,Object> params, XWikiContext context)
protected String getTitle(Document doc, Map<String,Object> params, XWikiContext context) throws XWikiException
XWikiException
protected String getDefaultDescription(Document doc, Map<String,Object> params, XWikiContext context)
protected com.sun.syndication.feed.synd.SyndContent getDescription(Document doc, Map<String,Object> params, XWikiContext context) throws XWikiException
XWikiException
protected List<com.sun.syndication.feed.synd.SyndCategory> getDefaultCategories(Document doc, Map<String,Object> params, XWikiContext context)
protected List<com.sun.syndication.feed.synd.SyndCategory> getCategories(Document doc, Map<String,Object> params, XWikiContext context) throws XWikiException
XWikiException
protected Date getDefaultPublishedDate(Document doc, Map<String,Object> params, XWikiContext context)
protected Date getPublishedDate(Document doc, Map<String,Object> params, XWikiContext context) throws XWikiException
XWikiException
protected Date getDefaultUpdateDate(Document doc, Map<String,Object> params, XWikiContext context)
protected Date getUpdateDate(Document doc, Map<String,Object> params, XWikiContext context) throws XWikiException
XWikiException
protected String getDefaultAuthor(Document doc, Map<String,Object> params, XWikiContext context)
protected String getAuthor(Document doc, Map<String,Object> params, XWikiContext context) throws XWikiException
XWikiException
protected List<String> getDefaultContributors(Document doc, Map<String,Object> params, XWikiContext context)
protected List<String> getContributors(Document doc, Map<String,Object> params, XWikiContext context) throws XWikiException
XWikiException
protected boolean isVelocityCode(String mapping)
mapping
- protected String parseString(String mapping, Document doc, XWikiContext context) throws XWikiException
XWikiException
protected Date parseDate(String mapping, Document doc, XWikiContext context) throws NumberFormatException, XWikiException
Date
instance. The velocity code must be evaluated to a long
representing a time stamp.NumberFormatException
XWikiException
protected List<Object> parseList(String mapping, Document doc, XWikiContext context) throws XWikiException
List
instance. The velocity code must be evaluated to a string with
the following format: "[item1,item2,...,itemN]".XWikiException
protected String getStringValue(String mapping, Document doc, XWikiContext context) throws XWikiException
XWikiException
protected Date getDateValue(String mapping, Document doc, XWikiContext context) throws XWikiException
XWikiException
protected List<Object> getListValue(String mapping, Document doc, XWikiContext context) throws XWikiException
XWikiException
protected Map<String,Object> joinParams(Map<String,Object> base, Map<String,Object> extra)
public static Document tidy(String xmlFragment, Properties config)
xmlFragment
- the XML fragment to be cleaned upconfig
- the configuration properties to usepublic static int innerTextLength(Node node)
node
- the root of the DOM sub-tree containing the textpublic static String getXMLPreview(String xmlFragment, int previewLength)
xmlFragment
- the full XML textpreviewLength
- the maximum number of characters allowed in the preview, considering only the XML text nodespreviewLength
characters in its text
nodespublic static String getHTMLPreview(String htmlFragment, int previewLength)
htmlFragment
- the full HTML textpreviewLength
- the maximum number of characters allowed in the preview, considering only the HTML text
nodespreviewLength
characters in its text
nodespublic static String getPlainPreview(String plainText, int previewLength)
plainText
- the full textpreviewLength
- the maximum number of characters allowed in the previewplainText
having at most previewLength
charactersprotected com.sun.syndication.feed.synd.SyndContent getSyndContent(String type, String value)
SyndContent
instance for the given content type and value.type
- content typevalue
- the contentSyndContent
instanceprotected Document castDocument(Object obj, XWikiContext context) throws XWikiException
Document
instance. The given object must be either a Document
instance already, a XWikiDocument
instance or the full name of the document.obj
- object to be castedcontext
- the XWiki contextXWikiException
- if the given object is neither a Document
instance, a XWikiDocument
instance nor the full name of the documentCopyright © 2004–2021 XWiki. All rights reserved.