use of com.xpn.xwiki.internal.filter.XWikiDocumentFilter in project xwiki-platform by xwiki.
the class XWikiDocumentOutputFilterStream method createFilter.
@Override
protected Object createFilter() {
List<XWikiDocumentFilter> filters = new ArrayList<>(this.children.size() + 1);
for (EntityOutputFilterStream<?> child : this.children) {
filters.add((XWikiDocumentFilter) child.getFilter());
}
filters.add(this);
this.filter = new XWikiDocumentFilterCollection(filters) {
@Override
public void beginWikiClass(FilterEventParameters parameters) throws FilterException {
if (!objectFilter.isEnabled()) {
classFilter.enable();
}
super.beginWikiClass(parameters);
}
@Override
public void endWikiClass(FilterEventParameters parameters) throws FilterException {
super.endWikiClass(parameters);
classFilter.disable();
}
@Override
public void beginWikiObject(String name, FilterEventParameters parameters) throws FilterException {
objectFilter.enable();
super.beginWikiObject(name, parameters);
}
@Override
public void endWikiObject(String name, FilterEventParameters parameters) throws FilterException {
super.endWikiObject(name, parameters);
objectFilter.disable();
}
@Override
public void onWikiAttachment(String name, InputStream content, Long size, FilterEventParameters parameters) throws FilterException {
attachmentFilter.enable();
super.onWikiAttachment(name, content, size, parameters);
attachmentFilter.disable();
}
};
if (this.contentListener != null) {
// Inject listener for the document content events
return this.filterManager.createCompositeFilter(this.contentListener, this.filter);
} else {
return this.filter;
}
}
Aggregations