Package org.jboss.as.controller
Class SimpleAttributeDefinition
- java.lang.Object
-
- org.jboss.as.controller.AttributeDefinition
-
- org.jboss.as.controller.SimpleAttributeDefinition
-
- Direct Known Subclasses:
ObjectTypeAttributeDefinition
public class SimpleAttributeDefinition extends AttributeDefinition
Defining characteristics of an attribute in aResource
or a parameter or reply value type field in anOperationDefinition
, with utility methods for conversion to and from xml and for validation.- Author:
- Brian Stansberry (c) 2011 Red Hat Inc.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.jboss.as.controller.AttributeDefinition
AttributeDefinition.NameAndGroup
-
-
Field Summary
-
Fields inherited from class org.jboss.as.controller.AttributeDefinition
COMPLEX_TYPES
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
SimpleAttributeDefinition(AbstractAttributeDefinitionBuilder<?,? extends SimpleAttributeDefinition> builder)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
marshallAsAttribute(org.jboss.dmr.ModelNode resourceModel, boolean marshallDefault, XMLStreamWriter writer)
Marshalls the value from the givenresourceModel
as an xml attribute, if itis marshallable
.void
marshallAsAttribute(org.jboss.dmr.ModelNode resourceModel, XMLStreamWriter writer)
Marshalls the value from the givenresourceModel
as an xml attribute, if itis marshallable
.void
marshallAsElement(org.jboss.dmr.ModelNode resourceModel, boolean marshallDefault, XMLStreamWriter writer)
Marshalls the value from the givenresourceModel
as an xml element, if itis marshallable
.void
parseAndSetParameter(String value, org.jboss.dmr.ModelNode operation, XMLStreamReader reader)
Creates aModelNode
using the givenvalue
after first validating the node againstthis object's validator
, and then stores it in the givenoperation
model node as a key/value pair whose key is this attribute'sname
.-
Methods inherited from class org.jboss.as.controller.AttributeDefinition
addAccessConstraints, addAllowedValuesToDescription, addCapabilityRequirements, addDeprecatedInfo, addOperationParameterDescription, addOperationParameterDescription, addOperationReplyDescription, addOperationReplyDescription, addResourceAttributeDescription, addResourceAttributeDescription, convertParameterExpressions, convertStringExpression, correctValue, getAccessConstraints, getAllowedValues, getAlternatives, getArbitraryDescriptors, getAttributeDeprecatedDescription, getAttributeGroup, getAttributeTextDescription, getCorrector, getDefaultValue, getDeprecationData, getFlags, getMarshaller, getMeasurementUnit, getName, getNoTextDescription, getParser, getReferenceRecorder, getRequires, getType, getUndefinedMetricValue, getValidator, getXmlName, hasAlternative, hasCapabilityRequirements, isAllowed, isAllowExpression, isDeprecated, isMarshallable, isMarshallable, isNillable, isNullSignificant, isRequired, isRequired, isResourceOnly, marshallAsElement, removeCapabilityRequirements, resolveModelAttribute, resolveModelAttribute, resolveValue, resolveValue, validateAndSet, validateOperation
-
-
-
-
Constructor Detail
-
SimpleAttributeDefinition
protected SimpleAttributeDefinition(AbstractAttributeDefinitionBuilder<?,? extends SimpleAttributeDefinition> builder)
-
-
Method Detail
-
parseAndSetParameter
public void parseAndSetParameter(String value, org.jboss.dmr.ModelNode operation, XMLStreamReader reader) throws XMLStreamException
Creates aModelNode
using the givenvalue
after first validating the node againstthis object's validator
, and then stores it in the givenoperation
model node as a key/value pair whose key is this attribute'sname
.If
value
isnull
anundefined
node will be stored if such a value is acceptable to the validator.The expected usage of this method is in parsers seeking to build up an operation to store their parsed data into the configuration.
- Parameters:
value
- the value. Will betrimmed
before use if notnull
.operation
- model node of typeModelType.OBJECT
into which the parsed value should be storedreader
-XMLStreamReader
from which thelocation
from which the attribute value was read can be obtained and used in anyXMLStreamException
, in case the given value is invalid.- Throws:
XMLStreamException
- ifvalue
is not valid
-
marshallAsAttribute
public void marshallAsAttribute(org.jboss.dmr.ModelNode resourceModel, XMLStreamWriter writer) throws XMLStreamException
Marshalls the value from the givenresourceModel
as an xml attribute, if itis marshallable
.Invoking this method is the same as calling
marshallAsAttribute(resourceModel, true, writer)
- Parameters:
resourceModel
- the model, a non-null node ofModelType.OBJECT
.writer
- stream writer to use for writing the attribute- Throws:
XMLStreamException
- ifwriter
throws an exception
-
marshallAsAttribute
public void marshallAsAttribute(org.jboss.dmr.ModelNode resourceModel, boolean marshallDefault, XMLStreamWriter writer) throws XMLStreamException
Marshalls the value from the givenresourceModel
as an xml attribute, if itis marshallable
.- Parameters:
resourceModel
- the model, a non-null node ofModelType.OBJECT
.marshallDefault
-true
if the value should be marshalled even if it matches the default valuewriter
- stream writer to use for writing the attribute- Throws:
XMLStreamException
- ifwriter
throws an exception
-
marshallAsElement
public void marshallAsElement(org.jboss.dmr.ModelNode resourceModel, boolean marshallDefault, XMLStreamWriter writer) throws XMLStreamException
Marshalls the value from the givenresourceModel
as an xml element, if itis marshallable
. This implementation marshalls the attribute value as text content of the element.- Overrides:
marshallAsElement
in classAttributeDefinition
- Parameters:
marshallDefault
-resourceModel
- the model, a non-null node ofModelType.OBJECT
.writer
- stream writer to use for writing the attribute- Throws:
XMLStreamException
-
-