public static MatchingElementName forAllElementsWithPrefix(final TemplateMode templateMode, final String matchingAllElementsWithPrefix) { Validate.notNull(templateMode, "Template mode cannot be null"); // Prefix can actually be null -> match all elements with no prefix return new MatchingElementName(templateMode, null, matchingAllElementsWithPrefix, false); }
final MatchingAttributeName matchingAttributeName = processor.getMatchingAttributeName(); if ((matchingElementName != null && matchingElementName.getTemplateMode() != templateMode) || (matchingAttributeName != null && matchingAttributeName.getTemplateMode() != templateMode)) { throw new ConfigurationException(templateMode + " processors must return " + templateMode + "element names and " + templateMode + " attribute names (processor: " + processor.getClass().getName() + ")"); if (matchingElementName != null && !matchingElementName.matches(name)) {
private static TextAttributeDefinition buildTextAttributeDefinition( final TemplateMode templateMode, final TextAttributeName 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) { if (processor.getTemplateMode() != templateMode) { // We are creating a text 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) || (matchingAttributeName != null && matchingAttributeName.getTemplateMode() != templateMode)) { throw new ConfigurationException(templateMode + " processors must return " + templateMode + "element names and " + templateMode + " 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 TextAttributeDefinition(name, associatedProcessors); }
public AbstractElementModelProcessor( final TemplateMode templateMode, final String dialectPrefix, final String elementName, final boolean prefixElementName, final String attributeName, final boolean prefixAttributeName, final int precedence) { super(templateMode, precedence); this.dialectPrefix = dialectPrefix; this.matchingElementName = (elementName == null? null : MatchingElementName.forElementName( templateMode, ElementNames.forName(templateMode, (prefixElementName? this.dialectPrefix : null), elementName))); this.matchingAttributeName = (attributeName == null? null : MatchingAttributeName.forAttributeName( templateMode, AttributeNames.forName(templateMode, (prefixAttributeName? this.dialectPrefix : null), attributeName))); }
if (matchingElementName != null && !matchingElementName.matches(this.elementDefinition.elementName)) { continue;
final MatchingElementName matchingElementName = processor.getMatchingElementName(); final MatchingAttributeName matchingAttributeName = processor.getMatchingAttributeName(); final String elementName = (matchingElementName == null? "*" : matchingElementName.toString()); final String attributeName = (matchingAttributeName == null? "*" : matchingAttributeName.toString()); logBuilder.line("[THYMELEAF] * [{} {}] [{}]: {}", final MatchingElementName matchingElementName = processor.getMatchingElementName(); final MatchingAttributeName matchingAttributeName = processor.getMatchingAttributeName(); final String elementName = (matchingElementName == null? "*" : matchingElementName.toString()); final String attributeName = (matchingAttributeName == null? "*" : matchingAttributeName.toString()); logBuilder.line("[THYMELEAF] * [{} {}] [{}]: {}",
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 (matchingElementName != null && !matchingElementName.matches(name)) {
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() + ")");
public AbstractElementTagProcessor( final TemplateMode templateMode, final String dialectPrefix, final String elementName, final boolean prefixElementName, final String attributeName, final boolean prefixAttributeName, final int precedence) { super(templateMode, precedence); this.dialectPrefix = dialectPrefix; this.matchingElementName = (elementName == null? null : MatchingElementName.forElementName( templateMode, ElementNames.forName(templateMode, (prefixElementName? this.dialectPrefix : null), elementName))); this.matchingAttributeName = (attributeName == null? null : MatchingAttributeName.forAttributeName( templateMode, AttributeNames.forName(templateMode, (prefixAttributeName? this.dialectPrefix : null), attributeName))); }
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 (matchingElementName != null && !matchingElementName.matches(name)) {
public static MatchingElementName forAllElements(final TemplateMode templateMode) { Validate.notNull(templateMode, "Template mode cannot be null"); return new MatchingElementName(templateMode, null, null, true); }
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() + ")");
public static MatchingElementName forElementName(final TemplateMode templateMode, final ElementName matchingElementName) { Validate.notNull(templateMode, "Template mode cannot be null"); Validate.notNull(matchingElementName, "Matching element name cannot be null"); if (templateMode == TemplateMode.HTML && !(matchingElementName instanceof HTMLElementName)) { throw new IllegalArgumentException("Element names for HTML template mode must be of class " + HTMLElementName.class.getName()); } else if (templateMode == TemplateMode.XML && !(matchingElementName instanceof XMLElementName)) { throw new IllegalArgumentException("Element names for XML template mode must be of class " + XMLElementName.class.getName()); } else if (templateMode.isText() && !(matchingElementName instanceof TextElementName)) { throw new IllegalArgumentException("Element names for any text template modes must be of class " + TextElementName.class.getName()); } return new MatchingElementName(templateMode, matchingElementName, null, false); }