Java Code Examples for com.sun.org.apache.xalan.internal.xsltc.runtime.AbstractTranslet#prepassDocument()

The following examples show how to use com.sun.org.apache.xalan.internal.xsltc.runtime.AbstractTranslet#prepassDocument() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LoadDocument.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Create a DTMAxisIterator for the newdom. This is currently only
 * used to create an iterator for the cached stylesheet DOM.
 *
 * @param newdom the cached stylesheet DOM
 * @param translet the translet
 * @param the main dom (should be a MultiDOM)
 * @return a DTMAxisIterator from the document root
 */
private static DTMAxisIterator document(DOM newdom,
                                        AbstractTranslet translet,
                                        DOM dom)
    throws Exception
{
    DTMManager dtmManager = ((MultiDOM)dom).getDTMManager();
    // Need to migrate the cached DTM to the new DTMManager
    if (dtmManager != null && newdom instanceof DTM) {
        ((DTM)newdom).migrateTo(dtmManager);
    }

    translet.prepassDocument(newdom);

    // Wrap the DOM object in a DOM adapter and add to multiplexer
    final DOMAdapter domAdapter = translet.makeDOMAdapter(newdom);
    ((MultiDOM)dom).addDOMAdapter(domAdapter);

    // Create index for any key elements
    translet.buildKeys(domAdapter, null, null,
                       newdom.getDocument());

    // Return a singleton iterator containing the root node
    return new SingletonIterator(newdom.getDocument(), true);
}
 
Example 2
Source File: LoadDocument.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create a DTMAxisIterator for the newdom. This is currently only
 * used to create an iterator for the cached stylesheet DOM.
 *
 * @param newdom the cached stylesheet DOM
 * @param translet the translet
 * @param the main dom (should be a MultiDOM)
 * @return a DTMAxisIterator from the document root
 */
private static DTMAxisIterator document(DOM newdom,
                                        AbstractTranslet translet,
                                        DOM dom)
    throws Exception
{
    DTMManager dtmManager = ((MultiDOM)dom).getDTMManager();
    // Need to migrate the cached DTM to the new DTMManager
    if (dtmManager != null && newdom instanceof DTM) {
        ((DTM)newdom).migrateTo(dtmManager);
    }

    translet.prepassDocument(newdom);

    // Wrap the DOM object in a DOM adapter and add to multiplexer
    final DOMAdapter domAdapter = translet.makeDOMAdapter(newdom);
    ((MultiDOM)dom).addDOMAdapter(domAdapter);

    // Create index for any key elements
    translet.buildKeys(domAdapter, null, null,
                       newdom.getDocument());

    // Return a singleton iterator containing the root node
    return new SingletonIterator(newdom.getDocument(), true);
}
 
Example 3
Source File: LoadDocument.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create a DTMAxisIterator for the newdom. This is currently only
 * used to create an iterator for the cached stylesheet DOM.
 *
 * @param newdom the cached stylesheet DOM
 * @param translet the translet
 * @param the main dom (should be a MultiDOM)
 * @return a DTMAxisIterator from the document root
 */
private static DTMAxisIterator document(DOM newdom,
                                        AbstractTranslet translet,
                                        DOM dom)
    throws Exception
{
    DTMManager dtmManager = ((MultiDOM)dom).getDTMManager();
    // Need to migrate the cached DTM to the new DTMManager
    if (dtmManager != null && newdom instanceof DTM) {
        ((DTM)newdom).migrateTo(dtmManager);
    }

    translet.prepassDocument(newdom);

    // Wrap the DOM object in a DOM adapter and add to multiplexer
    final DOMAdapter domAdapter = translet.makeDOMAdapter(newdom);
    ((MultiDOM)dom).addDOMAdapter(domAdapter);

    // Create index for any key elements
    translet.buildKeys(domAdapter, null, null,
                       newdom.getDocument());

    // Return a singleton iterator containing the root node
    return new SingletonIterator(newdom.getDocument(), true);
}
 
