Interface IAttribute
-
public interface IAttribute
Interface defining an attribute contained in a tag.
Container tags are implementations of
IProcessableElementTag
.Note that any implementations of this interface should be immutable.
- Since:
- 3.0.0
- Author:
- Daniel Fernández
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description String
getAttributeCompleteName()
Returns the complete name of the attribute, exactly as it was written in the original template (if it did appear there).AttributeDefinition
getAttributeDefinition()
Returns theAttributeDefinition
corresponding to this attribute.int
getCol()
Returns the column at which this attribute can be found in the template specified bygetTemplateName()
.int
getLine()
Returns the line at which this attribute can be found in the template specified bygetTemplateName()
.String
getOperator()
Returns the operator specified for this attribute.String
getTemplateName()
Returns the name of the template from which parsing this attribute was originally created.String
getValue()
Returns the value of this attribute, or null if it has none.AttributeValueQuotes
getValueQuotes()
Returns the type of quotes surrounding the attribute value.boolean
hasLocation()
Checks whether this attribute contains location information (template name, line and column).void
write(Writer writer)
Writes this attribute to the specifiedWriter
.
-
-
-
Method Detail
-
getAttributeCompleteName
String getAttributeCompleteName()
Returns the complete name of the attribute, exactly as it was written in the original template (if it did appear there).
- Returns:
- the complete name.
-
getAttributeDefinition
AttributeDefinition getAttributeDefinition()
Returns the
AttributeDefinition
corresponding to this attribute.The attribute definition contains several metadata related to the attribute. For example, if the template mode is
TemplateMode1.html
, an attribute definition could specify whether the attribute is boolean (represents a true/false value by appearing or not appearing at a specific tag).- Returns:
- the attribute definition.
-
getOperator
String getOperator()
Returns the operator specified for this attribute.
The operator itself, if present, is always an equals sign (
=
), but the reason this is specified as a separate field is that it could be surrounded by white space, which should be respected in output when present at the input template.If the attribute is specified without a value at all (and therefore no operator either), this method will return null.
- Returns:
- the attribute operator (might be null if no value specified).
-
getValue
String getValue()
Returns the value of this attribute, or null if it has none.
A null-valued attribute is an attribute of which only the name has been specified (only allowed in HTML mode).
- Returns:
- the value of this attribute, or null if it has none.
-
getValueQuotes
AttributeValueQuotes getValueQuotes()
Returns the type of quotes surrounding the attribute value.
- Returns:
- the
AttributeValueQuotes
value representing the attribute value quotes (might be null).
-
hasLocation
boolean hasLocation()
Checks whether this attribute contains location information (template name, line and column).
Only attributes that are generated during the parsing of templates contain location info, locating them in their original template. All attributes generated during template processing and not originally present at the template do not contain this location data.
- Returns:
- whether the attribute contains location data or not.
-
getTemplateName
String getTemplateName()
Returns the name of the template from which parsing this attribute was originally created.
- Returns:
- the name of the template
-
getLine
int getLine()
Returns the line at which this attribute can be found in the template specified by
getTemplateName()
.- Returns:
- the line number, starting in 1.
-
getCol
int getCol()
Returns the column at which this attribute can be found in the template specified by
getTemplateName()
.- Returns:
- the column number, starting in 1.
-
write
void write(Writer writer) throws IOException
Writes this attribute to the specified
Writer
.This is usually called as a part of
ITemplateEvent.write(Writer)
.- Parameters:
writer
- the writer this attribute should be written to.- Throws:
IOException
- if an input/output exception occurs.
-
-