Package org.pdf4j.saxon.sort

Examples of org.pdf4j.saxon.sort.LRUCache


     * @return true if the string is a valid URI
     */

    public static boolean isValidURI(CharSequence value) {

        LRUCache cache = (LRUCache)caches.get();
        if (cache == null) {
            cache = new LRUCache(10);
            caches.set(cache);
        }

        if (cache.get(value) != null) {
            return true;
        }

        String sv = Whitespace.trim(value);

        // Allow zero-length strings (RFC2396 is ambivalent on this point)
        if (sv.length() == 0) {
            return true;
        }

        // Allow a string if the java.net.URI class accepts it
        try {
            new URI(sv);
            cache.put(value, value);
            return true;
        } catch (URISyntaxException e) {
            // keep trying
            // Note: it's expensive to throw exceptions on a success path, so we keep a cache.
        }

        // Allow a string if it can be escaped into a form that java.net.URI accepts
        sv = EscapeURI.iriToUri(sv).toString();
        try {
            new URI(sv);
            cache.put(value, value);
            return true;
        } catch (URISyntaxException e) {
            return false;
        }
    }
View Full Code Here

TOP

Related Classes of org.pdf4j.saxon.sort.LRUCache

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.