Example 4
Source File: LoadDocument.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create a DTMAxisIterator for the newdom. This is currently only
 * used to create an iterator for the cached stylesheet DOM.
 *
 * @param newdom the cached stylesheet DOM
 * @param translet the translet
 * @param the main dom (should be a MultiDOM)
 * @return a DTMAxisIterator from the document root
 */
private static DTMAxisIterator document(DOM newdom,
                                        AbstractTranslet translet,
                                        DOM dom)
    throws Exception
{
    DTMManager dtmManager = ((MultiDOM)dom).getDTMManager();
    // Need to migrate the cached DTM to the new DTMManager
    if (dtmManager != null && newdom instanceof DTM) {
        ((DTM)newdom).migrateTo(dtmManager);
    }

    translet.prepassDocument(newdom);

    // Wrap the DOM object in a DOM adapter and add to multiplexer
    final DOMAdapter domAdapter = translet.makeDOMAdapter(newdom);
    ((MultiDOM)dom).addDOMAdapter(domAdapter);

    // Create index for any key elements
    translet.buildKeys(domAdapter, null, null,
                       newdom.getDocument());

    // Return a singleton iterator containing the root node
    return new SingletonIterator(newdom.getDocument(), true);
}
 
Example 5
Source File: LoadDocument.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * Create a DTMAxisIterator for the newdom. This is currently only
 * used to create an iterator for the cached stylesheet DOM.
 *
 * @param newdom the cached stylesheet DOM
 * @param translet the translet
 * @param the main dom (should be a MultiDOM)
 * @return a DTMAxisIterator from the document root
 */
private static DTMAxisIterator document(DOM newdom,
                                        AbstractTranslet translet,
                                        DOM dom)
    throws Exception
{
    DTMManager dtmManager = ((MultiDOM)dom).getDTMManager();
    // Need to migrate the cached DTM to the new DTMManager
    if (dtmManager != null && newdom instanceof DTM) {
        ((DTM)newdom).migrateTo(dtmManager);
    }

    translet.prepassDocument(newdom);

    // Wrap the DOM object in a DOM adapter and add to multiplexer
    final DOMAdapter domAdapter = translet.makeDOMAdapter(newdom);
    ((MultiDOM)dom).addDOMAdapter(domAdapter);

    // Create index for any key elements
    translet.buildKeys(domAdapter, null, null,
                       newdom.getDocument());

    // Return a singleton iterator containing the root node
    return new SingletonIterator(newdom.getDocument(), true);
}
 
Example 6
Source File: LoadDocument.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create a DTMAxisIterator for the newdom. This is currently only
 * used to create an iterator for the cached stylesheet DOM.
 *
 * @param newdom the cached stylesheet DOM
 * @param translet the translet
 * @param the main dom (should be a MultiDOM)
 * @return a DTMAxisIterator from the document root
 */
private static DTMAxisIterator document(DOM newdom,
                                        AbstractTranslet translet,
                                        DOM dom)
    throws Exception
{
    DTMManager dtmManager = ((MultiDOM)dom).getDTMManager();
    // Need to migrate the cached DTM to the new DTMManager
    if (dtmManager != null && newdom instanceof DTM) {
        ((DTM)newdom).migrateTo(dtmManager);
    }

    translet.prepassDocument(newdom);

    // Wrap the DOM object in a DOM adapter and add to multiplexer
    final DOMAdapter domAdapter = translet.makeDOMAdapter(newdom);
    ((MultiDOM)dom).addDOMAdapter(domAdapter);

    // Create index for any key elements
    translet.buildKeys(domAdapter, null, null,
                       newdom.getDocument());

    // Return a singleton iterator containing the root node
    return new SingletonIterator(newdom.getDocument(), true);
}
 
