Example usage for java.util Map size

List of usage examples for java.util Map size

Introduction

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

Prototype

int size();

Source Link

Document

Returns the number of key-value mappings in this map.

Usage

From source file:com.hangum.tadpole.rdb.core.dialog.export.sqltoapplication.application.SQLToAxisjConvert.java

public static List<AxisjHeaderDAO> initializeHead(List<AxisjHeaderDAO> listAxisjHeader, UserDBDAO userDB,
        String sql) {//from   ww  w. j a va2s  .com
    try {
        QueryExecuteResultDTO queryResult = QueryUtils.executeQuery(userDB, sql, 0, 4);
        Map<Integer, String> columnLabel = queryResult.getColumnLabelName();
        Map<Integer, Integer> columnType = queryResult.getColumnType();

        for (int i = 0; i < columnLabel.size(); i++) {
            AxisjHeaderDAO axisjHeader = new AxisjHeaderDAO();

            axisjHeader.setSeqNo(i);
            axisjHeader.setKey(columnLabel.get(i));
            axisjHeader.setLabel(columnLabel.get(i));

            boolean isNumber = RDBTypeToJavaTypeUtils.isNumberType(columnType.get(i));
            axisjHeader.setAlign(isNumber ? 2 : 0);// 0:left, 1:center, 2:right
            axisjHeader.setChecked("function(){return false;}");
            axisjHeader.setColHeadTool(false);
            axisjHeader.setDisabled("function(){return false;}");
            axisjHeader.setFormatter(isNumber ? "function(){return this.value.number();}" : "\"\"");
            axisjHeader.setSort(1); //0:false, 1:Ascending, 2:Descending
            //TODO: https://github.com/axisj/axisj/issues/887
            axisjHeader.setTooltip("function(){return this.value.replace(/\\\"/gi, \"`\");} ");
            axisjHeader.setWidth(100);

            listAxisjHeader.add(axisjHeader);
        }
    } catch (Exception e) {
        logger.error("SQL template exception", e);
    }
    return listAxisjHeader;
}

From source file:edu.purdue.cybercenter.dm.util.JsonTransformer.java

private static Object applyDirective(Map<String, Object> directive, Object data, Map<String, Object> context) {
    if (directive == null || directive.isEmpty()) {
        throw new RuntimeException("empty directive");
    }//from  www.ja  va2  s .  c  o m
    if (directive.size() != 1) {
        throw new RuntimeException("invalid directive format: " + Helper.deepSerialize(directive));
    }
    String name = directive.keySet().iterator().next();
    Map<String, Object> definition = (Map<String, Object>) directive.get(name);
    switch (name) {
    case JsonTransformer.JSON_DIRECTIVE_MERGE:
        data = jsonMerge(definition, data, context);
        break;
    default:
    }
    return data;
}

From source file:com.hangum.tadpole.engine.sql.util.export.HTMLExporter.java

/**
 * make content/*  w w  w  . ja  v a2 s  .c o m*/
 * 
 * @param tableName
 * @param rsDAO
 * @param intLimitCnt
 * @return
 */
public static String makeContent(String tableName, QueryExecuteResultDTO rsDAO, int intLimitCnt) {
    List<Map<Integer, Object>> dataList = rsDAO.getDataList().getData();
    // column .
    Map<Integer, String> mapLabelName = rsDAO.getColumnLabelName();
    StringBuffer sbHead = new StringBuffer();
    sbHead.append(String.format(strHead, "#"));
    for (int i = 1; i < mapLabelName.size(); i++) {
        sbHead.append(String.format(strHead, mapLabelName.get(i)));
    }
    String strLastColumnName = String.format(strGroup, sbHead.toString());

    StringBuffer sbBody = new StringBuffer("");
    for (int i = 0; i < dataList.size(); i++) {
        Map<Integer, Object> mapColumns = dataList.get(i);

        StringBuffer sbTmp = new StringBuffer();
        sbTmp.append(String.format(strHead, "" + (i + 1))); //$NON-NLS-1$
        for (int j = 1; j < mapColumns.size(); j++) {
            String strValue = mapColumns.get(j) == null ? "" : "" + mapColumns.get(j);
            sbTmp.append(String.format(strContent, StringEscapeUtils.unescapeHtml(strValue))); //$NON-NLS-1$
        }
        sbBody.append(String.format(strGroup, sbTmp.toString()));

        if (i == intLimitCnt)
            break;
    }
    String strLastBody = String.format(strContetntGroup, strLastColumnName, sbBody);

    return HTMLDefine.sbHtml + strLastBody;
}

From source file:samples.jms.AbstractMessagingTests.java

/**
 * Shutdown gracefully at the end of the test to avoid an ugly exception.
 * Doing it explicitly avoids that. This method automatically runs after all
 * tests and must be static./*from  ww w.  j  a va 2 s.com*/
 */
@AfterClass
public static void shutdown() {

    Map<String, DefaultMessageListenerContainer> ctrs = applicationContext
            .getBeansOfType(DefaultMessageListenerContainer.class);

    LoggerFactory.getLogger(AbstractMessagingTests.class)
            .info("Shutting down " + ctrs.size() + " message listener container(s).");

    for (DefaultMessageListenerContainer ctr : ctrs.values())
        ctr.shutdown();
}

