Example usage for java.util HashMap get

List of usage examples for java.util HashMap get

Introduction

In this page you can find the example usage for java.util HashMap get.

Prototype

public V get(Object key) 

Source Link

Document

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

Usage

From source file:com.gst.integrationtests.common.CenterHelper.java

public static int[] associateGroups(final int id, final int[] groupMembers,
        final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
    final String ASSOCIATE_GROUP_CENTER_URL = CENTERS_URL + "/" + id + "?command=associateGroups&"
            + Utils.TENANT_IDENTIFIER;// w ww . j  a v  a2s  . co  m
    HashMap groupMemberHashMap = new HashMap();
    groupMemberHashMap.put("groupMembers", groupMembers);
    System.out.println("---------------------------------ASSOCIATING GROUPS AT " + id
            + "--------------------------------------------");
    HashMap hash = Utils.performServerPost(requestSpec, responseSpec, ASSOCIATE_GROUP_CENTER_URL,
            new Gson().toJson(groupMemberHashMap), "changes");
    System.out.println(hash);
    ArrayList<String> arr = (ArrayList<String>) hash.get("groupMembers");
    int[] ret = new int[arr.size()];
    for (int i = 0; i < ret.length; i++) {
        ret[i] = Integer.parseInt(arr.get(i));
    }
    return ret;
}

From source file:es.pode.soporte.auditoria.registrar.Registrar.java

/**
 * A partir de los datos enviados se recupera la 
 * @param valores Son los datos interceptados
 * @return tipoBusqueda El tipo de bsqueda realizado
 *               /* www  .ja v  a2 s. c om*/
 */
private static String getAmbito(HashMap valores) {

    String numPagina = (String) valores.get(RegistroCtes.PARAMETRO_ORIGEN_PAGINA);
    String comunidadesSeleccionadas = (String) valores.get(RegistroCtes.PARAMETRO_COMUNIDADES);
    String ambito = null;

    if (numPagina == null || RegistroCtes.BUSCAR_PAGINA1.equals(numPagina))
        log("Pagina inicial. Se registra");
    else {
        /* No registramos las paginaciones */
        log("Pagina no inicial paginacin: " + numPagina + " no se registra");
        return VACIO;
    }

    if (comunidadesSeleccionadas != null)
        ambito = RegistroCtes.BUSQUEDA_FEDERADA;
    else
        ambito = RegistroCtes.BUSQUEDA_LOCAL;

    log("Ambito bsqueda: " + ambito);

    return ambito;
}

From source file:com.austin.base.commons.util.StringUtil.java

/**
 * @param map ?HashMap//  w  w  w  . j  av a  2 s  .  co m
 * @return ??
 */
public static String makeParamter(HashMap map) {
    StringBuilder sb = new StringBuilder();
    String result = null;
    java.util.Iterator iterator = map.keySet().iterator();
    String key = null;
    Object obj = null;
    boolean flag = iterator.hasNext();
    while (iterator.hasNext()) {
        key = iterator.next().toString();
        log.info("?Mapkey" + key);
        obj = map.get(key);
        log.info("?MapValue" + obj);
        if (obj == null) {
            obj = "";
        }
        sb.append(key);
        sb.append("=");
        sb.append(obj.toString());
        sb.append("&");
    }
    result = sb.toString();
    if (flag) {
        result = result.substring(0, result.length() - 1);
    }
    log.info("HashMap??" + result);
    return result;
}

From source file:es.pode.soporte.auditoria.registrar.Registrar.java

/**
 * En funcin del tipo de bsqueda el valor que hay que interceptar es distinto
 * Busqueda normal son las palabrasClave
 * Bsqueda arbol curricular es el areaCurricular
 * Bsqueda por tesauro es idTesauro//from ww  w .  ja  v a 2  s. c  o m
 * @param valores Son los datos interceptados
 * @return valorBuscado El tipo de bsqueda realizado
 *               
 */
private static String getValorBuscado(HashMap valores) {

    String palabrasClave = (String) valores.get(RegistroCtes.PARAMETRO_PALABRAS_CLAVE);
    String areaCurricular = (String) valores.get(RegistroCtes.PARAMETRO_AREACURRICULAR);
    String tesauro = (String) valores.get(RegistroCtes.PARAMETRO_TESAURO);
    String valorBuscado = null;

    if (palabrasClave != null && !palabrasClave.equals(""))
        valorBuscado = palabrasClave;
    else if (areaCurricular != null && !areaCurricular.equals(""))
        valorBuscado = areaCurricular;
    else if (tesauro != null && !tesauro.equals(""))
        valorBuscado = tesauro;
    else
        valorBuscado = VACIO;

    log("Valor buscado: " + valorBuscado);

    return valorBuscado;
}