Example 7
Source File: LoadDocument.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create a DTMAxisIterator for the newdom. This is currently only
 * used to create an iterator for the cached stylesheet DOM.
 *
 * @param newdom the cached stylesheet DOM
 * @param translet the translet
 * @param the main dom (should be a MultiDOM)
 * @return a DTMAxisIterator from the document root
 */
private static DTMAxisIterator document(DOM newdom,
                                        AbstractTranslet translet,
                                        DOM dom)
    throws Exception
{
    DTMManager dtmManager = ((MultiDOM)dom).getDTMManager();
    // Need to migrate the cached DTM to the new DTMManager
    if (dtmManager != null && newdom instanceof DTM) {
        ((DTM)newdom).migrateTo(dtmManager);
    }

    translet.prepassDocument(newdom);

    // Wrap the DOM object in a DOM adapter and add to multiplexer
    final DOMAdapter domAdapter = translet.makeDOMAdapter(newdom);
    ((MultiDOM)dom).addDOMAdapter(domAdapter);

    // Create index for any key elements
    translet.buildKeys(domAdapter, null, null,
                       newdom.getDocument());

    // Return a singleton iterator containing the root node
    return new SingletonIterator(newdom.getDocument(), true);
}
 
Example 8
Source File: LoadDocument.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create a DTMAxisIterator for the newdom. This is currently only
 * used to create an iterator for the cached stylesheet DOM.
 *
 * @param newdom the cached stylesheet DOM
 * @param translet the translet
 * @param the main dom (should be a MultiDOM)
 * @return a DTMAxisIterator from the document root
 */
private static DTMAxisIterator document(DOM newdom,
                                        AbstractTranslet translet,
                                        DOM dom)
    throws Exception
{
    DTMManager dtmManager = ((MultiDOM)dom).getDTMManager();
    // Need to migrate the cached DTM to the new DTMManager
    if (dtmManager != null && newdom instanceof DTM) {
        ((DTM)newdom).migrateTo(dtmManager);
    }

    translet.prepassDocument(newdom);

    // Wrap the DOM object in a DOM adapter and add to multiplexer
    final DOMAdapter domAdapter = translet.makeDOMAdapter(newdom);
    ((MultiDOM)dom).addDOMAdapter(domAdapter);

    // Create index for any key elements
    translet.buildKeys(domAdapter, null, null,
                       newdom.getDocument());

    // Return a singleton iterator containing the root node
    return new SingletonIterator(newdom.getDocument(), true);
}
 
Example 9
Source File: LoadDocument.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create a DTMAxisIterator for the newdom. This is currently only
 * used to create an iterator for the cached stylesheet DOM.
 *
 * @param newdom the cached stylesheet DOM
 * @param translet the translet
 * @param the main dom (should be a MultiDOM)
 * @return a DTMAxisIterator from the document root
 */
private static DTMAxisIterator document(DOM newdom,
                                        AbstractTranslet translet,
                                        DOM dom)
    throws Exception
{
    DTMManager dtmManager = ((MultiDOM)dom).getDTMManager();
    // Need to migrate the cached DTM to the new DTMManager
    if (dtmManager != null && newdom instanceof DTM) {
        ((DTM)newdom).migrateTo(dtmManager);
    }

    translet.prepassDocument(newdom);

    // Wrap the DOM object in a DOM adapter and add to multiplexer
    final DOMAdapter domAdapter = translet.makeDOMAdapter(newdom);
    ((MultiDOM)dom).addDOMAdapter(domAdapter);

    // Create index for any key elements
    translet.buildKeys(domAdapter, null, null,
                       newdom.getDocument());

    // Return a singleton iterator containing the root node
    return new SingletonIterator(newdom.getDocument(), true);
}
 
Example 10
Source File: LoadDocument.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * Create a DTMAxisIterator for the newdom. This is currently only
 * used to create an iterator for the cached stylesheet DOM.
 *
 * @param newdom the cached stylesheet DOM
 * @param translet the translet
 * @param the main dom (should be a MultiDOM)
 * @return a DTMAxisIterator from the document root
 */
