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.financial.analytics.ircurve.strips.PointsCurveNodeWithIdentifier.java

@Override
protected Object propertyGet(String propertyName, boolean quiet) {
    switch (propertyName.hashCode()) {
    case 368639974: // underlyingIdentifier
        return getUnderlyingIdentifier();
    case -876884845: // underlyingDataField
        return getUnderlyingDataField();
    }//  w  w w  .  j  av a 2  s.  c om
    return super.propertyGet(propertyName, quiet);
}

From source file:it.uniroma1.bdc.tesi.piccioli.giraphstandalone.ksimplecycle.KSimpleCycle_StoreInValue.java

@Override
public void compute(Vertex<Text, TextAndHashes, NullWritable> vertex, Iterable<CustomMessage> messages)
        throws IOException {

    int k = 5; //circuiti chiusi di lunghezza k
    //        LOG.info("LOG HASHES " + vertex.getValue().getGeneratedHash().size() + "\t" + vertex.getValue().getSeenHash().size());

    if (getSuperstep() == 0) {

        for (Edge<Text, NullWritable> edge : vertex.getEdges()) {

            //                int hsg = edge.hashCode();//TODO: da controllare
            String rnd = RandomStringUtils.random(32);//TODO: da controllare
            int hsg = rnd.hashCode();
            //                LOG.info("SEND TO ALL EDGE\t" + hsg);

            vertex.getValue().getGeneratedHash().add(hsg);

            CustomMessage msg = new CustomMessage(vertex.getId(), hsg);
            sendMessage(edge.getTargetVertexId(), msg);
        }/*  w w  w . j  a  va 2 s. c om*/

    } else if (getSuperstep() > 0 && getSuperstep() < k) {

        for (CustomMessage message : messages) {
            //                LOG.info(vertex.getId() + " RECEIVED MSG FROM " + message.getSource() + " CONTEINED " + message.getMessage());

            //Scarto messaggi contenente l'id del vertice durante i passi intermedi

            //init set relativo arco entrante al primo messaggio ricevuto
            if (!vertex.getValue().getSeenHash().containsKey(message.getSource())) {
                vertex.getValue().getSeenHash().put(message.getSource(), new HashSet<Integer>());
            }

            if (!vertex.getValue().getGeneratedHash().contains(message.getMessage()) && !vertex.getValue()
                    .getSeenHash().get(message.getSource()).contains(message.getMessage())) {

                vertex.getValue().getSeenHash().get(message.getSource()).add(message.getMessage());

                for (Edge<Text, NullWritable> edge : vertex.getEdges()) {
                    //evito "rimbalzo" di messaggi tra 2 vertici vicini
                    //ho eliminato controllo "rimbalzo" perche non puo piu accadare dopo l'introduzione controllo hash msg
                    if (!edge.getTargetVertexId().toString().equals(message.getSource().toString())) {

                        CustomMessage msg = new CustomMessage(vertex.getId(), message.getMessage());

                        //                        LOG.info("SEND MESSAGE " + msg.getMessage() + " FROM " + msg.getSource() + " TO " + edge.getTargetVertexId());
                        sendMessage(edge.getTargetVertexId(), msg);
                    }

                }

                //                    CustomMessage msg = new CustomMessage(vertex.getId(), message.getMessage());
                //                    System.out.println("Propagazione msg\t" + message);
            }
        }

    } else if (getSuperstep() == k) {
        LOG.info(this.printGeneratedHashSet(vertex));
        //            LOG.info(this.printSeenHashSet(vertex));

        Double T = 0.0;
        for (CustomMessage message : messages) {
            LOG.info(vertex.getId() + "\tReceive\t" + message);
            //                System.out.println(vertex.getSource()+"\t"+message);
            if (vertex.getValue().getGeneratedHash().contains(message.getMessage())) {
                T++;
            }
        }
        T = T / (2 * k);

        vertex.setValue(new TextAndHashes(new Text(T.toString())));
        vertex.voteToHalt();
        aggregate(SOMMA, new DoubleWritable(T));

    }

}

From source file:net.popgen.canephora.structure.marker.Marker.java

@Override
public int hashCode() {
    String st = this.getPloidy().toString() + ((Boolean) this.isPhased()).toString() + this.alleles.toString()
            + this.markerAlleles.toString();
    return st.hashCode();
}

From source file:com.budrotech.jukebox.service.RESTMusicService.java

