public static AttributeName forName(final TemplateMode templateMode, final String attributeName) { if (templateMode == null) { throw new IllegalArgumentException("Template Mode cannot be null"); } if (templateMode == TemplateMode.HTML) { return forHTMLName(attributeName); } if (templateMode == TemplateMode.XML) { return forXMLName(attributeName); } if (templateMode.isText()) { return forTextName(attributeName); } throw new IllegalArgumentException("Unknown template mode '" + templateMode + "'"); }
private static HTMLAttributeName buildHTMLAttributeName(final String prefix, final String attributeName) { if (attributeName == null || attributeName.length() == 0) { throw new IllegalArgumentException("Attribute name cannot be null or empty"); } if (prefix == null || prefix.trim().length() == 0) { return buildHTMLAttributeName(attributeName); } return HTMLAttributeName.forName(prefix, attributeName); }
private static TextAttributeName buildTextAttributeName(final String prefix, final String attributeName) { if (attributeName == null || attributeName.length() == 0) { throw new IllegalArgumentException("Attribute name cannot be null or empty"); } if (prefix == null || prefix.trim().length() == 0) { return buildTextAttributeName(attributeName); } return TextAttributeName.forName(prefix, attributeName); }
standardHTMLAttributeDefinitions.add( buildHTMLAttributeDefinition( AttributeNames.forHTMLName(attributeNameStr), elementProcessorsByTemplateMode.get(TemplateMode.HTML)));
private int searchAttribute(final TemplateMode templateMode, final String completeName) { if (this.attributes == null || this.attributes.length == 0) { return -1; } // We will first try exact match on the names with which the attributes appear on template, as an optimization // on the base case (use the AttributeDefinition). int n = this.attributes.length; while (n-- != 0) { if (this.attributes[n].completeName.equals(completeName)) { return n; } } // Not found that way - before discarding, let's search using AttributeDefinitions return searchAttribute(AttributeNames.forName(templateMode, completeName)); }
private static XMLAttributeName buildXMLAttributeName(final String prefix, final String attributeName) { if (attributeName == null || attributeName.length() == 0) { throw new IllegalArgumentException("Attribute name cannot be null or empty"); } if (prefix == null || prefix.trim().length() == 0) { return buildXMLAttributeName(attributeName); } return XMLAttributeName.forName(prefix, attributeName); }
@Override protected void doProcess( final ITemplateContext context, final IProcessableElementTag tag, final AttributeName attributeName, final String attributeValue, final IElementTagStructureHandler structureHandler) { if (LOGGER.isWarnEnabled()) { LOGGER.warn( "[THYMELEAF][{}][{}] Deprecated attribute {} found in template {}, line {}, col {}. " + "Please use {} instead, this deprecated attribute will be removed in future versions of Thymeleaf.", new Object[]{ TemplateEngine.threadIndex(), LoggingUtils.loggifyTemplateName(context.getTemplateData().getTemplate()), attributeName, tag.getTemplateName(), Integer.valueOf(tag.getAttribute(attributeName).getLine()), Integer.valueOf(tag.getAttribute(attributeName).getCol()), AttributeNames.forHTMLName(attributeName.getPrefix(), StandardReplaceTagProcessor.ATTR_NAME)}); } super.doProcess(context, tag, attributeName, attributeValue, structureHandler); }
private int searchAttribute(final TemplateMode templateMode, final String prefix, final String name) { if (this.attributes == null || this.attributes.length == 0) { return -1; } if (prefix == null || prefix.length() == 0) { // Optimization: searchAttribute(name) might be faster if we are able to avoid using AttributeDefinition return searchAttribute(templateMode, name); } return searchAttribute(AttributeNames.forName(templateMode, prefix, name)); }
public static AttributeName forName( final TemplateMode templateMode, final char[] attributeNameBuffer, final int attributeNameOffset, final int attributeNameLen) { if (templateMode == null) { throw new IllegalArgumentException("Template Mode cannot be null"); } if (templateMode == TemplateMode.HTML) { return forHTMLName(attributeNameBuffer, attributeNameOffset, attributeNameLen); } if (templateMode == TemplateMode.XML) { return forXMLName(attributeNameBuffer, attributeNameOffset, attributeNameLen); } if (templateMode.isText()) { return forTextName(attributeNameBuffer, attributeNameOffset, attributeNameLen); } throw new IllegalArgumentException("Unknown template mode '" + templateMode + "'"); }
if (bindStatus == null) { final AttributeName fieldAttributeName = AttributeNames.forHTMLName(attributeName.getPrefix(), AbstractSpringFieldTagProcessor.ATTR_NAME); throw new TemplateProcessingException( "Cannot apply \"" + attributeName + "\": this attribute requires the existence of " +
public OutputExpressionInlinePreProcessorHandler( final IEngineConfiguration configuration, final TemplateMode templateMode, final String standardDialectPrefix, final IInlinePreProcessorHandler handler) { super(); this.next = handler; this.standardDialectPrefix = standardDialectPrefix; this.inlineAttributeNames = AttributeNames.forName(templateMode, this.standardDialectPrefix, StandardInlineHTMLTagProcessor.ATTR_NAME).getCompleteAttributeNames(); this.blockElementName = ElementNames.forName(templateMode, this.standardDialectPrefix, StandardBlockTagProcessor.ELEMENT_NAME).getCompleteElementNames()[0].toCharArray(); this.escapedTextAttributeName = AttributeNames.forName(templateMode, this.standardDialectPrefix, StandardTextTagProcessor.ATTR_NAME).getCompleteAttributeNames()[0]; this.unescapedTextAttributeName = AttributeNames.forName(templateMode, this.standardDialectPrefix, StandardUtextTagProcessor.ATTR_NAME).getCompleteAttributeNames()[0]; this.inlineTemplateModes = new TemplateMode[DEFAULT_LEVELS_SIZE]; this.inlineExecLevels = new int[DEFAULT_LEVELS_SIZE]; Arrays.fill(this.inlineTemplateModes, null); Arrays.fill(this.inlineExecLevels, -1); this.inlineIndex = 0; this.execLevel = 0; this.inlineTemplateModes[this.inlineIndex] = templateMode; this.inlineExecLevels[this.inlineIndex] = this.execLevel; this.attributeBuffer = null; }
public static AttributeName forName(final TemplateMode templateMode, final String prefix, final String attributeName) { if (templateMode == null) { throw new IllegalArgumentException("Template Mode cannot be null"); } if (templateMode == TemplateMode.HTML) { return forHTMLName(prefix, attributeName); } if (templateMode == TemplateMode.XML) { return forXMLName(prefix, attributeName); } if (templateMode.isText()) { return forTextName(prefix, attributeName); } throw new IllegalArgumentException("Unknown template mode '" + templateMode + "'"); }
if (bindStatus == null) { final AttributeName fieldAttributeName = AttributeNames.forHTMLName(attributeName.getPrefix(), AbstractSpringFieldTagProcessor.ATTR_NAME); throw new TemplateProcessingException( "Cannot apply \"" + attributeName + "\": this attribute requires the existence of " +
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))); }
private AttributeDefinition storeAttribute(final char[] text, final int offset, final int len) { int index = binarySearch(this.templateMode.isCaseSensitive(), this.repositoryNames, text, offset, len); if (index >= 0) { // It was already added while we were waiting for the lock! return this.repository.get(index); } final Set<IElementProcessor> elementProcessors = this.elementProcessorsByTemplateMode.get(this.templateMode); final AttributeDefinition attributeDefinition; if (this.templateMode == TemplateMode.HTML) { attributeDefinition = buildHTMLAttributeDefinition(AttributeNames.forHTMLName(text, offset, len), elementProcessors); } else if (this.templateMode == TemplateMode.XML) { attributeDefinition = buildXMLAttributeDefinition(AttributeNames.forXMLName(text, offset, len), elementProcessors); } else { // this.templateMode.isText() attributeDefinition = buildTextAttributeDefinition(this.templateMode, AttributeNames.forTextName(text, offset, len), elementProcessors); } final String[] completeAttributeNames = attributeDefinition.attributeName.completeAttributeNames; for (final String completeAttributeName : completeAttributeNames) { index = binarySearch(this.templateMode.isCaseSensitive(), this.repositoryNames, completeAttributeName); // binary Search returned (-(insertion point) - 1) this.repositoryNames.add(((index + 1) * -1), completeAttributeName); this.repository.add(((index + 1) * -1), attributeDefinition); } return attributeDefinition; }
if (bindStatus == null) { final AttributeName fieldAttributeName = AttributeNames.forHTMLName(attributeName.getPrefix(), AbstractSpringFieldTagProcessor.ATTR_NAME); throw new TemplateProcessingException( "Cannot apply \"" + attributeName + "\": this attribute requires the existence of " +
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))); }
private AttributeDefinition storeAttribute(final String prefix, final String attributeName) { int index = binarySearch(this.templateMode.isCaseSensitive(), this.repositoryNames, prefix, attributeName); if (index >= 0) { // It was already added while we were waiting for the lock! return this.repository.get(index); } final Set<IElementProcessor> elementProcessors = this.elementProcessorsByTemplateMode.get(this.templateMode); final AttributeDefinition attributeDefinition; if (this.templateMode == TemplateMode.HTML) { attributeDefinition = buildHTMLAttributeDefinition(AttributeNames.forHTMLName(prefix, attributeName), elementProcessors); } else if (this.templateMode == TemplateMode.XML) { attributeDefinition = buildXMLAttributeDefinition(AttributeNames.forXMLName(prefix, attributeName), elementProcessors); } else { // this.templateMode.isText() attributeDefinition = buildTextAttributeDefinition(this.templateMode, AttributeNames.forTextName(prefix, attributeName), elementProcessors); } final String[] completeAttributeNames = attributeDefinition.attributeName.completeAttributeNames; for (final String completeAttributeName : completeAttributeNames) { index = binarySearch(this.templateMode.isCaseSensitive(), this.repositoryNames, completeAttributeName); // binary Search returned (-(insertion point) - 1) this.repositoryNames.add(((index + 1) * -1), completeAttributeName); this.repository.add(((index + 1) * -1), attributeDefinition); } return attributeDefinition; }
if (bindStatus == null) { final AttributeName fieldAttributeName = AttributeNames.forHTMLName(attributeName.getPrefix(), AbstractSpringFieldTagProcessor.ATTR_NAME); throw new TemplateProcessingException( "Cannot apply \"" + attributeName + "\": this attribute requires the existence of " +
private AttributeDefinition storeAttribute(final String attributeName) { int index = binarySearch(this.templateMode.isCaseSensitive(), this.repositoryNames, attributeName); if (index >= 0) { // It was already added while we were waiting for the lock! return this.repository.get(index); } final Set<IElementProcessor> elementProcessors = this.elementProcessorsByTemplateMode.get(this.templateMode); final AttributeDefinition attributeDefinition; if (this.templateMode == TemplateMode.HTML) { attributeDefinition = buildHTMLAttributeDefinition(AttributeNames.forHTMLName(attributeName), elementProcessors); } else if (this.templateMode == TemplateMode.XML) { attributeDefinition = buildXMLAttributeDefinition(AttributeNames.forXMLName(attributeName), elementProcessors); } else { // this.templateMode.isText() attributeDefinition = buildTextAttributeDefinition(this.templateMode, AttributeNames.forTextName(attributeName), elementProcessors); } final String[] completeAttributeNames = attributeDefinition.attributeName.completeAttributeNames; for (final String completeAttributeName : completeAttributeNames) { index = binarySearch(this.templateMode.isCaseSensitive(), this.repositoryNames, completeAttributeName); // binary Search returned (-(insertion point) - 1) this.repositoryNames.add(((index + 1) * -1), completeAttributeName); this.repository.add(((index + 1) * -1), attributeDefinition); } return attributeDefinition; }