private static DTMAxisIterator document(DOM newdom,
                                        AbstractTranslet translet,
                                        DOM dom)
    throws Exception
{
    DTMManager dtmManager = ((MultiDOM)dom).getDTMManager();
    // Need to migrate the cached DTM to the new DTMManager
    if (dtmManager != null && newdom instanceof DTM) {
        ((DTM)newdom).migrateTo(dtmManager);
    }

    translet.prepassDocument(newdom);

    // Wrap the DOM object in a DOM adapter and add to multiplexer
    final DOMAdapter domAdapter = translet.makeDOMAdapter(newdom);
    ((MultiDOM)dom).addDOMAdapter(domAdapter);

    // Create index for any key elements
    translet.buildKeys(domAdapter, null, null,
                       newdom.getDocument());

    // Return a singleton iterator containing the root node
    return new SingletonIterator(newdom.getDocument(), true);
}
 
Example 11
Source File: DocumentCache.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns a document either by finding it in the cache or
 * downloading it and putting it in the cache.
 */
@Override
public DOM retrieveDocument(String baseURI, String href, Translet trs) {
    CachedDocument doc;

String uri = href;
if (baseURI != null && !baseURI.equals("")) {
    try {
        uri = SystemIDResolver.getAbsoluteURI(uri, baseURI);
    } catch (TransformerException te) {
        // ignore
    }
}

    // Try to get the document from the cache first
    if ((doc = lookupDocument(uri)) == null) {
        doc = new CachedDocument(uri);
        if (doc == null) return null; // better error handling needed!!!
        doc.setLastModified(getLastModified(uri));
        insertDocument(uri, doc);
    }
    // If the document is in the cache we must check if it is still valid
    else {
        long now = System.currentTimeMillis();
        long chk = doc.getLastChecked();
        doc.setLastChecked(now);
        // Has the modification time for this file been checked lately?
        if (now > (chk + REFRESH_INTERVAL)) {
            doc.setLastChecked(now);
            long last = getLastModified(uri);
            // Reload document if it has been modified since last download
            if (last > doc.getLastModified()) {
                doc = new CachedDocument(uri);
                if (doc == null) return null;
                doc.setLastModified(getLastModified(uri));
                replaceDocument(uri, doc);
            }
        }

    }

    // Get the references to the actual DOM and DTD handler
    final DOM dom = doc.getDocument();

    // The dom reference may be null if the URL pointed to a
    // non-existing document
    if (dom == null) return null;

    doc.incAccessCount(); // For statistics

    final AbstractTranslet translet = (AbstractTranslet)trs;

    // Give the translet an early opportunity to extract any
    // information from the DOM object that it would like.
    translet.prepassDocument(dom);

    return(doc.getDocument());
}
 
Example 12
Source File: DocumentCache.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns a document either by finding it in the cache or
 * downloading it and putting it in the cache.
 */
@Override
public DOM retrieveDocument(String baseURI, String href, Translet trs) {
    CachedDocument doc;

String uri = href;
if (baseURI != null && !baseURI.equals("")) {
    try {
        uri = SystemIDResolver.getAbsoluteURI(uri, baseURI);
    } catch (TransformerException te) {
        // ignore
    }
}

    // Try to get the document from the cache first
    if ((doc = lookupDocument(uri)) == null) {
        doc = new CachedDocument(uri);
        if (doc == null) return null; // better error handling needed!!!
        doc.setLastModified(getLastModified(uri));
        insertDocument(uri, doc);
    }
    // If the document is in the cache we must check if it is still valid
    else {
        long now = System.currentTimeMillis();
        long chk = doc.getLastChecked();
        doc.setLastChecked(now);
        // Has the modification time for this file been checked lately?
        if (now > (chk + REFRESH_INTERVAL)) {
            doc.setLastChecked(now);
            long last = getLastModified(uri);
            // Reload document if it has been modified since last download
            if (last > doc.getLastModified()) {
                doc = new CachedDocument(uri);
                if (doc == null) return null;
                doc.setLastModified(getLastModified(uri));
                replaceDocument(uri, doc);
            }
        }

    }

    // Get the references to the actual DOM and DTD handler
    final DOM dom = doc.getDocument();

    // The dom reference may be null if the URL pointed to a
    // non-existing document
    if (dom == null) return null;

    doc.incAccessCount(); // For statistics

    final AbstractTranslet translet = (AbstractTranslet)trs;

    // Give the translet an early opportunity to extract any
    // information from the DOM object that it would like.
    translet.prepassDocument(dom);

    return(doc.getDocument());
}
 
