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


Java FactoryConfigurationError类代码示例

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


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

示例1: readFromXML

import javax.xml.parsers.FactoryConfigurationError; //导入依赖的package包/类
/**
 * Reads itself from XML format
 * New added - for Sandwich project (XML format instead of serialization) .
 * @param is input stream (which is parsed)
 * @return Table
 */
public void readFromXML(InputStream is, boolean validate)
throws SAXException {
    StringBuffer fileName = new StringBuffer();
    ElementHandler[] elmKeyService = { parseFirstLevel(), parseSecondLevel(fileName), parseThirdLevel(fileName) }; //
    String dtd = getClass().getClassLoader().getResource(DTD_PATH).toExternalForm();
    InnerParser parser = new InnerParser(PUBLIC_ID, dtd, elmKeyService);

    try {
        parser.parseXML(is, validate);
    } catch (Exception ioe) {
        throw (SAXException) ExternalUtil.copyAnnotation(
            new SAXException(NbBundle.getMessage(DefaultAttributes.class, "EXC_DefAttrReadErr")), ioe
        );
    } catch (FactoryConfigurationError fce) {
        // ??? see http://openide.netbeans.org/servlets/ReadMsg?msgId=340881&listName=dev
        throw (SAXException) ExternalUtil.copyAnnotation(
            new SAXException(NbBundle.getMessage(DefaultAttributes.class, "EXC_DefAttrReadErr")), fce
        );
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:DefaultAttributes.java

示例2: createXMLReader

import javax.xml.parsers.FactoryConfigurationError; //导入依赖的package包/类
/** Creates a SAX parser.
 *
 * <p>See {@link #parse} for hints on setting an entity resolver.
 *
 * @param validate if true, a validating parser is returned
 * @param namespaceAware if true, a namespace aware parser is returned
 *
 * @throws FactoryConfigurationError Application developers should never need to directly catch errors of this type.
 * @throws SAXException if a parser fulfilling given parameters can not be created
 *
 * @return XMLReader configured according to passed parameters
 */
public static synchronized XMLReader createXMLReader(boolean validate, boolean namespaceAware)
throws SAXException {
    SAXParserFactory factory = saxes[validate ? 0 : 1][namespaceAware ? 0 : 1];
    if (factory == null) {
        try {
            factory = SAXParserFactory.newInstance();
        } catch (FactoryConfigurationError err) {
            Exceptions.attachMessage(
                err, 
                "Info about thread context classloader: " + // NOI18N
                Thread.currentThread().getContextClassLoader()
            );
            throw err;
        }
        factory.setValidating(validate);
        factory.setNamespaceAware(namespaceAware);
        saxes[validate ? 0 : 1][namespaceAware ? 0 : 1] = factory;
    }

    try {
        return factory.newSAXParser().getXMLReader();
    } catch (ParserConfigurationException ex) {
        throw new SAXException("Cannot create parser satisfying configuration parameters", ex); //NOI18N                        
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:38,代码来源:XMLUtil.java

示例3: createDOM

import javax.xml.parsers.FactoryConfigurationError; //导入依赖的package包/类
/**
 * Creates a DOM (Document Object Model) <code>Document<code>.
 */
private void createDOM() {
	try {
		DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
		DocumentBuilder builder = factory.newDocumentBuilder();

		//data is a Document
		Document data = builder.newDocument();
		Element root = data.createElement("measure");
		root.setAttribute("name", name);
		root.setAttribute("meanValue", "null");
		root.setAttribute("upperBound", "null");
		root.setAttribute("lowerBound", "null");
		root.setAttribute("progress", Double.toString(getSamplesAnalyzedPercentage()));
		root.setAttribute("data", "null");
		root.setAttribute("finished", "false");
		root.setAttribute("discarded", "0");
		root.setAttribute("precision", Double.toString(analyzer.getPrecision()));
		root.setAttribute("maxSamples", Double.toString(getMaxSamples()));
		data.appendChild(root);
	} catch (FactoryConfigurationError factoryConfigurationError) {
		factoryConfigurationError.printStackTrace();
	} catch (ParserConfigurationException e) {
		e.printStackTrace();
	}
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:29,代码来源:Measure.java

示例4: parseXmlDocument

import javax.xml.parsers.FactoryConfigurationError; //导入依赖的package包/类
/**
 * Parses the given XML contents and returns a DOM {@link Document} for it.
 */
protected Document parseXmlDocument(String contents)
    throws FactoryConfigurationError, ParserConfigurationException,
        SAXException, IOException {
  DocumentBuilderFactory builderFactory =
      DocumentBuilderFactory.newInstance();
  builderFactory.setCoalescing(true);
  // TODO: Somehow do XML validation on Android
  // builderFactory.setValidating(true);
  builderFactory.setNamespaceAware(true);
  builderFactory.setIgnoringComments(true);
  builderFactory.setIgnoringElementContentWhitespace(true);
  DocumentBuilder documentBuilder = builderFactory.newDocumentBuilder();
  Document doc = documentBuilder.parse(
      new InputSource(new StringReader(contents)));
  return doc;
}
 
开发者ID:Plonk42,项目名称:mytracks,代码行数:20,代码来源:TrackWriterTest.java

示例5: DomDocumentBuilderFactory

import javax.xml.parsers.FactoryConfigurationError; //导入依赖的package包/类
public DomDocumentBuilderFactory()
{
  try
    {
      DOMImplementationRegistry reg =
        DOMImplementationRegistry.newInstance();
      impl = reg.getDOMImplementation("LS 3.0");
      if (impl == null)
        {
          throw new FactoryConfigurationError("no LS implementations found");
        }
      ls = (DOMImplementationLS) impl;
    }
  catch (Exception e)
    {
      throw new FactoryConfigurationError(e);
    }
}
 
开发者ID:vilie,项目名称:javify,代码行数:19,代码来源:DomDocumentBuilderFactory.java

示例6: parseElementMultipleNamespace

import javax.xml.parsers.FactoryConfigurationError; //导入依赖的package包/类
@Test
public void parseElementMultipleNamespace()
                throws ParserConfigurationException,
                FactoryConfigurationError, XmlPullParserException,
                IOException, TransformerException, SAXException {
    // @formatter:off
    final String stanza = XMLBuilder.create("outer", "outerNamespace").a("outerAttribute", "outerValue")
                    .element("inner", "innerNamespace").a("innverAttribute", "innerValue")
                        .element("innermost")
                            .t("some text")
                    .asString();
    // @formatter:on
    XmlPullParser parser = TestUtils.getParser(stanza, "outer");
    CharSequence result = PacketParserUtils.parseElement(parser, true);
    assertXMLEqual(stanza, result.toString());
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:17,代码来源:PacketParserUtilsTest.java

示例7: parseSASLFailureExtended

import javax.xml.parsers.FactoryConfigurationError; //导入依赖的package包/类
@Test
public void parseSASLFailureExtended() throws FactoryConfigurationError, TransformerException,
                ParserConfigurationException, XmlPullParserException, IOException, SAXException {
    // @formatter:off
    final String saslFailureString = XMLBuilder.create(SASLFailure.ELEMENT, SaslStreamElements.NAMESPACE)
                    .e(SASLError.account_disabled.toString())
                    .up()
                    .e("text").a("xml:lang", "en")
                        .t("Call 212-555-1212 for assistance.")
                    .up()
                    .e("text").a("xml:lang", "de")
                        .t("Bitte wenden sie sich an (04321) 123-4444")
                    .up()
                    .e("text")
                        .t("Wusel dusel")
                    .asString();
    // @formatter:on
    XmlPullParser parser = TestUtils.getParser(saslFailureString, SASLFailure.ELEMENT);
    SASLFailure saslFailure = PacketParserUtils.parseSASLFailure(parser);
    XmlUnitUtils.assertSimilar(saslFailureString, saslFailure.toXML());
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:22,代码来源:PacketParserUtilsTest.java

示例8: testConvertACIResponseToDOMInvalidDocumentBuilderFactory

import javax.xml.parsers.FactoryConfigurationError; //导入依赖的package包/类
@Test(expected = FactoryConfigurationError.class)
public void testConvertACIResponseToDOMInvalidDocumentBuilderFactory() throws AciErrorException, IOException, ProcessorException {
    // Set a duff property for the DocumentBuilderFactory...
    System.setProperty("javax.xml.parsers.DocumentBuilderFactory", "com.autonomy.DuffDocumentBuilderFactory");

    try {
        // Setup with a proper XML response file...
        final BasicHttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
        response.setEntity(new InputStreamEntity(getClass().getResourceAsStream("/GetVersion.xml"), -1));

        // Set the AciResponseInputStream...
        final AciResponseInputStream stream = new AciResponseInputStreamImpl(response);

        // Process...
        processor.process(stream);
        fail("Should have raised an ProcessorException.");
    } finally {
        // Remove the duff system property...
        System.clearProperty("javax.xml.parsers.DocumentBuilderFactory");
    }
}
 
开发者ID:hpe-idol,项目名称:java-aci-api-ng,代码行数:22,代码来源:DocumentProcessorTest.java

示例9: parse_xml

import javax.xml.parsers.FactoryConfigurationError; //导入依赖的package包/类
public static OMElement parse_xml(InputStream is) throws FactoryConfigurationError, XdsInternalException {

		//		create the parser
		XMLStreamReader parser=null;

		try {
			parser = XMLInputFactory.newInstance().createXMLStreamReader(is);
		} catch (XMLStreamException e) {
			throw new XdsInternalException("Could not create XMLStreamReader from InputStream");
		} 

		//		create the builder
		StAXOMBuilder builder = new StAXOMBuilder(parser);

		//		get the root element (in this case the envelope)
		OMElement documentElement =  builder.getDocumentElement();	
		if (documentElement == null)
			throw new XdsInternalException("No document element");
		return documentElement;
	}
 
开发者ID:jembi,项目名称:openxds,代码行数:21,代码来源:Util.java

示例10: doConfigure

import javax.xml.parsers.FactoryConfigurationError; //导入依赖的package包/类
/**
   Configure log4j by reading in a log4j.dtd compliant XML
   configuration file.

*/
public
void doConfigure(final InputStream inputStream, LoggerRepository repository) 
                                        throws FactoryConfigurationError {
    ParseAction action = new ParseAction() {
        public Document parse(final DocumentBuilder parser) throws SAXException, IOException {
            InputSource inputSource = new InputSource(inputStream);
            inputSource.setSystemId("dummy://log4j.dtd");
            return parser.parse(inputSource);
        }
        public String toString() { 
            return "input stream [" + inputStream.toString() + "]"; 
        }
    };
    doConfigure(action, repository);
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:21,代码来源:DOMConfigurator.java

示例11: doConfigure

import javax.xml.parsers.FactoryConfigurationError; //导入依赖的package包/类
/**
 * Configure log4j by reading in a log4j.dtd compliant XML configuration file.
 */
public void doConfigure(final InputStream inputStream, final LoggerRepository repository)
        throws FactoryConfigurationError {

   final ParseAction action = new ParseAction() {

      public Document parse(final DocumentBuilder parser) throws SAXException, IOException {

         final InputSource inputSource = new InputSource(inputStream);
         inputSource.setSystemId("dummy://log4j.dtd");
         return parser.parse(inputSource);
      }


      public String toString() {

         //noinspection ObjectToString
         return "input stream [" + inputStream + ']';
      }
   };
   doConfigure(action, repository);
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:25,代码来源:DOMConfigurator.java

示例12: extractPublications

import javax.xml.parsers.FactoryConfigurationError; //导入依赖的package包/类
@VisibleForTesting
List<Publication> extractPublications(InputStream inputStream, LocalDateTime lastImport, int total) throws FactoryConfigurationError {
    final List<Publication> publications = new ArrayList<>(total);
    final  SAXParserFactory parserFactory = SAXParserFactory.newInstance();
    parserFactory.setNamespaceAware(true);
    try {
        SAXParser parser = parserFactory.newSAXParser();
        parser.parse(inputStream, new ArxivSaxHandler(new PublicationCallbackHandler() {
            @Override
            public void onNewPublication(Publication publication) {
                publications.add(publication);
            }
        }, dao, lastImport));
    } catch (StopParsing ex) {
        logger.info("Stopped parsing because entries were before the last import date");
    } catch (SAXException | ParserConfigurationException | IOException e) {
        throw new IllegalStateException("Failed to parse input", e);
    }
    
    return publications;
}
 
开发者ID:Glamdring,项目名称:scientific-publishing,代码行数:22,代码来源:ArxivImporter.java

示例13: initializeRepository

import javax.xml.parsers.FactoryConfigurationError; //导入依赖的package包/类
private static void initializeRepository(final String configurationFile) throws FactoryConfigurationError {
    LOG.debug("Using URL [{}] for automatic settings4j configuration.", configurationFile);

    final URL url = ClasspathContentResolver.getResource(configurationFile);

    // If we have a non-null url, then delegate the rest of the
    // configuration to the DOMConfigurator.configure method.
    if (url != null) {
        LOG.info("The settings4j will be configured with the config: {}", url);
        try {
            DOMConfigurator.configure(url, getSettingsRepository());
        } catch (final NoClassDefFoundError e) {
            LOG.warn("Error during initialization {}", configurationFile, e);
        }
    } else {
        if (SettingsManager.DEFAULT_FALLBACK_CONFIGURATION_FILE.equals(configurationFile)) {
            LOG.error("Could not find resource: [{}].", configurationFile);
        } else {
            LOG.debug("Could not find resource: [{}]. Use default fallback.", configurationFile);
        }
    }
}
 
开发者ID:brabenetz,项目名称:settings4j,代码行数:23,代码来源:SettingsManager.java

示例14: createDom

import javax.xml.parsers.FactoryConfigurationError; //导入依赖的package包/类
/**
 * Creates a new DOM document.
 */
static Document createDom() {
    synchronized(JAXBContextImpl.class) {
        if(db==null) {
            try {
                DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
                dbf.setNamespaceAware(true);
                db = dbf.newDocumentBuilder();
            } catch (ParserConfigurationException e) {
                // impossible
                throw new FactoryConfigurationError(e);
            }
        }
        return db.newDocument();
    }
}
 
开发者ID:GeeQuery,项目名称:cxf-plus,代码行数:19,代码来源:JAXBContextImpl.java

示例15: test_getMessage

import javax.xml.parsers.FactoryConfigurationError; //导入依赖的package包/类
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "",
    method = "getMessage",
    args = {}
)
public void test_getMessage() {
    assertNull(new FactoryConfigurationError().getMessage());
    assertEquals("msg1",
            new FactoryConfigurationError("msg1").getMessage());
    assertEquals(new Exception("msg2").toString(),
            new FactoryConfigurationError(
                    new Exception("msg2")).getMessage());
    assertEquals(new NullPointerException().toString(),
            new FactoryConfigurationError(
                    new NullPointerException()).getMessage());
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:18,代码来源:FactoryConfigurationErrorTest.java


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