Example usage for javax.xml.parsers SAXParserFactory newInstance

List of usage examples for javax.xml.parsers SAXParserFactory newInstance

Introduction

In this page you can find the example usage for javax.xml.parsers SAXParserFactory newInstance.

Prototype


public static SAXParserFactory newInstance() 

Source Link

Document

Obtain a new instance of a SAXParserFactory .

Usage

From source file:net.sourceforge.fullsync.fs.connection.SyncFileBufferedConnection.java

protected void loadFromBuffer() throws IOException {
    File fsRoot = fs.getRoot();/*from ww  w  .j a v a  2  s.  c  o  m*/
    File f = fsRoot.getChild(BUFFER_FILENAME);

    root = new AbstractBufferedFile(this, fsRoot, null, true, true);
    if ((null == f) || !f.exists() || f.isDirectory()) {
        if (isMonitoringFileSystem()) {
            updateFromFileSystem(root);
        }
        return;
    }
    ByteArrayOutputStream out = new ByteArrayOutputStream((int) f.getSize());
    try (InputStream in = new GZIPInputStream(f.getInputStream())) {
        int i;
        byte[] block = new byte[4096];
        while ((i = in.read(block)) > 0) {
            out.write(block, 0, i);
        }
    }
    try {
        SAXParser sax = SAXParserFactory.newInstance().newSAXParser();
        sax.parse(new ByteArrayInputStream(out.toByteArray()), new SyncFileDefaultHandler(this));
    } catch (SAXParseException spe) {
        StringBuilder sb = new StringBuilder(spe.toString());
        sb.append("\n Line number: " + spe.getLineNumber()); //$NON-NLS-1$
        sb.append("\n Column number: " + spe.getColumnNumber()); //$NON-NLS-1$
        sb.append("\n Public ID: " + spe.getPublicId()); //$NON-NLS-1$
        sb.append("\n System ID: " + spe.getSystemId() + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
        System.err.println(sb.toString());
    } catch (IOException | SAXException | ParserConfigurationException | FactoryConfigurationError e) {
        ExceptionHandler.reportException(e);
    }

    if (isMonitoringFileSystem()) {
        updateFromFileSystem(root);
    }
}

From source file:dreamboxdataservice.DreamboxDataService.java

/**
 * @param service Service-ID// www  .  j  a v  a2  s  .c om
 * @return Data of specific service
 */
public TreeMap<String, String> getServiceDataBonquets(String service) {
    try {
        URL url = new URL("http://" + mProperties.getProperty("ip", "") + "/web/getservices?bRef=" + service);

        URLConnection connection = url.openConnection();

        String userpassword = mProperties.getProperty("username", "") + ":" + IOUtilities
                .xorEncode(mProperties.getProperty("password", ""), DreamboxSettingsPanel.PASSWORDSEED);
        String encoded = new String(Base64.encodeBase64(userpassword.getBytes()));
        connection.setRequestProperty("Authorization", "Basic " + encoded);

        connection.setConnectTimeout(10);
        InputStream stream = connection.getInputStream();

        SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser();

        DreamboxHandler handler = new DreamboxHandler();

        saxParser.parse(stream, handler);

        return handler.getData();
    } catch (ParserConfigurationException e) {
        e.printStackTrace();
    } catch (SAXException e) {
        e.printStackTrace();
    } catch (MalformedURLException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    return null;
}

From source file:hu.bme.mit.sette.tools.jpet.JPetParser.java

@Override
protected void parseSnippet(Snippet snippet, SnippetInputsXml inputsXml) throws Exception {
    File outputFile = RunnerProjectUtils.getSnippetOutputFile(getRunnerProjectSettings(), snippet);
    File errorFile = RunnerProjectUtils.getSnippetErrorFile(getRunnerProjectSettings(), snippet);

    if (errorFile.exists()) {
        // TODO enhance this section and make it clear
        List<String> lines = FileUtils.readLines(errorFile);

        String firstLine = lines.get(0);

        if (firstLine.startsWith("ERROR: test_data_generator:unfold_bck/6: Undefined procedure:")) {
            inputsXml.setResultType(ResultType.NA);
        } else if (firstLine.startsWith("ERROR: Domain error: `clpfd_expression' expected, found")) {
            inputsXml.setResultType(ResultType.NA);
        } else if (firstLine.startsWith("ERROR: Unknown message: error(resolve_classfile/")) {
            inputsXml.setResultType(ResultType.NA);
        } else if (firstLine.startsWith("ERROR: local_control:unfold/3: Undefined procedure:")) {
            inputsXml.setResultType(ResultType.NA);
        } else {/*w ww  .ja v a  2  s  . c  o m*/
            // TODO enhance error handling

            // this is debug (only if unhandled error)
            System.err.println("=============================");
            System.err.println(snippet.getMethod());
            System.err.println("=============================");

            for (String line : lines) {
                System.err.println(line);
            }
            System.err.println("=============================");

            // TODO enhance error handling
            throw new RuntimeException("PARSER PROBLEM, UNHANDLED ERROR");
        }
    } else {
        // TODO enhance

        // LineIterator lines = FileUtils.lineIterator(outputFile);
        List<String> lines = FileUtils.readLines(outputFile);

        if (lines.get(lines.size() - 1).startsWith("Error loading bytecode program")) {
            // System.err.println(snippet.getMethod().getName());
            // System.err.println("BYTECODE PROBLEM");
            inputsXml.setResultType(ResultType.EX);
            // throw new RuntimeException(""
        } else {
            inputsXml.setResultType(ResultType.S);

            // extract coverage
            if (lines.size() >= 8) {
                String fullCode = lines.get(lines.size() - 3).trim();
                String topCode = lines.get(lines.size() - 2).trim();

                Matcher mFull = PATTERN_FULL_CODE.matcher(fullCode);
                Matcher mTop = PATTERN_TOP_CODE.matcher(topCode);

                // TODO should not use jPET coverage information in the
                // future
                if (mFull.matches() && mTop.matches()) {
                    double full = Double.parseDouble(mFull.group(1));
                    double top = Double.parseDouble(mTop.group(1));

                    if (full == 100.0 && top == 100.0) {
                        // full -> C
                        inputsXml.setResultType(ResultType.C);
                    } else if (snippet.getIncludedConstructors().isEmpty()
                            && snippet.getIncludedMethods().isEmpty()) {
                        // only consider top, no included things
                        if (top >= snippet.getRequiredStatementCoverage()) {
                            inputsXml.setResultType(ResultType.C);
                        } else {
                            inputsXml.setResultType(ResultType.NC);
                            // System.err.println(snippet.getMethod()
                            // .getName());
                            // System.err
                            // .println(String
                            // .format("No incl. no statis. - Full: %.2f Top: %.2f Req: %.2f",
                            // full,
                            // top,
                            // snippet.getRequiredStatementCoverage()));
                        }
                    } else {
                        // few cases, not very usefol top and full now...
                        // System.err.println(snippet.getMethod()
                        // .getName());
                        // System.err.println(String.format(
                        // "Has included - Full: %.2f Top: %.2f Req: %.2f",
                        // full,
                        // top,
                        // snippet.getRequiredStatementCoverage()));

                    }
                } else {
                    // TODO error handling
                    System.err.println("Both should match");
                }
            }

            // extract inputs
            lines = null;

            File testCasesFile = getTool().getTestCaseXmlFile(getRunnerProjectSettings(), snippet);
            new FileValidator(testCasesFile).type(FileType.REGULAR_FILE).validate();

            if (testCasesFile.length() > 10 * 10e6) {
                // TODO enhance this section
                System.err.println("Filesize is bigger than 10 MB: " + testCasesFile);
            }
            // TODO it was used to dump the cases where jpet cannot decide
            // coverage
            // if (inputsXml.getResultType() == ResultType.S) {
            // System.out.println("Only S");
            // }

            // now skip, only 12 cases are S

            System.out.println(
                    snippet.getContainer().getJavaClass().getName() + "." + snippet.getMethod().getName());

            SAXParserFactory factory = SAXParserFactory.newInstance();
            SAXParser saxParser = factory.newSAXParser();

            JPetTestCaseXmlParser testCasesParser = new JPetTestCaseXmlParser();

            saxParser.parse(testCasesFile, testCasesParser);

            JPetTestCasesConverter.convert(snippet, testCasesParser.getTestCases(), inputsXml);
        }

        // find input lines
        //
        // List<String> inputLines = new ArrayList<>();
        // boolean shouldCollect = false;
        // while (lines.hasNext()) {
        // String line = lines.next();
        // if (line.trim()
        // .equals("====================================================== Method Summaries"))
        // {
        // shouldCollect = true;
        // } else if (shouldCollect) {
        // if
        // (line.startsWith("======================================================"))
        // {
        // // start of next section
        // shouldCollect = false;
        // break;
        // } else {
        // if (!StringUtils.isBlank(line)) {
        // inputLines.add(line.trim());
        // }
        // }
        // }
        // }
        //
        // // close iterator
        // lines.close();
        //
        // // remove duplicates
        // inputLines = new ArrayList<>(new LinkedHashSet<>(inputLines));
        //
        // String firstLine = inputLines.get(0);
        // assert (firstLine.startsWith("Inputs: "));
        // firstLine = firstLine.substring(7).trim();
        // String[] parameterStrings = StringUtils.split(firstLine, ',');
        // ParameterType[] parameterTypes = new
        // ParameterType[parameterStrings.length];
        //
        // if (inputLines.size() == 2
        // && inputLines.get(1).startsWith("No path conditions for")) {
        // InputElement input = new InputElement();
        // for (int i = 0; i < parameterStrings.length; i++) {
        // // no path conditions, only considering the "default" inputs
        // Class<?> type = snippet.getMethod().getParameterTypes()[i];
        // parameterTypes[i] = getParameterType(type);
        // input.parameters().add(
        // new ParameterElement(parameterTypes[i],
        // getDefaultParameterString(type)));
        // }
        // inputsXml.generatedInputs().add(input);
        // } else {
        // // parse parameter types
        //
        // Class<?>[] paramsJavaClass = snippet.getMethod()
        // .getParameterTypes();
        //
        // for (int i = 0; i < parameterStrings.length; i++) {
        // String parameterString = parameterStrings[i];
        // Class<?> pjc = ClassUtils
        // .primitiveToWrapper(paramsJavaClass[i]);
        //
        // if (parameterString.endsWith("SYMINT")) {
        // if (pjc == Boolean.class) {
        // parameterTypes[i] = ParameterType.BOOLEAN;
        // } else if (pjc == Byte.class) {
        // parameterTypes[i] = ParameterType.BYTE;
        // } else if (pjc == Short.class) {
        // parameterTypes[i] = ParameterType.SHORT;
        // } else if (pjc == Integer.class) {
        // parameterTypes[i] = ParameterType.INT;
        // } else if (pjc == Long.class) {
        // parameterTypes[i] = ParameterType.LONG;
        // } else {
        // // int for something else
        // parameterTypes[i] = ParameterType.INT;
        // }
        // } else if (parameterString.endsWith("SYMREAL")) {
        // if (pjc == Float.class) {
        // parameterTypes[i] = ParameterType.FLOAT;
        // } else if (pjc == Float.class) {
        // parameterTypes[i] = ParameterType.DOUBLE;
        // } else {
        // // int for something else
        // parameterTypes[i] = ParameterType.DOUBLE;
        // }
        // } else {
        // // TODO error handling
        // // int for something else
        // throw new RuntimeException("PARSER PROBLEM");
        // }
        // }
        //
        // // example
        // // inheritsAPIGuessTwoPrimitives(11,-2147483648(don't care)) -->
        // // "java.lang.IllegalArgumentException..."
        // // inheritsAPIGuessTwoPrimitives(9,11) -->
        // // "java.lang.IllegalArgumentException..."
        // // inheritsAPIGuessTwoPrimitives(7,9) -->
        // // "java.lang.RuntimeException: Out of range..."
        // // inheritsAPIGuessTwoPrimitives(4,1) --> Return Value: 1
        // // inheritsAPIGuessTwoPrimitives(0,0) --> Return Value: 0
        // // inheritsAPIGuessTwoPrimitives(9,-88) -->
        // // "java.lang.IllegalArgumentException..."
        // // inheritsAPIGuessTwoPrimitives(-88,-2147483648(don't care))
        // // --> "java.lang.IllegalArgumentException..."
        //
        // String ps = String.format("^%s\\((.*)\\) --> (.*)$", snippet
        // .getMethod().getName());
        //
        // ps = String.format("^%s(.*) --> (.*)$", snippet.getMethod()
        // .getName());
        // Pattern p = Pattern.compile(ps);
        //
        // // parse inputs
        // int i = -1;
        // for (String line : inputLines) {
        // i++;
        //
        // if (i == 0) {
        // // first line
        // continue;
        // } else if (StringUtils.isEmpty(line)) {
        // continue;
        // }
        //
        // Matcher m = p.matcher(line);
        //
        // if (m.matches()) {
        // String paramsString = StringUtils.substring(m.group(1)
        // .trim(), 1, -1);
        // String resultString = m.group(2).trim();
        //
        // paramsString = StringUtils.replace(paramsString,
        // "(don't care)", "");
        //
        // String[] paramsStrings = StringUtils.split(
        // paramsString, ',');
        //
        // InputElement input = new InputElement();
        //
        // // if index error -> lesser inputs than parameters
        // for (int j = 0; j < parameterTypes.length; j++) {
        // if (parameterTypes[j] == ParameterType.BOOLEAN
        // && paramsStrings[j].contains("-2147483648")) {
        // // don't care -> 0
        // paramsStrings[j] = "false";
        // }
        //
        // ParameterElement pe = new ParameterElement(
        // parameterTypes[j], paramsStrings[j].trim());
        //
        // try {
        // // just check the type format
        // pe.validate();
        // } catch (Exception e) {
        // // TODO debug - remove or log
        // System.out.println(parameterTypes[j]);
        // System.out.println(paramsStrings[j]);
        // System.out.println(pe.getType());
        // System.out.println(pe.getValue());
        // e.printStackTrace();
        //
        // System.err
        // .println("=============================");
        // System.err.println(snippet.getMethod());
        // System.err
        // .println("=============================");
        // for (String lll : inputLines) {
        // System.err.println(lll);
        // }
        // System.err
        // .println("=============================");
        //
        // System.exit(-1);
        // }
        //
        // input.parameters().add(pe);
        // }
        //
        // if (resultString.startsWith("Return Value:")) {
        // // has retval, nothing to do
        // } else {
        // // exception; example (" is present inside the
        // // string!!!):
        // // "java.lang.ArithmeticException: div by 0..."
        // // "java.lang.IndexOutOfBoundsException: Index: 1, Size: 5..."
        //
        // int pos = resultString.indexOf(':');
        // if (pos < 0) {
        // // not found :, search for ...
        // pos = resultString.indexOf("...");
        // }
        //
        // String ex = resultString.substring(1, pos);
        //
        // input.setExpected((Class<? extends Throwable>) Class
        // .forName(ex));
        //
        // // System.err.println(resultString);
        // // System.err.println(ex);
        // // // input.setExpected(expected);
        // }
        //
        // inputsXml.generatedInputs().add(input);
        // } else {
        // System.err.println("NO MATCH");
        // System.err.println(ps);
        // System.err.println(line);
        // throw new Exception("NO MATCH: " + line);
        // }
        // }
        // }
        //
        // inputsXml.validate();
    }
}

From source file:com.wooki.test.unit.ConversionsTest.java

@Test(enabled = true)
public void docbookConversion() {
    String result = "<book>     <bookinfo>       <title>An Example Book</title>              <author>         <firstname>Your first name</firstname>         <surname>Your surname</surname>         <affiliation>           <address><email>foo@example.com</email></address>         </affiliation>       </author>          <copyright>         <year>2000</year>         <holder>Copyright string here</holder>       </copyright>          <abstract>         <para>If your book has an abstract then it should go here.</para>       </abstract>     </bookinfo>        <preface>       <title>Preface</title>          <para>Your book may have a preface, in which case it should be placed         here.</para>     </preface>              <chapter>       <title>My First Chapter</title>          <para>This is the first chapter in my book.</para>          <sect1>         <title>My First Section</title>            <para>This is the first section in my book.</para>       </sect1>     </chapter>   </book>";
    Resource resource = new ByteArrayResource(result.getBytes());
    InputStream xhtml = fromDocbookConvertor.performTransformation(resource);
    File htmlFile = null;//from  w  w w  .java  2 s .c  o  m
    try {
        htmlFile = File.createTempFile("wooki", ".html");
        FileOutputStream fos = new FileOutputStream(htmlFile);
        logger.debug("HTML File is " + htmlFile.getAbsolutePath());
        byte[] content = null;
        int available = 0;
        while ((available = xhtml.available()) > 0) {
            content = new byte[available];
            xhtml.read(content);
            fos.write(content);
        }
        fos.flush();
        fos.close();
    } catch (IOException e) {
        e.printStackTrace();
        logger.error(e.getLocalizedMessage());
        return;
    }
    logger.debug("Docbook to xhtml ok");
    SAXParserFactory factory = SAXParserFactory.newInstance();

    // cration d'un parseur SAX
    SAXParser parser;
    try {
        parser = factory.newSAXParser();
        parser.parse(new InputSource(new FileInputStream(htmlFile)), htmlParser);
    } catch (ParserConfigurationException e) {
        e.printStackTrace();
        logger.error(e.getLocalizedMessage());
    } catch (SAXException e) {
        e.printStackTrace();
        logger.error(e.getLocalizedMessage());
    } catch (IOException e) {
        e.printStackTrace();
        logger.error(e.getLocalizedMessage());
    }

    Book book = htmlParser.getBook();
    logger.debug("The book title is " + book.getTitle());

}

From source file:com.centeractive.ws.builder.soap.XmlUtils.java

/**
 * XmlOptions configuration used in preventing XML Bomb
 * /*from   w w w.  j a v  a  2s . c  o m*/
 * @return XmlOptions
 */
public static XmlOptions createDefaultXmlOptions() {
    XmlOptions xmlOptions;

    try {
        SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser();
        SecurityManager securityManager = new SecurityManager();
        // Default seems to be 64000!
        // TODO
        // securityManager.setEntityExpansionLimit( 16 );

        saxParser.setProperty("http://apache.org/xml/properties/security-manager", securityManager);
        XMLReader xmlReader = saxParser.getXMLReader();
        xmlOptions = new XmlOptions().setLoadUseXMLReader(xmlReader);
    } catch (Exception e) {
        xmlOptions = new XmlOptions();
        log.error("Error creating XmlOptions; " + e.getMessage(), e);
    }
    return xmlOptions;
}

From source file:com.piketec.jenkins.plugins.tpt.publisher.TPTReportPublisher.java

/**
 * Xml SAXparser/*from  w  w  w .  j a v a 2s.c  o  m*/
 * 
 * @param xmlFile
 * @param tptFile
 * @param failedTests
 * @param reportDirOnRemote
 * @param executionConfiguration
 * @throws InterruptedException
 */
private void parse(FilePath xmlFile, TPTFile tptFile, ArrayList<TPTTestCase> failedTests,
        String reportDirOnRemote, String executionConfiguration, TptLogger logger) throws InterruptedException {
    SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();

    try {
        SAXParser saxParser = saxParserFactory.newSAXParser();
        TPTReportSAXHandler handler = new TPTReportSAXHandler(tptFile, failedTests, reportDirOnRemote,
                executionConfiguration);
        InputStream inputStream = xmlFile.read();
        try {
            saxParser.parse(inputStream, handler);
        } finally {
            IOUtils.closeQuietly(inputStream);
        }
    } catch (ParserConfigurationException | SAXException | IOException e) {
        logger.error(e.getMessage());
    }

}

From source file:jproxy.DefaultSamplerCreator.java

/**
 * Tries parsing to see if content is xml
 * @param postData String//  w ww . j av a  2  s  . c o  m
 * @return boolean
 */
private static boolean isPotentialXml(String postData) {
    try {
        SAXParserFactory spf = SAXParserFactory.newInstance();
        SAXParser saxParser = spf.newSAXParser();
        XMLReader xmlReader = saxParser.getXMLReader();
        ErrorDetectionHandler detectionHandler = new ErrorDetectionHandler();
        xmlReader.setContentHandler(detectionHandler);
        xmlReader.setErrorHandler(detectionHandler);
        xmlReader.parse(new InputSource(new StringReader(postData)));
        return !detectionHandler.isErrorDetected();
    } catch (ParserConfigurationException e) {
        return false;
    } catch (SAXException e) {
        return false;
    } catch (IOException e) {
        return false;
    }
}

From source file:com.gc.iotools.fmt.detect.droid.DroidDetectorImpl.java

private XMLReader getXMLReader(final SAXModelBuilder mb) throws Exception {
    final SAXParserFactory factory = SAXParserFactory.newInstance();
    factory.setNamespaceAware(true);/*from w w w .  j av  a2  s  .c  om*/
    // factory.setValidating(true);
    final SAXParser saxParser = factory.newSAXParser();
    final XMLReader parser = saxParser.getXMLReader();
    // URL url = DroidDetectorImpl.class
    // .getResource("DROID_SignatureFile.xsd");
    // parser.setProperty(
    // "http://java.sun.com/xml/jaxp/properties/schemaSource", url);
    mb.setupNamespace(SIGNATURE_FILE_NS, true);
    parser.setContentHandler(mb);
    return parser;
}

From source file:com.android.tools.idea.templates.RepositoryUrlManager.java

/**
 * Parses a Maven metadata file and returns a string of the highest found version
 *
 * @param metadataFile    the files to parse
 * @param includePreviews if false, preview versions of the library will not be returned
 * @return the string representing the highest version found in the file or "0.0.0" if no versions exist in the file
 */// w ww.  jav a2 s .  co m
@Nullable
private static String getLatestVersionFromMavenMetadata(@NotNull File metadataFile,
        @Nullable String filterPrefix, boolean includePreviews, @NotNull FileOp fileOp) throws IOException {
    String xml = fileOp.toString(metadataFile, StandardCharsets.UTF_8);

    List<GradleCoordinate> versions = Lists.newLinkedList();
    try {
        SAXParserFactory.newInstance().newSAXParser().parse(IOUtils.toInputStream(xml), new DefaultHandler() {
            boolean inVersionTag = false;

            @Override
            public void startElement(String uri, String localName, String qName, Attributes attributes)
                    throws SAXException {
                if (qName.equals(TAG_VERSION)) {
                    inVersionTag = true;
                }
            }

            @Override
            public void characters(char[] ch, int start, int length) throws SAXException {
                // Get the version and compare it to the current known max version
                if (inVersionTag) {
                    inVersionTag = false;
                    String revision = new String(ch, start, length);
                    //noinspection StatementWithEmptyBody
                    if (!includePreviews && "5.2.08".equals(revision)
                            && metadataFile.getPath().contains(PLAY_SERVICES.getArtifactId())) {
                        // This version (despite not having -rcN in its version name is actually a preview
                        // (See https://code.google.com/p/android/issues/detail?id=75292)
                        // Ignore it
                    } else if (filterPrefix == null || revision.startsWith(filterPrefix)) {
                        versions.add(GradleCoordinate.parseVersionOnly(revision));
                    }
                }
            }
        });
    } catch (Exception e) {
        LOG.warn(e);
    }

    if (versions.isEmpty()) {
        return REVISION_ANY;
    } else if (includePreviews) {
        return GRADLE_COORDINATE_ORDERING.max(versions).getRevision();
    } else {
        return versions.stream().filter(v -> !v.isPreview()).max(GRADLE_COORDINATE_ORDERING)
                .map(GradleCoordinate::getRevision).orElse(null);
    }
}

From source file:info.magnolia.about.app.AboutPresenter.java

String[] getConnectionString() {
    File config = null;//from   w w w .  j  a v a  2 s  . co  m
    // Assuming, the path to the repository-config.-file is configured relative, starting with WEB-INF.
    // Otherwise, assuming it's an absolute path for this config. (See JIRA MGNLUI-3163)
    String configuredPath = magnoliaProperties.getProperty("magnolia.repositories.jackrabbit.config");
    if (configuredPath != null) {
        if (configuredPath.startsWith("WEB-INF")) {
            config = new File(magnoliaProperties.getProperty("magnolia.app.rootdir") + "/" + configuredPath);
        } else {
            config = new File(configuredPath);
        }
    }
    // No special handling here if the config (file) is null or not existing.
    // If the path is wrong or not set, Magnolia won't start up properly and it won't be possible to launch the About-app.

    final String[] connectionString = new String[3];
    try {
        SAXParserFactory.newInstance().newSAXParser().parse(config, new DefaultHandler() {
            private boolean inPM;

            @Override
            public void startElement(String uri, String localName, String qName, Attributes attributes)
                    throws SAXException {
                super.startElement(uri, localName, qName, attributes);
                if ("PersistenceManager".equals(qName) || "DataSource".equals(qName)) {
                    inPM = true;
                }
                if (inPM && "param".equals(qName)) {
                    if ("url".equals(attributes.getValue("name"))) {
                        connectionString[0] = attributes.getValue("value");
                    }
                    if ("user".equals(attributes.getValue("name"))) {
                        connectionString[1] = attributes.getValue("value");
                    }
                    if ("password".equals(attributes.getValue("name"))) {
                        connectionString[2] = attributes.getValue("value");
                    }
                }
            }

            @Override
            public void endElement(String uri, String localName, String qName) throws SAXException {
                super.endElement(uri, localName, qName);
                if ("PersistenceManager".equals(localName) || "DataSource".equals(qName)) {
                    inPM = false;
                }
            }
        });
        return connectionString;
    } catch (Exception e) {
        log.debug("Failed to obtain DB connection info with {}", e.getMessage(), e);
    }
    return null;
}