Class MutableAttributeImpl
- All Implemented Interfaces:
Attribute, MutableAttribute, Immutable<Attribute, MutableAttribute>, Mutable<MutableAttribute, Attribute>
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Stringprivate Stringprivate final charprivate final charprivate LinkedHashMap<String, String> Fields inherited from interface Attribute
CLASS_ATTR, ID_ATTR, LINK_STATUS_ATTR, NAME_ATTR, NO_FOLLOW, NON_RENDERING_WHEN_EMPTY, NUL, STYLE_ATTR, TARGET_ATTR, TITLE_ATTR -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateMutableAttributeImpl(CharSequence name, CharSequence value, char valueListDelimiter, char valueNameDelimiter) -
Method Summary
Modifier and TypeMethodDescriptionbooleancontainsValue(CharSequence value) See if the attribute contains the value (if attribute has list delimiter set) or is equal to the value if no list delimiter is setcopy()booleanprivate voidforEachValue(CharSequence value, BiConsumer<String, String> consumer) getName()getValue()charcharinthashCode()booleanstatic MutableAttributeImplstatic MutableAttributeImplof(CharSequence attrName) static MutableAttributeImplof(CharSequence attrName, CharSequence value) static MutableAttributeImplof(CharSequence attrName, CharSequence value, char valueListDelimiter) static MutableAttributeImplof(CharSequence attrName, CharSequence value, char valueListDelimiter, char valueNameDelimiter) removeValue(CharSequence value) Add a new value or values depending on list and name delimiter settings and value content.replaceValue(CharSequence value) Replace the complete value of this attribute by a new valuevoidsetValue(CharSequence value) Add a new value or values depending on list and name delimiter settings and value contenttoString()protected StringReturn the attribute value string by splicing the values of the map using valueListDelimiter and valueNameDelimiter with replacements of the given name/value if provided.
-
Field Details
-
name
-
valueListDelimiter
private final char valueListDelimiter -
valueNameDelimiter
private final char valueNameDelimiter -
value
-
values
-
-
Constructor Details
-
MutableAttributeImpl
private MutableAttributeImpl(CharSequence name, CharSequence value, char valueListDelimiter, char valueNameDelimiter)
-
-
Method Details
-
getValueListDelimiter
public char getValueListDelimiter()- Specified by:
getValueListDelimiterin interfaceAttribute
-
getValueNameDelimiter
public char getValueNameDelimiter()- Specified by:
getValueNameDelimiterin interfaceAttribute
-
toImmutable
- Specified by:
toImmutablein interfaceMutable<MutableAttribute, Attribute>
-
toMutable
- Specified by:
toMutablein interfaceImmutable<Attribute, MutableAttribute>
-
copy
- Specified by:
copyin interfaceMutableAttribute
-
getName
-
getValue
-
resetToValuesMap
public void resetToValuesMap() -
getValueMap
-
valueFromMap
Return the attribute value string by splicing the values of the map using valueListDelimiter and valueNameDelimiter with replacements of the given name/value if provided. If the name is not empty and value is empty then this will be removed from the final string- Returns:
- string for value of this attribute from map
-
isNonRendering
public boolean isNonRendering()- Specified by:
isNonRenderingin interfaceAttribute
-
replaceValue
Description copied from interface:AttributeReplace the complete value of this attribute by a new value- Specified by:
replaceValuein interfaceAttribute- Specified by:
replaceValuein interfaceMutableAttribute- Parameters:
value- new value- Returns:
- new attribute or same attribute if nothing changed or attribute is mutable
-
setValue
Description copied from interface:AttributeAdd a new value or values depending on list and name delimiter settings and value contentIf the attribute does not have a list delimiter then its value will be set to the given value.
If the attribute has a list delimiter but not name delimiter then value will be split by list delimiter and all values will be added to the attribute's value list. New ones added at the end, old ones left as is.
If the attribute has a list delimiter and a name delimiter then value will be split by list delimiter and the name portion of each value will be used to find duplicates whose value will be replaced. New ones added at the end, old ones left where they are but with a new value.
- Specified by:
setValuein interfaceAttribute- Specified by:
setValuein interfaceMutableAttribute- Parameters:
value- value or list of values (if attribute has a list delimiter and name delimiter) to change- Returns:
- new attribute or same attribute if nothing changed or attribute is mutable
-
forEachValue
-
removeValue
Description copied from interface:AttributeAdd a new value or values depending on list and name delimiter settings and value content.If the attribute does not have a list delimiter and its value is equal to the given value then its value is set to empty
If the attribute has a list delimiter but not name delimiter then value will be split by list delimiter and any values in attribute's value list will be removed
If the attribute has a list delimiter and a name delimiter then value will be split by list delimiter and only the name portion of each value will be used for removal from the attribute's value list
- Specified by:
removeValuein interfaceAttribute- Specified by:
removeValuein interfaceMutableAttribute- Parameters:
value- value or list of values (if attribute has a list delimiter and name delimiter) to remove- Returns:
- new attribute or same attribute if nothing changed or attribute is mutable
-
containsValue
Description copied from interface:AttributeSee if the attribute contains the value (if attribute has list delimiter set) or is equal to the value if no list delimiter is set- Specified by:
containsValuein interfaceAttribute- Specified by:
containsValuein interfaceMutableAttribute- Parameters:
value- name part of the attribute value list or the value if the attribute does not have a value list delimiter- Returns:
- true if the attribute contains the valueName
-
equals
-
hashCode
-
toString
-
of
-
of
-
of
-
of
public static MutableAttributeImpl of(CharSequence attrName, CharSequence value, char valueListDelimiter) -
of
public static MutableAttributeImpl of(CharSequence attrName, CharSequence value, char valueListDelimiter, char valueNameDelimiter)
-