Example usage for java.util LinkedHashMap put

List of usage examples for java.util LinkedHashMap put

Introduction

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

Prototype

V put(K key, V value);

Source Link

Document

Associates the specified value with the specified key in this map (optional operation).

Usage

From source file:com.opengamma.analytics.math.interpolation.data.Interpolator1DDataBundleBuilderFunction.java

@Override
public LinkedHashMap<String, Interpolator1DDataBundle> evaluate(final DoubleMatrix1D x) {
    Validate.notNull(x, "null data x");
    Validate.isTrue(_nNodes == x.getNumberOfElements(), "x wrong length");

    final LinkedHashMap<String, Interpolator1DDataBundle> res = new LinkedHashMap<String, Interpolator1DDataBundle>();
    int index = 0;

    for (final String name : _interpolators.keySet()) {
        final Interpolator1D interpolator = _interpolators.get(name);
        final double[] nodes = _knotPoints.get(name);
        final double[] values = Arrays.copyOfRange(x.getData(), index, index + nodes.length);
        index += nodes.length;//  w  w  w  . j  a  v a  2s . c o m
        final Interpolator1DDataBundle db = interpolator.getDataBundleFromSortedArrays(nodes, values);
        res.put(name, db);
    }

    return res;
}

From source file:com.skysql.manager.api.Monitors.java

public Monitors deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
        throws JsonParseException, NullPointerException {
    Monitors monitors = new Monitors();

    JsonArray array = null;//  w  w w.ja v  a  2  s.com
    JsonObject object = null;

    if (json.getAsJsonObject().has("monitorclasses")) {
        JsonElement monitorsElement = json.getAsJsonObject().get("monitorclasses");
        if (monitorsElement.isJsonArray()) {
            array = monitorsElement.getAsJsonArray();
        } else {
            object = monitorsElement.getAsJsonObject();
        }
    } else if (json.getAsJsonObject().has("monitorclass")) {
        array = json.getAsJsonObject().get("monitorclass").getAsJsonArray();
    } else {
        monitors.setMonitorsMap(null);
        return monitors;
    }

    LinkedHashMap<String, LinkedHashMap<String, MonitorRecord>> monitorsMap = new LinkedHashMap<String, LinkedHashMap<String, MonitorRecord>>();
    monitors.setMonitorsMap(monitorsMap);
    for (String type : SystemTypes.getList().keySet()) {
        monitorsMap.put(type, new LinkedHashMap<String, MonitorRecord>());
    }

    if (array != null) {
        parseMonitors(array, monitorsMap);
    } else {
        for (String type : SystemTypes.getList().keySet()) {
            array = object.get(type).getAsJsonArray();
            parseMonitors(array, monitorsMap);
        }
    }

    return monitors;
}

From source file:jp.or.openid.eiwg.scim.servlet.ResourceTypes.java

