Example usage for java.util LinkedHashMap containsKey

List of usage examples for java.util LinkedHashMap containsKey

Introduction

In this page you can find the example usage for java.util LinkedHashMap containsKey.

Prototype

boolean containsKey(Object key);

Source Link

Document

Returns true if this map contains a mapping for the specified key.

Usage

From source file:com.espertech.esper.epl.spec.PatternStreamSpecRaw.java

private static StreamTypeService getStreamTypeService(String engineURI, String statementId,
        EventAdapterService eventAdapterService, Map<String, Pair<EventType, String>> taggedEventTypes,
        Map<String, Pair<EventType, String>> arrayEventTypes, Deque<Integer> subexpressionIdStack,
        String objectType) {//from w  w  w.  ja  v  a2s  .  c  o  m
    LinkedHashMap<String, Pair<EventType, String>> filterTypes = new LinkedHashMap<String, Pair<EventType, String>>();
    filterTypes.putAll(taggedEventTypes);

    // handle array tags (match-until clause)
    if (arrayEventTypes != null) {
        String patternSubexEventType = getPatternSubexEventType(statementId, objectType, subexpressionIdStack);
        EventType arrayTagCompositeEventType = eventAdapterService
                .createSemiAnonymousMapType(patternSubexEventType, new HashMap(), arrayEventTypes, false);
        for (Map.Entry<String, Pair<EventType, String>> entry : arrayEventTypes.entrySet()) {
            String tag = entry.getKey();
            if (!filterTypes.containsKey(tag)) {
                Pair<EventType, String> pair = new Pair<EventType, String>(arrayTagCompositeEventType, tag);
                filterTypes.put(tag, pair);
            }
        }
    }

    return new StreamTypeServiceImpl(filterTypes, engineURI, true, false);
}

From source file:com.qspin.qtaste.ui.tools.FileNode.java

/**
 * Loads the children, caching the results in the children ivar.
 *//*ww  w. j  av  a 2 s.  c  o m*/
public Object[] getChildren() {
    if (children != null) {
        return children;
    }
    if (this.isTestcaseDir()) {
        try {
            ArrayList<TestDataNode> arrayDataNode = new ArrayList<>();
            // load test case data
            File tcDataFile = this.getPythonTestScript().getTestcaseData();
            if (tcDataFile == null) {
                return new Object[] {};
            }
            CSVFile csvDataFile = new CSVFile(tcDataFile);
            List<LinkedHashMap<String, String>> data = csvDataFile.getCSVDataSet();
            Iterator<LinkedHashMap<String, String>> it = data.iterator();
            int rowIndex = 1;
            while (it.hasNext()) {
                LinkedHashMap<String, String> dataRow = it.next();
                if (dataRow.containsKey("COMMENT")) {
                    String comment = dataRow.get("COMMENT");
                    arrayDataNode.add(new TestDataNode(tcDataFile, comment, rowIndex));
                }
                rowIndex++;
            }
            children = arrayDataNode.toArray();
            return children;
        } catch (IOException ex) {
            // unable to read data file

        }

    } else {
        ArrayList<FileNode> arrayFileNode = new ArrayList<>();
        if (f.isDirectory()) {
            File[] childFiles = FileUtilities.listSortedFiles(f);
            for (File childFile : childFiles) {
                FileNode fn = new FileNode(childFile, childFile.getName(), m_TestSuiteDir);
                boolean nodeToAdd = fn.isTestcaseDir();
                if (!fn.isTestcaseDir()) {
                    // go recursilvely to its child and check if it must be added
                    nodeToAdd = checkIfDirectoryContainsTestScriptFile(childFile);
                }
                if (nodeToAdd && !childFile.isHidden()) {

                    arrayFileNode.add(fn);
                }
            }
        }
        children = arrayFileNode.toArray();
    }
    if (children == null) {
        return new Object[] {};
    } else {
        return children;
    }
}

From source file:org.eclipse.php.composer.api.entities.AbstractJsonObject.java

@SuppressWarnings("rawtypes")
protected void parseField(LinkedHashMap json, String property) {
    if (json.containsKey(property)) {
        Field field = getFieldByName(this.getClass(), property);

        if (field != null && JsonEntity.class.isAssignableFrom(field.getType())) {
            try {
                field.setAccessible(true);
                JsonEntity entity = (JsonEntity) field.get(this);
                entity.fromJson(json.get(property));
            } catch (Exception e) {
                log.error(e);/* w  ww. j a va  2 s.  c  o m*/
            }
        }
    }
}

