Example usage for java.util LinkedHashMap entrySet

List of usage examples for java.util LinkedHashMap entrySet

Introduction

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

Prototype

public Set<Map.Entry<K, V>> entrySet() 

Source Link

Document

Returns a Set view of the mappings contained in this map.

Usage

From source file:org.apache.hadoop.hbase.ChoreService.java

/**
 * Prints a summary of important details about the chore. Used for debugging purposes
 *///from  ww w. ja  v a 2  s.  c om
private void printChoreDetails(final String header, ScheduledChore chore) {
    LinkedHashMap<String, String> output = new LinkedHashMap<String, String>();
    output.put(header, "");
    output.put("Chore name: ", chore.getName());
    output.put("Chore period: ", Integer.toString(chore.getPeriod()));
    output.put("Chore timeBetweenRuns: ", Long.toString(chore.getTimeBetweenRuns()));

    for (Entry<String, String> entry : output.entrySet()) {
        if (LOG.isTraceEnabled())
            LOG.trace(entry.getKey() + entry.getValue());
    }
}

From source file:gov.llnl.lc.smt.command.system.SmtSystem.java

public String toSwitchString(OSM_System sys, boolean includePortDetails) {
    OSM_Fabric Fabric = OMService.getFabric();
    StringBuffer buff = new StringBuffer();
    String shortHeader = " lid            guid               name/description         #ports"
            + SmtConstants.NEW_LINE;/* w  w w. j  av a 2  s.c  o m*/
    String shortFormat = "%5d  %20s  %30s  %3d";

    String detailHeader = " lid            guid               name/description          lvl  up  down total"
            + SmtConstants.NEW_LINE;
    String detailFormat = "%5d  %20s  %30s  %2d  %3d  %3d  %3d";

    // lid  guid   name   num ports
    buff.append(includePortDetails ? detailHeader : shortHeader);

    if (includePortDetails) {
        LinkedHashMap<String, IB_Vertex> vMap = sys.getVertexMap();
        int maxDepth = sys.getMaxDepth();
        int minDepth = sys.getMinDepth();

        for (int d = maxDepth; d >= minDepth; d--) {
            LinkedHashMap<String, IB_Vertex> level = IB_Vertex.getVertexMapAtDepth(vMap, d);
            for (Entry<String, IB_Vertex> entry : level.entrySet()) {
                IB_Vertex v = entry.getValue();
                ArrayList<IB_Edge> el = v.getEdges();
                int upPorts = 0;
                int downPorts = 0;

                // if associated with an edge, then it is active (add up the ones at the lowest which will be external)
                for (IB_Edge e : el) {
                    if (e.getDepth() < v.getDepth())
                        downPorts++;
                    else
                        upPorts++;
                }
                IB_Guid g = v.getGuid();
                SBN_Node s = Fabric.getOSM_Node(g).sbnNode;
                String name = Fabric.getNameFromGuid(g);
                int lid = Fabric.getLidFromGuid(g);

                buff.append(String.format(detailFormat, lid, g.toColonString(), name, v.getDepth(), upPorts,
                        downPorts, v.getNumPorts()) + SmtConstants.NEW_LINE);
            }
        }
    } else
        for (IB_Guid g : sys.getGuidList()) {
            SBN_Node s = Fabric.getOSM_Node(g).sbnNode;
            String name = Fabric.getNameFromGuid(g);
            int lid = Fabric.getLidFromGuid(g);

            buff.append(String.format(shortFormat, lid, g.toColonString(), name, s.num_ports)
                    + SmtConstants.NEW_LINE);
        }
    return buff.toString();
}

From source file:org.kuali.rice.kew.docsearch.DocumentSearchCriteriaProcessorKEWAdapter.java

/**
 * Modifies the DataDictionary-defined applicationDocumentStatus field control to reflect whether the DocumentType
 * has specified a list of valid application document statuses (in which case a select control is rendered), or whether
 * it is free form (in which case a text control is rendered)
 *
 * @param field the applicationDocumentStatus field
 * @param documentType the document type
 *///from www .  j  a v  a2 s  .c o m
