Example usage for java.util HashMap size

List of usage examples for java.util HashMap size

Introduction

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

Prototype

int size

To view the source code for java.util HashMap size.

Click Source Link

Document

The number of key-value mappings contained in this map.

Usage

From source file:eu.scape_project.archiventory.identifiers.UnixFileIdentificationTest.java

/**
 * Test of identifyFileList method, of class UnixFileIdentification.
 *//*www. j  ava 2s  . com*/
@Test
public void testIdentifyFileList() throws Exception {
    UnixFileIdentification id = new UnixFileIdentification();
    id.setTool("unixfile");
    id.setOutputKeyFormat("%1$s/%2$s");
    id.setOutputValueFormat("%1$s %2$s %3$s");
    id.setCommand("file --mime-type");
    HashMap<String, List<String>> result = id.identifyFileList(arcFilesMap);
    assertEquals(5, result.size());
    for (String res : result.keySet()) {
        List<String> valueList = result.get(res);
        for (String val : valueList) {
            System.out.println(val);
        }
    }
    String tmpTestFilePath = ArcFilesTestMap.getInstance().getTmpTestFile().getAbsolutePath();
    List<String> vals = result.get(tmpTestFilePath + "/20130522085321/http://fue.onb.ac.at/test/image.png");
    assertEquals(vals.get(0), "unixfile mime image/png");
}

From source file:br.unicamp.ic.recod.gpsi.ml.gpsiLinearDiscriminantAnalysisClassificationAlgorithm.java

@Override
public void fit(HashMap<Byte, ArrayList<double[]>> x) {

    VectorialMean mean;//from w w w  .java  2  s. c  om

    this.centroids = new HashMap<>();
    this.nClasses = x.size();
    this.dimensionality = 0;
    for (byte label : x.keySet()) {
        if (this.dimensionality <= 0)
            this.dimensionality = x.get(label).get(0).length;

        mean = new VectorialMean(this.dimensionality);
        for (double[] v : x.get(label))
            mean.increment(v);

        this.centroids.put(label, mean.getResult());
    }
}

From source file:eu.scape_project.archiventory.identifiers.DroidIdentificationTest.java

/**
 * Test of identify method, of class DroidIdentification.
 */// www . ja  v  a 2 s  . c  o m
@Test
public void testIdentify() throws Exception {
    id.setTool("droid");
    id.setOutputKeyFormat("%1$s/%2$s");
    id.setOutputValueFormat("%1$s %2$s %3$s");
    HashMap<String, List<String>> result = id.identifyFileList(arcFilesMap);
    assertEquals(5, result.size());
    for (String res : result.keySet()) {
        List<String> valueList = result.get(res);
        for (String val : valueList) {
            System.out.println(val);
        }
    }
    String tmpTestFilePath = ArcFilesTestMap.getInstance().getTmpTestFile().getAbsolutePath();
    List<String> vals = result.get(tmpTestFilePath + "/20130522085321/http://fue.onb.ac.at/test/image.png");
    assertEquals(vals.get(0), "droid mime image/png");
    assertEquals(vals.get(1), "droid puid fmt/11");
}

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

/** 
 * Mtodo de invocacin que se ejecuta cuando se llama a un servicio web 
 * /*from w w  w. java2 s .  com*/
 * @param invocation Informacin de la clase que se est ejecutando y que se va a interceptar
 * @return returnObject Objeto Devuelta: Joinpoint
 */
public Object invoke(MethodInvocation invocation) throws Throwable {
    if (RegistroCtes.AUDITORIA_NO.equals(AUDITORIA)) {
        log.info("!!!!! Opcin sin auditora. No se capturan datos");
        return invocation.proceed();
    }

    try {
        /* Se interceptan los datos */
        DatosVO datosInterceptados = Interceptor.getDatosInterceptados(invocation);

        if (datosInterceptados != null) {
            HashMap valores = datosInterceptados.getValores();

            if (valores != null && valores.size() > 0)
                Registrar.operacion(datosInterceptados);
            else {
                if (log.isDebugEnabled())
                    log.debug("No se han interceptados valores");
            }
        }
    } catch (Throwable t) {
        log.error("Error: No se han interceptados los valores");
        log.error(t);
    }

    Object returnObject = invocation.proceed();

    return returnObject;
}

From source file:com.baidu.qa.service.test.verify.VerifyResponseImpl.java

