Example usage for java.util LinkedHashMap size

List of usage examples for java.util LinkedHashMap size

Introduction

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

Prototype

int size();

Source Link

Document

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

Usage

From source file:com.servioticy.datamodel.sensorupdate.SensorUpdate.java

@JsonSetter("channels")
public void setNotNullOrEmptyChannels(LinkedHashMap<String, SUChannel> channels) throws JsonMappingException {
    if (channels == null || channels.size() < 1) {
        throw new JsonMappingException("At least one channel is required");
    }/*  ww  w  .j a v a  2 s.  c  o m*/
    setChannels(channels);
}

From source file:com.zhumeng.dream.orm.hibernate.HibernateDao.java

/**
 * order by? :order by o.email desc , o.username asc
 * @author: lizhong//from   w  ww . j  a  v  a 2  s. co  m
 * @param orderBy key , valuedesc/asc.:
 * orderBy.put("email", "desc");
 * orderBy.put("username", "asc");
 * ?sql?order by o.email desc,o.username asc
 * @return
 */

public static String buildOrderby(LinkedHashMap<String, String> orderBy) {
    StringBuilder order = new StringBuilder();
    if (orderBy != null && orderBy.size() > 0) {
        order.append(" order by ");
        for (Entry<String, String> entry : orderBy.entrySet()) {
            order.append(" o.").append(entry.getKey()).append(" ").append(entry.getValue()).append(",");
        }
        order.deleteCharAt(order.length() - 1);
    }
    return order.toString();
}

From source file:ca.sfu.federation.model.Behavior.java

/**
 * On changes to the Context, take some action based on the user provided rules.
 * @param o Observable object./*from w  w w .java 2 s.co  m*/
 * @param arg Update message.
 */
public void update(Observable o, Object arg) {
    logger.log(Level.INFO, "Behavior update: on object {0}", o.toString());
    // filter the list using the user provided rules
    LinkedHashMap outputset = (LinkedHashMap) this.selection.update();
    if (outputset.size() > 0) {
        logger.log(Level.INFO, "Behavior {0} found targets: ", this.toString());
    }
    Iterator iter = outputset.values().iterator();
    StringBuilder sb = new StringBuilder();
    while (iter.hasNext()) {
        INamed named = (INamed) iter.next();
        sb.append(" ");
        sb.append(named.getName());
    }
    logger.log(Level.INFO, sb.toString());
    /*
    if (this.updateCondition != null && this.updateAction != null) {
    // determine the type of the update
    System out println("INFO: Behavior update: "+o.toString()+", "+arg.toString());
    // get the set of elements in the environment; remove bound assembly self from list
    LinkedHashMap inputset = (LinkedHashMap) this.context.getElementMap();
    // filter the list using the user provided rules
    LinkedHashMap outputset = (LinkedHashMap) this.selection.update();
    // take action based on the user rules
    if (outputset.size()>0) {
        // do something
    }
    }
     */
}

From source file:com.servioticy.datamodel.serviceobject.SO.java

@JsonSetter("streams")
protected void setCheckStreams(LinkedHashMap<String, Object> streams) throws IOException {
    if (streams == null || streams.size() < 1) {
        throw new JsonMappingException("At least one stream is required");
    }// ww w. j a va 2 s  .  co m
    this.streamsRaw = streams;
}

From source file:com.linkedin.haivvreo.AvroSerDe.java

