StandaloneElementTag setAttribute( final AttributeDefinitions attributeDefinitions, final AttributeDefinition attributeDefinition, final String completeName, final String value, final AttributeValueQuotes valueQuotes) { final Attributes oldAttributes = (this.attributes != null? this.attributes : Attributes.EMPTY_ATTRIBUTES); final Attributes newAttributes = oldAttributes.setAttribute(attributeDefinitions, this.templateMode, attributeDefinition, completeName, value, valueQuotes); return new StandaloneElementTag(this.templateMode, this.elementDefinition, this.elementCompleteName, newAttributes, this.synthetic, this.minimized, this.templateName, this.line, this.col); }
StandaloneElementTag removeAttribute(final String prefix, final String name) { final Attributes oldAttributes = (this.attributes != null? this.attributes : Attributes.EMPTY_ATTRIBUTES); final Attributes newAttributes = oldAttributes.removeAttribute(this.templateMode, prefix, name); if (oldAttributes == newAttributes) { return this; } return new StandaloneElementTag(this.templateMode, this.elementDefinition, this.elementCompleteName, newAttributes, this.synthetic, this.minimized, this.templateName, this.line, this.col); }
StandaloneElementTag replaceAttribute( final AttributeDefinitions attributeDefinitions, final AttributeName oldName, final AttributeDefinition newAttributeDefinition, final String completeNewName, final String value, final AttributeValueQuotes valueQuotes) { final Attributes oldAttributes = (this.attributes != null? this.attributes : Attributes.EMPTY_ATTRIBUTES); final Attributes newAttributes = oldAttributes.replaceAttribute(attributeDefinitions, this.templateMode, oldName, newAttributeDefinition, completeNewName, value, valueQuotes); return new StandaloneElementTag(this.templateMode, this.elementDefinition, this.elementCompleteName, newAttributes, this.synthetic, this.minimized, this.templateName, this.line, this.col); }
StandaloneElementTag removeAttribute(final String completeName) { final Attributes oldAttributes = (this.attributes != null? this.attributes : Attributes.EMPTY_ATTRIBUTES); final Attributes newAttributes = oldAttributes.removeAttribute(this.templateMode, completeName); if (oldAttributes == newAttributes) { return this; } return new StandaloneElementTag(this.templateMode, this.elementDefinition, this.elementCompleteName, newAttributes, this.synthetic, this.minimized, this.templateName, this.line, this.col); }
StandaloneElementTag removeAttribute(final AttributeName attributeName) { final Attributes oldAttributes = (this.attributes != null? this.attributes : Attributes.EMPTY_ATTRIBUTES); final Attributes newAttributes = oldAttributes.removeAttribute(attributeName); if (oldAttributes == newAttributes) { return this; } return new StandaloneElementTag(this.templateMode, this.elementDefinition, this.elementCompleteName, newAttributes, this.synthetic, this.minimized, this.templateName, this.line, this.col); }
@Override public IStandaloneElementTag createStandaloneElementTag(final String elementName, final boolean synthetic, final boolean minimized) { final ElementDefinition elementDefinition = this.elementDefinitions.forName(this.templateMode, elementName); return new StandaloneElementTag(this.templateMode, elementDefinition, elementName, null, synthetic, minimized); }
@Override public void handleStandaloneElementEnd( final char[] buffer, final int nameOffset, final int nameLen, final boolean minimized, final int line, final int col) throws ParseException { final String elementCompleteName = new String(buffer, nameOffset, nameLen); final ElementDefinition elementDefinition = this.elementDefinitions.forName(this.templateMode, elementCompleteName); final Attributes attributes; if (this.currentElementAttributes.isEmpty() && this.currentElementInnerWhiteSpaces.isEmpty()) { attributes = null; } else { final Attribute[] attributesArr = (this.currentElementAttributes.isEmpty()? Attributes.EMPTY_ATTRIBUTE_ARRAY : this.currentElementAttributes.toArray(new Attribute[this.currentElementAttributes.size()])); final String[] innerWhiteSpaces = this.currentElementInnerWhiteSpaces.toArray(new String[this.currentElementInnerWhiteSpaces.size()]); attributes = new Attributes(attributesArr, innerWhiteSpaces); } this.templateHandler.handleStandaloneElement( new StandaloneElementTag( this.templateMode, elementDefinition, elementCompleteName, attributes, false, minimized, this.templateName, this.lineOffset + this.currentElementLine, (this.currentElementLine == 1? this.colOffset : 0) + this.currentElementCol)); }
@Override public void handleStandaloneElementEnd( final char[] buffer, final int nameOffset, final int nameLen, final boolean minimized, final int line, final int col) throws TextParseException { final String elementCompleteName = new String(buffer, nameOffset, nameLen); final ElementDefinition elementDefinition = this.elementDefinitions.forName(this.templateMode, elementCompleteName); final Attributes attributes; if (this.currentElementAttributes.isEmpty()) { attributes = null; } else { final Attribute[] attributesArr = (this.currentElementAttributes.isEmpty()? Attributes.EMPTY_ATTRIBUTE_ARRAY : this.currentElementAttributes.toArray(new Attribute[this.currentElementAttributes.size()])); final String[] innerWhiteSpaces; if (attributesArr.length < SYNTHETIC_INNER_WHITESPACES.length) { innerWhiteSpaces = SYNTHETIC_INNER_WHITESPACES[attributesArr.length]; } else { innerWhiteSpaces = new String[attributesArr.length]; Arrays.fill(innerWhiteSpaces, Attributes.DEFAULT_WHITE_SPACE); } attributes = new Attributes(attributesArr, innerWhiteSpaces); } this.templateHandler.handleStandaloneElement( new StandaloneElementTag( this.templateMode, elementDefinition, elementCompleteName, attributes, false, minimized, this.templateName, this.lineOffset + this.currentElementLine, (this.currentElementLine == 1? this.colOffset : 0) + this.currentElementCol)); }
@Override public IStandaloneElementTag createStandaloneElementTag(final String elementName, final String attributeName, final String attributeValue, final boolean synthetic, final boolean minimized) { final ElementDefinition elementDefinition = this.elementDefinitions.forName(this.templateMode, elementName); final Attributes attributes = buildAttributes(new Attribute[] { buildAttribute(attributeName, attributeValue, null) }); return new StandaloneElementTag(this.templateMode, elementDefinition, elementName, attributes, synthetic, minimized); }
@Override public IStandaloneElementTag createStandaloneElementTag(final String elementName, final Map<String, String> attributes, final AttributeValueQuotes attributeValueQuotes, final boolean synthetic, final boolean minimized) { final ElementDefinition elementDefinition = this.elementDefinitions.forName(this.templateMode, elementName); final Attributes attributesObj = buildAttributes(buildAttributeArray(attributes, attributeValueQuotes)); return new StandaloneElementTag(this.templateMode, elementDefinition, elementName, attributesObj, synthetic, minimized); }
return new StandaloneElementTag( standaloneElementTag.getTemplateMode(), standaloneElementTag.getElementDefinition(), standaloneElementTag.getElementCompleteName(), attributes, standaloneElementTag.isSynthetic(), standaloneElementTag.isMinimized(),