Class SimpleAttributeDefinition

java.lang.Object
org.jboss.as.controller.AttributeDefinition
org.jboss.as.controller.SimpleAttributeDefinition
All Implemented Interfaces:
Feature
Direct Known Subclasses:
ObjectTypeAttributeDefinition

public class SimpleAttributeDefinition extends AttributeDefinition
Defining characteristics of an attribute in a Resource or a parameter or reply value type field in an OperationDefinition, with utility methods for conversion to and from xml and for validation.
Author:
Brian Stansberry (c) 2011 Red Hat Inc.
  • Constructor Details

  • Method Details

    • parseAndSetParameter

      public void parseAndSetParameter(String value, org.jboss.dmr.ModelNode operation, XMLStreamReader reader) throws XMLStreamException
      Creates a ModelNode using the given value after first validating the node against this object's validator, and then stores it in the given operation model node as a key/value pair whose key is this attribute's name.

      If value is null an undefined 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 be trimmed before use if not null.
      operation - model node of type ModelType.OBJECT into which the parsed value should be stored
      reader - XMLStreamReader from which the location from which the attribute value was read can be obtained and used in any XMLStreamException, in case the given value is invalid.
      Throws:
      XMLStreamException - if value is not valid
    • marshallAsAttribute

      public void marshallAsAttribute(org.jboss.dmr.ModelNode resourceModel, XMLStreamWriter writer) throws XMLStreamException
      Marshalls the value from the given resourceModel as an xml attribute, if it is marshallable.

      Invoking this method is the same as calling marshallAsAttribute(resourceModel, true, writer)

      Parameters:
      resourceModel - the model, a non-null node of ModelType.OBJECT.
      writer - stream writer to use for writing the attribute
      Throws:
      XMLStreamException - if writer throws an exception
    • marshallAsAttribute

      public void marshallAsAttribute(org.jboss.dmr.ModelNode resourceModel, boolean marshallDefault, XMLStreamWriter writer) throws XMLStreamException
      Marshalls the value from the given resourceModel as an xml attribute, if it is marshallable.
      Parameters:
      resourceModel - the model, a non-null node of ModelType.OBJECT.
      marshallDefault - true if the value should be marshalled even if it matches the default value
      writer - stream writer to use for writing the attribute
      Throws:
      XMLStreamException - if writer throws an exception
    • marshallAsElement

      public void marshallAsElement(org.jboss.dmr.ModelNode resourceModel, boolean marshallDefault, XMLStreamWriter writer) throws XMLStreamException
      Marshalls the value from the given resourceModel as an xml element, if it is marshallable. This implementation marshalls the attribute value as text content of the element.
      Overrides:
      marshallAsElement in class AttributeDefinition
      Parameters:
      marshallDefault -
      resourceModel - the model, a non-null node of ModelType.OBJECT.
      writer - stream writer to use for writing the attribute
      Throws:
      XMLStreamException