Example 13
Source File: DocumentCache.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns a document either by finding it in the cache or
 * downloading it and putting it in the cache.
 */
@Override
public DOM retrieveDocument(String baseURI, String href, Translet trs) {
    CachedDocument doc;

String uri = href;
if (baseURI != null && !baseURI.equals("")) {
    try {
        uri = SystemIDResolver.getAbsoluteURI(uri, baseURI);
    } catch (TransformerException te) {
        // ignore
    }
}

    // Try to get the document from the cache first
    if ((doc = lookupDocument(uri)) == null) {
        doc = new CachedDocument(uri);
        if (doc == null) return null; // better error handling needed!!!
        doc.setLastModified(getLastModified(uri));
        insertDocument(uri, doc);
    }
    // If the document is in the cache we must check if it is still valid
    else {
        long now = System.currentTimeMillis();
        long chk = doc.getLastChecked();
        doc.setLastChecked(now);
        // Has the modification time for this file been checked lately?
        if (now > (chk + REFRESH_INTERVAL)) {
            doc.setLastChecked(now);
            long last = getLastModified(uri);
            // Reload document if it has been modified since last download
            if (last > doc.getLastModified()) {
                doc = new CachedDocument(uri);
                if (doc == null) return null;
                doc.setLastModified(getLastModified(uri));
                replaceDocument(uri, doc);
            }
        }

    }

    // Get the references to the actual DOM and DTD handler
    final DOM dom = doc.getDocument();

    // The dom reference may be null if the URL pointed to a
    // non-existing document
    if (dom == null) return null;

    doc.incAccessCount(); // For statistics

    final AbstractTranslet translet = (AbstractTranslet)trs;

    // Give the translet an early opportunity to extract any
    // information from the DOM object that it would like.
    translet.prepassDocument(dom);

    return(doc.getDocument());
}
 
Example 14
Source File: DocumentCache.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
/**
 * Returns a document either by finding it in the cache or
 * downloading it and putting it in the cache.
 */
@Override
public DOM retrieveDocument(String baseURI, String href, Translet trs) {
    CachedDocument doc;

String uri = href;
if (baseURI != null && !baseURI.equals("")) {
    try {
        uri = SystemIDResolver.getAbsoluteURI(uri, baseURI);
    } catch (TransformerException te) {
        // ignore
    }
}

    // Try to get the document from the cache first
    if ((doc = lookupDocument(uri)) == null) {
        doc = new CachedDocument(uri);
        if (doc == null) return null; // better error handling needed!!!
        doc.setLastModified(getLastModified(uri));
        insertDocument(uri, doc);
    }
    // If the document is in the cache we must check if it is still valid
    else {
        long now = System.currentTimeMillis();
        long chk = doc.getLastChecked();
        doc.setLastChecked(now);
        // Has the modification time for this file been checked lately?
        if (now > (chk + REFRESH_INTERVAL)) {
            doc.setLastChecked(now);
            long last = getLastModified(uri);
            // Reload document if it has been modified since last download
            if (last > doc.getLastModified()) {
                doc = new CachedDocument(uri);
                if (doc == null) return null;
                doc.setLastModified(getLastModified(uri));
                replaceDocument(uri, doc);
            }
        }

    }

    // Get the references to the actual DOM and DTD handler
    final DOM dom = doc.getDocument();

    // The dom reference may be null if the URL pointed to a
    // non-existing document
    if (dom == null) return null;

    doc.incAccessCount(); // For statistics

    final AbstractTranslet translet = (AbstractTranslet)trs;

    // Give the translet an early opportunity to extract any
    // information from the DOM object that it would like.
    translet.prepassDocument(dom);

    return(doc.getDocument());
}
 
