Refine search
private HashMap<String,String> getPOSFeatures(String word, String pos) { HashMap<String, String> features = new HashMap<>(); String wordPos = word.toLowerCase() + '_' + pos; if (wordPosFeatureMap.containsKey(wordPos)) { features.putAll(wordPosFeatureMap.get(wordPos)); } else if (posFeatureMap.containsKey(pos)) { features.putAll(posFeatureMap.get(pos)); } if (isOrdinal(word, pos)) { features.put("NumType", "Ord"); } if (isMultiplicative(word, pos)) { features.put("NumType", "Mult"); } return features; }
public static Response buildMessage(int httpCode, Map<String, Object> params, String msg) { HashMap<String, Object> err = new HashMap<String, Object>(); err.put("error", msg); if (params != null) err.putAll(params); String json = "\"error\""; try { json = new ObjectMapper().writeValueAsString(err); } catch (IOException e) { } return Response.status(httpCode) .entity(json) .type(MediaType.APPLICATION_JSON) .build(); } }
@Override protected void merge(HashMap<Value, Integer> in1, HashMap<Value, Integer> in2, HashMap<Value, Integer> out) { // Copy over in1. This will be the baseline out.putAll(in1); // Merge in in2. Make sure that we do not have ambiguous values. for (Value val : in2.keySet()) { Integer i1 = in1.get(val); Integer i2 = in2.get(val); if (i2.equals(i1)) { out.put(val, i2); } else { throw new RuntimeException("Merge of different IDs not supported"); } } } }
public static String createJsonResponse(final String status, final String message, final String action, final Map<String, Object> params) { final HashMap<String, Object> response = new HashMap<>(); response.put("status", status); if (message != null) { response.put("message", message); } if (action != null) { response.put("action", action); } if (params != null) { response.putAll(params); } return JSONUtils.toJSON(response); }
@Override @SuppressWarnings("unchecked") public void initialize(Subject subject, CallbackHandler callbackHandler, Map<String, ?> sharedState, Map<String, ?> options) { addValidOptions(ALL_VALID_OPTIONS); this.realm = options.containsKey(REALM_OPTION) ? (String) options.get(REALM_OPTION) : DEFAULT_REALM; HashMap map = new HashMap(options); map.putAll(options); map.put("hashAlgorithm", "REALM"); map.put("hashStorePassword", "false"); super.initialize(subject, callbackHandler, sharedState, map); }
protected Map<String, Object> collectTransientVariables(HashMap<String, Object> variables) { VariableScopeImpl parentScope = getParentVariableScope(); if (parentScope != null) { variables.putAll(parentScope.collectVariables(variables)); } if (transientVariabes != null) { for (String variableName : transientVariabes.keySet()) { variables.put(variableName, transientVariabes.get(variableName).getValue()); } } return variables; }
/** * Build the environment used for all exec calls. * * @return The environment variables. */ public Map<String, String> execEnv(Map<String, String> env) { HashMap<String, String> res = new HashMap<String, String>(); for (String key : appConf.getStrings(AppConfig.EXEC_ENVS_NAME)) { String val = System.getenv(key); if (val != null) { res.put(key, val); } } if (env != null) res.putAll(env); for (Map.Entry<String, String> envs : res.entrySet()) { LOG.info("Env " + envs.getKey() + "=" + envs.getValue()); } return res; }
/** * <p>Get {@link Node} of the specific origin. Usually the origin is the Service Consumer's app name.</p> * <p>If the origin node for given origin is absent, then a new {@link StatisticNode} * for the origin will be created and returned.</p> * * @param origin The caller's name, which is designated in the {@code parameter} parameter * {@link ContextUtil#enter(String name, String origin)}. * @return the {@link Node} of the specific origin */ public Node getOrCreateOriginNode(String origin) { StatisticNode statisticNode = originCountMap.get(origin); if (statisticNode == null) { try { lock.lock(); statisticNode = originCountMap.get(origin); if (statisticNode == null) { // The node is absent, create a new node for the origin. statisticNode = new StatisticNode(); HashMap<String, StatisticNode> newMap = new HashMap<String, StatisticNode>( originCountMap.size() + 1); newMap.putAll(originCountMap); newMap.put(origin, statisticNode); originCountMap = newMap; } } finally { lock.unlock(); } } return statisticNode; }
protected Map<String, VariableInstance> collectVariableInstances(HashMap<String, VariableInstance> variables) { ensureVariableInstancesInitialized(); VariableScopeImpl parentScope = getParentVariableScope(); if (parentScope != null) { variables.putAll(parentScope.collectVariableInstances(variables)); } for (VariableInstance variableInstance : variableInstances.values()) { variables.put(variableInstance.getName(), variableInstance); } for (String variableName : usedVariablesCache.keySet()) { variables.put(variableName, usedVariablesCache.get(variableName)); } if (transientVariabes != null) { variables.putAll(transientVariabes); } return variables; }
/** * Update session meta data information and get the information in a map. * * @return a map containing the session meta data */ HashMap<String, Object> getInfo() { HashMap<String, Object> m = new HashMap<>(map.size() + 5); m.putAll(map); m.put("lastAccess", new Timestamp(lastAccess).toString()); try { m.put("url", conn == null ? "${text.admin.notConnected}" : conn.getMetaData().getURL()); m.put("user", conn == null ? "-" : conn.getMetaData().getUserName()); m.put("lastQuery", commandHistory.isEmpty() ? "" : commandHistory.get(0)); m.put("executing", executingStatement == null ? "${text.admin.no}" : "${text.admin.yes}"); } catch (SQLException e) { DbException.traceThrowable(e); } return m; }
@Override public HashMap<Integer, T_Sess> loadAllRawSessionsOf(OmemoDevice userDevice, BareJid contact) { HashMap<Integer, T_Sess> sessions = getCache(userDevice).sessions.get(contact); if (sessions == null) { sessions = new HashMap<>(); getCache(userDevice).sessions.put(contact, sessions); } if (sessions.isEmpty() && persistent != null) { sessions.putAll(persistent.loadAllRawSessionsOf(userDevice, contact)); } return new HashMap<>(sessions); }
protected void onlyReturnedFields(Map<String, Object> fieldsMap, List<Field> required,boolean allRequired) { HashMap<String,Object> filteredMap = new HashMap<>(); if(allFieldsReturn || allRequired) { filteredMap.putAll(fieldsMap); return; } for(Field field: required){ String name = field.getName(); String returnName = name; String alias = field.getAlias(); if(alias !=null && alias !=""){ returnName = alias; aliasesOnReturn.add(alias); } filteredMap.put(returnName, deepSearchInMap(fieldsMap, name)); } fieldsMap.clear(); fieldsMap.putAll(filteredMap); }
public String[][] getHeaders(Object value, Operation operation) throws ServiceException { Response delegate = (Response) value; HashMap map = new HashMap(); if (delegate.getContentDisposition() != null) { map.put("Content-Disposition", delegate.getContentDisposition()); } HashMap m = delegate.getResponseHeaders(); if (m != null && !m.isEmpty()) { map.putAll(m); } if (map == null || map.isEmpty()) return null; String[][] headers = new String[map.size()][2]; List keys = new ArrayList(map.keySet()); for (int i = 0; i < headers.length; i++) { headers[i][0] = (String) keys.get(i); headers[i][1] = (String) map.get(keys.get(i)); } return headers; }
protected void flowThrough(HashMap<Local, Set<NewExpr>> in, Unit unit, HashMap<Local, Set<NewExpr>> out) { Stmt s = (Stmt) unit; out.clear(); out.putAll(in); if (s instanceof DefinitionStmt) { DefinitionStmt ds = (DefinitionStmt) s; Value lhs = ds.getLeftOp(); Value rhs = ds.getRightOp(); if (lhs instanceof Local) { HashSet<NewExpr> lv = new HashSet<NewExpr>(); out.put((Local) lhs, lv); if (rhs instanceof NewExpr) { lv.add((NewExpr) rhs); } else if (rhs instanceof Local) { lv.addAll(in.get(rhs)); } else { lv.add(UNKNOWN); } } } }
@AssistedInject public MessageCountAlertCondition(Searches searches, @Assisted Stream stream, @Nullable @Assisted("id") String id, @Assisted DateTime createdAt, @Assisted("userid") String creatorUserId, @Assisted Map<String, Object> parameters, @Nullable @Assisted("title") String title) { super(stream, id, Type.MESSAGE_COUNT.toString(), createdAt, creatorUserId, parameters, title); this.searches = searches; this.time = Tools.getNumber(parameters.get("time"), 5).intValue(); final String thresholdType = (String) parameters.get("threshold_type"); final String upperCaseThresholdType = thresholdType.toUpperCase(Locale.ENGLISH); /* * Alert conditions created before 2.2.0 had a threshold_type parameter in lowercase, but this was * inconsistent with the parameters in FieldValueAlertCondition, which were always stored in uppercase. * To ensure we return the expected case in the API and also store the right case in the database, we * are converting the parameter to uppercase here, if it wasn't uppercase already. */ if (!thresholdType.equals(upperCaseThresholdType)) { final HashMap<String, Object> updatedParameters = new HashMap<>(); updatedParameters.putAll(parameters); updatedParameters.put("threshold_type", upperCaseThresholdType); super.setParameters(updatedParameters); } this.thresholdType = ThresholdType.valueOf(upperCaseThresholdType); this.threshold = Tools.getNumber(parameters.get("threshold"), 0).intValue(); this.query = (String) parameters.getOrDefault(CK_QUERY, CK_QUERY_DEFAULT_VALUE); }
private static Map<String, Type> collectTypeVariableLookup(Type type) { HashMap<String, Type> vars = new HashMap<String, Type>(); if (null == type) { return vars; } if (type instanceof ParameterizedType) { ParameterizedType pType = (ParameterizedType) type; Type[] actualTypeArguments = pType.getActualTypeArguments(); Class clazz = (Class) pType.getRawType(); for (int i = 0; i < clazz.getTypeParameters().length; i++) { TypeVariable variable = clazz.getTypeParameters()[i]; vars.put(variable.getName() + "@" + clazz.getCanonicalName(), actualTypeArguments[i]); } vars.putAll(collectTypeVariableLookup(clazz.getGenericSuperclass())); return vars; } if (type instanceof Class) { Class clazz = (Class) type; vars.putAll(collectTypeVariableLookup(clazz.getGenericSuperclass())); return vars; } if (type instanceof WildcardType) { return vars; } throw new JsonException("unexpected type: " + type); }
@Nullable private HashMap<Character, Mark> getAllFileMarks(@NotNull final Document doc) { VirtualFile vf = FileDocumentManager.getInstance().getFile(doc); if (vf == null) { return null; } HashMap<Character, Mark> res = new HashMap<>(); FileMarks<Character, Mark> fileMarks = getFileMarks(doc); if (fileMarks != null) { res.putAll(fileMarks); } for (Character ch : globalMarks.keySet()) { Mark mark = globalMarks.get(ch); if (vf.getPath().equals(mark.getFilename())) { res.put(ch, mark); } } return res; }