本文整理匯總了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
}
}
示例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);
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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
}
}
}
示例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$
}
}
}
示例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$
}
}
}
示例8: configure
import javax.xml.parsers.DocumentBuilder; //導入方法依賴的package包/類
@Override
protected void configure(DocumentBuilder documentBuilder)
{
documentBuilder.reset();
}