From source file:com.adobe.acs.commons.util.ParameterUtil.java

/**
 * Util for parsing Arrays of Service properties in the form &gt;value&lt;&gt;map-separator&lt;&gt;value&gt;list-separator&lt;&gt;value&lt;&lt;
 *
 * @param values    Array of key/value pairs in the format => [ a<map-separator>b, x<map-separator>y<list-separator>z ] ... ex. ["dog:woof", "cat:meow,purr"]
 * @param mapSeparator separator between the key/values in the amp
 * @param listSeparator separator between the values in each list
 * @return Map of key/value pairs; map.get("dog") => "woof", map.get("cat") => "meow"
 *///from www.ja  v a2s.  c  om
public static Map<String, String[]> toMap(final String[] values, final String mapSeparator,
        final String listSeparator) {
    final Map<String, String> map = toMap(values, mapSeparator);
    final Map<String, String[]> result = new LinkedHashMap<String, String[]>(map.size());
    for (final Map.Entry<String, String> entry : map.entrySet()) {
        result.put(entry.getKey(), StringUtils.split(entry.getValue(), listSeparator));
    }
    return result;
}

From source file:org.jasig.jpa.CacheKey.java

public static CacheKey build(String source, Map<? extends Serializable, ? extends Serializable> keyData) {
    final Serializable[] key = new Serializable[keyData.size()];

    int mapIndex = 0;
    for (final Map.Entry<? extends Serializable, ? extends Serializable> ve : keyData.entrySet()) {
        key[mapIndex++] = new Serializable[] { ve.getKey(), ve.getValue() };
    }//w w w .j a v  a 2s . co  m

    return new CacheKey(source, key);
}

From source file:com.xpn.xwiki.plugin.rightsmanager.RightsManagerPluginApi.java

/**
 * Convert Map/List pattern matching parameter from Velocity to [][] used in {@link RightsManager}.
 * //  w w w.  j  av  a2s.  c o  m
 * @param map a map of list from Velocity.
 * @return a table of table for {@link RightsManager} methods.
 */
static Object[][] createMatchingTable(Map<?, ?> map) {
    if (map == null || map.size() == 0) {
        return null;
    }

    Object[][] table = new Object[map.size()][3];

    int i = 0;
    for (Map.Entry<?, ?> entry : map.entrySet()) {
        table[i][0] = entry.getKey();

        if (entry.getValue() instanceof List) {
            List<?> typeValue = (List<?>) entry.getValue();
            table[i][1] = typeValue.get(0);
            if (typeValue.size() > 1) {
                table[i][2] = typeValue.get(1);
            }
        } else {
            table[i][2] = entry.getValue();
        }

        ++i;
    }

    return table;
}

From source file:com.threewks.thundr.http.URLEncoder.java

/**
 * Encodes the given query parameters into the query string such that it returns <code>?param1=value1&param2=value2&....</code>.
 * /*  www .  j  a v  a  2  s . co m*/
 * Uses toString on parameters to determine their string representation.
 * Returns an empty string if no parameters are provided.
 * 
 * @param parameters
 * @return
 */
public static final String encodeQueryString(Map<String, Object> parameters) {
    if (parameters == null) {
        parameters = Collections.emptyMap();
    }
    List<String> fragments = new ArrayList<String>(parameters.size());
    for (Map.Entry<String, Object> entry : parameters.entrySet()) {
        String key = entry.getKey();
        String value = entry.getValue() == null ? "" : entry.getValue().toString();
        fragments.add(encodeQueryComponent(key) + "=" + encodeQueryComponent(value));
    }
    return fragments.isEmpty() ? "" : "?" + StringUtils.join(fragments, "&");
}

From source file:com.bazaarvoice.jolt.SortrTest.java

private static String verifyMapOrder(Map<String, Object> actual, Map<String, Object> expected) {

    Iterator<String> actualIter = actual.keySet().iterator();
    Iterator<String> expectedIter = expected.keySet().iterator();

    for (int index = 0; index < actual.size(); index++) {
        String actualKey = actualIter.next();
        String expectedKey = expectedIter.next();

        if (!StringUtils.equals(actualKey, expectedKey)) {
            return "Found out of order keys '" + actualKey + "' and '" + expectedKey + "'";
        }/*w ww.ja v  a 2s  .c  om*/

        String result = verifyOrder(actual.get(actualKey), expected.get(expectedKey));
        if (result != null) {
            return result;
        }
    }

    return null; // success
}

From source file:com.hpe.application.automation.bamboo.tasks.AlmLabEnvPrepareTaskConfigurator.java

public static List<AlmConfigParameter> fetchAlmParametersFromContext(
        @NotNull final Map<String, String> context) {

    List<AlmConfigParameter> almParams = new ArrayList<AlmConfigParameter>(context.size());

    for (String key : context.keySet()) {
        if (key.startsWith("alm_param_")) {
            String[] arr = context.get(key).split("&;");
            almParams.add(new AlmConfigParameter(arr[0], arr[1], arr[2], arr[3]));
        }//from  w  ww .j  av  a2s  . c om
    }

    return almParams;
}