Package com.cedarsoftware.util

Examples of com.cedarsoftware.util.CaseInsensitiveMap$CaseInsensitiveString


    /**
     * @return Map (case insensitive keys) containing meta (additional) properties for the n-cube.
     */
    public Map<String, Object> getMetaProperties()
    {
        Map ret = metaProps == null ? new CaseInsensitiveMap() : metaProps;
        return Collections.unmodifiableMap(ret);
    }
View Full Code Here


    /**
     * @return Map (case insensitive keys) containing meta (additional) properties for the n-cube.
     */
    public Map<String, Object> getMetaProperties()
    {
        Map ret = metaProps == null ? new CaseInsensitiveMap() : metaProps;
        return Collections.unmodifiableMap(ret);
    }
View Full Code Here

            {
                throw new IllegalArgumentException("JSON format must have a root 'ncube' field containing the String name of the NCube.");
            }
            NCube ncube = new NCube(cubeName);
            ncube.setVersion("file");
            ncube.metaProps = new CaseInsensitiveMap();
            ncube.metaProps.putAll(jsonNCube);
            ncube.metaProps.remove("ncube");
            ncube.metaProps.remove("defaultCellValue");
            ncube.metaProps.remove("defaultCellValueType");
            ncube.metaProps.remove("ruleMode");
