throw duplicateNamedElement(reader, name);
}
// Elements
String levelName = null;
String encoding = null;
ModelNode fileSpec = null;
boolean append = true;
long rotateSize = 0L;
int maxBackupIndex = 1;
String formatterSpec = null;
final EnumSet<Element> requiredElem = EnumSet.of(Element.FILE);
final EnumSet<Element> encountered = EnumSet.noneOf(Element.class);
while (reader.nextTag() != END_ELEMENT) {
final Element element = Element.forName(reader.getLocalName());
if (!encountered.add(element)) {
throw unexpectedElement(reader);
}
requiredElem.remove(element);
switch (element) {
case LEVEL: {
levelName = readStringAttributeElement(reader, "name");
break;
}
case ENCODING: {
encoding = readStringAttributeElement(reader, "value");
break;
}
case FORMATTER: {
formatterSpec = parseFormatterElement(reader);
break;
}
case FILE: {
fileSpec = parseFileElement(reader);
break;
}
case APPEND: {
append = Boolean.parseBoolean(readStringAttributeElement(reader, "value"));
break;
}
case ROTATE_SIZE: {
rotateSize = parseSize(readStringAttributeElement(reader, "value"));
break;
}
case MAX_BACKUP_INDEX: {
try {
maxBackupIndex = Integer.parseInt(readStringAttributeElement(reader, "value"));
} catch (NumberFormatException e) {
throw new XMLStreamException(e.getMessage(), reader.getLocation(), e);
}
break;
}
default: {
throw unexpectedElement(reader);
}
}
}
if (!requiredElem.isEmpty()) {
throw missingRequired(reader, required);
}
final ModelNode node = new ModelNode();
node.get(OP).set(ADD);
node.get(OP_ADDR).set(address).add(SIZE_ROTATING_FILE_HANDLER, name);
node.get(AUTOFLUSH).set(autoflush);
node.get(LEVEL).set(levelName);
if(encoding != null) node.get(ENCODING).set(encoding);
if(formatterSpec != null) node.get(FORMATTER).set(formatterSpec);
node.get(FILE).set(fileSpec);
node.get(APPEND).set(append);
if (rotateSize > 0L) {
node.get(ROTATE_SIZE).set(rotateSize);
}
if (maxBackupIndex > 0) {
node.get(MAX_BACKUP_INDEX).set(maxBackupIndex);
}
list.add(node);
}