use of org.thymeleaf.processor.element.MatchingElementName in project thymeleaf by thymeleaf.
the class AttributeDefinitions method buildXMLAttributeDefinition.
private static XMLAttributeDefinition buildXMLAttributeDefinition(final XMLAttributeName name, final Set<IElementProcessor> elementProcessors) {
// No need to use a list for sorting - the elementProcessors set has already been ordered
final Set<IElementProcessor> associatedProcessors = new LinkedHashSet<IElementProcessor>(2);
if (elementProcessors != null) {
for (final IElementProcessor processor : elementProcessors) {
// Cannot be null -- has been previously validated
final TemplateMode templateMode = processor.getTemplateMode();
if (templateMode != TemplateMode.XML) {
// We are creating an XML element definition, therefore we are only interested on XML processors
continue;
}
final MatchingElementName matchingElementName = processor.getMatchingElementName();
final MatchingAttributeName matchingAttributeName = processor.getMatchingAttributeName();
if ((matchingElementName != null && matchingElementName.getTemplateMode() != TemplateMode.XML) || (matchingAttributeName != null && matchingAttributeName.getTemplateMode() != TemplateMode.XML)) {
throw new ConfigurationException("XML processors must return XML element names and XML attribute names (processor: " + processor.getClass().getName() + ")");
}
if (matchingAttributeName == null || matchingAttributeName.isMatchingAllAttributes()) {
// This processor does not relate to a specific attribute - surely an element processor
continue;
}
if (!matchingAttributeName.matches(name)) {
// Doesn't match. This processor is not associated with this attribute
continue;
}
associatedProcessors.add(processor);
}
}
// Build the final instance
return new XMLAttributeDefinition(name, associatedProcessors);
}
use of org.thymeleaf.processor.element.MatchingElementName in project thymeleaf by thymeleaf.
the class ElementDefinitions method buildXMLElementDefinition.
private static XMLElementDefinition buildXMLElementDefinition(final XMLElementName name, final Set<IElementProcessor> elementProcessors) {
// No need to use a list for sorting - the elementProcessors set has already been ordered
final Set<IElementProcessor> associatedProcessors = new LinkedHashSet<IElementProcessor>(2);
if (elementProcessors != null) {
for (final IElementProcessor processor : elementProcessors) {
// Cannot be null -- has been previously validated
final TemplateMode templateMode = processor.getTemplateMode();
if (templateMode != TemplateMode.XML) {
// We are creating an XML element definition, therefore we are only interested on XML processors
continue;
}
final MatchingElementName matchingElementName = processor.getMatchingElementName();
final MatchingAttributeName matchingAttributeName = processor.getMatchingAttributeName();
if ((matchingElementName != null && matchingElementName.getTemplateMode() != TemplateMode.XML) || (matchingAttributeName != null && matchingAttributeName.getTemplateMode() != TemplateMode.XML)) {
throw new ConfigurationException("XML processors must return XML element names and XML attribute names (processor: " + processor.getClass().getName() + ")");
}
if (matchingAttributeName != null && !matchingAttributeName.isMatchingAllAttributes()) {
// (will be instead associated with the attribute).
continue;
}
if (matchingElementName != null && !matchingElementName.matches(name)) {
// Note that elementName == null means "apply to all processors"
continue;
}
associatedProcessors.add(processor);
}
}
// Build the final instance
return new XMLElementDefinition(name, associatedProcessors);
}
use of org.thymeleaf.processor.element.MatchingElementName in project thymeleaf by thymeleaf.
the class ElementDefinitions method buildHTMLElementDefinition.
private static HTMLElementDefinition buildHTMLElementDefinition(final HTMLElementName name, final HTMLElementType type, final Set<IElementProcessor> elementProcessors) {
// No need to use a list for sorting - the elementProcessors set has already been ordered
final Set<IElementProcessor> associatedProcessors = new LinkedHashSet<IElementProcessor>(2);
if (elementProcessors != null) {
for (final IElementProcessor processor : elementProcessors) {
// Cannot be null -- has been previously validated
final TemplateMode templateMode = processor.getTemplateMode();
if (templateMode != TemplateMode.HTML) {
// We are creating an HTML element definition, therefore we are only interested on HTML processors
continue;
}
final MatchingElementName matchingElementName = processor.getMatchingElementName();
final MatchingAttributeName matchingAttributeName = processor.getMatchingAttributeName();
if ((matchingElementName != null && matchingElementName.getTemplateMode() != TemplateMode.HTML) || (matchingAttributeName != null && matchingAttributeName.getTemplateMode() != TemplateMode.HTML)) {
throw new ConfigurationException("HTML processors must return HTML element names and HTML attribute names (processor: " + processor.getClass().getName() + ")");
}
if (matchingAttributeName != null && !matchingAttributeName.isMatchingAllAttributes()) {
// (will be instead associated with the attribute).
continue;
}
if (matchingElementName != null && !matchingElementName.matches(name)) {
// Doesn't match. This processor cannot be associated with this element
continue;
}
associatedProcessors.add(processor);
}
}
// Build the final instance
return new HTMLElementDefinition(name, type, associatedProcessors);
}
Aggregations