/**
 * GET?//from   w  w w .j  av  a  2s. c o  m
 *
 * @param request 
 * @param response ?
 * @throws ServletException
 * @throws IOException
 */
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    // ?
    ServletContext context = getServletContext();

    // ??
    Operation op = new Operation();
    boolean result = op.Authentication(context, request);

    if (!result) {
        // 
        errorResponse(response, op.getErrorCode(), op.getErrorType(), op.getErrorMessage());
    } else {
        // location?URL?
        String location = request.getScheme() + "://" + request.getServerName();
        int serverPort = request.getServerPort();
        if (serverPort != 80 && serverPort != 443) {
            location += ":" + Integer.toString(serverPort);
        }
        location += request.getContextPath();

        // ?
        @SuppressWarnings("unchecked")
        ArrayList<LinkedHashMap<String, Object>> resourceTypes = (ArrayList<LinkedHashMap<String, Object>>) context
                .getAttribute("ResourceTypes");

        // location?
        Iterator<LinkedHashMap<String, Object>> resourceTypesIt = resourceTypes.iterator();
        while (resourceTypesIt.hasNext()) {
            LinkedHashMap<String, Object> resourceTypeInfo = resourceTypesIt.next();
            // meta?
            Object metaObject = SCIMUtil.getAttribute(resourceTypeInfo, "meta");
            if (metaObject != null && metaObject instanceof LinkedHashMap) {
                @SuppressWarnings("unchecked")
                LinkedHashMap<String, Object> metaInfo = (LinkedHashMap<String, Object>) metaObject;
                Object locationInfo = SCIMUtil.getAttribute(metaInfo, "location");
                if (locationInfo != null && locationInfo instanceof String) {
                    String locationValue = String.format(locationInfo.toString(), location);
                    metaInfo.put("location", locationValue);
                    resourceTypeInfo.put("meta", metaInfo);
                }
            }
        }

        try {
            // javaJSON??
            ObjectMapper mapper = new ObjectMapper();
            StringWriter writer = new StringWriter();
            mapper.writeValue(writer, resourceTypes);

            // ??
            String listResponse = "{\"schemas\":[\"urn:ietf:params:scim:api:messages:2.0:ListResponse\"],";
            listResponse += "\"totalResults\":" + resourceTypes.size();
            if (resourceTypes.size() > 0) {
                listResponse += ",\"Resources\":";
                listResponse += writer.toString();
            }
            listResponse += "}";

            response.setContentType("application/scim+json;charset=UTF-8");
            PrintWriter out = response.getWriter();
            out.println(listResponse);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}

From source file:jp.or.openid.eiwg.scim.servlet.Schemas.java

/**
 * GET?/*www .  j av  a 2  s . co m*/
 *
 * @param request 
 * @param response ?
 * @throws ServletException
 * @throws IOException
 */
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    // ?
    ServletContext context = getServletContext();

    // ??
    Operation op = new Operation();
    boolean result = op.Authentication(context, request);

    if (!result) {
        // 
        errorResponse(response, op.getErrorCode(), op.getErrorType(), op.getErrorMessage());
    } else {
        // location?URL?
        String location = request.getScheme() + "://" + request.getServerName();
        int serverPort = request.getServerPort();
        if (serverPort != 80 && serverPort != 443) {
            location += ":" + Integer.toString(serverPort);
        }
        location += request.getContextPath();

        // ?
        @SuppressWarnings("unchecked")
        ArrayList<LinkedHashMap<String, Object>> schemas = (ArrayList<LinkedHashMap<String, Object>>) context
                .getAttribute("Schemas");

        // location?
        Iterator<LinkedHashMap<String, Object>> schemasIt = schemas.iterator();
        while (schemasIt.hasNext()) {
            LinkedHashMap<String, Object> schemaInfo = schemasIt.next();
            // meta?
            Object metaObject = SCIMUtil.getAttribute(schemaInfo, "meta");
            if (metaObject != null && metaObject instanceof LinkedHashMap) {
                @SuppressWarnings("unchecked")
                LinkedHashMap<String, Object> metaInfo = (LinkedHashMap<String, Object>) metaObject;
                Object locationInfo = SCIMUtil.getAttribute(metaInfo, "location");
                if (locationInfo != null && locationInfo instanceof String) {
                    String locationValue = String.format(locationInfo.toString(), location);
                    metaInfo.put("location", locationValue);
                    schemaInfo.put("meta", metaInfo);
                }
            }
        }

        try {
            // javaJSON??
            ObjectMapper mapper = new ObjectMapper();
            StringWriter writer = new StringWriter();
            mapper.writeValue(writer, schemas);

            // ??
            String listResponse = "{\"schemas\":[\"urn:ietf:params:scim:api:messages:2.0:ListResponse\"],";
            listResponse += "\"totalResults\":" + schemas.size();
            if (schemas.size() > 0) {
                listResponse += ",\"Resources\":";
                listResponse += writer.toString();
            }
            listResponse += "}";

            response.setContentType("application/scim+json;charset=UTF-8");
            PrintWriter out = response.getWriter();
            out.println(listResponse);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}

From source file:com.itemanalysis.psychometrics.irt.equating.MeanSigmaMethodTest.java

@Test
public void mixedFormtRaschPCMTest() {
    System.out.println("Mixed format mean/sigma test: Rasch and PCM");

    LinkedHashMap<String, ItemResponseModel> itemFormX = new LinkedHashMap<String, ItemResponseModel>();
    LinkedHashMap<String, ItemResponseModel> itemFormY = new LinkedHashMap<String, ItemResponseModel>();

    itemFormX.put("Item1", new Irm3PL(1.0, -3.188047976, 0.0, 1.7));
    itemFormX.put("Item2", new Irm3PL(1.0, 1.031760328, 0.0, 1.7));
    itemFormX.put("Item3", new Irm3PL(1.0, 0.819040914, 0.0, 1.7));
    itemFormX.put("Item4", new Irm3PL(1.0, -2.706947360, 0.0, 1.7));
    itemFormX.put("Item5", new Irm3PL(1.0, -0.094527077, 0.0, 1.7));
    itemFormX.put("Item6", new Irm3PL(1.0, 0.689697135, 0.0, 1.7));
    itemFormX.put("Item7", new Irm3PL(1.0, -0.551837153, 0.0, 1.7));
    itemFormX.put("Item8", new Irm3PL(1.0, -0.359559276, 0.0, 1.7));
    double[] step1x = { -0.146619694, -0.636399040, 0.783018734 };
    itemFormX.put("Item9", new IrmPCM(-1.451470831, step1x, 1.0));

    itemFormY.put("Item1", new Irm3PL(1.0, -3.074599226, 0.0, 1.7));
    itemFormY.put("Item2", new Irm3PL(1.0, 1.012824350, 0.0, 1.7));
    itemFormY.put("Item3", new Irm3PL(1.0, 0.868538408, 0.0, 1.7));
    itemFormY.put("Item4", new Irm3PL(1.0, -2.404483603, 0.0, 1.7));
    itemFormY.put("Item5", new Irm3PL(1.0, 0.037402866, 0.0, 1.7));
    itemFormY.put("Item6", new Irm3PL(1.0, 0.700747420, 0.0, 1.7));
    itemFormY.put("Item7", new Irm3PL(1.0, -0.602555046, 0.0, 1.7));
    itemFormY.put("Item8", new Irm3PL(1.0, -0.350426446, 0.0, 1.7));
    double[] step1y = { -0.185885988, -0.61535623, 0.801242218 };
    itemFormY.put("Item9", new IrmPCM(-1.267744832, step1y, 1.0));

    MeanSigmaMethod meanSigmaMethod = new MeanSigmaMethod(itemFormX, itemFormY, true);
    meanSigmaMethod.setPrecision(6);//from   w  w  w.  ja  v a2  s. c o  m
    double B = meanSigmaMethod.getIntercept();
    double A = meanSigmaMethod.getScale();

    //        System.out.println("Slope: " + A);
    //        System.out.println("Intercept: " + B);

    assertEquals("Mean/sigma slope test", 0.950133, A, 1e-6);
    assertEquals("Mean/sigma intercept test", 0.060406, B, 1e-6);

}

From source file:org.n52.sensorweb.series.policy.editor.ctrl.SimplePermissionEditorController.java

/**
 * @param permissionSetName/* ww w.j a  v a 2  s  . c  o m*/
 *        whose permission is to be fetched
 * @param permissionName
 *        the permission to be edited
 * @return permission
 */
@RequestMapping(value = "/edit/{permissionSetName}/{permissionName}", method = RequestMethod.GET)
public ModelAndView editPermission(@PathVariable String permissionSetName, @PathVariable String permissionName,
        HttpServletRequest request) {
    ModelAndView mav = new ModelAndView("createPermission");
    PermissionSet permissionSet = simplePermissionService.getPermissionSet(permissionSetName);
    Permission permission = simplePermissionService.getPermission(permissionSetName, permissionName);
    if (permissionSet == null) {
        throw new ResourceNotFoundException(
                "No permissionSet '" + permissionSetName + "' with permission '" + permissionName + "'");
    }
    if (permission == null) {
        throw new ResourceNotFoundException(
                "No permission '" + permissionName + "' under permission set '" + permissionSetName + "'");
    }

    /*
     * Added because Subject field will need user roles defined in user database
     */
    mav.addObject("users", userService.getConfiguredUsers());
    mav.addObject(permission);

    /* for page titles */
    mav.addObject("pageTitle", "Modify Permission");
    mav.addObject("heading", "Modify " + permissionName);

    /* preparing the timeseries parameters */
    Map<String, String> queryParameters = new HashMap<String, String>();
    EnforcementPoint enforcementPoint = getEnforcementPoint(permissionSet.getActionDomains().get(0));
    queryParameters.put("service", enforcementPoint.getId());
    IoParameters query = IoParameters.createFromQuery(queryParameters);

    OfferingOutput[] offerings = parameterServiceProvider.getOfferingsService().getCondensedParameters(query);
    ProcedureOutput[] procedures = parameterServiceProvider.getProceduresService()
            .getCondensedParameters(query);
    FeatureOutput[] featuresOfInterest = parameterServiceProvider.getFeaturesService()
            .getCondensedParameters(query);
    PhenomenonOutput[] phenomenon = parameterServiceProvider.getPhenomenaService()
            .getCondensedParameters(query);

    /* These are the total exhaustive values */
    mav.addObject("offerings", offerings);
    mav.addObject("procedures", procedures);
    mav.addObject("featuresOfInterest", featuresOfInterest);
    mav.addObject("phenomenon", phenomenon);
    mav.addObject("actionValues", ActionValues.getActionValues());

    /* easing the load of the jsps, anyways they also execute on the server only */
    List<String> selectedProcedures = new ArrayList<String>();
    List<String> selectedOfferings = new ArrayList<String>();
    List<String> selectedObservedProperties = new ArrayList<String>();
    List<String> selectedFeaturesOfInterest = new ArrayList<String>();

    for (TargetValue tv : permission.getResources()) {
        String[] resource = tv.getValue().split("/");

        if (resource[0].equals("procedures")) {
            selectedProcedures.add(tv.getValue());
        } else if (resource[0].equals("offerings")) {
            selectedOfferings.add(tv.getValue());
        } else if (resource[0].equals("featuresOfInterest")) {
            selectedFeaturesOfInterest.add(tv.getValue());
        } else if (resource[0].equals("observedProperties")) {
            selectedObservedProperties.add(tv.getValue());
        }
    }

    mav.addObject("selectedProcedures", selectedProcedures);
    mav.addObject("selectedOfferings", selectedOfferings);
    mav.addObject("selectedObservedProperties", selectedObservedProperties);
    mav.addObject("selectedFeaturesOfInterest", selectedFeaturesOfInterest);

    /* For the breadcrumb */
    LinkedHashMap<String, String> breadCrumb = new LinkedHashMap<String, String>();
    breadCrumb.put("Manager", request.getContextPath() + "/editor/");
    breadCrumb.put("Permission Set", request.getContextPath() + "/editor/edit/" + permissionSetName);
    breadCrumb.put("Permission",
            request.getContextPath() + "/editor/edit/" + permissionSetName + "/" + permissionName);
    mav.addObject("breadCrumb", breadCrumb);

    /* Addded to see whether the user is attempting to save a permission for an existent permission set */
    mav.addObject("permissionSet", permissionSetName);
    mav.addObject("context", "modify");

    return mav;
}

From source file:com.streamsets.pipeline.stage.lib.hive.HiveQueryExecutor.java

/**
 * Returns {@link Set} of partitions//from  w  w w  .ja v  a 2s. c  o m
 * @param qualifiedTableName qualified table name
 * @return {@link Set} of partitions
 * @throws StageException in case of any {@link SQLException}
 */
public Set<LinkedHashMap<String, String>> executeShowPartitionsQuery(String qualifiedTableName)
        throws StageException {
    String sql = buildShowPartitionsQuery(qualifiedTableName);
    Set<LinkedHashMap<String, String>> partitionInfoSet = new HashSet<>();
    LOG.debug("Executing SQL:", sql);
    Statement statement = null;
    try (Connection con = DriverManager.getConnection(jdbcUrl)) {
        statement = con.createStatement();
        ResultSet rs = statement.executeQuery(sql);
        while (rs.next()) {
            String partitionInfoString = rs.getString(1);
            String[] partitionInfoSplit = partitionInfoString.split(HiveMetastoreUtil.SEP);
            LinkedHashMap<String, String> vals = new LinkedHashMap<>();
            for (String partitionValInfo : partitionInfoSplit) {
                String[] partitionNameVal = partitionValInfo.split("=");
                vals.put(partitionNameVal[0], partitionNameVal[1]);
            }
            partitionInfoSet.add(vals);
        }
        return partitionInfoSet;
    } catch (SQLException e) {
        LOG.error("SQL Exception happened when adding partition", e);
        throw new StageException(Errors.HIVE_20, sql, e.getMessage());
    } finally {
        closeStatement(statement);
    }
}

From source file:com.sillelien.dollar.api.types.DollarMap.java

@NotNull
private LinkedHashMap<var, var> deepClone(@NotNull LinkedHashMap<var, var> o) {
    LinkedHashMap<var, var> result = new LinkedHashMap<>();
    for (Map.Entry<var, var> entry : o.entrySet()) {
        result.put(entry.getKey(), entry.getValue());
    }/*from   w  ww.ja va2s  .  com*/
    return result;
}

From source file:com.redhat.example.rules.unittest.CsvTestHelper.java

private static Map<String, Boolean> createTestSkipMap(List<CsvColumnDef> columnDefs) {
    LinkedHashMap<String, Boolean> ret = new LinkedHashMap<String, Boolean>();
    for (CsvColumnDef columnDef : columnDefs) {
        Boolean isTestSkip = columnDef.getTestSkip() != null && columnDef.getTestSkip() == Boolean.TRUE;
        ret.put(columnDef.getColumnName(), isTestSkip);
    }/*from  w ww  .j a v a 2  s . c  o  m*/
    return ret;
}

From source file:org.jutge.joc.porra.controller.base.BetController.java

@EntityStashManaged(entities = EntityStashEntityModule.ALL, views = EntityStashViewModule.NONE)
@SuppressWarnings({ "rawtypes", "unchecked" })
@RequestMapping(value = "/usuari/fer-aposta", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody LinkedHashMap makeABet(@RequestBody final LinkedHashMap map, final EntityStash entityStash,
        final HttpServletRequest request, final Locale locale) {
    this.logger.info("BetController.makeABet");
    final LinkedHashMap response = new LinkedHashMap();
    try {//from   w ww .  ja  v  a  2 s.  c  o m
        final Bet bet = this.createBetInstance(map, entityStash, locale);
        this.betService.createBet(bet, entityStash);
        this.createResponse(response, entityStash, locale);
    } catch (final BetException exception) {
        response.put("errors", exception.getErrorMessages());
    }
    return response;
}