Example usage for javax.xml.datatype Duration toString

List of usage examples for javax.xml.datatype Duration toString

Introduction

In this page you can find the example usage for javax.xml.datatype Duration toString.

Prototype

public String toString() 

Source Link

Document

Returns a String representation of this Duration Object .

Usage

From source file:fr.efl.chaine.xslt.GauloisPipe.java

/**
 * Execute the pipe for the specified input stream to the specified
 * serializer.<br>//from  www . ja  v  a  2s .  c o m
 * <b>Warning</b>: this method is public for implementation reasons,
 * and <b>must not</b> be called outside of GauloisPipe
 *
 * @param pipe the pipe to run
 * @param input the specified input stream
 * @param listener the message listener to use
 * @throws SaxonApiException when a problem occurs
 * @throws java.net.MalformedURLException When an URL is not correctly formed
 * @throws fr.efl.chaine.xslt.InvalidSyntaxException When config file is invalid
 * @throws java.net.URISyntaxException When URI is invalid
 * @throws java.io.FileNotFoundException And when the file can not be found !
 */
public void execute(Pipe pipe, ParametrableFile input, MessageListener listener) throws SaxonApiException,
        MalformedURLException, InvalidSyntaxException, URISyntaxException, FileNotFoundException, IOException {
    boolean avoidCache = input.getAvoidCache();
    long start = System.currentTimeMillis();
    String key = input.getFile().getAbsolutePath().intern();
    XdmNode source = documentCache.get(key);
    if (source == null || avoidCache) {
        if (!avoidCache && documentCache.isLoading(instanceName)) {
            source = documentCache.waitForLoading(key);
        }
        if (source == null || avoidCache) {
            synchronized (key) {
                if (!avoidCache) {
                    source = documentCache.get(key);
                }
                if (source == null) {
                    documentCache.setLoading(key);
                    if (config.isLogFileSize()) {
                        LOGGER.info("[" + instanceName + "] " + input.toString() + " as input: "
                                + input.getFile().length());
                    }
                    source = builder.build(input.getFile());
                    if (!avoidCache && config.getSources().getFileUsage(input.getFile()) > 1) {
                        // on ne le met en cache que si il est utilis plusieurs fois !
                        LOGGER.debug("[" + instanceName + "] caching " + key);
                        documentCache.put(key, source);
                    } else {
                        documentCache.ignoreLoading(key);
                        if (avoidCache) {
                            LOGGER.trace("[" + instanceName + "] " + key + " exclued from cache");
                        } else {
                            LOGGER.trace("[" + instanceName + "] " + key + " used only once, no cache");
                        }
                    }
                }
            }
        }
    }
    HashMap<QName, ParameterValue> parameters = ParametersMerger.addInputInParameters(
            ParametersMerger.merge(input.getParameters(), config.getParams()), input.getFile());
    XsltTransformer transformer = buildTransformer(pipe, input.getFile(),
            input.getFile().toURI().toURL().toExternalForm(), parameters, listener, source);
    LOGGER.debug("[" + instanceName + "] transformer build");
    transformer.setInitialContextNode(source);
    transformer.transform();
    long duration = System.currentTimeMillis() - start;
    String distinctName = input.toString();
    try {
        Duration duree = DatatypeFactory.newInstance().newDuration(duration);
        LOGGER.info(
                "[" + instanceName + "] - " + distinctName + " - transform terminated: " + duree.toString());
    } catch (Exception ex) {
        LOGGER.info("[" + instanceName + "] - " + distinctName + " - transform terminated");
    }
}