当前位置: 首页>>代码示例>>Java>>正文


Java WstxInputProperties类代码示例

本文整理汇总了Java中com.ctc.wstx.api.WstxInputProperties的典型用法代码示例。如果您正苦于以下问题:Java WstxInputProperties类的具体用法?Java WstxInputProperties怎么用?Java WstxInputProperties使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


WstxInputProperties类属于com.ctc.wstx.api包,在下文中一共展示了WstxInputProperties类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getProperty

import com.ctc.wstx.api.WstxInputProperties; //导入依赖的package包/类
@Override
public Object getProperty(String name)
{
    /* 18-Nov-2008, TSa: As per [WSTX-50], should report the
     *   actual Base URL. It can be overridden by matching
     *   setProperty, but if not, is set to actual source
     *   of content being parsed.
     */
    if (WstxInputProperties.P_BASE_URL.equals(name)) {
    	try {
    		return mInput.getSource();
    	} catch (IOException e) { // not optimal but...
    		throw new IllegalStateException(e);
    	}
    }
    /* 23-Apr-2008, TSa: Let's NOT throw IllegalArgumentException
     *   for unknown property; JavaDocs do not suggest it needs
     *   to be done (different from that of XMLInputFactory
     *   and XMLStreamWriter specification)
     */
    return mConfig.safeGetProperty(name);
}
 
开发者ID:FasterXML,项目名称:woodstox,代码行数:23,代码来源:BasicStreamReader.java

示例2: testLongElementText

import com.ctc.wstx.api.WstxInputProperties; //导入依赖的package包/类
public void testLongElementText() throws Exception {
    try {
        Reader reader = createLongReader("", "", false);
        XMLInputFactory factory = getNewInputFactory();
        factory.setProperty(WstxInputProperties.P_MAX_TEXT_LENGTH, Integer.valueOf(100000));
        XMLStreamReader xmlreader = factory.createXMLStreamReader(reader);
        while (xmlreader.next() != XMLStreamReader.START_ELEMENT) {
        }
        assertEquals(XMLStreamReader.CHARACTERS, xmlreader.next());
        while (xmlreader.next() != XMLStreamReader.START_ELEMENT) {
        }
        fail("Should have failed");
    } catch (XMLStreamException ex) {
        _verifyTextLimitException(ex);
    }
}
 
开发者ID:FasterXML,项目名称:woodstox,代码行数:17,代码来源:TestCharacterLimits.java

示例3: testLongWhitespace

import com.ctc.wstx.api.WstxInputProperties; //导入依赖的package包/类
public void testLongWhitespace() throws Exception {
    try {
        Reader reader = createLongReader("", "", true);
        XMLInputFactory factory = getNewInputFactory();
        factory.setProperty(WstxInputProperties.P_MAX_TEXT_LENGTH, Integer.valueOf(50000));
        XMLStreamReader xmlreader = factory.createXMLStreamReader(reader);
        while (xmlreader.next() != XMLStreamReader.START_ELEMENT) {
        }
        assertEquals(XMLStreamReader.CHARACTERS, xmlreader.next());
        while (xmlreader.next() != XMLStreamReader.START_ELEMENT) {
        }
        fail("Should have failed");
    } catch (XMLStreamException ex) {
        _verifyTextLimitException(ex);
    }
}
 
开发者ID:FasterXML,项目名称:woodstox,代码行数:17,代码来源:TestCharacterLimits.java

示例4: testLongCDATA

import com.ctc.wstx.api.WstxInputProperties; //导入依赖的package包/类
public void testLongCDATA() throws Exception {
    try {
        Reader reader = createLongReader("<![CDATA[", "]]>", true);
        XMLInputFactory factory = getNewInputFactory();
        factory.setProperty(WstxInputProperties.P_MAX_TEXT_LENGTH, Integer.valueOf(50000));
        XMLStreamReader xmlreader = factory.createXMLStreamReader(reader);
        while (xmlreader.next() != XMLStreamReader.START_ELEMENT) {
        }
        assertEquals(XMLStreamReader.CDATA, xmlreader.next());
        while (xmlreader.next() != XMLStreamReader.START_ELEMENT) {
        }
        fail("Should have failed");
    } catch (XMLStreamException ex) {
        _verifyTextLimitException(ex);
    }
}
 
