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


Java DocumentBuilder.reset方法代码示例

本文整理汇总了Java中javax.xml.parsers.DocumentBuilder.reset方法的典型用法代码示例。如果您正苦于以下问题:Java DocumentBuilder.reset方法的具体用法?Java DocumentBuilder.reset怎么用?Java DocumentBuilder.reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.xml.parsers.DocumentBuilder的用法示例。


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

示例1: returnDocumentBuilderToPool

import javax.xml.parsers.DocumentBuilder; //导入方法依赖的package包/类
private void returnDocumentBuilderToPool(DocumentBuilder db) {
    try {
        db.reset();
        documentBuilderPool.offerFirst(db);
    } catch (UnsupportedOperationException e) {
        // document builders that don't support reset() can't be pooled
    }
}
 
开发者ID:MikaGuraN,项目名称:HL4A,代码行数:9,代码来源:XmlProcessor.java

示例2: releaseBuilder

import javax.xml.parsers.DocumentBuilder; //导入方法依赖的package包/类
private static void releaseBuilder(DocumentBuilder builder)
{
	if( builder != null && builders.size() < MAX_BUILDERS )
	{
		builder.reset();
		builders.offer(builder);
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:9,代码来源:PropBagEx.java

示例3: returnBuilder

import javax.xml.parsers.DocumentBuilder; //导入方法依赖的package包/类
/** {@inheritDoc} */
public void returnBuilder(DocumentBuilder builder) {
    if (!(builder instanceof DocumentBuilderProxy)) {
        return;
    }

    DocumentBuilderProxy proxiedBuilder = (DocumentBuilderProxy) builder;
    if (proxiedBuilder.getOwningPool() != this) {
        return;
    }
    
    synchronized (this) {
        if (proxiedBuilder.isReturned()) {
            return;
        }
        
        if (proxiedBuilder.getPoolVersion() != poolVersion) {
            return;
        }
        
        DocumentBuilder unwrappedBuilder = proxiedBuilder.getProxiedBuilder();
        unwrappedBuilder.reset();
        SoftReference<DocumentBuilder> builderReference = new SoftReference<DocumentBuilder>(unwrappedBuilder);

        if (builderPool.size() < maxPoolSize) {
            proxiedBuilder.setReturned(true);
            builderPool.push(builderReference);
        }
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:31,代码来源:BasicParserPool.java

示例4: returnBuilder

import javax.xml.parsers.DocumentBuilder; //导入方法依赖的package包/类
/** {@inheritDoc} */
public void returnBuilder(DocumentBuilder builder) {
    if (!(builder instanceof DocumentBuilderProxy)) {
        return;
    }
    
    DocumentBuilderProxy proxiedBuilder = (DocumentBuilderProxy) builder;
    if (proxiedBuilder.getOwningPool() != this) {
        return;
    }
    
    synchronized (proxiedBuilder) {
        if (proxiedBuilder.isReturned()) {
            return;
        }
        // Not strictly true in that it may not actually be pushed back
        // into the cache, depending on builderPool.size() below.  But 
        // that's ok.  returnBuilder() shouldn't normally be called twice
        // on the same builder instance anyway, and it also doesn't matter
        // whether a builder is ever logically returned to the pool.
        proxiedBuilder.setReturned(true);
    }
    
    DocumentBuilder unwrappedBuilder = proxiedBuilder.getProxiedBuilder();
    unwrappedBuilder.reset();
    SoftReference<DocumentBuilder> builderReference = new SoftReference<DocumentBuilder>(unwrappedBuilder);
    
    synchronized(builderPool) {
        if (builderPool.size() < maxPoolSize) {
            builderPool.push(builderReference);
        }
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:34,代码来源:StaticBasicParserPool.java

示例5: returnDocumentBuilderToPool

import javax.xml.parsers.DocumentBuilder; //导入方法依赖的package包/类
private synchronized void returnDocumentBuilderToPool(DocumentBuilder db) {
    if (documentBuilder == null) {
        try {
            db.reset();
            documentBuilder = db;
        } catch (UnsupportedOperationException e) {
            // document builders that don't support reset() can't
            // be pooled
        }
    }
}
 
开发者ID:middle2tw,项目名称:whackpad,代码行数:12,代码来源:XmlProcessor.java

示例6: getComponentConfig

import javax.xml.parsers.DocumentBuilder; //导入方法依赖的package包/类
/** Reads the xml configuration files stored under the platform installation.
 * 	These files contain the configuration required to create the component on UI. 
 * @return see {@link Component}
 * @throws RuntimeException 
 * @throws IOException 
 * @throws SAXException 
 */
public List<Component> getComponentConfig() throws RuntimeException, SAXException, IOException {
	if(componentList != null && !componentList.isEmpty()){
		return componentList;
	}
	else{
		try{
			JAXBContext jaxbContext = JAXBContext.newInstance(Config.class);
			Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
			String[] configFileList = getFilteredFiles(XML_CONFIG_FILES_PATH, getFileNameFilter(Messages.XMLConfigUtil_FILE_EXTENTION));
			DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
			dbf.setNamespaceAware(true);
			dbf.setExpandEntityReferences(false);
			dbf.setFeature(Constants.DISALLOW_DOCTYPE_DECLARATION,true);
			DocumentBuilder builder = dbf.newDocumentBuilder();
			for (int i = 0; i < configFileList.length; i++){
				logger.trace("Creating palette component: ", configFileList[i]);
				if(validateXMLSchema(COMPONENT_CONFIG_XSD_PATH, XML_CONFIG_FILES_PATH + SEPARATOR + configFileList[i])){
					
					Document document = builder.parse(new File(XML_CONFIG_FILES_PATH + SEPARATOR + configFileList[i]));
					Config config = (Config) unmarshaller.unmarshal(document);
					componentList.addAll(config.getComponent());
					builder.reset();
				}
			}
			validateAndFillComponentConfigList(componentList);
			return componentList;
		}catch(JAXBException | SAXException | IOException | ParserConfigurationException exception){
			Status status = new Status(IStatus.ERROR,Activator.PLUGIN_ID, "XML read failed", exception);
			StatusManager.getManager().handle(status, StatusManager.BLOCK);
			logger.error(exception.getMessage());
			throw new RuntimeException("Faild in reading XML Config files", exception); //$NON-NLS-1$
		}
	}
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:42,代码来源:XMLConfigUtil.java

示例7: getPolicyConfig

import javax.xml.parsers.DocumentBuilder; //导入方法依赖的package包/类
/**
 * Gets the policy config.
 * 
 * @return the policy config
 * @throws RuntimeException
 *             the runtime exception
 * @throws SAXException
 *             the SAX exception
 * @throws IOException
 *             Signals that an I/O exception has occurred.
 */
public PolicyConfig getPolicyConfig() throws RuntimeException, SAXException, IOException {
	if(policyConfig !=null){
		return policyConfig;
	}
	else{
		try{
			JAXBContext jaxbContext = JAXBContext.newInstance(PolicyConfig.class);
			Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
			
			DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
			dbf.setNamespaceAware(true);
			dbf.setExpandEntityReferences(false);
			dbf.setFeature(Constants.DISALLOW_DOCTYPE_DECLARATION,true);
			DocumentBuilder builder = dbf.newDocumentBuilder();
			
			String[] configFileList = getFilteredFiles(CONFIG_FILES_PATH + SEPARATOR + Messages.XMLConfigUtil_POLICY, getFileNameFilter(Messages.XMLConfigUtil_FILE_EXTENTION));
			for (int i = 0; i < configFileList.length; i++) {
				if(validateXMLSchema(POLICY_CONFIG_XSD_PATH, CONFIG_FILES_PATH + SEPARATOR + Messages.XMLConfigUtil_POLICY + SEPARATOR + configFileList[i]))	{
					Document document = builder.parse(new File(CONFIG_FILES_PATH + SEPARATOR
							+ Messages.XMLConfigUtil_POLICY + SEPARATOR + configFileList[i]));
					policyConfig = (PolicyConfig) unmarshaller.unmarshal(document);
					builder.reset();
				}
			}
			return policyConfig;
		}catch(JAXBException | SAXException | IOException | ParserConfigurationException  exception){
			Status status = new Status(IStatus.ERROR,Activator.PLUGIN_ID, "XML read failed", exception);
			StatusManager.getManager().handle(status, StatusManager.BLOCK);
			logger.error(exception.getMessage());
			throw new RuntimeException("Faild in reading XML Config files", exception); //$NON-NLS-1$
		}
	}
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:45,代码来源:XMLConfigUtil.java

示例8: configure

import javax.xml.parsers.DocumentBuilder; //导入方法依赖的package包/类
@Override
protected void configure(DocumentBuilder documentBuilder)
{
	documentBuilder.reset();
}
 
开发者ID:fluentxml4j,项目名称:fluentxml4j,代码行数:6,代码来源:DocumentBuilderConfigurerAdapterTest.java


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