private static String getCachedIndexesFilename(Context context, String musicFolderId) {
    String s = Util.getRestUrl(context, null) + musicFolderId;
    return String.format("indexes-%d.ser", Math.abs(s.hashCode()));
}

From source file:lu.lippmann.cdb.graph.GraphUtil.java

/**
 * /*ww w.  java  2s. co m*/
 */
public static GraphWithOperations buildGraphWithOperationsFromWekaRegressionString(final String graphStr)
        throws Exception {
    final Matcher nodeMatch = REGRESSION_NODE_PATTERN.matcher(graphStr);
    final Matcher edgeMatch = EDGE_PATTERN.matcher(graphStr);

    final GraphWithOperations gwo = new GraphWithOperations();

    final Map<String, CNode> map = new HashMap<String, CNode>();

    while (nodeMatch.find()) {
        final String id = nodeMatch.group(1);
        final String variableName = nodeMatch.group(2);
        final int pointCharIdx = variableName.indexOf('(');
        final CNode node = new CNode((long) id.hashCode(),
                pointCharIdx > 0 ? variableName.substring(0, pointCharIdx) : variableName);
        map.put(id, node);
        gwo.addVertex(node);
    }

    while (edgeMatch.find()) {
        final String from = edgeMatch.group(1);
        final String to = edgeMatch.group(2);

        final String condition = edgeMatch.group(3);

        final String fromNodeName = map.get(from).getName();

        gwo.superAddEdge(new CEdge(from + " -> " + to, fromNodeName + condition), map.get(from), map.get(to));
    }

    for (final CNode n : gwo.getVertices()) {
        n.setName(n.getName().substring(n.getName().indexOf(':') + 1));
    }
    for (final CEdge e : gwo.getEdges()) {
        e.setExpression(e.getExpression().substring(e.getExpression().indexOf(':') + 1));
    }

    return gwo;
}

From source file:com.honnix.yaacs.auth.SessionManager.java

private String generateSessionId(String userId, String password, Date date) {
    String tmp = new StringBuilder(userId).append(password).append(date.getTime()).toString();
    String sessionId = String.valueOf(tmp.hashCode());
    String encoded = MD5.getMD5Sum(tmp);

    if (encoded != null) {
        sessionId = encoded;//from  ww  w  . ja  va2 s .  c om
    }

    return sessionId;
}

From source file:com.opengamma.master.security.RawSecurity.java

@Override
protected void propertySet(String propertyName, Object newValue, boolean quiet) {
    switch (propertyName.hashCode()) {
    case 985253874: // rawData
        setRawData((byte[]) newValue);
        return;//from w w  w. jav  a 2s  .  c  o m
    }
    super.propertySet(propertyName, newValue, quiet);
}

From source file:com.intel.graphbuilder.util.SerializableBaseConfiguration.java

/**
 * Compute the hashcode based on the property values.
 *
 * The hashcode allows us to compare two configuration objects with the same property entries.
 *
 * @return Hashcode based on property values
 *//*from  w w w.j a  va  2  s .  c  o  m*/
@Override
public int hashCode() {
    final int prime = 31;
    int result = 1;

    for (Object property : store.keySet()) {
        String value = store.get(property).toString();
        if (value != null) {
            result = prime * result + value.hashCode();
        }
    }
    return result;
}

From source file:cai.sql.SQL.java

@SuppressWarnings("unchecked")
public PreparedStatement prepareStatement(String msg, String stm) {
    Integer hash = new Integer(Thread.currentThread().hashCode() ^ stm.hashCode() ^ msg.hashCode());// 
    PreparedStatement st = (PreparedStatement) prep_stms.get(hash);

    if (st != null)
        return st;

    try {/*from ww  w.j av a 2s .c o  m*/
        st = connection.prepareStatement(stm);
    } catch (SQLException e) {
        error_msg(msg, e, stm);
    }

    if (st != null)
        prep_stms.put(hash, st);

    return st;
}

From source file:com.opengamma.masterdb.security.hibernate.cashflow.CashFlowSecurityBean.java

@Override
protected Object propertyGet(String propertyName, boolean quiet) {
    switch (propertyName.hashCode()) {
    case 575402001: // currency
        return getCurrency();
    case 73828649: // settlement
        return getSettlement();
    case -1413853096: // amount
        return getAmount();
    }// w w w .  ja  v a  2 s.  co  m
    return super.propertyGet(propertyName, quiet);
}