Top Description Fields Constructors Methods
org.hibernate.validator.internal.xml

public Class XmlParserHelper

extends Object
Class Inheritance
Static Imports
org.hibernate.validator.internal.util.logging.Messages.MESSAGES

Provides common functionality used within the different XML descriptor parsers.
Author
Gunnar Morling

Field Summary

Modifier and TypeField and Description
private static final String
private static final Log
private static final int
NUMBER_OF_SCHEMAS

The expected number of XML schemas managed by this class.

private static final ConcurrentMap<String, Schema>
private static final QName
private final XMLInputFactory

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public synchronized XMLEventReader
createXmlEventReader(String resourceName, InputStream xmlStream)

private StartElement
public Schema

Returns:

the schema identified by the given resource name or null if the resource was not found or could not be loaded.
getSchema
(String
the resource name identifying the schema.
schemaResource
)

Returns the XML schema identified by the given resource name.

public String

Returns:

The value of the "version" attribute. For compatibility with BV 1.0, "1.0" will be returned if the given stream doesn't have a "version" attribute.
getSchemaVersion
(String
The name of the represented XML resource.
resourceName
,
XMLEventReader
An STAX event reader
xmlEventReader
)

Retrieves the schema version applying for the given XML input stream as represented by the "version" attribute of the root element of the stream.

private String
private Schema
loadSchema(String schemaResource)

private <T> T
run(PrivilegedAction<T> action)

Runs the given privileged action, using a privileged block if required.

private <T> T
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEFAULT_VERSIONback to summary
private static final String DEFAULT_VERSION
LOGback to summary
private static final Log LOG
NUMBER_OF_SCHEMASback to summary
private static final int NUMBER_OF_SCHEMAS

The expected number of XML schemas managed by this class. Used to set the initial cache size.

schemaCacheback to summary
private static final ConcurrentMap<String, Schema> schemaCache
VERSION_QNAMEback to summary
private static final QName VERSION_QNAME
xmlInputFactoryback to summary
private final XMLInputFactory xmlInputFactory

Constructor Detail

XmlParserHelperback to summary
public XmlParserHelper()

Method Detail

createXmlEventReaderback to summary
public synchronized XMLEventReader createXmlEventReader(String resourceName, InputStream xmlStream)
getRootElementback to summary
private StartElement getRootElement(XMLEventReader xmlEventReader) throws XMLStreamException
getSchemaback to summary
public Schema getSchema(String schemaResource)

Returns the XML schema identified by the given resource name.

Parameters
schemaResource:String

the resource name identifying the schema.

Returns:Schema

the schema identified by the given resource name or null if the resource was not found or could not be loaded.

getSchemaVersionback to summary
public String getSchemaVersion(String resourceName, XMLEventReader xmlEventReader)

Retrieves the schema version applying for the given XML input stream as represented by the "version" attribute of the root element of the stream.

The given reader will be advanced to the root element of the given XML structure. It can be used for unmarshalling from there.

Parameters
resourceName:String

The name of the represented XML resource.

xmlEventReader:XMLEventReader

An STAX event reader

Returns:String

The value of the "version" attribute. For compatibility with BV 1.0, "1.0" will be returned if the given stream doesn't have a "version" attribute.

getVersionValueback to summary
private String getVersionValue(StartElement startElement)
loadSchemaback to summary
private Schema loadSchema(String schemaResource)
runback to summary
private <T> T run(PrivilegedAction<T> action)

Runs the given privileged action, using a privileged block if required.

Note

This must never be changed into a publicly available method to avoid execution of arbitrary privileged actions within HV's protection domain.

Annotations
@IgnoreForbiddenApisErrors
reason:SecurityManager is deprecated in JDK17
runback to summary
private <T> T run(PrivilegedExceptionAction<T> action) throws Exception
Annotations
@IgnoreForbiddenApisErrors
reason:SecurityManager is deprecated in JDK17