From source file:com.opengamma.analytics.financial.curve.sensitivity.ParameterSensitivity.java

/**
 * Create a copy of the sensitivity and add a given named sensitivity to it. If the name / currency pair is in the map, the two sensitivity matrices are added.
 * Otherwise, a new entry is put into the map
 * @param nameCcy The name and the currency, not null
 * @param sensitivity The sensitivity to add, not null
 * @return The total sensitivity./*from  ww  w  . j a  va 2s.  c  o  m*/
 */
public ParameterSensitivity plus(final Pair<String, Currency> nameCcy, final DoubleMatrix1D sensitivity) {
    ArgumentChecker.notNull(nameCcy, "Name/currency");
    ArgumentChecker.notNull(sensitivity, "Matrix");
    final MatrixAlgebra algebra = MatrixAlgebraFactory.COMMONS_ALGEBRA;
    final LinkedHashMap<Pair<String, Currency>, DoubleMatrix1D> result = new LinkedHashMap<Pair<String, Currency>, DoubleMatrix1D>();
    result.putAll(_sensitivity);
    if (result.containsKey(nameCcy)) {
        result.put(nameCcy, (DoubleMatrix1D) algebra.add(result.get(nameCcy), sensitivity));
    } else {
        result.put(nameCcy, sensitivity);
    }
    return new ParameterSensitivity(result);
}

From source file:org.i3xx.step.uno.impl.service.builtin.ContextPropertiesService.java

/**
 * Reads the key value pairs from a JSON String, 
 * and adds the pairs to the map./*from   w  w w  .  ja v a2s .c om*/
 * 
 * @param json
 * @throws Exception
 */
public void fromJSON(String json) throws Exception {

    Map<String, Object> values = context.getValues();

    GsonBuilder gsonBuilder = new GsonBuilder();
    gsonBuilder.registerTypeAdapter(LinkedHashMap.class, new GsonHashMapDeserializer());
    Gson gson = gsonBuilder.create();

    final Callable rev = new Callable() {
        public Object call(Context cx, Scriptable scope, Scriptable thisObj, Object[] args) {
            //
            // sh, 12.12.2014
            // not really understood what happens, but
            // @see http://stackoverflow.com/questions/10856154/rhino-return-json-from-within-java
            // tested some toJSON/fromJSON sequences with success.
            //
            return args[1];
        }
    };

    Context jscx = Context.getCurrentContext();
    boolean jsf = jscx != null;
    if (!jsf)
        jscx = Context.enter();

    LinkedHashMap<?, ?> map = gson.fromJson(json, LinkedHashMap.class);
    Iterator<?> iter = map.keySet().iterator();
    while (iter.hasNext()) {
        String key = (String) iter.next();
        Object val = map.get(key);

        if (val == null) {
            //values.put(key, null);
        } else if (val instanceof Number) {
            values.put(key, val);
        } else if (val instanceof String) {
            values.put(key, val);
        } else if (val instanceof Map<?, ?>) {
            LinkedHashMap<?, ?> mo2 = (LinkedHashMap<?, ?>) val;
            if (mo2.containsKey("Object")) {
                String stmt = (String) mo2.get("Object");
                if (stmt != null) {
                    Object obj = writeValue(Base64.decodeBase64(stmt));
                    if (obj != null) {
                        values.put(key, obj);
                    } //fi
                } //fi
            } else if (mo2.containsKey("Scriptable")) {
                String stmt = (String) mo2.get("Scriptable");
                if (stmt != null) {
                    Scriptable scope = context.getScope();
                    Object obj = NativeJSON.parse(jscx, scope, stmt, rev);
                    if (obj != null) {
                        values.put(key, obj);
                    } //fi
                } //fi
            } else {
                continue;
            }
        } //fi
    } //while

    if (!jsf)
        Context.exit();
}

From source file:edu.csun.ecs.cs.multitouchj.ui.event.ObjectEventManager.java

