class XMLUtilities {

    public static boolean canUnmarshal(InputStream stream, StartElementInspector inspector)
    {
        boolean canUnmarshal = false;

        XMLInputFactory xmlInputFactory = XMLInputFactory.newInstance();
        try
        {
            XMLEventReader xmlEventReader = xmlInputFactory.createXMLEventReader(stream);

            XMLEvent event = null;

            while ((event = xmlEventReader.peek()) != null)
            {
                if (event.isStartElement())
                {
                    canUnmarshal = inspector.isValidStartElement((StartElement)event);

                    break;
                }

                xmlEventReader.next();
            }
        }
        catch (XMLStreamException e)
        {
            if (LOGGER.isDebugEnabled())
            {
                LOGGER.debug(e.getMessage(), e);
            }
        }
        finally
        {
            try
            {
                if (stream.markSupported())
                {
                    stream.reset();
                }
            }
            catch (IOException e)
            {
                LOGGER.error(e.getMessage(), e);
            }
        }

        return canUnmarshal;
    }

    private  XMLUtilities();

}