public class ExtensibilityModelImpl extends Object implements ExtensibilityModel
| Constructor and Description |
|---|
ExtensibilityModelImpl(ExtensibilityModel parentModel,
HandlesExtensibility handler)
Constructor for the model.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addDiscardContent()
Adds a new
DiscardUnboundContentModelElementImpl to the model and sets its
content as the current buffer element in the ModelWriter. |
void |
addUnboundContent()
Adds a new
UnboundContentModelElementImpl to the model and sets its
content as the current buffer element in the model writer. |
void |
after(ExtensibilityDirectiveData directiveData)
Generates the output from the supplied directive data and inserts it into the model at the index
after the end of the target defined in the directive.
|
void |
before(ExtensibilityDirectiveData directiveData)
Generates the output from the supplied directive data and inserts it into the model at the index
before the start of the target defined in the directive.
|
boolean |
clearRelocatedContent(String id,
String directiveName) |
List<DeferredContentSourceModelElement> |
enterDeferredContentEditMode(org.springframework.extensions.surf.extensibility.impl.ExtensibilityModelImpl.RangeData targetRange,
String action)
Iterates over the supplied
RangeData object and calls the enterEditMode method
on any DeferredContentSourceModelElement instances that are found within it. |
void |
exitDeferredContentEditMode(List<DeferredContentSourceModelElement> deferredSourceElements)
Iterates over the supplied
RangeData object and calls the exitEditMode method on
any DeferredContentSourceModelElement instances that are found within it. |
ContentModelElement |
findContentModelElement(String id)
Finds a specific
ContentModelElement (with the supplied identifier) in the model. |
void |
flushModel(Writer out)
Flushes the contents of the model to the supplied output stream.
|
List<ExtensibilityModelElement> |
getAdditionalContentElements()
Retrieves the current
List of ExtensibilityModelElement instances that are being
generated as part of extension processing. |
ExtensibilityDebugData |
getChildDebugData() |
ExtensibilityDebugData |
getDebugData() |
DeferredContentTargetModelElement |
getDeferredContent(String directiveId,
String directiveName)
Finds and returns the deferred
DeferredContentTargetModelElement specified by the supplied
directive ID and name. |
ExtensibilityModel |
getParentModel()
Extensibility models can be nested.
|
ModelWriter |
getWriter()
Returns the
ModelWriter that will be written to when the model is flushed. |
void |
insertDeferredContentTarget(int index,
OpenModelElement open,
DeferredContentTargetModelElement target,
CloseModelElement close)
Allows
DeferredContentTargetModelElement instances (along with their associated OpenModelElement and
CloseModelElement instances) to be inserted at a requested point in the model. |
boolean |
isExtensionProcessing()
Indicates whether or not extensions are being processed or not.
|
boolean |
isModelStarted()
Indicates whether or not the has been started.
|
void |
merge(ExtensibilityDirectiveData directiveData)
Merges the supplied
ExtensibilityDirectiveData instance into the model. |
void |
remove(ExtensibilityDirectiveData directiveData)
Finds the elements in the model that match the range (including all nested
and unbound content) with the specified id parameter and removes them.
|
void |
replace(ExtensibilityDirectiveData directiveData)
Replaces the elements of the content model within the range defined by the
id of the supplied directive with the output generated by rendering the supplied
TemplateDirectiveBody. |
void |
setChildDebugData(ExtensibilityDebugData childData)
Sets the
ExtensibilityDebugData associated with the nested child ExtensibilityModel. |
void |
switchToExtensionProcessing()
Switches the model into extension processing mode.
|
String |
toString() |
public ExtensibilityModelImpl(ExtensibilityModel parentModel, HandlesExtensibility handler)
Constructor for the model. Accepts a parent model if the new instance is to be nested.
parentModel - The parent model (if this instance is to be nested)handler - The handler used to create the model.public ExtensibilityModel getParentModel()
Extensibility models can be nested. If the current model is nested then this method will return the model that it is nested within.
getParentModel in interface ExtensibilityModelExtensibilityModel if the current model is nested and null otherwise.public ExtensibilityDebugData getDebugData()
getDebugData in interface ExtensibilityModelExtensibilityDebugData associated with the ExtensibilityModel.public ExtensibilityDebugData getChildDebugData()
getChildDebugData in interface ExtensibilityModelExtensibilityDebugData associated with the nested child ExtensibilityModel.public void setChildDebugData(ExtensibilityDebugData childData)
ExtensibilityModelSets the ExtensibilityDebugData associated with the nested child ExtensibilityModel.
setChildDebugData in interface ExtensibilityModelpublic boolean isModelStarted()
ExtensibilityModelIndicates whether or not the has been started.
isModelStarted in interface ExtensibilityModelpublic ModelWriter getWriter()
Returns the ModelWriter that will be written to when the model is flushed.
getWriter in interface ExtensibilityModelModelWriter used by this ExtensibilityModelpublic void switchToExtensionProcessing()
Switches the model into extension processing mode. This means that content can no longer me appended to the end of the model but directives must be extending the existing model in some way.
switchToExtensionProcessing in interface ExtensibilityModelpublic boolean isExtensionProcessing()
Indicates whether or not extensions are being processed or not.
isExtensionProcessing in interface ExtensibilityModeltrue if extensions are being processed or false if the base model
is still being created.public void insertDeferredContentTarget(int index,
OpenModelElement open,
DeferredContentTargetModelElement target,
CloseModelElement close)
Allows DeferredContentTargetModelElement instances (along with their associated OpenModelElement and
CloseModelElement instances) to be inserted at a requested point in the model. This facility should be used with
extreme care and was provided to allow WebScripts run outside of the context of a page to process dependencies.
insertDeferredContentTarget in interface ExtensibilityModelindex - The index within the model to insert the elementsopen - The OpenModelElement that identifies the start of the contenttarget - The DeferredContentTargetModelElement for adding deferred content intoclose - The CloseModelElement that identifies the end of the contentpublic void addUnboundContent()
Adds a new UnboundContentModelElementImpl to the model and sets its
content as the current buffer element in the model writer. This will capture any
output that is not contained within extensibility directives. Typically unbound
content is added before extensibility processing begins and then again once it
has completed.
addUnboundContent in interface ExtensibilityModelpublic void addDiscardContent()
Adds a new DiscardUnboundContentModelElementImpl to the model and sets its
content as the current buffer element in the ModelWriter. Any content that
is subsequently rendered will effectively be discarded until a new ContentModelElement
is added. This allows unbounded content in extending templates to be safely discarded.
addDiscardContent in interface ExtensibilityModelpublic DeferredContentTargetModelElement getDeferredContent(String directiveId, String directiveName)
Finds and returns the deferred DeferredContentTargetModelElement specified by the supplied
directive ID and name. The purpose of a DeferredContentTargetModelElement is to allow nested
content to directly manipulate content outside their scope. This has been provided for the purpose
of allowing WebScripts to add JavaScript and CSS dependencies into the <head> element of
the HTML page which would otherwise not normally be possible because by the time the WebScript
is being processed the <head> element would have already been processed.
This method will only return DeferredContentTargetModelElement objects and not any other
type of content added to the model. It will return null if the target content
cannot be found.
getDeferredContent in interface ExtensibilityModeldirectiveId - The ID of the deferred content to finddirectiveName - The directive name used to add the deferred content.DeferredContentTargetModelElement or null if it couldn't be found.public void flushModel(Writer out)
Flushes the contents of the model to the supplied output stream. This should be called once extensibility processing has completed.
flushModel in interface ExtensibilityModelout - The Writer to flush the model contents to.public void merge(ExtensibilityDirectiveData directiveData) throws freemarker.template.TemplateException, IOException
Merges the supplied ExtensibilityDirectiveData instance into the model. The merge action can only be
used as part of extension processing when it is not the root action of the extension. For example a
<@region> directive can be merged into the model as part of a "before", "after" or "replace" action of an enclosing
<@markup> directive. This relies on some additional content elements being created in the model for the new content
to be added to.
merge in interface ExtensibilityModeldirectiveData - The ExtensibilityDirectiveData instance to merge into the model.freemarker.template.TemplateExceptionIOExceptionpublic List<ExtensibilityModelElement> getAdditionalContentElements()
Retrieves the current List of ExtensibilityModelElement instances that are being
generated as part of extension processing. This List will either exist in the current ExtensibilityModel
or somewhere within the model hierarchy. This method will return null if no List has
been instantiated - this typically means that an extension has been created in error. Normally because a
"merge" action has been requested as the root extension action.
getAdditionalContentElements in interface ExtensibilityModelpublic void before(ExtensibilityDirectiveData directiveData) throws freemarker.template.TemplateException, IOException
Generates the output from the supplied directive data and inserts it into the model at the index before the start of the target defined in the directive. If the target directive cannot be found then the generated output is not inserted into the model.
WARNING: The content will also not be added if the model has not been switched into extension processing mode as it is not valid for a model declaring template to manipulate its own contents.
before in interface ExtensibilityModeldirectiveData - ExtensibilityDirectiveDataIOExceptionfreemarker.template.TemplateExceptionpublic void after(ExtensibilityDirectiveData directiveData) throws freemarker.template.TemplateException, IOException
Generates the output from the supplied directive data and inserts it into the model at the index after the end of the target defined in the directive. If the target directive cannot be found then the generated output is not inserted into the model.
WARNING: The content will also not be added if the model has not been switched into extension processing mode as it is not valid for a model declaring template to manipulate its own contents.
after in interface ExtensibilityModeldirectiveData - ExtensibilityDirectiveDataIOExceptionfreemarker.template.TemplateExceptionpublic void remove(ExtensibilityDirectiveData directiveData)
Finds the elements in the model that match the range (including all nested and unbound content) with the specified id parameter and removes them.
remove in interface ExtensibilityModeldirectiveData - The id of the range of elements to removepublic void replace(ExtensibilityDirectiveData directiveData) throws freemarker.template.TemplateException, IOException
Replaces the elements of the content model within the range defined by the
id of the supplied directive with the output generated by rendering the supplied
TemplateDirectiveBody.
replace in interface ExtensibilityModeldirectiveData - The directive requesting to replace the existing elements with the same idfreemarker.template.TemplateExceptionIOExceptionpublic List<DeferredContentSourceModelElement> enterDeferredContentEditMode(org.springframework.extensions.surf.extensibility.impl.ExtensibilityModelImpl.RangeData targetRange, String action)
Iterates over the supplied RangeData object and calls the enterEditMode method
on any DeferredContentSourceModelElement instances that are found within it. This allows deferred content
to be manipulated when extensions are applied to it. For example - deferred content may have already been
set which needs to be replaced.
targetRange - The range of elements that need to be checked for DeferredContentSourceModelElement instancesaction - The name of the action being processedList of the DeferredContentSourceModelElement instances found - this is returned as the range is likely
to be cleared.public void exitDeferredContentEditMode(List<DeferredContentSourceModelElement> deferredSourceElements)
Iterates over the supplied RangeData object and calls the exitEditMode method on
any DeferredContentSourceModelElement instances that are found within it. This indicates to the
associated DeferredContentTargetModelElement instance that editing is now finished.
deferredSourceElements - Listpublic ContentModelElement findContentModelElement(String id)
ExtensibilityModelFinds a specific ContentModelElement (with the supplied identifier) in the model.
findContentModelElement in interface ExtensibilityModelid - Stringpublic boolean clearRelocatedContent(String id, String directiveName)
clearRelocatedContent in interface ExtensibilityModelCopyright © 2005–2016 Alfresco Software. All rights reserved.