Class IncludeDescriptorsProcessor
java.lang.Object
org.craftercms.core.processors.impl.IncludeDescriptorsProcessor
- All Implemented Interfaces:
ItemProcessor
- Direct Known Subclasses:
PageAwareIncludeDescriptorsProcessor
ItemProcessor
that finds special "include" tags found in a descriptor
document and inserts there the document tree of descriptors specified in these "include" tags.- Author:
- Sumer Jabri, Alfonso Vásquez
-
Field Summary
Modifier and TypeFieldDescriptionprotected ContentStoreService
The content store service, used to retrieve the descriptors to include.protected String
XPath query relative to include elements for nodes tha specify if the include is disabled or not.protected ItemProcessor
Processor to use for included items.protected static final ThreadLocal<Stack<String>>
protected String
XPath query for the include element.protected String
XPath query for the locale code elementprotected boolean
Flag to indicate if the include element should be removed (false by default). -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
boolean
Returns true if the specifiedIncludeDescriptorsProcessor
's and this instance's fields are equal.protected Item
getItemToInclude
(Context context, CachingOptions cachingOptions, String includeSrcPath) int
hashCode()
Returns the hash code for this instance, which is basically the combination of the hash code of each field.protected void
includeDescriptors
(Context context, CachingOptions cachingOptions, Item item) protected boolean
isIncludeDisabled
(org.dom4j.Element includeElement) process
(Context context, CachingOptions cachingOptions, Item item) Replaces special include tags found in a descriptor document with the document tree of descriptors specified in these include tags.void
setContentStoreService
(ContentStoreService contentStoreService) Sets the content store service, used to retrieve the descriptors to include.void
setDisabledIncludeNodeXPathQuery
(String disabledIncludeNodeXPathQuery) Sets the XPath query relative to include elements for nodes tha specify if the include is disabled or not.void
setIncludedItemsProcessor
(ItemProcessor includedItemsProcessor) Sets the processor to use for included items.void
setIncludeElementXPathQuery
(String includeElementXPathQuery) Sets the XPath query used to retrieve the include elements.void
setLocaleCodeXPathQuery
(String localeCodeXPathQuery) void
setRemoveIncludeElement
(boolean removeIncludeElement) Sets the flag to indicate if the include element should be removed (false by default).toString()
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.craftercms.core.processors.ItemProcessor
isExclusive
-
Field Details
-
includedItemsStack
-
includeElementXPathQuery
XPath query for the include element. -
removeIncludeElement
protected boolean removeIncludeElementFlag to indicate if the include element should be removed (false by default). -
disabledIncludeNodeXPathQuery
XPath query relative to include elements for nodes tha specify if the include is disabled or not. -
contentStoreService
The content store service, used to retrieve the descriptors to include. -
includedItemsProcessor
Processor to use for included items. -
localeCodeXPathQuery
XPath query for the locale code element
-
-
Constructor Details
-
IncludeDescriptorsProcessor
public IncludeDescriptorsProcessor()
-
-
Method Details
-
setIncludeElementXPathQuery
Sets the XPath query used to retrieve the include elements. -
setRemoveIncludeElement
public void setRemoveIncludeElement(boolean removeIncludeElement) Sets the flag to indicate if the include element should be removed (false by default). -
setDisabledIncludeNodeXPathQuery
Sets the XPath query relative to include elements for nodes tha specify if the include is disabled or not. -
setContentStoreService
Sets the content store service, used to retrieve the descriptors to include. -
setIncludedItemsProcessor
Sets the processor to use for included items. -
setLocaleCodeXPathQuery
-
process
public Item process(Context context, CachingOptions cachingOptions, Item item) throws ItemProcessingException Replaces special include tags found in a descriptor document with the document tree of descriptors specified in these include tags. If the include tag specifies a XPath query expression (through the select attribute), only the elements returned by the query will be included.- Specified by:
process
in interfaceItemProcessor
- Parameters:
context
- the current contextcachingOptions
- caching options in case you need access to itemsitem
- the item to process- Returns:
- the modified item or a new item.
- Throws:
ItemProcessingException
- if there was an error while trying to perform an include
-
includeDescriptors
protected void includeDescriptors(Context context, CachingOptions cachingOptions, Item item) throws ItemProcessingException - Throws:
ItemProcessingException
-
isIncludeDisabled
protected boolean isIncludeDisabled(org.dom4j.Element includeElement) -
getItemToInclude
protected Item getItemToInclude(Context context, CachingOptions cachingOptions, String includeSrcPath) throws ItemProcessingException - Throws:
ItemProcessingException
-
doInclude
protected void doInclude(Item item, org.dom4j.Element includeElement, Item itemToInclude) throws ItemProcessingException - Throws:
ItemProcessingException
-
equals
Returns true if the specifiedIncludeDescriptorsProcessor
's and this instance's fields are equal. -
hashCode
public int hashCode()Returns the hash code for this instance, which is basically the combination of the hash code of each field. As with any otherItemProcessor
, this method is defined because any processor which is passed in the method call of aContentStoreService
can be used as part of a key for caching. -
toString
-