From source file:es.pode.soporte.auditoria.registrar.Registrar.java

/**
 * A partir de los datos enviados se recupera el tipo de bsqueda avanzada, simple, rbol curricular y tesauro
 * @param valores Son los datos interceptados
 * @return tipo El tipo de bsqueda realizado
 *               //from  w w w  .  j  av  a 2 s.c  o m
 */
private static String getTipoBusqueda(HashMap valores) {

    String tipoBusqueda = (String) valores.get(RegistroCtes.PARAMETRO_TIPO_BUSQUEDA);
    String tipo = null;

    if (tipoBusqueda == null)
        tipo = RegistroCtes.ENVIO_BUSQUEDA_NORMAL; // Por defecto se considera nulo
    else if (tipoBusqueda.equals(RegistroCtes.VALORES_BUSCAR_SIMPLE))
        tipo = RegistroCtes.ENVIO_BUSQUEDA_NORMAL;
    else if (tipoBusqueda.equals(RegistroCtes.VALORES_BUSCAR_AVANZADO))
        tipo = RegistroCtes.ENVIO_BUSQUEDA_AVANZADA;
    else if (tipoBusqueda.equals(RegistroCtes.VALORES_BUSCAR_ARBOLCURRICULAR))
        tipo = RegistroCtes.ENVIO_BUSQUEDA_AREACURRICULAR;
    else if (tipoBusqueda.equals(RegistroCtes.VALORES_BUSCAR_TESAURO))
        tipo = RegistroCtes.ENVIO_BUSQUEDA_TESAURO;
    else
        tipo = RegistroCtes.ENVIO_BUSQUEDA_NORMAL; // Por defecto se considera nulo

    log("Tipo de bsqueda a realizar: " + tipo);

    return tipo;
}

From source file:foam.zizim.android.net.BoskoiHttpClient.java

public static boolean PostFileUpload(String URL, HashMap<String, String> params) throws IOException {
    ClientHttpRequest req = null;/* w ww. j av a 2 s.  c o  m*/

    try {
        URL url = new URL(URL);
        req = new ClientHttpRequest(url);

        req.setParameter("task", params.get("task"));
        req.setParameter("incident_title", params.get("incident_title"));
        req.setParameter("incident_description", params.get("incident_description"));
        req.setParameter("incident_date", params.get("incident_date"));
        req.setParameter("incident_hour", params.get("incident_hour"));
        req.setParameter("incident_minute", params.get("incident_minute"));
        req.setParameter("incident_ampm", params.get("incident_ampm"));
        req.setParameter("incident_category", params.get("incident_category"));
        req.setParameter("latitude", params.get("latitude"));
        req.setParameter("longitude", params.get("longitude"));
        req.setParameter("location_name", params.get("location_name"));
        req.setParameter("person_first", params.get("person_first"));
        req.setParameter("person_last", params.get("person_last"));
        req.setParameter("person_email", params.get("person_email"));

        if (!TextUtils.isEmpty(params.get("filename"))) {
            File f = new File(BoskoiService.savePath + params.get("filename"));
            // sometimes seems to get the last image left over in the params?
            // todo: need to clear somewhere?
            if (f.exists()) {
                req.setParameter("incident_photo[]", f);
            }
        }

        Log.i("ZZZZ", req.toString());

        InputStream serverInput = req.post();

        if (Util.extractPayloadJSON(GetText(serverInput))) {
            return true;
        }
        // fix - api failing on images causing duplication problems
        // if it got here then there is a connection anyway...
        // todo: need to repo this to fix properly
        return true;

    } catch (MalformedURLException ex) {
        Log.i("XXXX", "MalformedURLException");
        //fall through and return false
    }
    Log.i("XXXX", "failed");
    return false;
}

From source file:com.impetus.kundera.rest.common.EntityUtils.java

/**
 * @param queryString/*from w w w.  j  a v  a2  s .  com*/
 * @param q
 */
public static void setQueryParameters(String queryString, HashMap<String, String> paramsMap, Query q) {
    KunderaQuery kq = ((QueryImpl) q).getKunderaQuery();
    Set<Parameter<?>> parameters = kq.getParameters();
    for (String paramName : paramsMap.keySet()) {
        String value = paramsMap.get(paramName);

        if (StringUtils.isNumeric(paramName)) {
            for (Parameter param : parameters) {
                if (param.getPosition() == Integer.parseInt(paramName)) {
                    Class<?> paramClass = param.getParameterType();
                    PropertyAccessor accessor = PropertyAccessorFactory.getPropertyAccessor(paramClass);
                    Object paramValue = accessor.fromString(paramClass, value);
                    q.setParameter(Integer.parseInt(paramName), paramValue);
                    break;
                }
            }
        } else {
            for (Parameter param : parameters) {
                if (param.getName().equals(paramName)) {
                    Class<?> paramClass = param.getParameterType();
                    PropertyAccessor accessor = PropertyAccessorFactory.getPropertyAccessor(paramClass);
                    Object paramValue = accessor.fromString(paramClass, value);
                    if (paramName.equalsIgnoreCase("firstResult")) {
                        q.setFirstResult(Integer.parseInt((String) paramValue));
                    } else if (paramName.equalsIgnoreCase("maxResult")) {
                        q.setMaxResults(Integer.parseInt((String) paramValue));
                    } else {
                        q.setParameter(paramName, paramValue);
                    }
                    break;
                }
            }

        }
    }
}