Example 15
Source File: DocumentCache.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns a document either by finding it in the cache or
 * downloading it and putting it in the cache.
 */
@Override
public DOM retrieveDocument(String baseURI, String href, Translet trs) {
    CachedDocument doc;

String uri = href;
if (baseURI != null && !baseURI.equals("")) {
    try {
        uri = SystemIDResolver.getAbsoluteURI(uri, baseURI);
    } catch (TransformerException te) {
        // ignore
    }
}

    // Try to get the document from the cache first
    if ((doc = lookupDocument(uri)) == null) {
        doc = new CachedDocument(uri);
        if (doc == null) return null; // better error handling needed!!!
        doc.setLastModified(getLastModified(uri));
        insertDocument(uri, doc);
    }
    // If the document is in the cache we must check if it is still valid
    else {
        long now = System.currentTimeMillis();
        long chk = doc.getLastChecked();
        doc.setLastChecked(now);
        // Has the modification time for this file been checked lately?
        if (now > (chk + REFRESH_INTERVAL)) {
            doc.setLastChecked(now);
            long last = getLastModified(uri);
            // Reload document if it has been modified since last download
            if (last > doc.getLastModified()) {
                doc = new CachedDocument(uri);
                if (doc == null) return null;
                doc.setLastModified(getLastModified(uri));
                replaceDocument(uri, doc);
            }
        }

    }

    // Get the references to the actual DOM and DTD handler
    final DOM dom = doc.getDocument();

    // The dom reference may be null if the URL pointed to a
    // non-existing document
    if (dom == null) return null;

    doc.incAccessCount(); // For statistics

    final AbstractTranslet translet = (AbstractTranslet)trs;

    // Give the translet an early opportunity to extract any
    // information from the DOM object that it would like.
    translet.prepassDocument(dom);

    return(doc.getDocument());
}
 
Example 16
Source File: DocumentCache.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns a document either by finding it in the cache or
 * downloading it and putting it in the cache.
 */
@Override
public DOM retrieveDocument(String baseURI, String href, Translet trs) {
    CachedDocument doc;

String uri = href;
if (baseURI != null && !baseURI.equals("")) {
    try {
        uri = SystemIDResolver.getAbsoluteURI(uri, baseURI);
    } catch (TransformerException te) {
        // ignore
    }
}

    // Try to get the document from the cache first
    if ((doc = lookupDocument(uri)) == null) {
        doc = new CachedDocument(uri);
        if (doc == null) return null; // better error handling needed!!!
        doc.setLastModified(getLastModified(uri));
        insertDocument(uri, doc);
    }
    // If the document is in the cache we must check if it is still valid
    else {
        long now = System.currentTimeMillis();
        long chk = doc.getLastChecked();
        doc.setLastChecked(now);
        // Has the modification time for this file been checked lately?
        if (now > (chk + REFRESH_INTERVAL)) {
            doc.setLastChecked(now);
            long last = getLastModified(uri);
            // Reload document if it has been modified since last download
            if (last > doc.getLastModified()) {
                doc = new CachedDocument(uri);
                if (doc == null) return null;
                doc.setLastModified(getLastModified(uri));
                replaceDocument(uri, doc);
            }
        }

    }

    // Get the references to the actual DOM and DTD handler
    final DOM dom = doc.getDocument();

    // The dom reference may be null if the URL pointed to a
    // non-existing document
    if (dom == null) return null;

    doc.incAccessCount(); // For statistics

    final AbstractTranslet translet = (AbstractTranslet)trs;

    // Give the translet an early opportunity to extract any
    // information from the DOM object that it would like.
    translet.prepassDocument(dom);

    return(doc.getDocument());
}
 