protected void applyApplicationDocumentStatusCustomizations(Field field, DocumentType documentType) {

    if (documentType.getValidApplicationStatuses() == null
            || documentType.getValidApplicationStatuses().size() == 0) {
        // use a text input field
        // StandardSearchCriteriaField(String fieldKey, String propertyName, String fieldType, String datePickerKey, String labelMessageKey, String helpMessageKeyArgument, boolean hidden, String displayOnlyPropertyName, String lookupableImplServiceName, boolean lookupTypeRequired)
        // new StandardSearchCriteriaField(DocumentSearchCriteriaProcessor.CRITERIA_KEY_APP_DOC_STATUS,"criteria.appDocStatus",StandardSearchCriteriaField.TEXT,null,null,"DocSearchApplicationDocStatus",false,null,null,false));
        // String fieldKey DocumentSearchCriteriaProcessor.CRITERIA_KEY_APP_DOC_STATUS
        field.setFieldType(Field.TEXT);
    } else {
        // multiselect
        // String fieldKey DocumentSearchCriteriaProcessor.CRITERIA_KEY_APP_DOC_STATUS + "_VALUES"
        field.setFieldType(Field.MULTISELECT);
        List<KeyValue> validValues = new ArrayList<KeyValue>();

        // add to set for quick membership check and removal.  LinkedHashSet to preserve order
        Set<String> statusesToDisplay = new LinkedHashSet<String>();
        for (ApplicationDocumentStatus status : documentType.getValidApplicationStatuses()) {
            statusesToDisplay.add(status.getStatusName());
        }

        // KULRICE-7786: support for groups (categories) of application document statuses

        LinkedHashMap<String, List<String>> appDocStatusCategories = ApplicationDocumentStatusUtils
                .getApplicationDocumentStatusCategories(documentType.getName());

        if (!appDocStatusCategories.isEmpty()) {
            for (Map.Entry<String, List<String>> group : appDocStatusCategories.entrySet()) {
                boolean addedCategoryHeading = false; // only add category if it has valid members
                for (String member : group.getValue()) {
                    if (statusesToDisplay.remove(member)) { // remove them from the set as we display them
                        if (!addedCategoryHeading) {
                            addedCategoryHeading = true;
                            validValues.add(new ConcreteKeyValue("category:" + group.getKey(), group.getKey()));
                        }
                        validValues.add(new ConcreteKeyValue(member, "- " + member));
                    }
                }
            }
        }

        // add remaining statuses, if any.
        for (String member : statusesToDisplay) {
            validValues.add(new ConcreteKeyValue(member, member));
        }

        field.setFieldValidValues(validValues);

        // size the multiselect as appropriate
        if (validValues.size() > 5) {
            field.setSize(5);
        } else {
            field.setSize(validValues.size());
        }

        //dropDown.setOptionsCollectionProperty("validApplicationStatuses");
        //dropDown.setCollectionKeyProperty("statusName");
        //dropDown.setCollectionLabelProperty("statusName");
        //dropDown.setEmptyCollectionMessage("Select a document status.");
    }
}

From source file:nl.nn.adapterframework.webcontrol.api.ShowConfiguration.java

@PUT
@RolesAllowed({ "IbisAdmin", "IbisTester" })
@Path("/configurations")
@Consumes(MediaType.APPLICATION_JSON)/*from w  ww. j a va  2s .co m*/
@Produces(MediaType.APPLICATION_JSON)
public Response fullReload(LinkedHashMap<String, Object> json) throws ApiException {
    initBase(servletConfig);

    Response.ResponseBuilder response = Response.status(Response.Status.NO_CONTENT); //PUT defaults to no content

    for (Entry<String, Object> entry : json.entrySet()) {
        String key = entry.getKey();
        Object value = entry.getValue();
        if (key.equalsIgnoreCase("action")) {
            if (value.equals("reload")) {
                ibisManager.handleAdapter("FULLRELOAD", "", "", "", null, true);
            }
            response.entity("{\"status\":\"ok\"}");
        }
    }

    return response.build();
}

From source file:gov.llnl.lc.smt.command.node.SmtNode.java

public static String getErrorPortSummary(OSM_FabricDeltaAnalyzer fda, OSM_Node n,
        LinkedHashMap<String, IB_Link> links, boolean includeStaticErrors) {
    OSM_Fabric fabric = fda.getDelta().getFabric2();
    StringBuffer buff = new StringBuffer();
    int num_errs = 0;
    // loop through the nodes port numbers, and print out the ones with errors ports
    for (int pn = 0; pn < n.sbnNode.num_ports; pn++) {
        String pKey = OSM_Fabric.getOSM_PortKey(n.getNodeGuid().getGuid(), (short) (pn + 1));
        OSM_Port p = fabric.getOSM_Port(pKey);
        String errStr = fda.getPortErrorState(n.getNodeGuid(), pn + 1);

        // if this is a port with an error, continue
        if ((errStr.length() > 1)
                && (includeStaticErrors || errStr.equals(OSM_FabricDeltaAnalyzer.DYNAMIC_ERROR))) {
            num_errs++;//from www.j  a  va 2s .c om
            IB_Link l = null;
            boolean down = true;
            // is this one of the active links? If not, count it as down
            for (Map.Entry<String, IB_Link> entry : links.entrySet()) {
                l = entry.getValue();
                if (l.contains(p)) {
                    // not one of the down ones
                    down = false;
                    break;
                }
            }
            if (down)
                buff.append(SmtNode.getDownPortLine(p, l, errStr) + SmtConstants.NEW_LINE);
            else
                buff.append(SmtNode.getLinkLine(p, l, fabric,
                        String.format(portFormatString, p.getPortNumber(), errStr)) + SmtConstants.NEW_LINE);
        }
    }
    return "(" + num_errs + ") Error ports" + SmtConstants.NEW_LINE + buff.toString();
}

