• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java JAXPUtils类的典型用法和代码示例

java 1次浏览

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

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

示例1: getStylesheetSystemId

点赞 3

import org.apache.tools.ant.util.JAXPUtils; //导入依赖的package包/类
/**
 * Get the systemid of the appropriate stylesheet based on its
 * name and styledir. If no styledir is defined it will load
 * it as a java resource in the xsl child package, otherwise it
 * will get it from the given directory.
 * @return system ID of the stylesheet.
 * @throws IOException thrown if the requested stylesheet does
 * not exist.
 */
protected String getStylesheetSystemId() throws IOException {
    String xslname = "junit-frames.xsl";
    if (NOFRAMES.equals(format)) {
        xslname = "junit-noframes.xsl";
    }
    if (styleDir == null) {
        URL url = getClass().getResource("xsl/" + xslname);
        if (url == null) {
            throw new FileNotFoundException("Could not find jar resource " + xslname);
        }
        return url.toExternalForm();
    }
    File file = new File(styleDir, xslname);
    if (!file.exists()) {
        throw new FileNotFoundException("Could not find file '" + file + "'");
    }
    return JAXPUtils.getSystemId(file);
}
 

开发者ID:apache,
项目名称:ant,
代码行数:28,
代码来源:AggregateTransformer.java

示例2: getSource

点赞 3

import org.apache.tools.ant.util.JAXPUtils; //导入依赖的package包/类
/**
 * Get the source instance from the stream and id of the file.
 * @param is the stream containing the stylesheet data.
 * @param infile the file that will be used for the systemid.
 * @return the configured source instance matching the stylesheet.
 * @throws ParserConfigurationException if a parser cannot be created which
 * satisfies the requested configuration.
 * @throws SAXException in case of problem detected by the SAX parser.
 */
private Source getSource(final InputStream is, final File infile)
    throws ParserConfigurationException, SAXException {
    // todo: is this comment still relevant ??
    // FIXME: need to use a SAXSource as the source for the transform
    // so we can plug in our own entity resolver
    Source src = null;
    if (entityResolver != null) {
        if (getFactory().getFeature(SAXSource.FEATURE)) {
            final SAXParserFactory spFactory = SAXParserFactory.newInstance();
            spFactory.setNamespaceAware(true);
            final XMLReader reader = spFactory.newSAXParser().getXMLReader();
            reader.setEntityResolver(entityResolver);
            src = new SAXSource(reader, new InputSource(is));
        } else {
            throw new IllegalStateException("xcatalog specified, but "
                + "parser doesn't support SAX");
        }
    } else {
        // WARN: Don't use the StreamSource(File) ctor. It won't work with
        // xalan prior to 2.2 because of systemid bugs.
        src = new StreamSource(is);
    }
    src.setSystemId(JAXPUtils.getSystemId(infile));
    return src;
}
 

开发者ID:apache,
项目名称:ant,
代码行数:35,
代码来源:TraXLiaison.java

示例3: testNonUTF8Characters

点赞 3

import org.apache.tools.ant.util.JAXPUtils; //导入依赖的package包/类
@Test
public void testNonUTF8Characters() throws Exception {
    CVSEntry entry = new CVSEntry(new Date(), "Se\u00f1orita", "2003 < 2004 && 3 > 5");
    entry.addFile("Medicare & review.doc", "1.1");
    entry.addFile("El\u00e8ments de style", "1.2");
    CVSEntry[] entries = {entry};

    ByteArrayOutputStream output = new ByteArrayOutputStream();
    PrintWriter pwriter = new PrintWriter(new OutputStreamWriter(output, "UTF-8"));
    writer.printChangeLog(pwriter, entries);

    // make sure that the parsing does not break
    XMLReader xmlReader = JAXPUtils.getXMLReader();
    InputStream input = new ByteArrayInputStream(output.toByteArray());
    xmlReader.setContentHandler(new NullContentHandler());
    xmlReader.parse(new InputSource(input));
}
 

开发者ID:apache,
项目名称:ant,
代码行数:18,
代码来源:ChangeLogWriterTest.java

示例4: getParserClassName

点赞 2

import org.apache.tools.ant.util.JAXPUtils; //导入依赖的package包/类
/**
 * Returns name of an XML parser.
 * Magic string {@link #JAXP_PARSER} is also accepted.
 *
 * @param className Name of the XML parser class or a magic string.
 *
 * @return Name of an XML parser.
 *
 * @throws BuildException Unable to get the name of JAXP parser.
 */
private String getParserClassName(final String className) {
    String name = className;
    if ((className == null) || className.equals(JAXP_PARSER)) {
        // Set first JAXP parser.
        // Throws BuildException.
        XMLReader reader = JAXPUtils.getXMLReader();
        name = reader.getClass().getName();
    }

    log("Using class '" + name + "' to parse SVG documents.", Project.MSG_VERBOSE);
    return name;
}
 

开发者ID:git-moss,
项目名称:Push2Display,
代码行数:23,
代码来源:RasterizerTask.java

示例5: getNamespaceParserName

点赞 2

import org.apache.tools.ant.util.JAXPUtils; //导入依赖的package包/类
private static String getNamespaceParserName() {
    try {
        XMLReader reader = JAXPUtils.getNamespaceXMLReader();
        return reader.getClass().getName();
    } catch (BuildException e) {
        //ignore
        ignoreThrowable(e);
        return null;
    }
}
 

开发者ID:apache,
项目名称:ant,
代码行数:11,
代码来源:Diagnostics.java

示例6: getNamespaceParserLocation

点赞 2

