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:ru.apertum.qsystem.reports.formirovators.DistributionMedDayServices.java

@Override
public String validate(String driverClassName, String url, String username, String password,
        HttpRequest request, HashMap<String, String> params) {
    //   ?  //from  ww  w  .  j a v a  2  s  .  c o  m
    QLog.l().logger().trace("?  \"" + params.toString() + "\".");
    if (params.size() == 1) {
        // date/service_id/service
        Date date;
        String sdate;
        try {
            date = Uses.format_dd_MM_yyyy.parse(params.get("date"));
            sdate = (new java.text.SimpleDateFormat("yyyy-MM-dd")).format(date);
        } catch (NumberFormatException | ParseException ex) {
            return "<br>  ! ? ?    (..).";
        }
        paramMap.put("sdate", sdate);
        paramMap.put("date", date);
    } else {
        return "<br>  !";
    }
    return null;
}

From source file:edu.gmu.cs.sim.util.media.chart.PieChartGenerator.java

String[] revisedLabels(HashMap map) {
    // Sort labels
    String[] labels = new String[map.size()];
    labels = (String[]) (map.keySet().toArray(labels));
    Arrays.sort(labels);//www. ja va2s.  c  om
    return labels;
}

From source file:com.thoughtworks.go.util.SvnLogXmlParserTest.java

@Test
public void shouldParseSvnInfoOutputToConstructUrlToRemoteUUIDMapping() {
    final SvnLogXmlParser svnLogXmlParser = new SvnLogXmlParser();
    final String svnInfoOutput = "<?xml version=\"1.0\"?>\n" + "<info>\n" + "<entry\n" + "   kind=\"dir\"\n"
            + "   path=\"trunk\"\n" + "   revision=\"3432\">\n"
            + "<url>http://gears.googlecode.com/svn/trunk</url>\n" + "<repository>\n"
            + "<root>http://gears.googlecode.com/svn</root>\n"
            + "<uuid>fe895e04-df30-0410-9975-d76d301b4276</uuid>\n" + "</repository>\n" + "<commit\n"
            + "   revision=\"3430\">\n" + "<author>gears.daemon</author>\n"
            + "<date>2010-10-06T02:00:50.517477Z</date>\n" + "</commit>\n" + "</entry>\n" + "</info>";
    final HashMap<String, String> map = svnLogXmlParser.parseInfoToGetUUID(svnInfoOutput,
            "http://gears.googlecode.com/svn/trunk", new SAXBuilder());
    assertThat(map.size(), is(1));
    assertThat(map.get("http://gears.googlecode.com/svn/trunk"), is("fe895e04-df30-0410-9975-d76d301b4276"));
}

From source file:test.googlecode.genericdao.BaseTest.java

protected void assertListEqual(Person[] expected, List<Person> actual) {
    Assert.assertEquals("The list did not have the expected length", expected.length, actual.size());

    HashMap<Long, Object> unmatched = new HashMap<Long, Object>();
    for (Person person : expected) {
        unmatched.put(person.getId(), "");
    }/*from  w  w  w.  j a va  2  s  .  c  o m*/
    for (Person person : actual) {
        unmatched.remove(person.getId());
    }

    if (unmatched.size() != 0)
        Assert.fail("The list did not match the expected results.");
}

From source file:sim.util.media.chart.PieChartGenerator.java

double[] amounts(HashMap map, String[] revisedLabels) {
    // Extract amounts
    double[] amounts = new double[map.size()];
    for (int i = 0; i < amounts.length; i++)
        amounts[i] = ((Double) (map.get(revisedLabels[i]))).doubleValue();
    return amounts;
}

From source file:com.marketcloud.marketcloud.Utilities.java

/**
 * Returns a list of objects that comply with the given query.
 *
 * @param baseURL endpoint of the database
 * @param m HashMap containing a list of filters
 * @return a JSONArray containing a list of objects that comply with the given filter
 *///  w w w  .  j  a  v  a2 s  .c  o  m
