/** * convert an xml element in String value * * @param reader the StAX reader * @param attributeName the name of the attribute * @return the string representing element * @throws XMLStreamException StAX exception */ protected String attributeAsString(XMLStreamReader reader, String attributeName) throws XMLStreamException { String attributeString = rawAttributeText(reader, attributeName); return getSubstitutionValue(attributeString); }
/** * convert an xml element in String value * * @param reader the StAX reader * @param attributeName the name of the attribute * @return the string representing element * @throws XMLStreamException StAX exception */ protected Integer attributeAsInt(XMLStreamReader reader, String attributeName) throws XMLStreamException { String attributeString = getSubstitutionValue(rawAttributeText(reader, attributeName)); return attributeString != null ? Integer.valueOf(getSubstitutionValue(attributeString)) : null; }
/** * convert an xml attribute in boolean value. Empty elements results with false * * @param reader the StAX reader * @param attributeName the name of the attribute * @param defaultValue defaultValue * @return the boolean representing element * @throws XMLStreamException StAX exception * @throws ParserException in case of not valid boolena for given attribute */ protected Boolean attributeAsBoolean(XMLStreamReader reader, String attributeName, Boolean defaultValue) throws XMLStreamException, ParserException { String attributeString = rawAttributeText(reader, attributeName); String stringValue = getSubstitutionValue(attributeString); if (stringValue == null || stringValue.length() == 0 || stringValue.trim().equalsIgnoreCase("true") || stringValue.trim().equalsIgnoreCase("false")) { return attributeString == null ? defaultValue : Boolean.valueOf(reader.getAttributeValue("", attributeName).trim()); } else { throw new ParserException(bundle.attributeAsBoolean(attributeString, reader.getLocalName())); } }