Class MutableAttributeImpl
- java.lang.Object
-
- com.vladsch.flexmark.util.html.MutableAttributeImpl
-
- All Implemented Interfaces:
Attribute
,MutableAttribute
,Immutable<Attribute,MutableAttribute>
,Mutable<MutableAttribute,Attribute>
public class MutableAttributeImpl extends java.lang.Object implements MutableAttribute
-
-
Field Summary
-
Fields inherited from interface com.vladsch.flexmark.util.html.Attribute
CLASS_ATTR, ID_ATTR, LINK_STATUS_ATTR, NAME_ATTR, NO_FOLLOW, NON_RENDERING_WHEN_EMPTY, NUL, STYLE_ATTR, TARGET_ATTR, TITLE_ATTR
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
containsValue(java.lang.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 setMutableAttribute
copy()
boolean
equals(java.lang.Object o)
java.lang.String
getName()
java.lang.String
getValue()
char
getValueListDelimiter()
protected java.util.Map<java.lang.String,java.lang.String>
getValueMap()
char
getValueNameDelimiter()
int
hashCode()
boolean
isNonRendering()
static MutableAttributeImpl
of(Attribute other)
static MutableAttributeImpl
of(java.lang.CharSequence attrName)
static MutableAttributeImpl
of(java.lang.CharSequence attrName, java.lang.CharSequence value)
static MutableAttributeImpl
of(java.lang.CharSequence attrName, java.lang.CharSequence value, char valueListDelimiter)
static MutableAttributeImpl
of(java.lang.CharSequence attrName, java.lang.CharSequence value, char valueListDelimiter, char valueNameDelimiter)
MutableAttributeImpl
removeValue(java.lang.CharSequence value)
Add a new value or values depending on list and name delimiter settings and value content.MutableAttributeImpl
replaceValue(java.lang.CharSequence value)
Replace the complete value of this attribute by a new valuevoid
resetToValuesMap()
MutableAttributeImpl
setValue(java.lang.CharSequence value)
Add a new value or values depending on list and name delimiter settings and value contentAttribute
toImmutable()
MutableAttribute
toMutable()
java.lang.String
toString()
protected java.lang.String
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.
-
-
-
Method Detail
-
getValueListDelimiter
public char getValueListDelimiter()
- Specified by:
getValueListDelimiter
in interfaceAttribute
-
getValueNameDelimiter
public char getValueNameDelimiter()
- Specified by:
getValueNameDelimiter
in interfaceAttribute
-
toImmutable
public Attribute toImmutable()
- Specified by:
toImmutable
in interfaceMutable<MutableAttribute,Attribute>
-
toMutable
public MutableAttribute toMutable()
- Specified by:
toMutable
in interfaceImmutable<Attribute,MutableAttribute>
-
copy
public MutableAttribute copy()
- Specified by:
copy
in interfaceMutableAttribute
-
resetToValuesMap
public void resetToValuesMap()
-
getValueMap
protected java.util.Map<java.lang.String,java.lang.String> getValueMap()
-
valueFromMap
protected java.lang.String 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:
isNonRendering
in interfaceAttribute
-
replaceValue
public MutableAttributeImpl replaceValue(java.lang.CharSequence value)
Description copied from interface:Attribute
Replace the complete value of this attribute by a new value- Specified by:
replaceValue
in interfaceAttribute
- Specified by:
replaceValue
in interfaceMutableAttribute
- Parameters:
value
- new value- Returns:
- new attribute or same attribute if nothing changed or attribute is mutable
-
setValue
public MutableAttributeImpl setValue(java.lang.CharSequence value)
Description copied from interface:Attribute
Add 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:
setValue
in interfaceAttribute
- Specified by:
setValue
in 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
-
removeValue
public MutableAttributeImpl removeValue(java.lang.CharSequence value)
Description copied from interface:Attribute
Add 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:
removeValue
in interfaceAttribute
- Specified by:
removeValue
in 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
public boolean containsValue(java.lang.CharSequence value)
Description copied from interface:Attribute
See 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:
containsValue
in interfaceAttribute
- Specified by:
containsValue
in 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
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
of
public static MutableAttributeImpl of(Attribute other)
-
of
public static MutableAttributeImpl of(java.lang.CharSequence attrName)
-
of
public static MutableAttributeImpl of(java.lang.CharSequence attrName, java.lang.CharSequence value)
-
of
public static MutableAttributeImpl of(java.lang.CharSequence attrName, java.lang.CharSequence value, char valueListDelimiter)
-
of
public static MutableAttributeImpl of(java.lang.CharSequence attrName, java.lang.CharSequence value, char valueListDelimiter, char valueNameDelimiter)
-
-