import org.apache.tools.ant.util.JAXPUtils; //导入依赖的package包/类
private static String getNamespaceParserLocation() {
    try {
        XMLReader reader = JAXPUtils.getNamespaceXMLReader();
        URL location = getClassLocation(reader.getClass());
        return location != null ? location.toString() : null;
    } catch (BuildException e) {
        //ignore
        ignoreThrowable(e);
        return null;
    }
}
 

开发者ID:apache,
项目名称:ant,
代码行数:12,
代码来源:Diagnostics.java

示例7: createDefaultReaderOrParser

点赞 2

import org.apache.tools.ant.util.JAXPUtils; //导入依赖的package包/类
/**
 * Returns a SAX-based XMLReader or a SAX-based Parser.
 * @return reader or parser
 */
private Object createDefaultReaderOrParser() {
    Object reader;
    try {
        reader = createDefaultReader();
    } catch (BuildException exc) {
        reader = JAXPUtils.getParser();
    }
    return reader;
}
 

开发者ID:apache,
项目名称:ant,
代码行数:14,
代码来源:XMLValidateTask.java

示例8: transform

点赞 2

import org.apache.tools.ant.util.JAXPUtils; //导入依赖的package包/类
/**
 * Transform an input file.
 * @param infile the file to transform
 * @param outfile the result file
 * @throws Exception on error
 */
public void transform(final File infile, final File outfile) throws Exception {
    if (transformer == null) {
        createTransformer();
    }

    InputStream fis = null;
    OutputStream fos = null;
    try {
        fis = new BufferedInputStream(Files.newInputStream(infile.toPath()));
        fos = new BufferedOutputStream(Files.newOutputStream(outfile.toPath()));
        final StreamResult res = new StreamResult(fos);
        // not sure what could be the need of this...
        res.setSystemId(JAXPUtils.getSystemId(outfile));
        final Source src = getSource(fis, infile);

        // set parameters on each transformation, maybe something has changed
        //(e.g. value of file name parameter)
        setTransformationParameters();

        transformer.transform(src, res);
    } finally {
        // make sure to close all handles, otherwise the garbage
        // collector will close them...whenever possible and
        // Windows may complain about not being able to delete files.
        FileUtils.close(fis);
        FileUtils.close(fos);
    }
}
 

开发者ID:apache,
项目名称:ant,
代码行数:35,
代码来源:TraXLiaison.java

示例9: testListChildNodes

点赞 2

import org.apache.tools.ant.util.JAXPUtils; //导入依赖的package包/类
@Test
public void testListChildNodes() throws SAXException, IOException {
    DocumentBuilder db = JAXPUtils.getDocumentBuilder();
    InputStream is = this.getClass().getClassLoader().getResourceAsStream("taskdefs/optional/junit/matches.xml");
    Document doc = db.parse(is);
    NodeList nl = DOMUtil.listChildNodes(doc.getDocumentElement(), new FooNodeFilter(), true);
    assertEquals("expecting 3", 3, nl.getLength());
}
 

开发者ID:apache,
项目名称:ant,
代码行数:9,
代码来源:DOMUtilTest.java

示例10: testSystemId

点赞 2

import org.apache.tools.ant.util.JAXPUtils; //导入依赖的package包/类
@Test
public void testSystemId() {
    File file = null;
    if (File.separatorChar == '\\') {
        file = new File("d:\\jdk");
    } else {
        file = new File("/user/local/bin");
    }
    String systemid = JAXPUtils.getSystemId(file);
    assertTrue("SystemIDs should start by file:/", systemid.startsWith("file:/"));
    assertTrue("SystemIDs should not start with file:////", !systemid.startsWith("file:////"));
}
 

开发者ID:apache,
项目名称:ant,
代码行数:13,
代码来源:TraXLiaisonTest.java

示例11: getReader

点赞 2

import org.apache.tools.ant.util.JAXPUtils; //导入依赖的package包/类
/**
 * Get our reader
 * @return a reader
 */
private XMLReader getReader() {
    JAXPUtils.getParser();
    return JAXPUtils.getXMLReader();
}
 

开发者ID:apache,
项目名称:ant,
代码行数:9,
代码来源:ParserSupports.java

示例12: toURLString

点赞 2

import org.apache.tools.ant.util.JAXPUtils; //导入依赖的package包/类
private static String toURLString(File file) throws MalformedURLException {
    return JAXPUtils.getSystemId(file);
}
 

开发者ID:apache,
项目名称:ant,
代码行数:4,
代码来源:XMLCatalogTest.java

示例13: createDefaultReader

点赞 1

import org.apache.tools.ant.util.JAXPUtils; //导入依赖的package包/类
/**
 * Create a reader if the use of the class did not specify another one.
 * If a BuildException is thrown, the caller may revert to an alternate
 * reader.
 * @return a new reader.
 * @throws BuildException if something went wrong
 */
protected XMLReader createDefaultReader() {
    return JAXPUtils.getXMLReader();
}
 

开发者ID:apache,
项目名称:ant,
代码行数:11,
代码来源:XMLValidateTask.java

示例14: getSystemId

点赞 1

import org.apache.tools.ant.util.JAXPUtils; //导入依赖的package包/类
/**
 * @param file the filename to use for the systemid
 * @return the systemid
 * @deprecated since 1.5.x.
 *             Use org.apache.tools.ant.util.JAXPUtils#getSystemId instead.
 */
@Deprecated
protected String getSystemId(final File file) {
    return JAXPUtils.getSystemId(file);
}
 

开发者ID:apache,
项目名称:ant,
代码行数:11,
代码来源:TraXLiaison.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)