Java Code Examples for javax.xml.stream.XMLStreamReader#getProperty()

The following examples show how to use javax.xml.stream.XMLStreamReader#getProperty() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StAXEventReader.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public StAXEventReader(XMLStreamReader reader) throws  XMLStreamException {
    _streamReader = reader ;
    _eventAllocator = (XMLEventAllocator)reader.getProperty(XMLInputFactory.ALLOCATOR);
    if(_eventAllocator == null){
        _eventAllocator = new StAXEventAllocatorBase();
    }
    //initialize
    if (_streamReader.hasNext())
    {
        _streamReader.next();
        _currentEvent =_eventAllocator.allocate(_streamReader);
        events[0] = _currentEvent;
        hasEvent = true;
    } else {
        throw new XMLStreamException(CommonResourceBundle.getInstance().getString("message.noElement"));
    }
}
 
Example 2
Source File: StAXEventReader.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public StAXEventReader(XMLStreamReader reader) throws  XMLStreamException {
    _streamReader = reader ;
    _eventAllocator = (XMLEventAllocator)reader.getProperty(XMLInputFactory.ALLOCATOR);
    if(_eventAllocator == null){
        _eventAllocator = new StAXEventAllocatorBase();
    }
    //initialize
    if (_streamReader.hasNext())
    {
        _streamReader.next();
        _currentEvent =_eventAllocator.allocate(_streamReader);
        events[0] = _currentEvent;
        hasEvent = true;
    } else {
        throw new XMLStreamException(CommonResourceBundle.getInstance().getString("message.noElement"));
    }
}
 
Example 3
Source File: StAXEventReader.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public StAXEventReader(XMLStreamReader reader) throws  XMLStreamException {
    _streamReader = reader ;
    _eventAllocator = (XMLEventAllocator)reader.getProperty(XMLInputFactory.ALLOCATOR);
    if(_eventAllocator == null){
        _eventAllocator = new StAXEventAllocatorBase();
    }
    //initialize
    if (_streamReader.hasNext())
    {
        _streamReader.next();
        _currentEvent =_eventAllocator.allocate(_streamReader);
        events[0] = _currentEvent;
        hasEvent = true;
    } else {
        throw new XMLStreamException(CommonResourceBundle.getInstance().getString("message.noElement"));
    }
}
 
Example 4
Source File: StAXEventReader.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public StAXEventReader(XMLStreamReader reader) throws  XMLStreamException {
    _streamReader = reader ;
    _eventAllocator = (XMLEventAllocator)reader.getProperty(XMLInputFactory.ALLOCATOR);
    if(_eventAllocator == null){
        _eventAllocator = new StAXEventAllocatorBase();
    }
    //initialize
    if (_streamReader.hasNext())
    {
        _streamReader.next();
        _currentEvent =_eventAllocator.allocate(_streamReader);
        events[0] = _currentEvent;
        hasEvent = true;
    } else {
        throw new XMLStreamException(CommonResourceBundle.getInstance().getString("message.noElement"));
    }
}
 
Example 5
Source File: StAXEventReader.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public StAXEventReader(XMLStreamReader reader) throws  XMLStreamException {
    _streamReader = reader ;
    _eventAllocator = (XMLEventAllocator)reader.getProperty(XMLInputFactory.ALLOCATOR);
    if(_eventAllocator == null){
        _eventAllocator = new StAXEventAllocatorBase();
    }
    //initialize
    if (_streamReader.hasNext())
    {
        _streamReader.next();
        _currentEvent =_eventAllocator.allocate(_streamReader);
        events[0] = _currentEvent;
        hasEvent = true;
    } else {
        throw new XMLStreamException(CommonResourceBundle.getInstance().getString("message.noElement"));
    }
}
 
Example 6
Source File: StAXEventReader.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public StAXEventReader(XMLStreamReader reader) throws  XMLStreamException {
    _streamReader = reader ;
    _eventAllocator = (XMLEventAllocator)reader.getProperty(XMLInputFactory.ALLOCATOR);
    if(_eventAllocator == null){
        _eventAllocator = new StAXEventAllocatorBase();
    }
    //initialize
    if (_streamReader.hasNext())
    {
        _streamReader.next();
        _currentEvent =_eventAllocator.allocate(_streamReader);
        events[0] = _currentEvent;
        hasEvent = true;
    } else {
        throw new XMLStreamException(CommonResourceBundle.getInstance().getString("message.noElement"));
    }
}
 
Example 7
Source File: StAXStreamConnector.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private static boolean checkImplementaionNameOfSjsxp(XMLStreamReader reader) {
    try {
        Object name = reader.getProperty("http://java.sun.com/xml/stream/properties/implementation-name");
        return name!=null && name.equals("sjsxp");
    } catch (Exception e) {
        // be defensive against broken StAX parsers since javadoc is not clear
        // about when an error happens
        return false;
    }
}
 
Example 8
Source File: StAXStreamConnector.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private static boolean checkImplementaionNameOfSjsxp(XMLStreamReader reader) {
    try {
        Object name = reader.getProperty("http://java.sun.com/xml/stream/properties/implementation-name");
        return name!=null && name.equals("sjsxp");
    } catch (Exception e) {
        // be defensive against broken StAX parsers since javadoc is not clear
        // about when an error happens
        return false;
    }
}
 
