Class IncludeDescriptorsProcessor
- java.lang.Object
-
- org.craftercms.core.processors.impl.IncludeDescriptorsProcessor
-
- All Implemented Interfaces:
ItemProcessor
- Direct Known Subclasses:
PageAwareIncludeDescriptorsProcessor
public class IncludeDescriptorsProcessor extends Object implements ItemProcessor
ItemProcessorthat 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
Fields Modifier and Type Field Description protected ContentStoreServicecontentStoreServiceThe content store service, used to retrieve the descriptors to include.protected StringdisabledIncludeNodeXPathQueryXPath query relative to include elements for nodes tha specify if the include is disabled or not.protected ItemProcessorincludedItemsProcessorProcessor to use for included items.protected static ThreadLocal<Stack<String>>includedItemsStackprotected StringincludeElementXPathQueryXPath query for the include element.protected StringlocaleCodeXPathQueryXPath query for the locale code elementprotected booleanremoveIncludeElementFlag to indicate if the include element should be removed (false by default).
-
Constructor Summary
Constructors Constructor Description IncludeDescriptorsProcessor()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voiddoInclude(Item item, org.dom4j.Element includeElement, Item itemToInclude)booleanequals(Object o)Returns true if the specifiedIncludeDescriptorsProcessor's and this instance's fields are equal.protected ItemgetItemToInclude(Context context, CachingOptions cachingOptions, String includeSrcPath)inthashCode()Returns the hash code for this instance, which is basically the combination of the hash code of each field.protected voidincludeDescriptors(Context context, CachingOptions cachingOptions, Item item)protected booleanisIncludeDisabled(org.dom4j.Element includeElement)Itemprocess(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.voidsetContentStoreService(ContentStoreService contentStoreService)Sets the content store service, used to retrieve the descriptors to include.voidsetDisabledIncludeNodeXPathQuery(String disabledIncludeNodeXPathQuery)Sets the XPath query relative to include elements for nodes tha specify if the include is disabled or not.voidsetIncludedItemsProcessor(ItemProcessor includedItemsProcessor)Sets the processor to use for included items.voidsetIncludeElementXPathQuery(String includeElementXPathQuery)Sets the XPath query used to retrieve the include elements.voidsetLocaleCodeXPathQuery(String localeCodeXPathQuery)voidsetRemoveIncludeElement(boolean removeIncludeElement)Sets the flag to indicate if the include element should be removed (false by default).StringtoString()
-
-
-
Field Detail
-
includedItemsStack
protected static final ThreadLocal<Stack<String>> includedItemsStack
-
includeElementXPathQuery
protected String includeElementXPathQuery
XPath query for the include element.
-
removeIncludeElement
protected boolean removeIncludeElement
Flag to indicate if the include element should be removed (false by default).
-
disabledIncludeNodeXPathQuery
protected String disabledIncludeNodeXPathQuery
XPath query relative to include elements for nodes tha specify if the include is disabled or not.
-
contentStoreService
protected ContentStoreService contentStoreService
The content store service, used to retrieve the descriptors to include.
-
includedItemsProcessor
protected ItemProcessor includedItemsProcessor
Processor to use for included items.
-
localeCodeXPathQuery
protected String localeCodeXPathQuery
XPath query for the locale code element
-
-
Method Detail
-
setIncludeElementXPathQuery
public void setIncludeElementXPathQuery(String includeElementXPathQuery)
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
public void setDisabledIncludeNodeXPathQuery(String disabledIncludeNodeXPathQuery)
Sets the XPath query relative to include elements for nodes tha specify if the include is disabled or not.
-
setContentStoreService
public void setContentStoreService(ContentStoreService contentStoreService)
Sets the content store service, used to retrieve the descriptors to include.
-
setIncludedItemsProcessor
public void setIncludedItemsProcessor(ItemProcessor includedItemsProcessor)
Sets the processor to use for included items.
-
setLocaleCodeXPathQuery
public void setLocaleCodeXPathQuery(String localeCodeXPathQuery)
-
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:
processin 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
public boolean equals(Object o)
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 aContentStoreServicecan be used as part of a key for caching.
-
-