From source file:com.redhat.rcm.version.Cli.java

private static String formatHelpMap(final LinkedHashMap<String, Object> map, final String itemSeparator) {
    final StringWriter sw = new StringWriter();
    final PrintWriter pw = new PrintWriter(sw);

    final int max = maxKeyLength(map.keySet());

    final int descMax = 75 - max;
    final String fmt = "%-" + max + "s    %-" + descMax + "s" + itemSeparator;

    for (final Map.Entry<String, Object> entry : map.entrySet()) {
        final String key = entry.getKey();
        final String description = entry.getValue() == null ? "-NONE-" : String.valueOf(entry.getValue());
        printKVLine(key, description, fmt, descMax, pw);
    }//  www.  j  a v  a2s  . c  o m

    return sw.toString();
}

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 {//w ww .  j a va2 s  . c om
            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:org.loklak.geo.GeoNames.java

/**
 * Match a given sequence mix with geolocations. First all locations matching with sequences larger than one
 * word are collected. If the result of this collection is not empty, the largest plase (measured by population)
 * is returned. If no such location can be found, matching with single-word locations is attempted and then also
 * the largest place is returned.//w w w . ja  va2  s .  co  m
 * @param mix the sequence mix
 * @return the largest place, matching with the mix, several-word matchings preferred
 */
private GeoMatch geomatch(LinkedHashMap<Integer, String> mix, final boolean preferLargePopulation) {
    TreeMap<Long, GeoMatch> cand = new TreeMap<>();
    int hitcount = 0;
    for (Map.Entry<Integer, String> entry : mix.entrySet()) {
        if (cand.size() > 0 && entry.getValue().indexOf(' ') < 0)
            return preferNonStopwordLocation(cand.values(), preferLargePopulation); // if we have location matches for place names with more than one word, return the largest place (measured by the population)
        List<Integer> locs = this.hash2ids.get(entry.getKey());
        if (locs == null || locs.size() == 0)
            continue;
        for (Integer i : locs) {
            GeoLocation loc = this.id2loc.get(i);
            if (loc != null) {
                for (String name : loc.getNames()) {
                    if (normalize(entry.getValue()).equals(normalize(name))) {
                        cand.put(hitcount++ - loc.getPopulation(), new GeoMatch(entry.getValue(), loc));
                        break;
                    }
                }
            }
        }
    }
    // finally return the largest place (if any found)
    return cand.size() > 0 ? preferNonStopwordLocation(cand.values(), preferLargePopulation) : null;
}

From source file:gov.llnl.lc.smt.command.node.SmtNode.java

public static String getDownPortSummary(OSM_FabricDelta fabricDelta, OSM_Node n,
        LinkedHashMap<String, IB_Link> links) {
    OSM_FabricDeltaAnalyzer fda = new OSM_FabricDeltaAnalyzer(fabricDelta);
    OSM_Fabric fabric = fabricDelta.getFabric2();
    StringBuffer buff = new StringBuffer();
    int num_ports = n.sbnNode.num_ports;
    int num_links = links.size();
    int num_down = num_ports - num_links;
    if (num_down > 0) {
        buff.append("(" + num_down + ") Down ports" + SmtConstants.NEW_LINE);
        // loop through the nodes port numbers, and print out the downed ports
        for (int pn = 0; pn < n.sbnNode.num_ports; pn++) {
            String pKey = OSM_Fabric.getOSM_PortKey(n.getNodeGuid().getGuid(), (short) (pn + 1));
            OSM_Port p = fabric.getOSM_Port(pKey);
            String errStr = fda.getPortErrorState(n.getNodeGuid(), pn + 1);

            IB_Link l = null;//from w  w  w. ja va 2 s  . c o m
            boolean down = true;
            // is this one of the active links? If not, count it as down
            for (Map.Entry<String, IB_Link> entry : links.entrySet()) {
                l = entry.getValue();
                if (l.contains(p)) {
                    // not one of the down ones
                    down = false;
                    break;
                }
            }
            if (down)
                buff.append(SmtNode.getDownPortLine(p, l, errStr) + SmtConstants.NEW_LINE);
        }
    }
    return buff.toString();
}

From source file:org.apache.hadoop.hbase.ChoreService.java

/**
 * Prints a summary of important details about the service. Used for debugging purposes
 *///from   www .j  a  v  a  2 s . com
private void printChoreServiceDetails(final String header) {
    LinkedHashMap<String, String> output = new LinkedHashMap<String, String>();
    output.put(header, "");
    output.put("ChoreService corePoolSize: ", Integer.toString(getCorePoolSize()));
    output.put("ChoreService scheduledChores: ", Integer.toString(getNumberOfScheduledChores()));
    output.put("ChoreService missingStartTimeCount: ", Integer.toString(getNumberOfChoresMissingStartTime()));

    for (Entry<String, String> entry : output.entrySet()) {
        if (LOG.isTraceEnabled())
            LOG.trace(entry.getKey() + entry.getValue());
    }
}