public JSONObject list(final String baseURL, final HashMap<String, Object> m)
        throws ExecutionException, InterruptedException, JSONException {

    String url = baseURL;

    //Concatenate the filters to the base URL

    int index = 0;
    int max = m.size() - 1;

    for (Map.Entry<String, Object> entry : m.entrySet()) {

        url += entry.getKey() + "=" + entry.getValue();

        if (index != max)
            url += "&";

        index++;
    }

    return new Connect(context).run("get", url, publicKey);
}

From source file:com.nridge.core.io.gson.DocumentJSON.java

/**
 * Saves the Document to the writer stream specified as a parameter.
 *
 * @param aWriter Json writer stream instance.
 * @param aDocument Document instance./* w  ww.ja v a2s  .  c  o m*/
 *
 * @throws java.io.IOException I/O related exception.
 */
public void save(JsonWriter aWriter, Document aDocument) throws IOException {
    aWriter.beginObject();

    IOJSON.writeNameValue(aWriter, IO.JSON_NAME_MEMBER_NAME, aDocument.getName());
    IOJSON.writeNameValue(aWriter, IO.JSON_VERSION_MEMBER_NAME, aDocument.getSchemaVersion());
    IOJSON.writeNameValue(aWriter, IO.JSON_TYPE_MEMBER_NAME, aDocument.getType());
    IOJSON.writeNameValue(aWriter, IO.JSON_TITLE_MEMBER_NAME, aDocument.getTitle());
    IOJSON.writeNameValue(aWriter, IO.JSON_FEATURES_ARRAY_NAME, aDocument.getFeatures());

    DataTableJSON dataTableJSON = new DataTableJSON(aDocument.getTable());
    dataTableJSON.save(aWriter, true);

    ArrayList<Relationship> relationshipList = aDocument.getRelationships();
    if (relationshipList.size() > 0) {
        aWriter.name(IO.JSON_RELATED_ARRAY_NAME).beginArray();
        RelationshipJSON relationshipJSON = new RelationshipJSON();
        for (Relationship relationship : relationshipList)
            relationshipJSON.save(aWriter, relationship);
        aWriter.endArray();
    }

    HashMap<String, String> docACL = aDocument.getACL();
    if (docACL.size() > 0) {
        aWriter.name(IO.JSON_ACL_ARRAY_NAME).beginArray();
        for (Map.Entry<String, String> aclEntry : docACL.entrySet()) {
            aWriter.beginObject();
            aWriter.name(IO.JSON_NAME_MEMBER_NAME).value(aclEntry.getKey());
            aWriter.name(IO.JSON_VALUE_MEMBER_NAME).value(aclEntry.getValue());
            aWriter.endObject();
        }
        aWriter.endArray();
    }

    aWriter.endObject();
}

From source file:cc.kune.core.server.manager.I18nManagerDefaultTest.java

/**
 * By default use english./*  www  .j av  a 2  s.c o m*/
 */
@Test
public void byDefaultUseEnglish() {
    final HashMap<String, String> map = translationManager.getLexicon("en");
    final HashMap<String, String> map2 = translationManager.getLexicon("af");
    assertEquals(map.size(), map2.size());
}

From source file:com.odoo.support.provider.OContentProvider.java

private void handleManyToMany(HashMap<String, List<Integer>> record_ids, int _id) {
    if (record_ids.size() > 0) {
        for (String key : record_ids.keySet()) {
            List<Integer> ids = record_ids.get(key);
            OColumn column = model.getColumn(key);
            OModel rel_model = model.createInstance(column.getType());
            model.manageManyToManyRecords(model.getWritableDatabase(), rel_model, ids, _id, Command.Replace);
        }//from w w w  .j av a2s.c  o  m
    }
}

From source file:com.sfs.dao.GadgetPreferencesDAOImplTest.java

/**
 * Test of loadMap method, of class GadgetPreferencesDAOImpl.
 *
 * @throws Exception the exception/*  w ww . j av a2  s.  c o  m*/
 */
@Test
public final void testLoadMap() throws Exception {
    System.out.println("loadMap");

    final int expResult = 3;

    HashMap<Integer, GadgetPreferencesBean> result = this.gadgetPreferencesDAO.loadMap(testUser.getDN());

    assertEquals(expResult, result.size());
}