private Properties determineCorrectProperties(Configuration configuration, Properties properties) {
    if ((configuration instanceof JobConf) && HaivvreoUtils.insideMRJob((JobConf) configuration)) {
        LOG.info("In MR job, extracting table-level properties");
        MapredWork mapRedWork = Utilities.getMapRedWork(configuration);
        LinkedHashMap<String, PartitionDesc> a = mapRedWork.getAliasToPartnInfo();
        if (a.size() == 1) {
            LOG.info("Only one PartitionDesc found.  Returning that Properties");
            PartitionDesc p = a.values().iterator().next();
            TableDesc tableDesc = p.getTableDesc();
            return tableDesc.getProperties();
        } else {//from   w w w .ja  v a  2  s  .  c  o m
            String tableName = properties.getProperty("name");
            LOG.info("Multiple PartitionDescs.  Return properties for " + tableName);

            for (Map.Entry<String, PartitionDesc> partitionDescs : a.entrySet()) {
                Properties p = partitionDescs.getValue().getTableDesc().getProperties();
                if (p.get("name").equals(tableName)) {
                    // We've found the matching table partition
                    LOG.info("Matched table name against " + partitionDescs.getKey()
                            + ", return its properties");
                    return p;
                }
            }
            // Didn't find anything in partitions to match on.  WARN, at least.
            LOG.warn("Couldn't find any matching properties for table: " + tableName
                    + ". Returning original properties");
        }

    }
    return properties;
}

From source file:com.logsniffer.reader.filter.support.JsonParseFilterTest.java

@SuppressWarnings("unchecked")
@Test//from  w  ww .j  av  a2 s  .c  o  m
public void testFiltering() {
    f.setTargetField("jsonObj");
    f.setSourceField("jsonStr");
    fields.put("jsonStr", "{'abc':'def'}");

    // Check
    f.filter(fields);
    Assert.assertNotNull(fields.get("jsonObj"));
    Assert.assertEquals("def", ((Map<String, Object>) fields.get("jsonObj")).get("abc"));

    LinkedHashMap<String, FieldBaseTypes> types = new LinkedHashMap<>();
    f.filterKnownFields(types);
    Assert.assertEquals(1, types.size());
    Assert.assertEquals(FieldBaseTypes.OBJECT, types.get("jsonObj"));
}

From source file:gov.llnl.lc.smt.command.route.SmtMulticast.java

public static String getStatus(OpenSmMonitorService OMService) {
    // return a string representation of the multicast statistics, similar to the smt-console
    if (OMService == null) {
        logger.severe("Can't get status from a null OMS object");
        return "Can't get status from a null OMS object";
    }//from www.  j a v  a2 s  .  com
    OSM_Fabric Fabric = OMService.getFabric();
    LinkedHashMap<String, SBN_MulticastGroup> mcGroups = preenMCastGroups(OMService);

    OsmServerStatus RStatus = OMService.getRemoteServerStatus();
    StringBuffer buff = new StringBuffer();

    buff.append(String.format("                Multicast Groups\n"));
    buff.append(SmtConstants.NEW_LINE);
    buff.append(String.format("Fabric Name:               %20s\n", Fabric.getFabricName()));
    if (RStatus != null)
        buff.append(
                String.format("Up since:                  %20s\n", RStatus.Server.getStartTime().toString()));
    buff.append(String.format("timestamp:                 %20s\n", Fabric.getTimeStamp().toString()));
    buff.append(SmtConstants.NEW_LINE);

    int numGroups = mcGroups.size();
    int numSingleGroups = getGroupsWithMembers(mcGroups, 1).length;
    int numActualGroups = getGroupsWithMembers(mcGroups, 2).length;
    int numEmptyGroups = numGroups - numSingleGroups;
    numSingleGroups -= numActualGroups;

    String format = "%38s:    %4d" + SmtConstants.NEW_LINE;
    buff.append(String.format(format, "total multicast groups", numGroups));
    buff.append(String.format(format, "empty multicast groups", numEmptyGroups));
    buff.append(String.format(format, "multicast groups with a single member", numSingleGroups));
    buff.append(String.format(format, "multicast groups with many members", numActualGroups));
    buff.append(
            String.format(format, "well known multicast groups", getWellKnownGroups(mcGroups, true).length));
    buff.append(String.format(format, "unknown multicast groups", getWellKnownGroups(mcGroups, false).length));

    return buff.toString();
}

From source file:org.deegree.tools.feature.gml.ApplicationSchemaTool.java

