@Override protected void doProcess( final ITemplateContext context, final IProcessableElementTag tag, final IElementTagStructureHandler structureHandler) { // Nothing to do, this processor is just a marker. Simply remove the attribute final AttributeName attributeName = getMatchingAttributeName().getMatchingAttributeName(); structureHandler.removeAttribute(attributeName); }
public StandardDefaultAttributesTagProcessor(final TemplateMode templateMode, final String dialectPrefix) { super(templateMode, PRECEDENCE); this.dialectPrefix = dialectPrefix; this.matchingAttributeName = MatchingAttributeName.forAllAttributesWithPrefix(getTemplateMode(), dialectPrefix); }
public static MatchingAttributeName forAllAttributesWithPrefix(final TemplateMode templateMode, final String matchingAllAttributesWithPrefix) { Validate.notNull(templateMode, "Template mode cannot be null"); // Prefix can actually be null -> match all attributes with no prefix return new MatchingAttributeName(templateMode, null, matchingAllAttributesWithPrefix, false); }
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); }
(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()) {
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))); }
(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()) { if (!matchingAttributeName.matches(name)) {
(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()) {
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))); }
try { attributeName = getMatchingAttributeName().getMatchingAttributeName(); firstEvent = (IProcessableElementTag) model.get(0);
public DataProcessor(TemplateMode templateMode, String dialectPrefix) { super(templateMode, PRECEDENCE); this.dialectPrefix = dialectPrefix; matchingAttributeName = MatchingAttributeName.forAllAttributesWithPrefix(getTemplateMode(), dialectPrefix); }
(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()) { if (!matchingAttributeName.matches(name)) {
(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()) {
public static MatchingAttributeName forAllAttributes(final TemplateMode templateMode) { Validate.notNull(templateMode, "Template mode cannot be null"); return new MatchingAttributeName(templateMode, null, null, true); }
try { attributeName = getMatchingAttributeName().getMatchingAttributeName();
public DataProcessor(TemplateMode templateMode, String dialectPrefix) { super(templateMode, PRECEDENCE); this.dialectPrefix = dialectPrefix; matchingAttributeName = MatchingAttributeName.forAllAttributesWithPrefix(getTemplateMode(), dialectPrefix); }
public static MatchingAttributeName forAttributeName(final TemplateMode templateMode, final AttributeName matchingAttributeName) { Validate.notNull(templateMode, "Template mode cannot be null"); Validate.notNull(matchingAttributeName, "Matching attribute name cannot be null"); if (templateMode == TemplateMode.HTML && !(matchingAttributeName instanceof HTMLAttributeName)) { throw new IllegalArgumentException("Attribute names for HTML template mode must be of class " + HTMLAttributeName.class.getName()); } else if (templateMode == TemplateMode.XML && !(matchingAttributeName instanceof XMLAttributeName)) { throw new IllegalArgumentException("Attribute names for XML template mode must be of class " + XMLAttributeName.class.getName()); } else if (templateMode.isText() && !(matchingAttributeName instanceof TextAttributeName)) { throw new IllegalArgumentException("Attribute names for any text template modes must be of class " + TextAttributeName.class.getName()); } return new MatchingAttributeName(templateMode, matchingAttributeName, null, false); }
public void setAttributeDefinitions(final AttributeDefinitions attributeDefinitions) { Validate.notNull(attributeDefinitions, "Attribute Definitions cannot be null"); // We precompute the AttributeDefinitions in order to being able to use much // faster methods for setting/replacing attributes on the ElementAttributes implementation final String dialectPrefix = getMatchingAttributeName().getMatchingAttributeName().getPrefix(); this.targetAttributeDefinition = attributeDefinitions.forName(TEMPLATE_MODE, TARGET_ATTR_NAME); this.fieldAttributeDefinition = attributeDefinitions.forName(TEMPLATE_MODE, dialectPrefix, AbstractSpringFieldTagProcessor.ATTR_NAME); this.typeAttributeDefinition = attributeDefinitions.forName(TEMPLATE_MODE, TYPE_ATTR_NAME); this.nameAttributeDefinition = attributeDefinitions.forName(TEMPLATE_MODE, NAME_ATTR_NAME); }
public void setAttributeDefinitions(final AttributeDefinitions attributeDefinitions) { Validate.notNull(attributeDefinitions, "Attribute Definitions cannot be null"); // We precompute the AttributeDefinitions in order to being able to use much // faster methods for setting/replacing attributes on the ElementAttributes implementation final String dialectPrefix = getMatchingAttributeName().getMatchingAttributeName().getPrefix(); this.targetAttributeDefinition = attributeDefinitions.forName(TEMPLATE_MODE, TARGET_ATTR_NAME); this.fieldAttributeDefinition = attributeDefinitions.forName(TEMPLATE_MODE, dialectPrefix, AbstractSpringFieldTagProcessor.ATTR_NAME); this.typeAttributeDefinition = attributeDefinitions.forName(TEMPLATE_MODE, TYPE_ATTR_NAME); this.nameAttributeDefinition = attributeDefinitions.forName(TEMPLATE_MODE, NAME_ATTR_NAME); }
public void setAttributeDefinitions(final AttributeDefinitions attributeDefinitions) { Validate.notNull(attributeDefinitions, "Attribute Definitions cannot be null"); // We precompute the AttributeDefinitions in order to being able to use much // faster methods for setting/replacing attributes on the ElementAttributes implementation final String dialectPrefix = getMatchingAttributeName().getMatchingAttributeName().getPrefix(); this.targetAttributeDefinition = attributeDefinitions.forName(TEMPLATE_MODE, TARGET_ATTR_NAME); this.fieldAttributeDefinition = attributeDefinitions.forName(TEMPLATE_MODE, dialectPrefix, AbstractSpringFieldTagProcessor.ATTR_NAME); this.typeAttributeDefinition = attributeDefinitions.forName(TEMPLATE_MODE, TYPE_ATTR_NAME); this.nameAttributeDefinition = attributeDefinitions.forName(TEMPLATE_MODE, NAME_ATTR_NAME); }