Example 17
Source File: DocumentCache.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
/**
 * Returns a document either by finding it in the cache or
 * downloading it and putting it in the cache.
 */
@Override
public DOM retrieveDocument(String baseURI, String href, Translet trs) {
    CachedDocument doc;

String uri = href;
if (baseURI != null && !baseURI.equals("")) {
    try {
        uri = SystemIDResolver.getAbsoluteURI(uri, baseURI);
    } catch (TransformerException te) {
        // ignore
    }
}

    // Try to get the document from the cache first
    if ((doc = lookupDocument(uri)) == null) {
        doc = new CachedDocument(uri);
        if (doc == null) return null; // better error handling needed!!!
        doc.setLastModified(getLastModified(uri));
        insertDocument(uri, doc);
    }
    // If the document is in the cache we must check if it is still valid
    else {
        long now = System.currentTimeMillis();
        long chk = doc.getLastChecked();
        doc.setLastChecked(now);
        // Has the modification time for this file been checked lately?
        if (now > (chk + REFRESH_INTERVAL)) {
            doc.setLastChecked(now);
            long last = getLastModified(uri);
            // Reload document if it has been modified since last download
            if (last > doc.getLastModified()) {
                doc = new CachedDocument(uri);
                if (doc == null) return null;
                doc.setLastModified(getLastModified(uri));
                replaceDocument(uri, doc);
            }
        }

    }

    // Get the references to the actual DOM and DTD handler
    final DOM dom = doc.getDocument();

    // The dom reference may be null if the URL pointed to a
    // non-existing document
    if (dom == null) return null;

    doc.incAccessCount(); // For statistics

    final AbstractTranslet translet = (AbstractTranslet)trs;

    // Give the translet an early opportunity to extract any
    // information from the DOM object that it would like.
    translet.prepassDocument(dom);

    return(doc.getDocument());
}
 
Example 18
Source File: DocumentCache.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns a document either by finding it in the cache or
 * downloading it and putting it in the cache.
 */
@Override
public DOM retrieveDocument(String baseURI, String href, Translet trs) {
    CachedDocument doc;

String uri = href;
if (baseURI != null && !baseURI.equals("")) {
    try {
        uri = SystemIDResolver.getAbsoluteURI(uri, baseURI);
    } catch (TransformerException te) {
        // ignore
    }
}

    // Try to get the document from the cache first
    if ((doc = lookupDocument(uri)) == null) {
        doc = new CachedDocument(uri);
        if (doc == null) return null; // better error handling needed!!!
        doc.setLastModified(getLastModified(uri));
        insertDocument(uri, doc);
    }
    // If the document is in the cache we must check if it is still valid
    else {
        long now = System.currentTimeMillis();
        long chk = doc.getLastChecked();
        doc.setLastChecked(now);
        // Has the modification time for this file been checked lately?
        if (now > (chk + REFRESH_INTERVAL)) {
            doc.setLastChecked(now);
            long last = getLastModified(uri);
            // Reload document if it has been modified since last download
            if (last > doc.getLastModified()) {
                doc = new CachedDocument(uri);
                if (doc == null) return null;
                doc.setLastModified(getLastModified(uri));
                replaceDocument(uri, doc);
            }
        }

    }

    // Get the references to the actual DOM and DTD handler
    final DOM dom = doc.getDocument();

    // The dom reference may be null if the URL pointed to a
    // non-existing document
    if (dom == null) return null;

    doc.incAccessCount(); // For statistics

    final AbstractTranslet translet = (AbstractTranslet)trs;

    // Give the translet an early opportunity to extract any
    // information from the DOM object that it would like.
    translet.prepassDocument(dom);

    return(doc.getDocument());
}
 
