Class AttributeSet
- java.lang.Object
-
- org.infinispan.commons.configuration.attributes.AttributeSet
-
- All Implemented Interfaces:
AttributeListener<Object>
,Matchable<AttributeSet>
public class AttributeSet extends Object implements AttributeListener<Object>, Matchable<AttributeSet>
AttributeSet is a container forAttribute
s. It is constructed by passing in a list ofAttributeDefinition
s. AttributeSets are initially unprotected, which means that the contained attributes can be modified. If theprotect()
method is invoked then only attributes which are notAttributeDefinition.isImmutable()
can be modified from then on.- Since:
- 7.2
- Author:
- Tristan Tarrant
-
-
Constructor Summary
Constructors Constructor Description AttributeSet(Class<?> klass, AttributeDefinition<?>... attributeDefinitions)
AttributeSet(Class<?> klass, AttributeSet attributeSet, AttributeDefinition<?>... attributeDefinitions)
AttributeSet(String name, AttributeDefinition<?>... attributeDefinitions)
AttributeSet(String name, AttributeSet attributeSet, AttributeDefinition<?>[] attributeDefinitions)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> Attribute<T>
attribute(String name)
Returns the named attribute<T> Attribute<T>
attribute(AttributeDefinition<T> def)
Returns the attribute identified by the suppliedAttributeDefinition
void
attributeChanged(Attribute<Object> attribute, Object oldValue)
Collection<Attribute<?>>
attributes()
AttributeSet
checkProtection()
boolean
contains(String name)
Returns whether this attribute set contains the specified named attribute<T> boolean
contains(AttributeDefinition<T> def)
Returns whether this set contains the specified attribute definitionboolean
equals(Object obj)
Class<?>
getKlass()
String
getName()
int
hashCode()
boolean
isModified()
Returns whether any attributes in this set have been modifiedboolean
isProtected()
Returns whether this attribute set is protectedboolean
matches(AttributeSet other)
AttributeSet
protect()
Returns a new ValueSet where immutableAttribute
s are write-protectedvoid
read(AttributeSet other)
Copies all attribute from another AttributeSetvoid
reset()
String
toString()
String
toString(String name)
void
write(XMLStreamWriter writer)
Writes the attributes of this attributeset as part of the current elementvoid
write(XMLStreamWriter writer, String xmlElementName)
Writes this attributeset to the specified XMLStreamWriter as an elementvoid
write(XMLStreamWriter writer, String xmlElementName, AttributeDefinition<?>... defs)
Writes the specified attributes in this attributeset to the specified XMLStreamWriter as an elementvoid
write(XMLStreamWriter writer, AttributeDefinition<?> def)
Writer a single attribute to the specifiedXMLStreamWriter
using the attribute's xmlNamevoid
write(XMLStreamWriter writer, AttributeDefinition<?> def, Enum<?> name)
Writer a single attribute to the specifiedXMLStreamWriter
using the supplied namevoid
write(XMLStreamWriter writer, AttributeDefinition<?> def, String name)
Writer a single attribute to the specifiedXMLStreamWriter
using the supplied name
-
-
-
Constructor Detail
-
AttributeSet
public AttributeSet(Class<?> klass, AttributeDefinition<?>... attributeDefinitions)
-
AttributeSet
public AttributeSet(String name, AttributeDefinition<?>... attributeDefinitions)
-
AttributeSet
public AttributeSet(Class<?> klass, AttributeSet attributeSet, AttributeDefinition<?>... attributeDefinitions)
-
AttributeSet
public AttributeSet(String name, AttributeSet attributeSet, AttributeDefinition<?>[] attributeDefinitions)
-
-
Method Detail
-
getKlass
public Class<?> getKlass()
-
getName
public String getName()
-
contains
public boolean contains(String name)
Returns whether this attribute set contains the specified named attribute- Parameters:
name
- the name of the attribute
-
contains
public <T> boolean contains(AttributeDefinition<T> def)
Returns whether this set contains the specified attribute definition- Parameters:
def
- theAttributeDefinition
-
attribute
public <T> Attribute<T> attribute(String name)
Returns the named attribute- Parameters:
name
- the name of the attribute to return- Returns:
- the attribute
-
attribute
public <T> Attribute<T> attribute(AttributeDefinition<T> def)
Returns the attribute identified by the suppliedAttributeDefinition
- Parameters:
def
- the attribute definition- Returns:
- the attribute
-
read
public void read(AttributeSet other)
Copies all attribute from another AttributeSet- Parameters:
other
- the source AttributeSet
-
protect
public AttributeSet protect()
Returns a new ValueSet where immutableAttribute
s are write-protected- Returns:
-
isModified
public boolean isModified()
Returns whether any attributes in this set have been modified
-
isProtected
public boolean isProtected()
Returns whether this attribute set is protected
-
write
public void write(XMLStreamWriter writer, AttributeDefinition<?> def) throws XMLStreamException
Writer a single attribute to the specifiedXMLStreamWriter
using the attribute's xmlName- Parameters:
writer
- the writerdef
- the Attribute definition- Throws:
XMLStreamException
-
write
public void write(XMLStreamWriter writer, AttributeDefinition<?> def, Enum<?> name) throws XMLStreamException
Writer a single attribute to the specifiedXMLStreamWriter
using the supplied name- Parameters:
writer
- the writerdef
- the Attribute definitionname
- the XML tag name for the attribute- Throws:
XMLStreamException
-
write
public void write(XMLStreamWriter writer, AttributeDefinition<?> def, String name) throws XMLStreamException
Writer a single attribute to the specifiedXMLStreamWriter
using the supplied name- Parameters:
writer
- the writerdef
- the Attribute definitionname
- the XML tag name for the attribute- Throws:
XMLStreamException
-
write
public void write(XMLStreamWriter writer, String xmlElementName) throws XMLStreamException
Writes this attributeset to the specified XMLStreamWriter as an element- Parameters:
writer
-- Throws:
XMLStreamException
-
write
public void write(XMLStreamWriter writer, String xmlElementName, AttributeDefinition<?>... defs) throws XMLStreamException
Writes the specified attributes in this attributeset to the specified XMLStreamWriter as an element- Parameters:
writer
-- Throws:
XMLStreamException
-
write
public void write(XMLStreamWriter writer) throws XMLStreamException
Writes the attributes of this attributeset as part of the current element- Parameters:
writer
-- Throws:
XMLStreamException
-
matches
public boolean matches(AttributeSet other)
- Specified by:
matches
in interfaceMatchable<AttributeSet>
-
checkProtection
public AttributeSet checkProtection()
-
reset
public void reset()
-
attributeChanged
public void attributeChanged(Attribute<Object> attribute, Object oldValue)
- Specified by:
attributeChanged
in interfaceAttributeListener<Object>
-
attributes
public Collection<Attribute<?>> attributes()
-
-