Package net.sf.saxon.sort

Examples of net.sf.saxon.sort.LRUCache


    public static boolean isValidURI(CharSequence value) {

        // TODO: XSD 1.1 allows any string to be used as an instance of xs:anyURI

        LRUCache cache = 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 net.sf.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.