Example 19
Source File: DocumentCache.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns a document either by finding it in the cache or
 * downloading it and putting it in the cache.
 */
@Override
public DOM retrieveDocument(String baseURI, String href, Translet trs) {
    CachedDocument doc;

String uri = href;
if (baseURI != null && !baseURI.equals("")) {
    try {
        uri = SystemIDResolver.getAbsoluteURI(uri, baseURI);
    } catch (TransformerException te) {
        // ignore
    }
}

    // Try to get the document from the cache first
    if ((doc = lookupDocument(uri)) == null) {
        doc = new CachedDocument(uri);
        if (doc == null) return null; // better error handling needed!!!
        doc.setLastModified(getLastModified(uri));
        insertDocument(uri, doc);
    }
    // If the document is in the cache we must check if it is still valid
    else {
        long now = System.currentTimeMillis();
        long chk = doc.getLastChecked();
        doc.setLastChecked(now);
        // Has the modification time for this file been checked lately?
        if (now > (chk + REFRESH_INTERVAL)) {
            doc.setLastChecked(now);
            long last = getLastModified(uri);
            // Reload document if it has been modified since last download
            if (last > doc.getLastModified()) {
                doc = new CachedDocument(uri);
                if (doc == null) return null;
                doc.setLastModified(getLastModified(uri));
                replaceDocument(uri, doc);
            }
        }

    }

    // Get the references to the actual DOM and DTD handler
    final DOM dom = doc.getDocument();

    // The dom reference may be null if the URL pointed to a
    // non-existing document
    if (dom == null) return null;

    doc.incAccessCount(); // For statistics

    final AbstractTranslet translet = (AbstractTranslet)trs;

    // Give the translet an early opportunity to extract any
    // information from the DOM object that it would like.
    translet.prepassDocument(dom);

    return(doc.getDocument());
}
 
Example 20
Source File: DocumentCache.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
/**
 * Returns a document either by finding it in the cache or
 * downloading it and putting it in the cache.
 */
@Override
public DOM retrieveDocument(String baseURI, String href, Translet trs) {
    CachedDocument doc;

String uri = href;
if (baseURI != null && !baseURI.equals("")) {
    try {
        uri = SystemIDResolver.getAbsoluteURI(uri, baseURI);
    } catch (TransformerException te) {
        // ignore
    }
}

    // Try to get the document from the cache first
    if ((doc = lookupDocument(uri)) == null) {
        doc = new CachedDocument(uri);
        if (doc == null) return null; // better error handling needed!!!
        doc.setLastModified(getLastModified(uri));
        insertDocument(uri, doc);
    }
    // If the document is in the cache we must check if it is still valid
    else {
        long now = System.currentTimeMillis();
        long chk = doc.getLastChecked();
        doc.setLastChecked(now);
        // Has the modification time for this file been checked lately?
        if (now > (chk + REFRESH_INTERVAL)) {
            doc.setLastChecked(now);
            long last = getLastModified(uri);
            // Reload document if it has been modified since last download
            if (last > doc.getLastModified()) {
                doc = new CachedDocument(uri);
                if (doc == null) return null;
                doc.setLastModified(getLastModified(uri));
                replaceDocument(uri, doc);
            }
        }

    }

    // Get the references to the actual DOM and DTD handler
    final DOM dom = doc.getDocument();

    // The dom reference may be null if the URL pointed to a
    // non-existing document
    if (dom == null) return null;

    doc.incAccessCount(); // For statistics

    final AbstractTranslet translet = (AbstractTranslet)trs;

    // Give the translet an early opportunity to extract any
    // information from the DOM object that it would like.
    translet.prepassDocument(dom);

    return(doc.getDocument());
}