View Full Code Here

    {
        if (_headers == null)
        {
            _headers = new String[]{};
        }
        Map headerStrings = new CaseInsensitiveMap();
        for (String header : _headers)
        {
            headerStrings.put(header, null);
        }
        // Step 1. Sort axes from smallest to largest.
        // Hypercubes look best when the smaller axes are on the inside, and the larger axes are on the outside.
        List<Axis> axes = new ArrayList<Axis>(ncube.getAxes());
        Collections.sort(axes, new Comparator<Axis>()
        {
            public int compare(Axis a1, Axis a2)
            {
                return a2.size() - a1.size();
            }
        });

        // Step 2.  Now find an axis that is a good candidate for the single (top) axis.  This would be an axis
        // with the number of columns closest to 12.
        int smallestDelta = Integer.MAX_VALUE;
        int candidate = -1;
        int count = 0;

        for (Axis axis : axes)
        {
            if (headerStrings.keySet().contains(axis.getName()))
            {
                candidate = count;
                break;
            }
            int delta = abs(axis.size() - 12);
View Full Code Here

    /**
     * @return Map (case insensitive keys) containing meta (additional) properties for the n-cube.
     */
    public Map<String, Object> getMetaProperties()
    {
        Map ret = metaProps == null ? new CaseInsensitiveMap() : metaProps;
        return Collections.unmodifiableMap(ret);
    }
View Full Code Here

        final Map<Long, Object[]> ruleColExecutionValue = new HashMap<>();
        final Map<String, Integer> ruleAxisBindCount = new HashMap<>();
        final Map<RuleMetaKeys, Object> ruleInfo = new CaseInsensitiveMap<>();
        boolean done = false;
        boolean anyRuleAxes = false;
        Map trace = new CaseInsensitiveMap();
        ruleInfo.put(RuleMetaKeys.RULES_EXECUTED, trace);

        try
        {
            while (!done)
            {
                // Step #1 Create coordinate for current counter positions
                final Map<String, Column> coord = new CaseInsensitiveMap<>();
                idCoord.clear();
                List ruleIds = new ArrayList();

                for (final String axisName : axisNames)
                {
                    final List<Column> cols = boundCoordinates.get(axisName);
                    final Column boundColumn = cols.get(counters.get(axisName) - 1);
                    final Axis axis = axisList.get(axisName);

                    if (axis.getType() == AxisType.RULE)
                    {
                        anyRuleAxes = true;
                        Object conditionValue;
                        Object[] ruleValueHolder = ruleColExecutionValue.get(boundColumn.id);
                        if (ruleValueHolder == null)
                        {   // Has the condition on the Rule axis been run this execution?  If not, run it and cache it.
                            CommandCell cmd = (CommandCell) boundColumn.getValue();
                            Map<String, Object> ctx = prepareExecutionContext(validCoord, output);

                            // If the cmd == null, then we are looking at a default column on a rule axis.

                            conditionValue = cmd == null ? isZero(ruleAxisBindCount.get(axisName)) : cmd.execute(ctx);
                            ruleColExecutionValue.put(boundColumn.id, new Object[]{conditionValue});

                            if (didRuleFire(conditionValue))
                            {   // Rule fired
                                Integer count = ruleAxisBindCount.get(axisName);
                                ruleAxisBindCount.put(axisName, count == null ? 1 : count + 1);
                            }
                        }
                        else
                        {   // re-use condition on this rule axis (happens when more than one rule axis on an n-cube)
                            conditionValue = ruleValueHolder[0];
                        }
                        // A rule column on a given axis can be accessed more than once (example: A, B, C on
                        // one rule axis, X, Y, Z on another).  This generates coordinate combinations
                        // (AX, AY, AZ, BX, BY, BZ, CX, CY, CZ).  The condition columns must be run only once, on
                        // subsequent access, the cached result of the condition is used.
                        if (didRuleFire(conditionValue))
                        {
                            coord.put(axisName, boundColumn);
                            idCoord.add(boundColumn);
                            Object ruleId = boundColumn.getMetaProperties().get("name");
                            if (ruleId == null)
                            {
                                ruleId = boundColumn.id;
                            }
                            ruleIds.add(ruleId);
                        }
                    }
                    else
                    {
                        coord.put(axisName, boundColumn);
                        idCoord.add(boundColumn);
                    }
                }

                // Step #2 Execute cell and store return value, associating it to the Axes and Columns it bound to
                if (idCoord.size() == axisNames.length)
                {   // Conditions on rule axes that do not evaluate to true, do not generate complete coordinates (intentionally skipped)
                    T cellValue = getCellById(idCoord, validCoord, output);
                    executedCells.put(coord, cellValue);
                    if (!ruleIds.isEmpty())
                    {   // Record the names (or IDs) of the conditions that fired associated to the executed statements return value
                        trace.put(ruleIds, cellValue);
                    }
                }

                // Step #3 increment counters (variable radix increment)
                done = incrementVariableRadixCount(counters, boundCoordinates, axisNames.length - 1, axisNames);
View Full Code Here

            {
                throw new IllegalArgumentException("JSON format must have a root 'ncube' field containing the String name of the NCube.");
            }
            NCube ncube = new NCube(cubeName);
            ncube.setVersion("file");
            ncube.metaProps = new CaseInsensitiveMap();
            ncube.metaProps.putAll(jsonNCube);
            ncube.metaProps.remove("ncube");
            ncube.metaProps.remove("defaultCellValue");
            ncube.metaProps.remove("defaultCellValueType");
            ncube.metaProps.remove("ruleMode");
View Full Code Here

    /**
     * @return Map (case insensitive keys) containing meta (additional) properties for the n-cube.
     */
    public Map<String, Object> getMetaProperties()
    {
        Map ret = metaProps == null ? new CaseInsensitiveMap() : metaProps;
        return Collections.unmodifiableMap(ret);
    }
View Full Code Here

    /**
     * @return Map (case insensitive keys) containing meta (additional) properties for the n-cube.
     */
    public Map<String, Object> getMetaProperties()
    {
        Map ret = metaProps == null ? new CaseInsensitiveMap() : metaProps;
        return Collections.unmodifiableMap(ret);
    }
View Full Code Here

     */
    public Object setMetaProperty(String key, Object value)
    {
        if (metaProps == null)
        {
            metaProps = new CaseInsensitiveMap();
        }
        return metaProps.put(key, value);
    }
View Full Code Here

TOP

Related Classes of com.cedarsoftware.util.CaseInsensitiveMap$CaseInsensitiveString

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.