Package nokogiri.internals

Examples of nokogiri.internals.NokogiriNamespaceCache$CacheEntry


                                                IRubyObject prefix,
                                                IRubyObject href) {
        String prefixString = rubyStringToString(prefix);
        String hrefString = rubyStringToString(href);

        NokogiriNamespaceCache nsCache = NokogiriHelpers.getNamespaceCacheFormNode(node);
        XmlNamespace cachedNamespace = nsCache.get(prefixString, hrefString);
        if (cachedNamespace != null) return cachedNamespace;

        Node namespaceOwner;
        if (node.getNodeType() == Node.ELEMENT_NODE) {
            namespaceOwner = node;
View Full Code Here


    }

    @JRubyMethod
    public IRubyObject namespace(ThreadContext context) {
        if (doc instanceof HtmlDocument) return context.getRuntime().getNil();
        NokogiriNamespaceCache nsCache = NokogiriHelpers.getNamespaceCacheFormNode(node);
        String prefix = node.getPrefix();
        XmlNamespace namespace = nsCache.get(prefix == null ? "" : prefix, node.getNamespaceURI());
        if (namespace == null || namespace.isEmpty()) {
            return context.getRuntime().getNil();
        }

        return namespace;
View Full Code Here

            previousNode = findPreviousElement(node);
        }
        if (previousNode == null) return scoped_namespaces;

        List<String> prefixes_in_scope = new ArrayList<String>();
        NokogiriNamespaceCache nsCache = NokogiriHelpers.getNamespaceCacheFormNode(previousNode);
        for (Node previous=previousNode; previous != null; ) {
            List<XmlNamespace> namespaces = nsCache.get(previous);
            for (XmlNamespace namespace : namespaces) {
                if (prefixes_in_scope.contains(namespace.getPrefix())) continue;
                scoped_namespaces.append(namespace);
                prefixes_in_scope.add(namespace.getPrefix());
            }
View Full Code Here

    public NokogiriNamespaceCache getNamespaceCache() {
        return nsCache;
    }

    public void initializeNamespaceCacheIfNecessary() {
        if (nsCache == null) nsCache = new NokogiriNamespaceCache();
    }
View Full Code Here

*/
public class LeastRecentlyUsedEvictionAlgorithm implements EvictionAlgorithm {

    @SuppressWarnings("unchecked")
    public void evict(CacheImpl cache) {
        CacheEntry lruCacheEntry = null;
        for (Object o : cache.getAll()) {
            CacheEntry cacheEntry = (CacheEntry) o;
            if (lruCacheEntry == null) {
                lruCacheEntry = cacheEntry;
            } else if (lruCacheEntry.getLastAccessed() > cacheEntry.getLastAccessed()) {
                lruCacheEntry = cacheEntry;
            }
        }
        if (lruCacheEntry != null) {
            cache.evict(lruCacheEntry.getKey());
View Full Code Here

*/
public class MostRecentlyUsedEvictionAlgorithm implements EvictionAlgorithm {

    @SuppressWarnings("unchecked")
    public void evict(CacheImpl cache) {
        CacheEntry mruCacheEntry = null;
        for (Object o : cache.getAll()) {
            CacheEntry cacheEntry = (CacheEntry) o;
            if (mruCacheEntry == null) {
                mruCacheEntry = cacheEntry;
            } else if (mruCacheEntry.getLastAccessed() < cacheEntry.getLastAccessed()) {
                mruCacheEntry = cacheEntry;
            }
        }
        if (mruCacheEntry != null) {
            cache.evict(mruCacheEntry.getKey());
View Full Code Here

public class RandomEvictionAlgorithm implements EvictionAlgorithm {
    private static Random random = new Random();

    @SuppressWarnings("unchecked")
    public void evict(CacheImpl cache) {
        CacheEntry lruCacheEntry = null;
        Collection all = cache.getAll();
        int evictionIndex = random.nextInt(all.size());
        int index = 0;

        for (Object anAll : all) {
            CacheEntry cacheEntry = (CacheEntry) anAll;
            if (index == evictionIndex) {
                lruCacheEntry = cacheEntry;
                break;
            }
            index++;
View Full Code Here

TOP

Related Classes of nokogiri.internals.NokogiriNamespaceCache$CacheEntry

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.