Package javolution.util

Examples of javolution.util.FastMap$EntrySet


        }

        @Override
        public void setField(Object obj, Class forClass, Class type) {
            synchronized (forClass) { // We don't want to attach simultaneously to the same class.
                FastMap typeToField = (FastMap) _fields.get(forClass);
                if ((typeToField != null) && typeToField.containsKey(type))
                    throw new IllegalArgumentException("Field of type " + type + " already attached to class " + forClass);
                if (typeToField == null) {
                    typeToField = new FastMap();
                    _fields.put(forClass, typeToField);
                }
                typeToField.put(type, obj);
            }
        }
View Full Code Here


         *        the outer value.
         */
        public void set( T  value) {
            LocalContext ctx = Reference.getLocalContext();
            if (ctx != null) {
                FastMap references = ctx._references;
                references.put(this, value);
                _hasBeenLocallyOverriden = true;
                return;
            }
            // No local context, sets default value.
            _defaultValue = value;
View Full Code Here

        allocators.clear();
    }

    // Overrides.
    protected Allocator getAllocator(ObjectFactory factory) {
        final FastMap factoryToAllocator = (FastMap) FACTORY_TO_ALLOCATOR.get();
        ImmortalAllocator allocator = (ImmortalAllocator) factoryToAllocator.get(factory);
        if (allocator == null) {
            allocator = new ImmortalAllocator(factory);
            factoryToAllocator.put(factory, allocator);
        }
        if (allocator.user == null) { // Activate.
            allocator.user = Thread.currentThread();
            FastTable activeAllocators = (FastTable) ACTIVE_ALLOCATORS.get();
            activeAllocators.add(allocator);
View Full Code Here

        allocators.clear();
    }

    // Overrides.
    protected Allocator getAllocator(ObjectFactory factory) {
        final FastMap factoryToAllocator = (FastMap) FACTORY_TO_ALLOCATOR.get();
        HeapAllocator allocator = (HeapAllocator) factoryToAllocator.get(factory);
        if (allocator == null) {
            allocator = new HeapAllocator(factory);
            factoryToAllocator.put(factory, allocator);
        }
        if (allocator.user == null) { // Activate.
            allocator.user = Thread.currentThread();
            FastTable activeAllocators = (FastTable) ACTIVE_ALLOCATORS.get();
            activeAllocators.add(allocator);
View Full Code Here

    }

    public void put(T key, T subKey, Y d) {
        Map<T, Y> subMap = get(key);
        if (subMap == null) {
            FastMap rMap = new FastMap<T, Y>();
            //noinspection unchecked
            rMap.setKeyComparator(this.getKeyComparator());
            //noinspection unchecked
            subMap = rMap;

            put(key, subMap);
        }
View Full Code Here

    @SuppressWarnings("unchecked")
    public void save(Object key, Object subKey, Double d) {
        Map<Object, Double> subMap = get(key);
        if (subMap == null) {
            FastMap rMap = new FastMap<Object, Double>();
            rMap.setKeyComparator(this.getKeyComparator());
            subMap = rMap;

            put(key, subMap);
        }
View Full Code Here

    }

    /** Gets a FastMap of site configuration variables. */
    public static Map loadConfigMap(Element root, URL xml) {
        long startTime = System.currentTimeMillis();
        FastMap map = FastMap.newInstance();
        if (root == null) {
            root = loadDocument(xml);
        }
       
        if (root == null) {
            return map;
        }

        List includeElementList = UtilXml.childElementList(root, INCLUDE);
        Iterator includeElementIter = includeElementList.iterator();
        while (includeElementIter.hasNext()) {
            Element includeElement = (Element) includeElementIter.next();
            String includeLocation = includeElement.getAttribute(INCLUDE_LOCATION);
            if ((includeLocation != null) && (includeLocation.length() > 0)) {
                try {
                    Map subMap = loadConfigMap(null, FlexibleLocation.resolveLocation(includeLocation));
                    map.putAll(subMap);
                } catch (MalformedURLException mue) {
                    Debug.logError(mue, "Error processing include at [" + includeLocation + "]:" + mue.toString(), module);
                }
            }
        }

        // default error page
        String errorpage = UtilXml.childElementValue(root, DEFAULT_ERROR_PAGE);
        if (UtilValidate.isNotEmpty(errorpage)) map.put(DEFAULT_ERROR_PAGE, errorpage);

        // site owner
        String owner = UtilXml.childElementValue(root, SITE_OWNER);
        if (UtilValidate.isNotEmpty(owner)) map.put(SITE_OWNER, owner);

        // security class
        String securityClass = UtilXml.childElementValue(root, SECURITY_CLASS);
        if (UtilValidate.isNotEmpty(securityClass)) map.put(SECURITY_CLASS, securityClass);

        // first visit event
        Element firstvisitElement = UtilXml.firstChildElement(root, FIRSTVISIT);
        if (firstvisitElement != null) {
            List eventList = FastList.newInstance();
            List eventElementList = UtilXml.childElementList(firstvisitElement, EVENT);
            Iterator eventElementIter = eventElementList.iterator();
            while (eventElementIter.hasNext()) {
                Element eventElement = (Element) eventElementIter.next();
                FastMap eventMap = FastMap.newInstance();
                eventMap.put(EVENT_TYPE, eventElement.getAttribute(EVENT_TYPE));
                eventMap.put(EVENT_PATH, eventElement.getAttribute(EVENT_PATH));
                eventMap.put(EVENT_METHOD, eventElement.getAttribute(EVENT_METHOD));
           
                // Check for a global-transaction attribute - default to true
                eventMap.put(EVENT_GLOBAL_TRANSACTION, eventElement.hasAttribute(EVENT_GLOBAL_TRANSACTION) ? eventElement.getAttribute(EVENT_GLOBAL_TRANSACTION) : "true");
                eventList.add(eventMap);
            }
            map.put(FIRSTVISIT, eventList);
        }

        // preprocessor events
        Element preprocessorElement = UtilXml.firstChildElement(root, PREPROCESSOR);
        if (preprocessorElement != null) {
            List eventList = FastList.newInstance();
            List eventElementList = UtilXml.childElementList(preprocessorElement, EVENT);
            Iterator eventElementIter = eventElementList.iterator();
            while (eventElementIter.hasNext()) {
                Element eventElement = (Element) eventElementIter.next();
                FastMap eventMap = FastMap.newInstance();
                eventMap.put(EVENT_TYPE, eventElement.getAttribute(EVENT_TYPE));
                eventMap.put(EVENT_PATH, eventElement.getAttribute(EVENT_PATH));
                eventMap.put(EVENT_METHOD, eventElement.getAttribute(EVENT_METHOD));
           
                // Check for a global-transaction attribute - default to true
                eventMap.put(EVENT_GLOBAL_TRANSACTION, eventElement.hasAttribute(EVENT_GLOBAL_TRANSACTION) ? eventElement.getAttribute(EVENT_GLOBAL_TRANSACTION) : "true");
                eventList.add(eventMap);
            }
            map.put(PREPROCESSOR, eventList);
        }

        // postprocessor events
        Element postprocessorElement = UtilXml.firstChildElement(root, POSTPROCESSOR);
        if (postprocessorElement != null) {
            List eventList = FastList.newInstance();
            List eventElementList = UtilXml.childElementList(postprocessorElement, EVENT);
            Iterator eventElementIter = eventElementList.iterator();
            while (eventElementIter.hasNext()) {
                Element eventElement = (Element) eventElementIter.next();
                FastMap eventMap = FastMap.newInstance();
                eventMap.put(EVENT_TYPE, eventElement.getAttribute(EVENT_TYPE));
                eventMap.put(EVENT_PATH, eventElement.getAttribute(EVENT_PATH));
                eventMap.put(EVENT_METHOD, eventElement.getAttribute(EVENT_METHOD));
           
                // Check for a global-transaction attribute - default to true
                eventMap.put(EVENT_GLOBAL_TRANSACTION, eventElement.hasAttribute(EVENT_GLOBAL_TRANSACTION) ? eventElement.getAttribute(EVENT_GLOBAL_TRANSACTION) : "true");
                eventList.add(eventMap);
            }
            map.put(POSTPROCESSOR, eventList);
        }

        // after-login events
        Element afterLoginElement = UtilXml.firstChildElement(root, "after-login");
        if (afterLoginElement != null) {
            List eventList = FastList.newInstance();
            List eventElementList = UtilXml.childElementList(afterLoginElement, EVENT);
            Iterator eventElementIter = eventElementList.iterator();
            while (eventElementIter.hasNext()) {
                Element eventElement = (Element) eventElementIter.next();
                FastMap eventMap = FastMap.newInstance();
                eventMap.put(EVENT_TYPE, eventElement.getAttribute(EVENT_TYPE));
                eventMap.put(EVENT_PATH, eventElement.getAttribute(EVENT_PATH));
                eventMap.put(EVENT_METHOD, eventElement.getAttribute(EVENT_METHOD));
           
                // Check for a global-transaction attribute - default to true
                eventMap.put(EVENT_GLOBAL_TRANSACTION, eventElement.hasAttribute(EVENT_GLOBAL_TRANSACTION) ? eventElement.getAttribute(EVENT_GLOBAL_TRANSACTION) : "true");
                eventList.add(eventMap);
            }
            map.put("after-login", eventList);
        }

        // before-logout events
        Element beforeLogoutElement = UtilXml.firstChildElement(root, "before-logout");
        if (beforeLogoutElement != null) {
            List eventList = FastList.newInstance();
            List eventElementList = UtilXml.childElementList(beforeLogoutElement, EVENT);
            Iterator eventElementIter = eventElementList.iterator();
            while (eventElementIter.hasNext()) {
                Element eventElement = (Element) eventElementIter.next();
                FastMap eventMap = FastMap.newInstance();
                eventMap.put(EVENT_TYPE, eventElement.getAttribute(EVENT_TYPE));
                eventMap.put(EVENT_PATH, eventElement.getAttribute(EVENT_PATH));
                eventMap.put(EVENT_METHOD, eventElement.getAttribute(EVENT_METHOD));
           
                // Check for a global-transaction attribute - default to true
                eventMap.put(EVENT_GLOBAL_TRANSACTION, eventElement.hasAttribute(EVENT_GLOBAL_TRANSACTION) ? eventElement.getAttribute(EVENT_GLOBAL_TRANSACTION) : "true");
                eventList.add(eventMap);
            }
            map.put("before-logout", eventList);
        }

View Full Code Here

        return controllerConfig != null ? controllerConfig.handlerMap : null;
    }

    public static Map loadHandlerMap(Element root, URL xml) {
        long startTime = System.currentTimeMillis();
        FastMap map = FastMap.newInstance();
        if (root == null) {
            root = loadDocument(xml);
        }
        if (root == null) {
            return map;
        }

        List includeElementList = UtilXml.childElementList(root, INCLUDE);
        Iterator includeElementIter = includeElementList.iterator();
        while (includeElementIter.hasNext()) {
            Element includeElement = (Element) includeElementIter.next();
            String includeLocation = includeElement.getAttribute(INCLUDE_LOCATION);
            if ((includeLocation != null) && (includeLocation.length() > 0)) {
                try {
                    Map subMap = loadHandlerMap(null, FlexibleLocation.resolveLocation(includeLocation));

                    Map newViewHandlerMap = (Map) subMap.get("view");
                    Map viewHandlerMap = (Map) map.get("view");
                    if (viewHandlerMap == null) {
                        map.put("view", newViewHandlerMap);
                    } else {
                        if (newViewHandlerMap != null) {
                            viewHandlerMap.putAll(newViewHandlerMap);
                        }
                    }

                    Map newEventHandlerMap = (Map) subMap.get("event");
                    Map eventHandlerMap = (Map) map.get("event");
                    if (eventHandlerMap == null) {
                        map.put("event", newEventHandlerMap);
                    } else {
                        if (newEventHandlerMap != null) {
                            eventHandlerMap.putAll(newEventHandlerMap);
                        }
                    }
                } catch (MalformedURLException mue) {
                    Debug.logError(mue, "Error processing include at [" + includeLocation + "]:" + mue.toString(), module);
                }
            }
        }

        Map eventMap = FastMap.newInstance();
        Map viewMap = FastMap.newInstance();

        List handlerElementList = UtilXml.childElementList(root, HANDLER);
        Iterator handlerElementIter = handlerElementList.iterator();
        while (handlerElementIter.hasNext()) {
            Element handlerElement = (Element) handlerElementIter.next();
            String hName = checkEmpty(handlerElement.getAttribute(HANDLER_NAME));
            String hClass = checkEmpty(handlerElement.getAttribute(HANDLER_CLASS));
            String hType = checkEmpty(handlerElement.getAttribute(HANDLER_TYPE));
            if (hType.equals("view")) {
                viewMap.put(hName, hClass);
            } else {
                eventMap.put(hName, hClass);
            }
        }

        Map viewHandlerMap = (Map) map.get("view");
        if (viewHandlerMap == null) {
            map.put("view", viewMap);
        } else {
            if (viewMap != null) {
                viewHandlerMap.putAll(viewMap);
            }
        }
        Map eventHandlerMap = (Map) map.get("event");
        if (eventHandlerMap == null) {
            map.put("event", eventMap);
        } else {
            if (eventMap != null) {
                eventHandlerMap.putAll(eventMap);
            }
        }

        /* Debugging */
        if (Debug.verboseOn()) {
            Debug.logVerbose("-------- Handler Mappings --------", module);
            Map debugMap = (Map) map.get("event");

            if (debugMap != null && debugMap.size() > 0) {
                Debug.logVerbose("-------------- EVENT -------------", module);
                Set debugSet = debugMap.keySet();
                Iterator i = debugSet.iterator();
                while (i.hasNext()) {
                    Object o = i.next();
                    String handlerName = (String) o;
                    String className = (String) debugMap.get(o);
                    Debug.logVerbose("[EH] : " + handlerName + " => " + className, module);
                }
            }
            debugMap = (Map) map.get("view");
            if (debugMap != null && debugMap.size() > 0) {
                Debug.logVerbose("-------------- VIEW --------------", module);
                Set debugSet = debugMap.keySet();
                Iterator i = debugSet.iterator();
                while (i.hasNext()) {
                    Object o = i.next();
                    String handlerName = (String) o;
                    String className = (String) debugMap.get(o);
                    Debug.logVerbose("[VH] : " + handlerName + " => " + className, module);
                }
            }
            Debug.logVerbose("------ End Handler Mappings ------", module);
        }

        double totalSeconds = (System.currentTimeMillis() - startTime)/1000.0;
        if (Debug.infoOn()) Debug.logInfo("HandlerMap Created: (" + ((Map) map.get("view")).size() + ") view handlers and (" + ((Map) map.get("event")).size() + ") request/event handlers in " + totalSeconds + "s", module);
        return map;
    }
View Full Code Here

     * of a particular row. The keys will be stripped of the _o_N suffix.
     * There is an additionaly key "row" for each Map that holds the
     * index of the row.
     */
    public static Collection parseMultiFormData(Map parameters) {
        FastMap rows = new FastMap(); // stores the rows keyed by row number

        // first loop through all the keys and create a hashmap for each ${ROW_SUBMIT_PREFIX}${N} = Y
        Iterator keys = parameters.keySet().iterator();
        while (keys.hasNext()) {
            String key = (String) keys.next();

            // skip everything that is not ${ROW_SUBMIT_PREFIX}N
            if (key == null || key.length() <= ROW_SUBMIT_PREFIX_LENGTH) continue;
            if (key.indexOf(MULTI_ROW_DELIMITER) <= 0) continue;
            if (!key.substring(0, ROW_SUBMIT_PREFIX_LENGTH).equals(ROW_SUBMIT_PREFIX)) continue;
            if (!parameters.get(key).equals("Y")) continue;

            // decode the value of N and create a new map for it
            Integer n = Integer.decode(key.substring(ROW_SUBMIT_PREFIX_LENGTH, key.length()));
            Map m = new FastMap();
            m.put("row", n); // special "row" = N tuple
            rows.put(n, m); // key it to N
        }

        // next put all parameters with matching N in the right map
        keys = parameters.keySet().iterator();
View Full Code Here

    /**
     * Returns a new map containing all the parameters from the input map except for the
     * multi form parameters (usually named according to the ${param}_o_N notation).
     */
    public static Map removeMultiFormParameters(Map parameters) {
        FastMap filteredParameters = new FastMap();
        Iterator keys = parameters.keySet().iterator();
        while (keys.hasNext()) {
            String key = (String) keys.next();

            if (key != null && (key.indexOf(MULTI_ROW_DELIMITER) != -1 || key.indexOf("_useRowSubmit") != -1 || key.indexOf("_rowCount") != -1)) {
                continue;
            }

            filteredParameters.put(key, parameters.get(key));
        }
        return filteredParameters;
    }
View Full Code Here

TOP

Related Classes of javolution.util.FastMap$EntrySet

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.