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:sachin.spider.Page.java

/**
 * Constructor of the Page Class//from w w  w.j a  va2 s  . c  o  m
 *
 * @param address URL for the webPage
 * @param document document of the webPage
 */
Page(String address, Document document) {
    this.address = address;
    this.document = document;
    this.docid = address.hashCode();
    parents = new ArrayList<>();
}

From source file:it.readbeyond.minstrel.librarian.FormatHandlerAbstractZIP.java

public Publication parseFile(File file) {
    Publication p = new Publication();
    String name = file.getName();
    String ap = file.getAbsolutePath();
    String id = Integer.toHexString(ap.hashCode());
    p.setAbsolutePath(ap);//w w w . j  a  v  a 2 s .  c  o  m
    p.setRelativePath(name);
    p.setID(id);
    p.setSize(file.length());
    p.setTitle("File " + name);
    return p;
}

From source file:com.digitalpebble.stormcrawler.util.URLStreamGrouping.java

@Override
public List<Integer> chooseTasks(int taskId, List<Object> values) {
    List<Integer> boltIds = new LinkedList<>();

    // optimisation : single target
    if (numTasks == 1) {
        boltIds.add(0);/*from   ww w.  ja v a 2 s .co m*/
        return boltIds;
    }

    if (values.size() < 2) {
        // TODO log!
        return boltIds;
    }

    // the first value is always the URL
    // and the second the metadata
    String url = (String) values.get(0);
    Metadata metadata = (Metadata) values.get(1);
    String partitionKey = partitioner.getPartition(url, metadata);

    if (StringUtils.isBlank(partitionKey)) {
        // TODO log!
        return boltIds;
    }

    // hash on the key
    int partition = Math.abs(partitionKey.hashCode() % numTasks);
    boltIds.add(partition);

    return boltIds;
}

From source file:com.auditbucket.engine.repo.neo4j.model.TrackTagRelationship.java

/**
 * For non-persistent relationship. If caller is not tracking in the graph, then this
 * constructor can be used to create header data suitable for writing to search
 *
 * @param header       Header object//from   www .j ava  2s  . c  o  m
 * @param tag          Tag object
 * @param relationship Name of the relationship
 * @param propMap      Relationship properties
 */
public TrackTagRelationship(MetaHeader header, Tag tag, String relationship, Map<String, Object> propMap) {
    this.metaId = header.getId();
    this.tag = tag;
    this.tagType = relationship;
    this.id = System.currentTimeMillis() + relationship.hashCode(); // random...
    if (propMap != null) {
        if (propMap.get("weight") != null)
            this.weight = (Integer) propMap.get("weight");
    }
}

From source file:org.mahasen.util.DeleteUtil.java

/**
 * @param fileToDelete//  w  w w .ja  v a  2  s  . co m
 * @throws MalformedURLException
 * @throws RegistryException
 */
public void delete(String fileToDelete)
        throws MalformedURLException, RegistryException, MahasenConfigurationException, MahasenException {
    Id resourceId = Id.build(String.valueOf(fileToDelete.hashCode()));
    String currentFileName = null;

    try {
        MahasenResource mahasenResource = mahasenManager.lookupDHT(resourceId);

        if (mahasenManager.lookupDHT(resourceId) == null) {
            throw new MahasenException("File not found");
        }

        String fileName = mahasenResource.getProperty(MahasenConstants.FILE_NAME).toString();
        Hashtable<String, Vector<String>> iptable = mahasenResource.getSplittedPartsIpTable();

        int totalNoOfParts = 0;
        for (String partName : mahasenResource.getPartNames()) {
            totalNoOfParts += iptable.get(partName).size();
        }

        setStoredNoOfParts(totalNoOfParts);

        for (String partName : mahasenResource.getPartNames()) {
            currentFileName = fileName + "." + partName;
            for (int i = 0; i < iptable.get(partName).size(); i++) {
                String nodeIp = iptable.get(partName).get(i);

                ArrayList<NameValuePair> qparams = new ArrayList<NameValuePair>();
                qparams.add(new BasicNameValuePair(MahasenConstants.FILE_NAME, fileName + "." + partName));

                URI uri = null;
                try {
                    uri = URIUtils.createURI("https", nodeIp + ":" + MahasenConstants.SERVER_PORT, -1,
                            "/mahasen/delete_request_ajaxprocessor.jsp",
                            URLEncodedUtils.format(qparams, "UTF-8"), null);
                    MahasenDeleteWorker mahasenDeleteWorker = new MahasenDeleteWorker(uri);
                    Thread deleteThread = new Thread(mahasenDeleteWorker);
                    deleteThread.start();

                } catch (URISyntaxException e) {
                    log.info("URI not found");
                    return;
                }
            }
        }

        final BlockFlag blockFlag = new BlockFlag(true, 1500);
        while (true) {

            if (storedNoOfParts.intValue() == 0) {
                MahasenResource resourceToDelete = mahasenManager.lookupDHT(resourceId);
                mahasenManager.deletePropertyFromTreeMap(resourceId, resourceToDelete);
                mahasenManager.deleteContent(resourceId);
                blockFlag.unblock();
                break;
            }

            if (blockFlag.isBlocked()) {

                mahasenManager.getNode().getEnvironment().getTimeSource().sleep(10);
            } else {
                throw new MahasenException("Time out in delete operation for " + fileName);
            }
        }
    } catch (InterruptedException e) {
        log.error("Error deleting file : " + currentFileName);
    }
}

From source file:org.LexGrid.LexBIG.Impl.helpers.DefaultCodeToReturnResolver.java

private String getKey(String code, String namespace) {
    return Integer.toString(code.hashCode()) + Integer.toString(namespace.hashCode());
}

From source file:com.rabross.android.minecraftskinwidget.ImageDownloader.java

private String getCacheName(String name, String url, boolean hasHat) {
    if (hasHat) {
        return url.hashCode() + "" + name;
    } else {// w  w  w .ja v a2  s.  c o m
        return url.hashCode() + "" + name + hasHat;
    }
}

From source file:com.github.stephanarts.cas.ticket.registry.provider.DeleteMethodTest.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 DeleteMethod(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);

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

    try {//from ww  w .  ja va2s.  c  o m
        method.execute(params);
    } catch (final JSONRPCException e) {
        Assert.fail(e.getMessage());
    } catch (final Exception e) {
        throw new Exception(e);
    }
}

From source file:com.cloudera.oryx.app.serving.AbstractOryxResource.java

protected final void sendInput(String message) {
    @SuppressWarnings("unchecked")
    TopicProducer<String, String> inputProducer = (TopicProducer<String, String>) getInputProducer();
    inputProducer.send(Integer.toHexString(message.hashCode()), message);
}

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

@Override
protected Object propertyGet(String propertyName, boolean quiet) {
    switch (propertyName.hashCode()) {
    case -211372413: // functionName
        return getFunctionName();
    case -1553345806: // targetSpecification
        return getTargetSpecification();
    case -1217189620: // executionLog
        return getExecutionLog();
    }//from w  w w.  j ava 2s.c  o  m
    return super.propertyGet(propertyName, quiet);
}