OpenElementTag 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 OpenElementTag(this.templateMode, this.elementDefinition, this.elementCompleteName, newAttributes, this.synthetic, this.templateName, this.line, this.col); }
OpenElementTag 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 OpenElementTag(this.templateMode, this.elementDefinition, this.elementCompleteName, newAttributes, this.synthetic, this.templateName, this.line, this.col); }
OpenElementTag 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 OpenElementTag(this.templateMode, this.elementDefinition, this.elementCompleteName, newAttributes, this.synthetic, this.templateName, this.line, this.col); }
OpenElementTag 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 OpenElementTag(this.templateMode, this.elementDefinition, this.elementCompleteName, newAttributes, this.synthetic, this.templateName, this.line, this.col); }
OpenElementTag 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 OpenElementTag(this.templateMode, this.elementDefinition, this.elementCompleteName, newAttributes, this.synthetic, this.templateName, this.line, this.col); }
@Override public IOpenElementTag createOpenElementTag(final String elementName, final boolean synthetic) { final ElementDefinition elementDefinition = this.elementDefinitions.forName(this.templateMode, elementName); return new OpenElementTag(this.templateMode, elementDefinition, elementName, null, synthetic); }
@Override public void handleOpenElementEnd( final char[] buffer, final int nameOffset, final int nameLen, 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.handleOpenElement( new OpenElementTag( this.templateMode, elementDefinition, elementCompleteName, attributes, false, this.templateName, this.lineOffset + this.currentElementLine, (this.currentElementLine == 1? this.colOffset : 0) + this.currentElementCol)); }
@Override public void handleAutoOpenElementEnd( final char[] buffer, final int nameOffset, final int nameLen, 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.handleOpenElement( new OpenElementTag( this.templateMode, elementDefinition, elementCompleteName, attributes, true, // synthetic = true this.templateName, this.lineOffset + this.currentElementLine, (this.currentElementLine == 1? this.colOffset : 0) + this.currentElementCol)); }
@Override public void handleOpenElementEnd( final char[] buffer, final int nameOffset, final int nameLen, 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.handleOpenElement( new OpenElementTag( this.templateMode, elementDefinition, elementCompleteName, attributes, false, this.templateName, this.lineOffset + this.currentElementLine, (this.currentElementLine == 1? this.colOffset : 0) + this.currentElementCol)); }
@Override public IOpenElementTag createOpenElementTag(final String elementName, final String attributeName, final String attributeValue, final boolean synthetic) { final ElementDefinition elementDefinition = this.elementDefinitions.forName(this.templateMode, elementName); final Attributes attributes = buildAttributes(new Attribute[] { buildAttribute(attributeName, attributeValue, null) }); return new OpenElementTag(this.templateMode, elementDefinition, elementName, attributes, synthetic); }
@Override public IOpenElementTag createOpenElementTag(final String elementName, final Map<String, String> attributes, final AttributeValueQuotes attributeValueQuotes, final boolean synthetic) { final ElementDefinition elementDefinition = this.elementDefinitions.forName(this.templateMode, elementName); final Attributes attributesObj = buildAttributes(buildAttributeArray(attributes, attributeValueQuotes)); return new OpenElementTag(this.templateMode, elementDefinition, elementName, attributesObj, synthetic); }
GatheringModelProcessable createStandaloneEquivalentModel( final StandaloneElementTag standaloneElementTag, final ProcessorExecutionVars processorExecutionVars) { SkipBody gatheredSkipBody = this.skipBodyByLevel[this.modelLevel]; gatheredSkipBody = (gatheredSkipBody == SkipBody.SKIP_ELEMENTS ? SkipBody.PROCESS_ONE_ELEMENT : gatheredSkipBody); final boolean gatheredSkipCloseTagByLevel = this.skipCloseTagByLevel[this.modelLevel]; final OpenElementTag openTag = new OpenElementTag( standaloneElementTag.templateMode, standaloneElementTag.elementDefinition, standaloneElementTag.elementCompleteName, standaloneElementTag.attributes, standaloneElementTag.synthetic, standaloneElementTag.templateName, standaloneElementTag.line, standaloneElementTag.col); final CloseElementTag closeTag = new CloseElementTag( standaloneElementTag.templateMode, standaloneElementTag.elementDefinition, standaloneElementTag.elementCompleteName, null, standaloneElementTag.synthetic, false, standaloneElementTag.templateName, standaloneElementTag.line, standaloneElementTag.col); final GatheringModelProcessable equivalentModel = new GatheringModelProcessable( this.configuration, this.processorTemplateHandler, this.context, this, this.templateFlowController, gatheredSkipBody, gatheredSkipCloseTagByLevel, processorExecutionVars); equivalentModel.gatherOpenElement(openTag); equivalentModel.gatherCloseElement(closeTag); return equivalentModel; }
return new OpenElementTag( openElementTag.getTemplateMode(), openElementTag.getElementDefinition(), openElementTag.getElementCompleteName(), attributes, openElementTag.isSynthetic(),