protected void handleObjectObserverEvent(ObjectType objectType, ObjectObserverEvent event) {
    if (isRunning()) {
        synchronized (activeObjects) {
            LinkedHashMap<Integer, ObjectObserverEvent> objects = activeObjects.get(objectType);
            // remove is needed to keep its order
            if (objects.containsKey(event.getId())) {
                objects.remove(event.getId());
            }/* w  ww .  j av a 2s.  c  om*/
            objects.put(event.getId(), event);

            setUpdated(true);
        }
    }
}

From source file:org.i3xx.step.uno.impl.service.builtin.ContextAdministrationService.java

/**
 * Reads the key value pairs from a JSON String, clears the existing map
 * and puts the pairs into the map./*from   www.j  a va 2 s. c om*/
 * 
 * @param json
 * @throws Exception
 */
public void fromJSON(String json) throws Exception {

    Map<String, Object> values = context.getValues();
    values.clear();

    GsonBuilder gsonBuilder = new GsonBuilder();
    gsonBuilder.registerTypeAdapter(LinkedHashMap.class, new GsonHashMapDeserializer());
    Gson gson = gsonBuilder.create();

    final Callable rev = new Callable() {
        public Object call(Context cx, Scriptable scope, Scriptable thisObj, Object[] args) {
            //
            // sh, 12.12.2014
            // not really understood what happens, but
            // @see http://stackoverflow.com/questions/10856154/rhino-return-json-from-within-java
            // tested some toJSON/fromJSON sequences with success.
            //
            return args[1];
        }
    };

    Context jscx = Context.getCurrentContext();
    boolean jsf = jscx != null;
    if (!jsf)
        jscx = Context.enter();

    LinkedHashMap<?, ?> map = gson.fromJson(json, LinkedHashMap.class);
    Iterator<?> iter = map.keySet().iterator();
    while (iter.hasNext()) {
        String key = (String) iter.next();
        Object val = map.get(key);

        if (val == null) {
            //values.put(key, null);
        } else if (val instanceof Number) {
            values.put(key, val);
        } else if (val instanceof String) {
            values.put(key, val);
        } else if (val instanceof Map<?, ?>) {
            LinkedHashMap<?, ?> mo2 = (LinkedHashMap<?, ?>) val;
            if (mo2.containsKey("Object")) {
                String stmt = (String) mo2.get("Object");
                if (stmt != null) {
                    Object obj = writeValue(Base64.decodeBase64(stmt));
                    if (obj != null) {
                        values.put(key, obj);
                    } //fi
                } //fi
            } else if (mo2.containsKey("Scriptable")) {
                String stmt = (String) mo2.get("Scriptable");
                if (stmt != null) {
                    Scriptable scope = context.getScope();
                    Object obj = NativeJSON.parse(jscx, scope, stmt, rev);
                    if (obj != null) {
                        values.put(key, obj);
                    } //fi
                } //fi
            } else {
                continue;
            }
        } //fi
    } //while

    if (!jsf)
        Context.exit();
}

From source file:org.eda.fpsrv.StrTable.java

public void setFromJSONString(String jsonString) {
    LinkedHashMap<String, String> h_map;
    try {//from   w  w w .  j a  va  2s.c  o m

        h_map = new ObjectMapper().readValue(jsonString, new TypeReference<LinkedHashMap<String, Object>>() {
        });
        FPProperty property;
        for (String key : keySet()) {
            if (h_map.containsKey(key)) {
                put(key, h_map.get(key));
            }
        }
    } catch (IOException ex) {
        Logger.getLogger(StrTable.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:ca.sfu.federation.model.InputTable.java

/**
 * Get Input by name./*ww w  . ja va  2 s  .com*/
 * @return Input
 */
public Input getInput(String Name) {
    // init
    Input result = null;
    // if the named Input exists in the table
    LinkedHashMap index = this.getInputIndex();
    if (index.containsKey(Name)) {
        result = (Input) index.get(Name);
    }
    // return result
    return result;
}

From source file:ca.sfu.federation.model.InputTable.java

/**
 * Determine if the InputTable contains the named Input.
 * @return True if the input table contains the named property, false otherwise.
 *//*from  ww w .ja  v  a 2 s .  com*/
public boolean hasInput(String PropertyName) {
    // init
    boolean result = false;
    // check if index contains propertyname
    LinkedHashMap index = this.getInputIndex();
    if (index.containsKey(PropertyName)) {
        result = true;
    }
    // return result
    return result;
}