Example usage for java.lang String hashCode

List of usage examples for java.lang String hashCode

Introduction

In this page you can find the example usage for java.lang String hashCode.

Prototype

public int hashCode() 

Source Link

Document

Returns a hash code for this string.

Usage

From source file:com.opengamma.component.factory.AbstractSpringComponentFactory.java

@Override
protected Object propertyGet(String propertyName, boolean quiet) {
    switch (propertyName.hashCode()) {
    case 1361354025: // springFile
        return getSpringFile();
    case 1613702479: // propertiesFile
        return getPropertiesFile();
    }/*from ww  w.  j  av  a  2 s  . c o  m*/
    return super.propertyGet(propertyName, quiet);
}

From source file:edu.umn.se.trap.form.Location.java

@Override
public int hashCode() {
    String s = "";
    if (city != null) {
        s += city.toLowerCase();//from  w ww .  j  a va  2s.  c om
    }
    if (state != null) {
        s += state.toLowerCase();
    }
    if (country != null) {
        s += country.toLowerCase();
    }
    return s.hashCode();
}

From source file:com.javielinux.utils.Utils.java

public static String getHashFromFile(String file) {
    return String.valueOf(Math.abs(file.hashCode()));
}

From source file:com.github.stephanarts.cas.ticket.registry.provider.GetMethodTest.java

@Test
public void testValidInput() throws Exception {
    final HashMap<Integer, Ticket> map = new HashMap<Integer, Ticket>();
    final JSONObject params = new JSONObject();
    final IMethod method = new GetMethod(map);
    final JSONObject result;

    final String ticketId = "ST-1234567890ABCDEFGHIJKL-crud";
    final ServiceTicket ticket = mock(ServiceTicket.class, withSettings().serializable());
    when(ticket.getId()).thenReturn(ticketId);

    map.put(ticketId.hashCode(), ticket);

    params.put("ticket-id", ticketId);

    try {//from   w w  w.  j  a  v a 2  s . c  o  m
        result = method.execute(params);
    } catch (final JSONRPCException e) {
        Assert.fail(e.getMessage());
    } catch (final Exception e) {
        throw new Exception(e);
    }
}

From source file:com.opengamma.engine.view.ExecutionLogWithContext.java

@Override
protected void propertySet(String propertyName, Object newValue, boolean quiet) {
    switch (propertyName.hashCode()) {
    case -211372413: // functionName
        setFunctionName((String) newValue);
        return;// w  w  w .  ja va 2s  .  co m
    case -1553345806: // targetSpecification
        setTargetSpecification((ComputationTargetSpecification) newValue);
        return;
    case -1217189620: // executionLog
        setExecutionLog((ExecutionLog) newValue);
        return;
    }
    super.propertySet(propertyName, newValue, quiet);
}

From source file:com.github.stephanarts.cas.ticket.registry.provider.UpdateMethodTest.java

@Test
public void testValidInput() throws Exception {
    final byte[] serializedTicket;
    final HashMap<Integer, Ticket> map = new HashMap<Integer, Ticket>();
    final JSONObject params = new JSONObject();
    final IMethod method = new UpdateMethod(map);

    final String ticketId = "ST-1234567890ABCDEFGHIJKL-crud";
    final ServiceTicket ticket = mock(ServiceTicket.class, withSettings().serializable());
    when(ticket.getId()).thenReturn(ticketId);

    map.put(ticketId.hashCode(), ticket);

    try {// w  w  w  .j a va  2  s .  c o m
        ByteArrayOutputStream bo = new ByteArrayOutputStream();
        ObjectOutputStream so = new ObjectOutputStream(bo);
        so.writeObject(ticket);
        so.flush();
        serializedTicket = bo.toByteArray();

        params.put("ticket-id", ticketId);
        params.put("ticket", DatatypeConverter.printBase64Binary(serializedTicket));
        method.execute(params);

    } catch (final JSONRPCException e) {
        Assert.fail(e.getMessage());
    } catch (final Exception e) {
        throw new Exception(e);
    }
}

From source file:com.opengamma.component.factory.AbstractSpringComponentFactory.java

@Override
protected void propertySet(String propertyName, Object newValue, boolean quiet) {
    switch (propertyName.hashCode()) {
    case 1361354025: // springFile
        setSpringFile((Resource) newValue);
        return;// ww  w  .j a  v  a 2s .  co  m
    case 1613702479: // propertiesFile
        setPropertiesFile((Resource) newValue);
        return;
    }
    super.propertySet(propertyName, newValue, quiet);
}

From source file:com.opengamma.component.factory.master.RemoteMastersComponentFactory.java

@Override
protected Object propertyGet(String propertyName, boolean quiet) {
    switch (propertyName.hashCode()) {
    case -332625701: // baseUri
        return getBaseUri();
    case -614707837: // publishRest
        return isPublishRest();
    case -1495762275: // jmsConnector
        return getJmsConnector();
    }/*from w  ww . j  av  a2 s .  com*/
    return super.propertyGet(propertyName, quiet);
}

From source file:github.daneren2005.dsub.util.Util.java

public static String getCacheName(Context context, int instance, String name) {
    String s = getRestUrl(context, null, instance, false);
    return name + "-" + s.hashCode() + ".ser";
}

From source file:github.daneren2005.dsub.util.Util.java

public static String getCacheName(Context context, int instance, String name, String id) {
    String s = getRestUrl(context, null, instance, false) + id;
    return name + "-" + s.hashCode() + ".ser";
}