开发者ID:FasterXML,项目名称:woodstox,代码行数:17,代码来源:TestCharacterLimits.java

示例5: testLongCDATANextTag

import com.ctc.wstx.api.WstxInputProperties; //导入依赖的package包/类
public void testLongCDATANextTag() throws Exception {
    Reader reader = createLongReader("<![CDATA[", "]]>", true);
    XMLInputFactory factory = getNewInputFactory();
    factory.setProperty(WstxInputProperties.P_MAX_TEXT_LENGTH, Integer.valueOf(1000));
    XMLStreamReader xmlreader = factory.createXMLStreamReader(reader);
    try {
        int tokens = 0;
        while (xmlreader.next() != XMLStreamReader.START_ELEMENT) {
            ++tokens;
        }
        int code = xmlreader.nextTag();
        fail("Should have failed: instead got "+tokens+" tokens; and one following START_ELEMENT: "+code);
    } catch (XMLStreamException ex) {
        _verifyTextLimitException(ex);
    }
}
 
开发者ID:FasterXML,项目名称:woodstox,代码行数:17,代码来源:TestCharacterLimits.java

示例6: testSingleDocumentMode

import com.ctc.wstx.api.WstxInputProperties; //导入依赖的package包/类
public void testSingleDocumentMode()
    throws XMLStreamException
{
    // First the valid case:
    streamThrough(getReader(XML_SINGLE_DOC,
                            WstxInputProperties.PARSING_MODE_DOCUMENT));

    // Others will fail though
    streamThroughFailing(getReader(XML_FRAGMENT,
                                   WstxInputProperties.PARSING_MODE_DOCUMENT),
                         "Expected an exception for fragment (non-single root) input, in single-document mode");
    streamThroughFailing(getReader(XML_FRAGMENT2,
                                   WstxInputProperties.PARSING_MODE_DOCUMENT),
                         "Expected an exception for fragment (root-level text) input, in single-document mode");
    streamThroughFailing(getReader(XML_MULTI_DOC,
                                   WstxInputProperties.PARSING_MODE_DOCUMENT),
                         "Expected an exception for multi-document input, in single-document mode");


    // As should the generally invalid ones:
    streamThroughFailing(getReader(XML_UNBALANCED,
                                   WstxInputProperties.PARSING_MODE_DOCUMENT),
                         "Expected an exception for unbalanced xml content");
}
 
开发者ID:FasterXML,项目名称:woodstox,代码行数:25,代码来源:TestParsingMode.java

示例7: testDefaultNamespacePrefixAsNull

import com.ctc.wstx.api.WstxInputProperties; //导入依赖的package包/类
public void testDefaultNamespacePrefixAsNull() throws Exception
{
    String XML = "<blah xmlns=\"http://blah.org\"><foo>foo</foo></blah>";
    System.setProperty("com.ctc.wstx.returnNullForDefaultNamespace", "true");
    XMLInputFactory factory = getInputFactory();
    XMLStreamReader r = factory.createXMLStreamReader(new StringReader(XML));
    while (r.hasNext()) {
        r.next();
        if ((r.getEventType() == XMLEvent.START_ELEMENT) && (r.getLocalName().equals("blah"))) {
            String prefix = r.getNamespacePrefix(0);
            if (prefix != null) {
                throw new Exception("Null value is not returned for the default namespace prefix while "
                        + WstxInputProperties.P_RETURN_NULL_FOR_DEFAULT_NAMESPACE + " is set true");
            }
            break;
        }
    }
}
 
开发者ID:FasterXML,项目名称:woodstox,代码行数:19,代码来源:TestDefaultNamespacePrefix.java

示例8: testDefaultNamespacePrefixAsEmptyString

import com.ctc.wstx.api.WstxInputProperties; //导入依赖的package包/类
public void testDefaultNamespacePrefixAsEmptyString() throws Exception
{
    String XML = "<blah xmlns=\"http://blah.org\"><foo>foo</foo></blah>";
    System.setProperty("com.ctc.wstx.returnNullForDefaultNamespace", "false");
    XMLInputFactory factory = getInputFactory();
    XMLStreamReader r = factory.createXMLStreamReader(new StringReader(XML));
    while (r.hasNext()) {
        r.next();
        if ((r.getEventType() == XMLEvent.START_ELEMENT) && (r.getLocalName().equals("blah"))) {
            String prefix = r.getNamespacePrefix(0);
            if (!"".equals(prefix)) {
                throw new Exception("Null value is not returned for the default namespace prefix while "
                        + WstxInputProperties.P_RETURN_NULL_FOR_DEFAULT_NAMESPACE + " is set true");
            }
            break;
        }
    }
}
 