private static void mapToPostGIS(InputFormat inputFormat, String inputFileName, String rulesFileName)
        throws ClassCastException, ClassNotFoundException, InstantiationException, IllegalAccessException,
        JAXBException, IOException {

    LinkedHashMap<String, String> rules = new LinkedHashMap<String, String>();
    if (rulesFileName != null) {
        BufferedReader reader = new BufferedReader(new FileReader(rulesFileName));
        String line = null;//from  w w w  .j  a va 2s.co  m
        while ((line = reader.readLine()) != null) {
            line = line.trim();
            int indexOfDelim = line.indexOf('=');
            if (indexOfDelim != -1) {
                String from = line.substring(0, indexOfDelim);
                String to = line.substring(indexOfDelim + 1, line.length());
                rules.put(from, to);
            }
        }
        System.err.println("Loaded " + rules.size() + " replacement rule(s) from " + rulesFileName);
    } else {
        System.err.println("Continuing without rules file.");
    }

    AppSchema schema = loadAppSchema(inputFormat, inputFileName);

    Map<QName, FeatureTypeMapping> ftNameToHints = new HashMap<QName, FeatureTypeMapping>();
    FeatureType[] fts = schema.getFeatureTypes();
    Arrays.sort(fts, new Comparator<FeatureType>() {
        @Override
        public int compare(FeatureType o1, FeatureType o2) {
            return o1.getName().toString().compareTo(o2.getName().toString());
        }
    });
    for (FeatureType ft : fts) {
        // ftNameToHints.put( ft.getName(), getFtHints( schema, ft, rules ) );
    }

    // PostGISApplicationSchema postgisSchema = new PostGISApplicationSchema( schema, getGlobalHints( schema ),
    // ftNameToHints );
    // ApplicationSchemaDecl jaxbSchema = JAXBApplicationSchemaAdapter.toJAXB( postgisSchema );
    // JAXBContext jc = JAXBContext.newInstance( "org.deegree.feature.persistence.postgis.jaxbconfig" );
    // Marshaller m = jc.createMarshaller();
    // m.setProperty( Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE );
    // m.setProperty( Marshaller.JAXB_SCHEMA_LOCATION,
    // "http://www.deegree.org/feature/featuretype http://schemas.deegree.org/feature/0.5.0/postgis_appschema.xsd"
    // );
    // m.marshal( jaxbSchema, System.out );
}

From source file:com.kunalkene1797.blackboxkit.utils.database.ProfileDB.java

public void putProfile(String name, LinkedHashMap<String, String> commands) {
    try {//from w w  w.j  a v a2s . c o  m
        JSONObject items = new JSONObject();
        items.put("name", name);

        JSONArray commandArray = new JSONArray();
        for (int i = 0; i < commands.size(); i++) {
            JSONObject item = new JSONObject();
            item.put("path", commands.keySet().toArray()[i]);
            item.put("command", commands.values().toArray()[i]);
            commandArray.put(item);
        }

        items.put("commands", commandArray);

        putItem(items);
    } catch (JSONException e) {
        e.printStackTrace();
    }
}

From source file:eu.hydrologis.jgrass.charting.impl.JGrassXYLineChart.java

/**
 * A line chart creator basing on series made up two values per row. More series, independing
 * one from the other are supported.// w w w . ja v a  2 s  . c  o  m
 * 
 * @param chartValues - a hashmap containing as keys the name of the series and as values the
 *        double[][] representing the data. Important: the data matrix has to be passed as two
 *        rows (not two columns)
 */
public JGrassXYLineChart(LinkedHashMap<String, double[][]> chartValues) {
    chartSeries = new XYSeries[chartValues.size()];
    // extrapolate the data from the Hashmap and convert it to a XYSeries
    // Collection
    final Iterator<String> it = chartValues.keySet().iterator();
    int count = 0;
    while (it.hasNext()) {
        final String key = it.next();
        final double[][] values = chartValues.get(key);

        chartSeries[count] = new XYSeries(key);
        for (int i = 0; i < values[0].length; i++) {
            // important: the data matrix has to be passed as two rows (not
            // two columns)
            double val = values[1][i];
            if (isNovalue(val))
                continue;
            chartSeries[count].add(values[0][i], val);
        }
        count++;
    }

    lineDataset = new XYSeriesCollection();
    for (int i = 0; i < chartSeries.length; i++) {
        lineDataset.addSeries(chartSeries[i]);
    }

}