private static XMLStreamException wrapMissingRequiredAttribute(final XMLStreamException ex, final XMLStreamReader reader, final Set<String> required) { return new XMLStreamValidationException(ex.getMessage(), ValidationError.from(ex, ErrorType.REQUIRED_ATTRIBUTE_MISSING) .element(reader.getName()) .alternatives(required), ex); }
private static XMLStreamException wrapMissingRequiredAttribute(final XMLStreamException ex, final XMLStreamReader reader, final Set<String> required) { return new XMLStreamValidationException(ex.getMessage(), ValidationError.from(ex, ErrorType.REQUIRED_ATTRIBUTE_MISSING) .element(reader.getName()) .alternatives(required), ex); }
/** * Get an exception reporting a missing, required XML child element. * @param reader the stream reader * @param required a set of enums whose toString method returns the * attribute name * @return the exception */ public static XMLStreamException missingOneOf(final XMLExtendedStreamReader reader, final Set<?> required) { final StringBuilder b = new StringBuilder(); Iterator<?> iterator = required.iterator(); while (iterator.hasNext()) { final Object o = iterator.next(); b.append(o.toString()); if (iterator.hasNext()) { b.append(", "); } } final XMLStreamException ex = ControllerLogger.ROOT_LOGGER.missingOneOf(b, reader.getLocation()); Set<String> set = new HashSet<>(); for (Object o : required) { String toString = o.toString(); set.add(toString); } return new XMLStreamValidationException(ex.getMessage(), ValidationError.from(ex, ErrorType.REQUIRED_ELEMENT_MISSING) .element(reader.getName()) .alternatives(set), ex); }
/** * Get an exception reporting a missing, required XML child element. * @param reader the stream reader * @param required a set of enums whose toString method returns the * attribute name * @return the exception */ public static XMLStreamException missingOneOf(final XMLExtendedStreamReader reader, final Set<?> required) { final StringBuilder b = new StringBuilder(); Iterator<?> iterator = required.iterator(); while (iterator.hasNext()) { final Object o = iterator.next(); b.append(o.toString()); if (iterator.hasNext()) { b.append(", "); } } final XMLStreamException ex = ControllerLogger.ROOT_LOGGER.missingOneOf(b, reader.getLocation()); Set<String> set = new HashSet<>(); for (Object o : required) { String toString = o.toString(); set.add(toString); } return new XMLStreamValidationException(ex.getMessage(), ValidationError.from(ex, ErrorType.REQUIRED_ELEMENT_MISSING) .element(reader.getName()) .alternatives(set), ex); }
/** * Get an exception reporting that an attribute of a given name has already * been declared in this scope. * @param reader the stream reader * @param name the name that was redeclared * @return the exception */ public static XMLStreamException duplicateAttribute(final XMLExtendedStreamReader reader, final String name) { final XMLStreamException ex = ControllerLogger.ROOT_LOGGER.duplicateAttribute(name, reader.getLocation()); return new XMLStreamValidationException(ex.getMessage(), ValidationError.from(ex, ErrorType.DUPLICATE_ATTRIBUTE) .element(reader.getName()) .attribute(new QName(name)), ex); }
/** * Get an exception reporting that an attribute of a given name has already * been declared in this scope. * @param reader the stream reader * @param name the name that was redeclared * @return the exception */ public static XMLStreamException duplicateAttribute(final XMLExtendedStreamReader reader, final String name) { final XMLStreamException ex = ControllerLogger.ROOT_LOGGER.duplicateAttribute(name, reader.getLocation()); return new XMLStreamValidationException(ex.getMessage(), ValidationError.from(ex, ErrorType.DUPLICATE_ATTRIBUTE) .element(reader.getName()) .attribute(new QName(name)), ex); }
/** * Get an exception reporting an unexpected XML element. * @param reader the stream reader * @return the exception */ public static XMLStreamException unexpectedElement(final XMLExtendedStreamReader reader) { final XMLStreamException ex = ControllerLogger.ROOT_LOGGER.unexpectedElement(reader.getName(), reader.getLocation()); return new XMLStreamValidationException(ex.getMessage(), ValidationError.from(ex, ErrorType.UNEXPECTED_ELEMENT) .element(reader.getName()), ex); }
/** * Get an exception reporting an unexpected XML element. * @param reader the stream reader * @return the exception */ public static XMLStreamException unexpectedElement(final XMLExtendedStreamReader reader) { final XMLStreamException ex = ControllerLogger.ROOT_LOGGER.unexpectedElement(reader.getName(), reader.getLocation()); return new XMLStreamValidationException(ex.getMessage(), ValidationError.from(ex, ErrorType.UNEXPECTED_ELEMENT) .element(reader.getName()), ex); }
/** * Get an exception reporting that an element of a given type and name has * already been declared in this scope. * @param reader the stream reader * @param name the name that was redeclared * @return the exception */ public static XMLStreamException duplicateNamedElement(final XMLExtendedStreamReader reader, final String name) { final XMLStreamException ex = ControllerLogger.ROOT_LOGGER.duplicateNamedElement(name, reader.getLocation()); return new XMLStreamValidationException(ex.getMessage(), ValidationError.from(ex, ErrorType.DUPLICATE_ELEMENT) .element(reader.getName()) .attribute(QName.valueOf("name")) .attributeValue(name), ex); }
/** * Get an exception reporting that an element of a given type and name has * already been declared in this scope. * @param reader the stream reader * @param name the name that was redeclared * @return the exception */ public static XMLStreamException duplicateNamedElement(final XMLExtendedStreamReader reader, final String name) { final XMLStreamException ex = ControllerLogger.ROOT_LOGGER.duplicateNamedElement(name, reader.getLocation()); return new XMLStreamValidationException(ex.getMessage(), ValidationError.from(ex, ErrorType.DUPLICATE_ELEMENT) .element(reader.getName()) .attribute(QName.valueOf("name")) .attributeValue(name), ex); }
/** * Get an exception reporting an unexpected XML element. * @param reader the stream reader * @return the exception */ public static XMLStreamException unexpectedElement(final XMLExtendedStreamReader reader, Set<String> possible) { final XMLStreamException ex = ControllerLogger.ROOT_LOGGER.unexpectedElement(reader.getName(), asStringList(possible), reader.getLocation()); return new XMLStreamValidationException(ex.getMessage(), ValidationError.from(ex, ErrorType.UNEXPECTED_ELEMENT) .element(reader.getName()) .alternatives(possible), ex); }
/** * Get an exception reporting an unexpected XML attribute. * @param reader the stream reader * @param index the attribute index * @return the exception */ public static XMLStreamException unexpectedAttribute(final XMLExtendedStreamReader reader, final int index) { final XMLStreamException ex = ControllerLogger.ROOT_LOGGER.unexpectedAttribute(reader.getAttributeName(index), reader.getLocation()); return new XMLStreamValidationException(ex.getMessage(), ValidationError.from(ex, ErrorType.UNEXPECTED_ATTRIBUTE) .element(reader.getName()) .attribute(reader.getAttributeName(index)), ex); }
/** * Get an exception reporting a missing, required XML attribute. * @param reader the stream reader * @param supportedElement the element that is to be used in place of the unsupported one. * @return the exception */ public static XMLStreamException unsupportedElement(final XMLExtendedStreamReader reader, String supportedElement) { XMLStreamException ex = ControllerLogger.ROOT_LOGGER.unsupportedElement( new QName(reader.getNamespaceURI(), reader.getLocalName(),reader.getPrefix()), reader.getLocation(), supportedElement); return new XMLStreamValidationException(ex.getMessage(), ValidationError.from(ex, ErrorType.UNSUPPORTED_ELEMENT) .element(reader.getName()) .alternatives(new HashSet<String>() {{add(supportedElement);}}), ex); } }
/** * Get an exception reporting an unexpected XML element. * @param reader the stream reader * @return the exception */ public static XMLStreamException unexpectedElement(final XMLExtendedStreamReader reader, Set<String> possible) { final XMLStreamException ex = ControllerLogger.ROOT_LOGGER.unexpectedElement(reader.getName(), asStringList(possible), reader.getLocation()); return new XMLStreamValidationException(ex.getMessage(), ValidationError.from(ex, ErrorType.UNEXPECTED_ELEMENT) .element(reader.getName()) .alternatives(possible), ex); }
/** * Get an exception reporting an unexpected XML attribute. * @param reader the stream reader * @param index the attribute index * @return the exception */ public static XMLStreamException unexpectedAttribute(final XMLExtendedStreamReader reader, final int index) { final XMLStreamException ex = ControllerLogger.ROOT_LOGGER.unexpectedAttribute(reader.getAttributeName(index), reader.getLocation()); return new XMLStreamValidationException(ex.getMessage(), ValidationError.from(ex, ErrorType.UNEXPECTED_ATTRIBUTE) .element(reader.getName()) .attribute(reader.getAttributeName(index)), ex); }
/** * Get an exception reporting a missing, required XML attribute. * @param reader the stream reader * @param supportedElement the element that is to be used in place of the unsupported one. * @return the exception */ public static XMLStreamException unsupportedElement(final XMLExtendedStreamReader reader, String supportedElement) { XMLStreamException ex = ControllerLogger.ROOT_LOGGER.unsupportedElement( new QName(reader.getNamespaceURI(), reader.getLocalName(),reader.getPrefix()), reader.getLocation(), supportedElement); return new XMLStreamValidationException(ex.getMessage(), ValidationError.from(ex, ErrorType.UNSUPPORTED_ELEMENT) .element(reader.getName()) .alternatives(new HashSet<String>() {{add(supportedElement);}}), ex); } }
/** * Get an exception reporting an unexpected XML attribute. * @param reader the stream reader * @param index the attribute index * @param possibleAttributes attributes that are expected on this element * @return the exception */ public static XMLStreamException unexpectedAttribute(final XMLExtendedStreamReader reader, final int index, Set<String> possibleAttributes) { final XMLStreamException ex = ControllerLogger.ROOT_LOGGER.unexpectedAttribute(reader.getAttributeName(index), asStringList(possibleAttributes), reader.getLocation()); return new XMLStreamValidationException(ex.getMessage(), ValidationError.from(ex, ErrorType.UNEXPECTED_ATTRIBUTE) .element(reader.getName()) .attribute(reader.getAttributeName(index)) .alternatives(possibleAttributes), ex); }
/** * 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) { final XMLStreamException ex = ControllerLogger.ROOT_LOGGER.invalidAttributeValue(reader.getAttributeValue(index), reader.getAttributeName(index), reader.getLocation()); return new XMLStreamValidationException(ex.getMessage(), ValidationError.from(ex, ErrorType.INVALID_ATTRIBUTE_VALUE) .element(reader.getName()) .attribute(reader.getAttributeName(index)) .attributeValue(reader.getAttributeValue(index)), ex); }
/** * Get an exception reporting an unexpected XML attribute. * @param reader the stream reader * @param index the attribute index * @param possibleAttributes attributes that are expected on this element * @return the exception */ public static XMLStreamException unexpectedAttribute(final XMLExtendedStreamReader reader, final int index, Set<String> possibleAttributes) { final XMLStreamException ex = ControllerLogger.ROOT_LOGGER.unexpectedAttribute(reader.getAttributeName(index), asStringList(possibleAttributes), reader.getLocation()); return new XMLStreamValidationException(ex.getMessage(), ValidationError.from(ex, ErrorType.UNEXPECTED_ATTRIBUTE) .element(reader.getName()) .attribute(reader.getAttributeName(index)) .alternatives(possibleAttributes), ex); }
/** * 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) { final XMLStreamException ex = ControllerLogger.ROOT_LOGGER.invalidAttributeValue(reader.getAttributeValue(index), reader.getAttributeName(index), reader.getLocation()); return new XMLStreamValidationException(ex.getMessage(), ValidationError.from(ex, ErrorType.INVALID_ATTRIBUTE_VALUE) .element(reader.getName()) .attribute(reader.getAttributeName(index)) .attributeValue(reader.getAttributeValue(index)), ex); }