Example 9
Source File: StAXStreamConnector.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private static boolean getBoolProp(XMLStreamReader r, String n) {
    try {
        Object o = r.getProperty(n);
        if(o instanceof Boolean)    return (Boolean)o;
        return false;
    } catch (Exception e) {
        // be defensive against broken StAX parsers since javadoc is not clear
        // about when an error happens
        return false;
    }
}
 
Example 10
Source File: StAXStreamConnector.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private static boolean checkImplementaionNameOfSjsxp(XMLStreamReader reader) {
    try {
        Object name = reader.getProperty("http://java.sun.com/xml/stream/properties/implementation-name");
        return name!=null && name.equals("sjsxp");
    } catch (Exception e) {
        // be defensive against broken StAX parsers since javadoc is not clear
        // about when an error happens
        return false;
    }
}
 
Example 11
Source File: StAXStreamConnector.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private static boolean getBoolProp(XMLStreamReader r, String n) {
    try {
        Object o = r.getProperty(n);
        if(o instanceof Boolean)    return (Boolean)o;
        return false;
    } catch (Exception e) {
        // be defensive against broken StAX parsers since javadoc is not clear
        // about when an error happens
        return false;
    }
}
 
Example 12
Source File: StAXStreamConnector.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static boolean getBoolProp(XMLStreamReader r, String n) {
    try {
        Object o = r.getProperty(n);
        if(o instanceof Boolean)    return (Boolean)o;
        return false;
    } catch (Exception e) {
        // be defensive against broken StAX parsers since javadoc is not clear
        // about when an error happens
        return false;
    }
}
 
Example 13
Source File: StAXStreamConnector.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static boolean checkImplementaionNameOfSjsxp(XMLStreamReader reader) {
    try {
        Object name = reader.getProperty("http://java.sun.com/xml/stream/properties/implementation-name");
        return name!=null && name.equals("sjsxp");
    } catch (Exception e) {
        // be defensive against broken StAX parsers since javadoc is not clear
        // about when an error happens
        return false;
    }
}
 
Example 14
Source File: StAXStreamConnector.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private static boolean getBoolProp(XMLStreamReader r, String n) {
    try {
        Object o = r.getProperty(n);
        if(o instanceof Boolean)    return (Boolean)o;
        return false;
    } catch (Exception e) {
        // be defensive against broken StAX parsers since javadoc is not clear
        // about when an error happens
        return false;
    }
}
 
Example 15
Source File: StAXStreamConnector.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static boolean getBoolProp(XMLStreamReader r, String n) {
    try {
        Object o = r.getProperty(n);
        if(o instanceof Boolean)    return (Boolean)o;
        return false;
    } catch (Exception e) {
        // be defensive against broken StAX parsers since javadoc is not clear
        // about when an error happens
        return false;
    }
}
 
Example 16
Source File: StAXStreamConnector.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static boolean checkImplementaionNameOfSjsxp(XMLStreamReader reader) {
    try {
        Object name = reader.getProperty("http://java.sun.com/xml/stream/properties/implementation-name");
        return name!=null && name.equals("sjsxp");
    } catch (Exception e) {
        // be defensive against broken StAX parsers since javadoc is not clear
        // about when an error happens
        return false;
    }
}
 
Example 17
Source File: StAXStreamConnector.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private static boolean getBoolProp(XMLStreamReader r, String n) {
    try {
        Object o = r.getProperty(n);
        if(o instanceof Boolean)    return (Boolean)o;
        return false;
    } catch (Exception e) {
        // be defensive against broken StAX parsers since javadoc is not clear
        // about when an error happens
        return false;
    }
}
 
Example 18
Source File: Stax2DomBuilder.java    From red5-io with Apache License 2.0 5 votes vote down vote up
protected void checkReaderSettings(XMLStreamReader r) throws XMLStreamException {
    Object o = r.getProperty(XMLInputFactory.IS_NAMESPACE_AWARE);
    /*
     * StAX defaults to namespace aware, so let's use similar logics (although all compliant implementations really should return a valid value)
     */
    if ((o instanceof Boolean) && !((Boolean) o).booleanValue()) {
        mNsAware = false;
    } else {
        mNsAware = true;
    }
}
 
Example 19
Source File: StAXStreamConnector.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static boolean getBoolProp(XMLStreamReader r, String n) {
    try {
        Object o = r.getProperty(n);
        if(o instanceof Boolean)    return (Boolean)o;
        return false;
    } catch (Exception e) {
        // be defensive against broken StAX parsers since javadoc is not clear
        // about when an error happens
        return false;
    }
}
 
Example 20
Source File: StAXStreamConnector.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static boolean checkImplementaionNameOfSjsxp(XMLStreamReader reader) {
    try {
        Object name = reader.getProperty("http://java.sun.com/xml/stream/properties/implementation-name");
        return name!=null && name.equals("sjsxp");
    } catch (Exception e) {
        // be defensive against broken StAX parsers since javadoc is not clear
        // about when an error happens
        return false;
    }
}