Package org.ametys.cms.content
Class ContentExtractor
java.lang.Object
org.ametys.cms.content.ContentExtractor
- All Implemented Interfaces:
Component
,Serviceable
- Direct Known Subclasses:
ContentExtractor
Component responsible to extract a
Content
from an XML document.-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected Boolean
booleanValue
(org.apache.xpath.objects.XObject xObject) Consumes anXObject
to retrieve the value as aBoolean
protected Date
dateValue
(org.apache.xpath.objects.XObject xObject) Consumes anXObject
to retrieve the value as aDate
protected void
fillAttributes
(ModifiableContent content, Node contentNode, XMLValuesExtractorAdditionalDataGetter additionalDataGetter) Fills the given content with the attributes from the providedNode
protected void
fillComment
(Comment comment, Node commentNode) Fills the given comment with the values from the providedNode
void
fillContent
(ModifiableContent content, Node node, XMLValuesExtractorAdditionalDataGetter additionalDataGetter) Fills the given content with the values from the providedNode
.protected void
fillContentComments
(CommentableContent content, Node contentNode) Fills the given content with the comments from the providedNode
protected void
fillDublinCore
(ModifiableDublinCoreAwareAmetysObject dcObject, Node node) Fills the given object with the dublin core values from the providedNode
.protected void
fillReactions
(ReactionableObject reactionable, Node node) Fills the givenReactionableObject
with the reactions from the providedNode
protected void
fillReports
(ReportableObject reportable, Node node) Fills the givenReportableObject
with the reports from the providedNode
void
service
(ServiceManager manager) protected <T> void
setIfNotNull
(Node node, String expression, LambdaUtils.ThrowingFunction<org.apache.xpath.objects.XObject, T> retriever, Consumer<T> setter) Sets a value through the given setter if the value is not nullprotected String[]
values
(org.apache.xpath.objects.XObject xObject) Consumes anXObject
to retrieve the value as a String array
-
Field Details
-
CMS_CONTENT_EXTACTOR_ROLE
Avalon role.
-
-
Constructor Details
-
ContentExtractor
public ContentExtractor()
-
-
Method Details
-
service
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
fillContent
public void fillContent(ModifiableContent content, Node node, XMLValuesExtractorAdditionalDataGetter additionalDataGetter) throws Exception Fills the given content with the values from the providedNode
.
This is the anti-operation ofContentSaxer.saxContent(org.ametys.cms.repository.Content, org.xml.sax.ContentHandler, java.util.Locale, org.ametys.runtime.model.View, java.lang.String, boolean, boolean, boolean, java.lang.String)
, as the org.w3c.dom.Node should be a Node previously generated with SAX events from this method.- Parameters:
content
- The content to fillnode
- The node to read for retrieving values to filladditionalDataGetter
- The object that will retrieve potential additional data for the content's attributes- Throws:
Exception
- if an exception occurs
-
fillDublinCore
protected void fillDublinCore(ModifiableDublinCoreAwareAmetysObject dcObject, Node node) throws Exception Fills the given object with the dublin core values from the providedNode
.- Parameters:
dcObject
- The object to fillnode
- The node to read to get the values to fill- Throws:
Exception
- if an exception occurs
-
fillContentComments
Fills the given content with the comments from the providedNode
- Parameters:
content
- The content to fillcontentNode
- the node to read to get the comments' values- Throws:
Exception
- if an error occurs
-
fillComment
Fills the given comment with the values from the providedNode
- Parameters:
comment
- The comment to fillcommentNode
- the node to read to get the comment's values- Throws:
Exception
- if an error occurs
-
fillReactions
Fills the givenReactionableObject
with the reactions from the providedNode
- Parameters:
reactionable
- TheReactionableObject
to fillnode
- the node to read to get the reactions- Throws:
Exception
- if an error occurs
-
fillReports
Fills the givenReportableObject
with the reports from the providedNode
- Parameters:
reportable
- TheReportableObject
to fillnode
- the node to read to get the reports- Throws:
Exception
- if an error occurs
-
fillAttributes
protected void fillAttributes(ModifiableContent content, Node contentNode, XMLValuesExtractorAdditionalDataGetter additionalDataGetter) throws Exception Fills the given content with the attributes from the providedNode
- Parameters:
content
- The content to fillcontentNode
- the node to read to get the attributesadditionalDataGetter
- The object that will retrieve potential additional data for the content's attributes- Throws:
Exception
- if an error occurs
-
setIfNotNull
protected <T> void setIfNotNull(Node node, String expression, LambdaUtils.ThrowingFunction<org.apache.xpath.objects.XObject, T> retriever, Consumer<T> setter) throws ExceptionSets a value through the given setter if the value is not null- Type Parameters:
T
- The type of the value to set- Parameters:
node
- The node to read to get the valueexpression
- The expression to apply on the node to get the valueretriever
- TheFunction
that will retrieve the typed value from theXObject
evaluated from the expressionsetter
- TheConsumer
that will be used to set the value- Throws:
Exception
- if an error occurs
-
dateValue
Consumes anXObject
to retrieve the value as aDate
- Parameters:
xObject
- The consumedXObject
- Returns:
- The
Date
value
-
booleanValue
Consumes anXObject
to retrieve the value as aBoolean
- Parameters:
xObject
- The consumedXObject
- Returns:
- The
Boolean
value
-
values
Consumes anXObject
to retrieve the value as a String array- Parameters:
xObject
- The consumedXObject
- Returns:
- The String array
- Throws:
TransformerException
- if an error occurs
-