开发者ID:FasterXML,项目名称:woodstox,代码行数:19,代码来源:TestDefaultNamespacePrefix.java

示例9: getOrCreateInputFactory

import com.ctc.wstx.api.WstxInputProperties; //导入依赖的package包/类
private static XMLInputFactory getOrCreateInputFactory() throws FactoryConfigurationError {
	if (ourInputFactory == null) {
		XMLInputFactory inputFactory = XMLInputFactory.newInstance();

		if (!ourHaveLoggedStaxImplementation) {
			logStaxImplementation(inputFactory.getClass());
		}

		/*
		 * In the following few lines, you can uncomment the first and comment the second to disable automatic
		 * parsing of extended entities, e.g. &sect;
		 * 
		 * Note that these properties are Woodstox specific and they cause a crash in environments where SJSXP is
		 * being used (e.g. glassfish) so we don't set them there.
		 */
		try {
			Class.forName("com.ctc.wstx.stax.WstxInputFactory");
			if (inputFactory instanceof com.ctc.wstx.stax.WstxInputFactory) {
				// inputFactory.setProperty(WstxInputFactory.IS_REPLACING_ENTITY_REFERENCES, false);
				inputFactory.setProperty(WstxInputProperties.P_UNDECLARED_ENTITY_RESOLVER, XML_RESOLVER);
			}
		} catch (ClassNotFoundException e) {
			ourLog.debug("WstxOutputFactory (Woodstox) not found on classpath");
		}
		ourInputFactory = inputFactory;
	}
	return ourInputFactory;
}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:29,代码来源:XmlUtil.java

示例10: XmlDumpParser

import com.ctc.wstx.api.WstxInputProperties; //导入依赖的package包/类
/**
 * Constructor used by Multistream parser
 * @param header   parsed header
 * @param xmlInput parallel input stream
 */
public XmlDumpParser(Header header, InputStream xmlInput) {
    try {
        this.header = header;

        XMLInputFactory2 factory = (XMLInputFactory2) XMLInputFactory2.newInstance();
        factory.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, Boolean.TRUE);
        factory.setProperty(WstxInputProperties.P_INPUT_PARSING_MODE, WstxInputProperties.PARSING_MODE_FRAGMENT);

        xmlReader = (XMLStreamReader2)factory.createXMLStreamReader(xmlInput);

    } catch (XMLStreamException e) {
        throw new IOError(e);
    }
}
 
开发者ID:marcusklang,项目名称:wikiforia,代码行数:20,代码来源:XmlDumpParser.java

示例11: XMLInputFactoryImpl

import com.ctc.wstx.api.WstxInputProperties; //导入依赖的package包/类
public XMLInputFactoryImpl()
{
    super();
    // Aalto & Woodstox
    delegate.setProperty( XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, false );
    // Woodstox
    delegate.setProperty( WstxInputProperties.P_MAX_ATTRIBUTES_PER_ELEMENT, DEFAULT_MAX_ATTRIBUTES_PER_ELEMENT );
    delegate.setProperty( WstxInputProperties.P_MAX_ATTRIBUTE_SIZE, DEFAULT_MAX_ATTRIBUTE_LENGTH );
    delegate.setProperty( WstxInputProperties.P_MAX_ELEMENT_DEPTH, DEFAULT_MAX_ELEMENT_DEPTH );
    delegate.setProperty( WstxInputProperties.P_MAX_ENTITY_COUNT, DEFAULT_MAX_ENTITY_COUNT );
    delegate.setProperty( WstxInputProperties.P_MAX_ENTITY_DEPTH, DEFAULT_MAX_ENTITY_DEPTH );
    // delegate.setProperty( WstxInputProperties.P_MAX_CHARACTERS, 42 );
    // delegate.setProperty( WstxInputProperties.P_MAX_CHILDREN_PER_ELEMENT, 42 );
    // delegate.setProperty( WstxInputProperties.P_MAX_ELEMENT_COUNT, 42 );
    // delegate.setProperty( WstxInputProperties.P_MAX_TEXT_LENGTH, 42 );
    // None
    try
    {
        delegate.setProperty(
            XMLConstants.ACCESS_EXTERNAL_DTD,
            Internal.EXTERNAL_ENTITIES.get() ? ACCESS_EXTERNAL_ALL : ACCESS_EXTERNAL_NONE
        );
    }
    catch( IllegalArgumentException ex )
    {
        LOG.trace( "JAXP<1.5 - {} on {}", ex.getMessage(), delegate );
    }
    delegate.setXMLResolver( Internal.RESOLVER.get() );
    delegate.setXMLReporter( Errors.INSTANCE );
}
 
