當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。