Beispiel #1
0
 public static ModelNode parseBoundedIntegerAttribute(
     final XMLExtendedStreamReader reader,
     final int index,
     final int minInclusive,
     final int maxInclusive,
     boolean allowExpression)
     throws XMLStreamException {
   final String stringValue = reader.getAttributeValue(index);
   if (allowExpression) {
     ModelNode expression = parsePossibleExpression(stringValue);
     if (expression.getType() == ModelType.EXPRESSION) {
       return expression;
     }
   }
   try {
     final int value = Integer.parseInt(stringValue);
     if (value < minInclusive || value > maxInclusive) {
       throw ControllerLogger.ROOT_LOGGER.invalidAttributeValue(
           value,
           reader.getAttributeName(index),
           minInclusive,
           maxInclusive,
           reader.getLocation());
     }
     return new ModelNode().set(value);
   } catch (NumberFormatException nfe) {
     throw ControllerLogger.ROOT_LOGGER.invalidAttributeValueInt(
         nfe, stringValue, reader.getAttributeName(index), reader.getLocation());
   }
 }
Beispiel #2
0
 /**
  * Get an exception reporting an invalid XML attribute value.
  *
  * @param reader the stream reader
  * @param index the attribute index
  * @return the exception
  */
 public static XMLStreamException invalidAttributeValue(
     final XMLExtendedStreamReader reader, final int index) {
   return ControllerLogger.ROOT_LOGGER.invalidAttributeValue(
       reader.getAttributeValue(index), reader.getAttributeName(index), reader.getLocation());
 }