public void verifyResponseWithExpectString(File expectfile, String actual) {

    FileCharsetDetector det = new FileCharsetDetector();
    String expectedStr = FileUtil.readFileByLines(expectfile);
    try {//from   ww w  .  j  a  va2  s  . c  om
        String oldcharset = det.guestFileEncoding(expectfile);
        if (oldcharset.equalsIgnoreCase("UTF-8") == false)
            FileUtil.transferFile(expectfile, oldcharset, "UTF-8");
    } catch (Exception ex) {
        log.error("[change expect file charset error]:" + ex);
    }

    //???json??actual.contain(expect)
    if (!BJSON.BooleanJudgeStringJson(actual) || !BJSON.BooleanJudgeStringJson(expectedStr)) {

        List<String> datalist = FileUtil.getListFromFileWithBOMFilter(expectfile);
        for (String data : datalist) {
            log.info("[expected string]:" + data);
            Assert.assertTrue("[response different with expect][expect]:" + data.trim() + "[actual]:" + actual,
                    actual.contains(data.trim()));
        }
    }
    //json????
    else {

        BJSON service = new BJSON();
        HashMap<String, String> diffHash = service.findDiffSingleInJson(actual, expectedStr);
        if (diffHash.size() != 0) {
            for (Entry<String, String> it : diffHash.entrySet()) {
                log.error(it.getKey() + "----" + it.getValue());
            }
            Assert.assertEquals(0, diffHash.size());
        }
    }
}

From source file:com.tealeaf.Downloader.java

public boolean moveAll(HashMap<String, File> files) {
    String[] uris = new String[files.size()];
    files.keySet().toArray(uris);/*  w  ww. ja  v a  2  s  .c  o m*/
    for (int i = 0; i < uris.length; i++) {
        cache(uris[i], files.get(uris[i]));
    }
    return true;
}

From source file:amie.keys.CombinationsExplorationNew.java

/**
 * It outputs all the conditional keys on a KB given a minimum support
 * threshold./*from  www  .ja  va 2 s . c  om*/
 *
 * @param support
 * @param kb
 */
public static void discoverConditionalKeys() {
    HashMap<Rule, GraphNew> ruleToGraphNewFirstLevel = new HashMap<>();
    /**
     * We build a graph for each property. The graph contains nodes for each
     * of the other properties and all its possible combinations. For
     * instance given the relations 1, 2, 3, 4. The graph for property 1
     * contains as nodes: 2, 3, 4, 23, 24, 34, 234 with their corresponding
     * parent relationships, e.g., 23 has 2 and 3 as parents. While
     * relations are strings, we have mapped them to an integer space (that
     * is why the key is an integer)
     *
     */
    //System.out.println("idToPro:"+id2Property);
    HashMap<Integer, GraphNew> instantiatedProperty2GraphNew = buildPropertyGraphsOnTheFly((int) support);
    System.out.println("Key\tCondition\tSupport");
    /**
     * Here we find all conditional keys when the condition has size 1,
     * i.e., it involves only one property such as residence=Paris |
     * zipCode, field. The map contains the conditions as keys and the list
     * of potential properties that could be used to extend this condition
     * as values.
     */
    HashMap<Rule, HashSet<String>> conditionsToPotentialExtensions = discoverConditionalKeysFirstLevel(
            ruleToGraphNewFirstLevel, instantiatedProperty2GraphNew);
    /**for (Rule rule : ruleToGraphNewFirstLevel.keySet()) {
    System.out.println("rule:" + rule + " => " + ruleToGraphNewFirstLevel.get(rule));
    }**/
    if (conditionsToPotentialExtensions.size() != 0) {
        discoverConditionalKeysPerLevel(conditionsToPotentialExtensions, ruleToGraphNewFirstLevel,
                ruleToGraphNewFirstLevel);
    }
    System.out.println("We found " + conditions2Keys.valueSize() + " key(s)");

}

From source file:org.kitodo.data.elasticsearch.index.type.DocketTypeTest.java

@Test
public void shouldCreateDocuments() {
    DocketType docketType = new DocketType();

    List<Docket> dockets = prepareData();
    HashMap<Integer, HttpEntity> documents = docketType.createDocuments(dockets);
    assertEquals("HashMap of documents doesn't contain given amount of elements!", 2, documents.size());
}

From source file:org.kitodo.data.elasticsearch.index.type.RulesetTypeTest.java

@Test
public void shouldCreateDocuments() {
    RulesetType rulesetType = new RulesetType();

    List<Ruleset> rulesets = prepareData();
    HashMap<Integer, HttpEntity> documents = rulesetType.createDocuments(rulesets);
    assertEquals("HashMap of documents doesn't contain given amount of elements!", 2, documents.size());
}

From source file:inflor.core.plots.CategoricalNumberAxis.java

public CategoricalNumberAxis(String name, HashMap<Integer, String> lableMap) {
    super(name);/*w  w  w.j  a  v a2  s . com*/
    this.labelMap = lableMap;

    Integer[] yValues = lableMap.keySet().toArray(new Integer[lableMap.size()]);
    double yMin = Double.MAX_VALUE;
    double yMax = Double.MIN_VALUE;

    for (Integer d : yValues) {
        if (d < yMin) {
            yMin = d;
        }
        if (d > yMax) {
            yMax = d;
        }
    }
    this.setRange(new Range(yMin - 0.5, yMax + 0.5));
    NumberFormat formatter = new CategoryNumberFormat(lableMap);
    this.setNumberFormatOverride(formatter);
    this.setTickMarkOutsideLength(2);
}