开发者ID:werval,项目名称:werval,代码行数:31,代码来源:XMLInputFactoryImpl.java

示例12: getAttributeType

import com.ctc.wstx.api.WstxInputProperties; //导入依赖的package包/类
/**
 * @return Schema (DTD, RNG, W3C Schema) based type of the attribute
 *   in specified index
 */
@Override
public final String getAttributeType(int index)
{
    if (index == mIdAttrIndex && index >= 0) { // second check to ensure -1 is not passed
        return "ID";
    }
    return (mValidator == null) ? WstxInputProperties.UNKNOWN_ATTR_TYPE : 
        mValidator.getAttributeType(index);
}
 
开发者ID:FasterXML,项目名称:woodstox,代码行数:14,代码来源:InputElementStack.java

示例13: setProperty

import com.ctc.wstx.api.WstxInputProperties; //导入依赖的package包/类
/**
 * @param name Name of the property to set
 * @param value Value to set property to.
 *
 * @return True, if the specified property was <b>succesfully</b>
 *    set to specified value; false if its value was not changed
 */
@Override
public boolean setProperty(String name, Object value)
{
    boolean ok = mConfig.setProperty(name, value);
    /* To make [WSTX-50] work fully dynamically (i.e. allow
     * setting BASE_URL after stream reader has been constructed)
     * need to force
     */
    if (ok && WstxInputProperties.P_BASE_URL.equals(name)) {
        // Easiest to just access from config: may come in as a String etc
        mInput.overrideSource(mConfig.getBaseURL());
    }
    return ok;
}
 
开发者ID:FasterXML,项目名称:woodstox,代码行数:22,代码来源:BasicStreamReader.java

示例14: getAttributeType

import com.ctc.wstx.api.WstxInputProperties; //导入依赖的package包/类
@Override
public String getAttributeType(int index)
{
    DTDAttribute attr = mAttrSpecs[index];
    return (attr == null) ? WstxInputProperties.UNKNOWN_ATTR_TYPE : 
        attr.getValueTypeString();
}
 
开发者ID:FasterXML,项目名称:woodstox,代码行数:8,代码来源:DTDValidatorBase.java

示例15: testMaxAttributesLimit

import com.ctc.wstx.api.WstxInputProperties; //导入依赖的package包/类
public void testMaxAttributesLimit() throws Exception
{
    final int max = 100;
    XMLInputFactory factory = getNewInputFactory();
    factory.setProperty(WstxInputProperties.P_MAX_ATTRIBUTES_PER_ELEMENT, Integer.valueOf(50));
    Reader reader = new Reader() {
        StringReader sreader = new StringReader("<ns:element xmlns:ns=\"http://foo.com\"");
        int count;
        boolean done;
        @Override
        public int read(char[] cbuf, int off, int len) throws IOException {
            int i = sreader.read(cbuf, off, len);
            if (i == -1) {
                if (count < max) {
                    sreader = new StringReader(" attribute" + count++ + "=\"foo\"");
                } else if (!done) {
                    sreader = new StringReader("/>");
                    done = true;
                }
                i = sreader.read(cbuf, off, len);
            }
            return i;
        }
        @Override
        public void close() throws IOException { }
    };
    XMLStreamReader xmlreader = factory.createXMLStreamReader(reader);
    try {
        xmlreader.nextTag();
        fail("Should have failed");
    } catch (XMLStreamException ex) {
        verifyException(ex, "Attribute limit (50)");
    }
}
 
开发者ID:FasterXML,项目名称:woodstox,代码行数:35,代码来源:TestAttributeLimits.java


注:本文中的com.ctc.wstx.api.WstxInputProperties类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。