/**
* 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
);
}
}
java类javax.xml.parsers.FactoryConfigurationError的实例源码
DefaultAttributes.java 文件源码
项目:incubator-netbeans
阅读 21
收藏 0
点赞 0
评论 0
XMLUtil.java 文件源码
项目:incubator-netbeans
阅读 25
收藏 0
点赞 0
评论 0
/** 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
}
}
Measure.java 文件源码
项目:jmt
阅读 21
收藏 0
点赞 0
评论 0
/**
* 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();
}
}
TrackWriterTest.java 文件源码
项目:mytracks
阅读 17
收藏 0
点赞 0
评论 0
/**
* 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;
}
DomDocumentBuilderFactory.java 文件源码
项目:javify
阅读 19
收藏 0
点赞 0
评论 0
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);
}
}
PacketParserUtilsTest.java 文件源码
项目:Smack
阅读 24
收藏 0
点赞 0
评论 0
@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());
}
PacketParserUtilsTest.java 文件源码
项目:Smack
阅读 24
收藏 0
点赞 0
评论 0
@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());
}
DocumentProcessorTest.java 文件源码
项目:java-aci-api-ng
阅读 20
收藏 0
点赞 0
评论 0
@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");
}
}
Util.java 文件源码
项目:openxds
阅读 27
收藏 0
点赞 0
评论 0
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;
}
DOMConfigurator.java 文件源码
项目:cacheonix-core
阅读 22
收藏 0
点赞 0
评论 0
/**
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);
}
DOMConfigurator.java 文件源码
项目:cacheonix-core
阅读 20
收藏 0
点赞 0
评论 0
/**
Configure log4j by reading in a log4j.dtd compliant XML
configuration file.
*/
public
void doConfigure(final Reader reader, LoggerRepository repository)
throws FactoryConfigurationError {
ParseAction action = new ParseAction() {
public Document parse(final DocumentBuilder parser) throws SAXException, IOException {
InputSource inputSource = new InputSource(reader);
inputSource.setSystemId("dummy://log4j.dtd");
return parser.parse(inputSource);
}
public String toString() {
return "reader [" + reader.toString() + "]";
}
};
doConfigure(action, repository);
}
DOMConfigurator.java 文件源码
项目:cacheonix-core
阅读 20
收藏 0
点赞 0
评论 0
/**
Configure log4j by reading in a log4j.dtd compliant XML
configuration file.
*/
protected
void doConfigure(final InputSource inputSource, LoggerRepository repository)
throws FactoryConfigurationError {
if (inputSource.getSystemId() == null) {
inputSource.setSystemId("dummy://log4j.dtd");
}
ParseAction action = new ParseAction() {
public Document parse(final DocumentBuilder parser) throws SAXException, IOException {
return parser.parse(inputSource);
}
public String toString() {
return "input source [" + inputSource.toString() + "]";
}
};
doConfigure(action, repository);
}
DOMConfigurator.java 文件源码
项目:cacheonix-core
阅读 26
收藏 0
点赞 0
评论 0
/**
* 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);
}
DOMConfigurator.java 文件源码
项目:cacheonix-core
阅读 25
收藏 0
点赞 0
评论 0
/**
* Configure log4j by reading in a log4j.dtd compliant XML configuration file.
*/
public void doConfigure(final Reader reader, final LoggerRepository repository)
throws FactoryConfigurationError {
final ParseAction action = new ParseAction() {
public Document parse(final DocumentBuilder parser) throws SAXException, IOException {
final InputSource inputSource = new InputSource(reader);
inputSource.setSystemId("dummy://log4j.dtd");
return parser.parse(inputSource);
}
public String toString() {
//noinspection ObjectToString
return "reader [" + reader + ']';
}
};
doConfigure(action, repository);
}
DOMConfigurator.java 文件源码
项目:cacheonix-core
阅读 26
收藏 0
点赞 0
评论 0
/**
* Configure log4j by reading in a log4j.dtd compliant XML configuration file.
*/
private void doConfigure(final InputSource inputSource, final LoggerRepository repository)
throws FactoryConfigurationError {
if (inputSource.getSystemId() == null) {
inputSource.setSystemId("dummy://log4j.dtd");
}
final ParseAction action = new ParseAction() {
public Document parse(final DocumentBuilder parser) throws SAXException, IOException {
return parser.parse(inputSource);
}
public String toString() {
//noinspection ObjectToString
return "input source [" + inputSource + ']';
}
};
doConfigure(action, repository);
}
DomDocumentBuilderFactory.java 文件源码
项目:jvm-stm
阅读 28
收藏 0
点赞 0
评论 0
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);
}
}
ArxivImporter.java 文件源码
项目:scientific-publishing
阅读 16
收藏 0
点赞 0
评论 0
@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;
}
DOMConfigurator.java 文件源码
项目:daq-eclipse
阅读 23
收藏 0
点赞 0
评论 0
/**
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);
}
DOMConfigurator.java 文件源码
项目:daq-eclipse
阅读 21
收藏 0
点赞 0
评论 0
/**
Configure log4j by reading in a log4j.dtd compliant XML
configuration file.
*/
public
void doConfigure(final Reader reader, LoggerRepository repository)
throws FactoryConfigurationError {
ParseAction action = new ParseAction() {
public Document parse(final DocumentBuilder parser) throws SAXException, IOException {
InputSource inputSource = new InputSource(reader);
inputSource.setSystemId("dummy://log4j.dtd");
return parser.parse(inputSource);
}
public String toString() {
return "reader [" + reader.toString() + "]";
}
};
doConfigure(action, repository);
}
DOMConfigurator.java 文件源码
项目:daq-eclipse
阅读 28
收藏 0
点赞 0
评论 0
/**
Configure log4j by reading in a log4j.dtd compliant XML
configuration file.
*/
protected
void doConfigure(final InputSource inputSource, LoggerRepository repository)
throws FactoryConfigurationError {
if (inputSource.getSystemId() == null) {
inputSource.setSystemId("dummy://log4j.dtd");
}
ParseAction action = new ParseAction() {
public Document parse(final DocumentBuilder parser) throws SAXException, IOException {
return parser.parse(inputSource);
}
public String toString() {
return "input source [" + inputSource.toString() + "]";
}
};
doConfigure(action, repository);
}
SettingsManager.java 文件源码
项目:settings4j
阅读 25
收藏 0
点赞 0
评论 0
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);
}
}
}
JAXBContextImpl.java 文件源码
项目:cxf-plus
阅读 23
收藏 0
点赞 0
评论 0
/**
* 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();
}
}
FactoryConfigurationErrorTest.java 文件源码
项目:In-the-Box-Fork
阅读 18
收藏 0
点赞 0
评论 0
@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());
}
DOMConfigurator.java 文件源码
项目:nabs
阅读 22
收藏 0
点赞 0
评论 0
/**
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);
}
DOMConfigurator.java 文件源码
项目:nabs
阅读 25
收藏 0
点赞 0
评论 0
/**
Configure log4j by reading in a log4j.dtd compliant XML
configuration file.
*/
public
void doConfigure(final Reader reader, LoggerRepository repository)
throws FactoryConfigurationError {
ParseAction action = new ParseAction() {
public Document parse(final DocumentBuilder parser) throws SAXException, IOException {
InputSource inputSource = new InputSource(reader);
inputSource.setSystemId("dummy://log4j.dtd");
return parser.parse(inputSource);
}
public String toString() {
return "reader [" + reader.toString() + "]";
}
};
doConfigure(action, repository);
}
DOMConfigurator.java 文件源码
项目:nabs
阅读 23
收藏 0
点赞 0
评论 0
/**
Configure log4j by reading in a log4j.dtd compliant XML
configuration file.
*/
protected
void doConfigure(final InputSource inputSource, LoggerRepository repository)
throws FactoryConfigurationError {
if (inputSource.getSystemId() == null) {
inputSource.setSystemId("dummy://log4j.dtd");
}
ParseAction action = new ParseAction() {
public Document parse(final DocumentBuilder parser) throws SAXException, IOException {
return parser.parse(inputSource);
}
public String toString() {
return "input source [" + inputSource.toString() + "]";
}
};
doConfigure(action, repository);
}
GeoUtils.java 文件源码
项目:AugmentedOxford
阅读 24
收藏 0
点赞 0
评论 0
@Deprecated
private Document getDocumentFromUrl(String url) throws IOException,
MalformedURLException, ProtocolException,
FactoryConfigurationError, ParserConfigurationException,
SAXException {
HttpURLConnection urlConnection = (HttpURLConnection) new URL(url)
.openConnection();
urlConnection.setRequestMethod("GET");
urlConnection.setDoOutput(true);
urlConnection.setDoInput(true);
urlConnection.connect();
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
// get the kml file. And parse it to get the coordinates(direction
// route):
Document doc = db.parse(urlConnection.getInputStream());
return doc;
}
DomDocumentBuilderFactory.java 文件源码
项目:JamVM-PH
阅读 24
收藏 0
点赞 0
评论 0
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);
}
}
GSAccessControlList.java 文件源码
项目:jets3t-aws-roles
阅读 17
收藏 0
点赞 0
评论 0
@Override
public XMLBuilder toXMLBuilder() throws ServiceException, ParserConfigurationException,
FactoryConfigurationError, TransformerException
{
XMLBuilder builder = XMLBuilder.create("AccessControlList");
// Owner
if (owner != null) {
XMLBuilder ownerBuilder = builder.elem("Owner");
ownerBuilder.elem("ID").text(owner.getId()).up();
if (owner.getDisplayName() != null) {
ownerBuilder.elem("Name").text(owner.getDisplayName());
}
}
XMLBuilder accessControlList = builder.elem("Entries");
for (GrantAndPermission gap: grants) {
GranteeInterface grantee = gap.getGrantee();
Permission permission = gap.getPermission();
accessControlList
.elem("Entry")
.importXMLBuilder(grantee.toXMLBuilder())
.elem("Permission").text(permission.toString());
}
return builder;
}
AccessControlList.java 文件源码
项目:jets3t-aws-roles
阅读 20
收藏 0
点赞 0
评论 0
public XMLBuilder toXMLBuilder() throws ServiceException, ParserConfigurationException,
FactoryConfigurationError, TransformerException
{
if (owner == null) {
throw new ServiceException("Invalid AccessControlList: missing an owner");
}
XMLBuilder builder = XMLBuilder.create("AccessControlPolicy")
.attr("xmlns", Constants.XML_NAMESPACE)
.elem("Owner")
.elem("ID").text(owner.getId()).up()
.elem("DisplayName").text(owner.getDisplayName()).up()
.up();
XMLBuilder accessControlList = builder.elem("AccessControlList");
for (GrantAndPermission gap: grants) {
GranteeInterface grantee = gap.getGrantee();
Permission permission = gap.getPermission();
accessControlList
.elem("Grant")
.importXMLBuilder(grantee.toXMLBuilder())
.elem("Permission").text(permission.toString());
}
return builder;
}