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 forAttributes. It is constructed by passing in a list ofAttributeDefinitions. 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 suppliedAttributeDefinitionvoidattributeChanged(Attribute<Object> attribute, Object oldValue)Collection<Attribute<?>>attributes()AttributeSetcheckProtection()booleancontains(String name)Returns whether this attribute set contains the specified named attribute<T> booleancontains(AttributeDefinition<T> def)Returns whether this set contains the specified attribute definitionbooleanequals(Object obj)Class<?>getKlass()StringgetName()inthashCode()booleanisModified()Returns whether any attributes in this set have been modifiedbooleanisProtected()Returns whether this attribute set is protectedbooleanmatches(AttributeSet other)AttributeSetprotect()Returns a new ValueSet where immutableAttributes are write-protectedvoidread(AttributeSet other)Copies all attribute from another AttributeSetvoidreset()StringtoString()StringtoString(String name)voidwrite(XMLStreamWriter writer)Writes the attributes of this attributeset as part of the current elementvoidwrite(XMLStreamWriter writer, String xmlElementName)Writes this attributeset to the specified XMLStreamWriter as an elementvoidwrite(XMLStreamWriter writer, String xmlElementName, AttributeDefinition<?>... defs)Writes the specified attributes in this attributeset to the specified XMLStreamWriter as an elementvoidwrite(XMLStreamWriter writer, AttributeDefinition<?> def)Writer a single attribute to the specifiedXMLStreamWriterusing the attribute's xmlNamevoidwrite(XMLStreamWriter writer, AttributeDefinition<?> def, Enum<?> name)Writer a single attribute to the specifiedXMLStreamWriterusing the supplied namevoidwrite(XMLStreamWriter writer, AttributeDefinition<?> def, String name)Writer a single attribute to the specifiedXMLStreamWriterusing 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 immutableAttributes 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 specifiedXMLStreamWriterusing 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 specifiedXMLStreamWriterusing 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 specifiedXMLStreamWriterusing 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:
matchesin interfaceMatchable<AttributeSet>
-
checkProtection
public AttributeSet checkProtection()
-
reset
public void reset()
-
attributeChanged
public void attributeChanged(Attribute<Object> attribute, Object oldValue)
- Specified by:
attributeChangedin interfaceAttributeListener<Object>
-
attributes
public Collection<Attribute<?>> attributes()
-
-