From source file:edu.isistan.carcha.util.PluginUtil.java

/**
 * Gets the cross cutting concerns distribution.
 *
 * @param cp the cp//w w w .ja v a 2s.c  om
 * @return the cross cutting concerns distribution
 */
public static HashMap<String, Integer> getCrossCuttingConcernsDistribution(CarchaProject cp) {
    HashMap<String, Integer> values = new HashMap<String, Integer>();
    Integer temp = 0;

    for (isistan.edu.carcha.model.carcha.TraceabilityLink link : cp.getLinks()) {
        temp = values.get(link.getConcern().getKind());
        if (temp != null) {
            temp++;
        } else {
            temp = 1;
        }
        values.put(link.getConcern().getKind(), temp);
    }
    return values;
}

From source file:com.mycompany.craftdemo.utility.java

public static void send(long phno, double price, double profit, String domain, String company) {
    HashMap<String, String> domainMap = new HashMap<>();
    domainMap.put("TMobile", "tmomail.net ");
    domainMap.put("ATT", "txt.att.net");
    domainMap.put("Sprint", "messaging.sprintpcs.com");
    domainMap.put("Verizon", "vtext.com");
    String to = phno + "@" + domainMap.get(domain); //change accordingly

    // Sender's email ID needs to be mentioned
    String from = "uni5prince@gmail.com"; //change accordingly
    final String username = "uni5prince"; //change accordingly
    final String password = "savageph8893"; //change accordingly

    // Assuming you are sending email through relay.jangosmtp.net
    String host = "smtp.gmail.com";

    Properties props = new Properties();
    props.put("mail.smtp.auth", "true");
    props.put("mail.smtp.starttls.enable", "true");
    props.put("mail.smtp.host", host);
    props.put("mail.smtp.port", "587");

    // Get the Session object.
    Session session = Session.getInstance(props, new javax.mail.Authenticator() {
        protected PasswordAuthentication getPasswordAuthentication() {
            return new PasswordAuthentication(username, password);
        }/*  w  ww  . ja v a  2  s  . com*/
    });

    try {
        // Create a default MimeMessage object.
        Message message = new MimeMessage(session);

        // Set From: header field of the header.
        message.setFrom(new InternetAddress(from));

        // Set To: header field of the header.
        message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(to));

        // Set Subject: header field
        message.setSubject("Prices have gone up!!");

        // Now set the actual message
        message.setText("Hello Jane, Stock prices for " + company + " has reached to $" + price
                + " with profit of $" + profit);

        // Send message
        Transport.send(message);

        System.out.println("Sent message successfully....");

    } catch (MessagingException e) {
        throw new RuntimeException(e);
    }
}

From source file:com.clustercontrol.accesscontrol.util.RoleObjectPrivilegeUtil.java

/**
 * DB??????(HashMap)???//from  w w w.  j  ava  2 s  .c o m
 */
public static HashMap<String, ObjectPrivilegeBean> dto2beanMap(List<ObjectPrivilegeInfo> infoList) {

    HashMap<String, ObjectPrivilegeBean> resultMap = new HashMap<String, ObjectPrivilegeBean>();
    ObjectPrivilegeBean bean = null;

    if (infoList == null) {
        return null;
    }

    for (ObjectPrivilegeInfo info : infoList) {

        // ID?????????
        if (resultMap.get(info.getRoleId()) == null) {
            bean = new ObjectPrivilegeBean();
            bean.setRoleId(info.getRoleId());
            resultMap.put(info.getRoleId(), bean);
        } else
            bean = resultMap.get(info.getRoleId());

        if (info.getObjectPrivilege().equals(ObjectPrivilegeMode.READ.toString())) {
            bean.setReadPrivilege(true);
        } else if (info.getObjectPrivilege().equals(ObjectPrivilegeMode.MODIFY.toString())) {
            bean.setWritePrivilege(true);
        } else if (info.getObjectPrivilege().equals(ObjectPrivilegeMode.EXEC.toString())) {
            bean.setExecPrivilege(true);
        }

    }

    return resultMap;
}