Example usage for java.util SortedMap keySet

List of usage examples for java.util SortedMap keySet

Introduction

In this page you can find the example usage for java.util SortedMap keySet.

Prototype

Set<K> keySet();

Source Link

Document

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

Usage

From source file:com.romeikat.datamessie.core.base.util.sparsetable.SparseSingleTable.java

@Override
public synchronized List<Y> getColumnHeadersSorted(final X rowHeader,
        final Comparator<? super Y> columnHeaderComparator, final Comparator<? super Z> rowValueComparator) {
    final SortedMap<Y, Z> rowSorted = getRowSorted(rowHeader, columnHeaderComparator, rowValueComparator);
    final List<Y> columnHeadersSorted = Lists.newArrayList(rowSorted.keySet());
    // Done/*  ww  w .j  a v  a  2s. c o m*/
    return columnHeadersSorted;
}

From source file:com.aurel.track.fieldType.runtime.matchers.run.CompositeSelectMatcherRT.java

/**
 * Add a match expression to the criteria
 *///from  w  ww . jav a  2  s . c  o  m
@Override
public void addCriteria(Criteria crit) {
    if (relation == MatchRelations.IS_NULL || relation == MatchRelations.NOT_IS_NULL) {
        String alias = addAliasAndJoin(crit);
        addNullExpressionToCriteria(crit, alias + "." + "CUSTOMOPTIONID");
        return;
    }
    SortedMap<Integer, Object> matcherValueMap = null;
    try {
        matcherValueMap = (SortedMap<Integer, Object>) matchValue;
    } catch (Exception e) {
        LOGGER.warn("Converting the matcher value of type " + matchValue.getClass().getName()
                + " to SortedMap<Integer, Object> failed with " + e.getMessage());
        LOGGER.debug(ExceptionUtils.getStackTrace(e));
    }
    if (matcherValueMap != null && matcherValueMap.size() != 0) {
        Iterator<Integer> iterator = matcherValueMap.keySet().iterator();
        Criterion criterion = null;
        while (iterator.hasNext()) {
            Integer parameterCode = iterator.next();
            Integer[] matcherValueCustomOption = null;
            try {
                matcherValueCustomOption = (Integer[]) matcherValueMap.get(parameterCode);
            } catch (Exception e) {
                LOGGER.error("Converting the matcher value for part " + parameterCode
                        + " to Integer[] failed with " + e.getMessage());
                LOGGER.debug(ExceptionUtils.getStackTrace(e));
                return;
            }
            if (matcherValueCustomOption == null || matcherValueCustomOption.length == 0) {
                matcherValueCustomOption = new Integer[0];
            }
            String alias = null;
            switch (relation) {
            case MatchRelations.EQUAL:
                alias = addAliasAndJoin(crit, parameterCode);
                crit.addIn(alias + "." + "CUSTOMOPTIONID", matcherValueCustomOption);
                break;
            case MatchRelations.NOT_EQUAL:
                alias = addAliasAndJoin(crit, parameterCode);
                if (criterion == null) {
                    criterion = crit.getNewCriterion(alias + "." + "CUSTOMOPTIONID", matcherValueCustomOption,
                            Criteria.NOT_IN);
                } else {
                    criterion = criterion.or(crit.getNewCriterion(alias + "." + "CUSTOMOPTIONID",
                            matcherValueCustomOption, Criteria.NOT_IN));
                }
                break;
            case MatchRelations.PARTIAL_MATCH:
                if (matcherValueCustomOption[0].equals(ANY_FROM_LEVEL)) {
                    return;
                } else {
                    alias = addAliasAndJoin(crit, parameterCode);
                    crit.addIn(alias + "." + "CUSTOMOPTIONID", matcherValueCustomOption);
                }
                break;
            case MatchRelations.PARTIAL_NOTMATCH:
                if (!matcherValueCustomOption[0].equals(NONE_FROM_LEVEL)) {
                    alias = addAliasAndJoin(crit, parameterCode);
                    if (criterion == null) {
                        criterion = crit.getNewCriterion(alias + "." + "CUSTOMOPTIONID",
                                matcherValueCustomOption, Criteria.NOT_IN);
                    } else {
                        criterion = criterion.or(crit.getNewCriterion(alias + "." + "CUSTOMOPTIONID",
                                matcherValueCustomOption, Criteria.NOT_IN));
                    }
                }
                break;
            }
        }
        if (criterion != null) {
            crit.add(criterion);
        }
    }
}

From source file:de.tudarmstadt.ukp.experiments.argumentation.sequence.feature.coreference.CoreferenceFeatures.java

@Override
protected List<Feature> extract(JCas jCas, Sentence sentence, String sentencePrefix)
        throws TextClassificationException {
    List<List<CoreferenceLink>> coreferenceChains = extractCoreferenceChains(jCas);

    FrequencyDistribution<String> featuresAcrossAllChains = new FrequencyDistribution<>();
    DescriptiveStatistics chainLength = new DescriptiveStatistics();
    DescriptiveStatistics distanceToPreviousSentence = new DescriptiveStatistics();
    DescriptiveStatistics distanceToNextSentence = new DescriptiveStatistics();
    DescriptiveStatistics interSentencesCorLinks = new DescriptiveStatistics();

    for (List<CoreferenceLink> chain : coreferenceChains) {

        SortedMap<Integer, List<CoreferenceLink>> sentencesAndLinks = extractSentencesAndLinksFromChain(chain,
                jCas);//from  w ww.jav  a 2s .  co  m

        int currentSentencePos = getCurrentSentencePos(jCas, sentence);

        log.debug(sentencesAndLinks.keySet() + ", current " + currentSentencePos);

        // is the sentence in chain that spans more sentences?
        boolean partOfChain = sentencesAndLinks.containsKey(currentSentencePos) && sentencesAndLinks.size() > 1;

        // is part of a chain?
        if (partOfChain) {
            log.debug(chainToString(chain));
            featuresAcrossAllChains.inc(FN_PART_OF_CHAIN);

            // starts the chain?
            if (sentencesAndLinks.firstKey().equals(currentSentencePos)) {
                featuresAcrossAllChains.inc(FN_STARTS_THE_CHAIN);
            } else if (sentencesAndLinks.lastKey().equals(currentSentencePos)) {
                // ends the chain?
                featuresAcrossAllChains.inc(FN_ENDS_THE_CHAIN);
            } else {
                // in the middle of chain?
                featuresAcrossAllChains.inc(FN_IN_THE_MIDDLE_OF_CHAIN);
            }

            // length of the chain
            chainLength.addValue(sentencesAndLinks.size());

            List<CoreferenceLink> currentSentenceLinks = sentencesAndLinks.get(currentSentencePos);
            CoreferenceLink currentSentenceFirstLink = currentSentenceLinks.get(0);
            CoreferenceLink currentSentenceLastLink = currentSentenceLinks.get(currentSentenceLinks.size() - 1);

            // transition to the previous link, i.e. NOMINAL -> PRONOMINAL
            if (!sentencesAndLinks.firstKey().equals(currentSentencePos)) {
                // find the previous sentence
                List<CoreferenceLink> previousSentenceLinks = null;
                int prevSentNo = currentSentencePos;
                while (previousSentenceLinks == null && prevSentNo >= 0) {
                    prevSentNo--;

                    if (sentencesAndLinks.containsKey(prevSentNo)) {
                        previousSentenceLinks = sentencesAndLinks.get(prevSentNo);
                    }
                }

                if (previousSentenceLinks == null) {
                    throw new IllegalStateException("Oops :))");
                }

                // distance to previous sentence
                distanceToPreviousSentence.addValue(currentSentencePos - prevSentNo);

                // get the last link from the previous sentence
                CoreferenceLink prevSentenceLastLink = previousSentenceLinks
                        .get(previousSentenceLinks.size() - 1);

                // add type type transition
                String prevSentenceLastLinkReferenceType = prevSentenceLastLink.getReferenceType();
                String currentSentenceFirstLinkReferenceType = currentSentenceFirstLink.getReferenceType();
                String transitionType = prevSentenceLastLinkReferenceType + GLUE
                        + currentSentenceFirstLinkReferenceType;
                featuresAcrossAllChains.addSample(FN_TRANSITION_IN_TYPE_TYPE + transitionType, 1);

                // add token - type transition
                String glueCoreferenceCurrentSentence = glueCoreferenceLinkTokens(currentSentenceFirstLink);
                String typeToken = prevSentenceLastLinkReferenceType + GLUE + glueCoreferenceCurrentSentence;
                featuresAcrossAllChains.addSample(FN_TRANSITION_IN_TYPE_TOKEN + typeToken, 1);

                // add type - token transition
                String glueCoreferencePrevSentence = glueCoreferenceLinkTokens(prevSentenceLastLink);
                String tokenType = glueCoreferencePrevSentence + GLUE + currentSentenceFirstLinkReferenceType;
                featuresAcrossAllChains.addSample(FN_TRANSITION_IN_TOKEN_TYPE + tokenType, 1);

                // add token token transition
                String tokenToken = glueCoreferencePrevSentence + GLUE + glueCoreferenceCurrentSentence;
                featuresAcrossAllChains.addSample(FN_TRANSITION_IN_TOKEN_TOKEN + tokenToken, 1);

                // exact matching token-token reference?
                if (glueCoreferencePrevSentence.equals(glueCoreferenceCurrentSentence)) {
                    featuresAcrossAllChains.addSample(FN_TRANSITION_IN_TOKEN_TOKEN_MATCH, 1);
                }
            }

            // transition to the previous link, i.e. NOMINAL -> PRONOMINAL
            if (!sentencesAndLinks.lastKey().equals(currentSentencePos)) {
                // find the previous sentence
                List<CoreferenceLink> nextSentenceLinks = null;
                int nextSentNo = currentSentencePos;
                while (nextSentenceLinks == null && nextSentNo <= sentencesAndLinks.lastKey()) {
                    nextSentNo++;

                    if (sentencesAndLinks.containsKey(nextSentNo)) {
                        nextSentenceLinks = sentencesAndLinks.get(nextSentNo);
                    }
                }

                if (nextSentenceLinks == null) {
                    throw new IllegalStateException("Oops :))");
                }

                // distance to next sentence
                distanceToNextSentence.addValue(nextSentNo - currentSentencePos);

                // get the last link from the previous sentence
                CoreferenceLink nextSentenceFirstLink = nextSentenceLinks.get(0);

                // add type type transition
                String currentSentenceLastLinkReferenceType = currentSentenceLastLink.getReferenceType();
                String nextSentenceFirstLinkReferenceType = nextSentenceFirstLink.getReferenceType();
                String transitionType = currentSentenceLastLinkReferenceType + GLUE
                        + nextSentenceFirstLinkReferenceType;
                featuresAcrossAllChains.addSample(FN_TRANSITION_OUT_TYPE_TYPE + transitionType, 1);

                // add token - type transition
                String glueCoreferenceCurrentSent = glueCoreferenceLinkTokens(currentSentenceLastLink);
                String typeToken = glueCoreferenceCurrentSent + GLUE + nextSentenceFirstLinkReferenceType;
                featuresAcrossAllChains.addSample(FN_TRANSITION_OUT_TOKEN_TYPE + typeToken, 1);

                // add type - token transition
                String glueCoreferenceNextSent = glueCoreferenceLinkTokens(nextSentenceFirstLink);
                String tokenType = currentSentenceLastLinkReferenceType + GLUE + glueCoreferenceNextSent;
                featuresAcrossAllChains.addSample(FN_TRANSITION_OUT_TYPE_TOKEN + tokenType, 1);

                // add token token transition
                String tokenToken = glueCoreferenceCurrentSent + GLUE + glueCoreferenceNextSent;
                featuresAcrossAllChains.addSample(FN_TRANSITION_OUT_TOKEN_TOKEN + tokenToken, 1);

                // exact matching token-token reference?
                if (glueCoreferenceNextSent.equals(glueCoreferenceCurrentSent)) {
                    featuresAcrossAllChains.addSample(FN_TRANSITION_OUT_TOKEN_TOKEN_MATCH, 1);
                }
            }
        }

        // number of inter-sentence coreference links
        if (sentencesAndLinks.containsKey(currentSentencePos)) {
            int coreferenceLinks = sentencesAndLinks.get(currentSentencePos).size();
            interSentencesCorLinks.addValue(coreferenceLinks);
        }

        /*
        List<Integer> positions = positionsOfSentenceInCurrentChain(chain, sentence);
                
        // ok, we're in a chain
        if (!positions.isEmpty()) {
        log.debug(printChain(chain));
        log.debug(sentence.getCoveredText());
        log.debug(positions);
        Integer lastPosition = positions.get(positions.size() - 1);
        Integer firstPosition = positions.get(0);
                
        if (lastPosition == positions.size() - 1) {
            log.debug("Last sentence of chain");
        }
                
        log.debug("-----");
        }
        */
    }

    List<Feature> result = new ArrayList<>();

    log.debug(featuresAcrossAllChains);
    if (distanceToNextSentence.getN() > 0) {
        log.debug("Next:" + distanceToNextSentence);

        result.add(new Feature(sentencePrefix + FEATURE_NAME + FN_DIST_TO_NEXT_MIN,
                distanceToNextSentence.getMin()));
        result.add(new Feature(sentencePrefix + FEATURE_NAME + FN_DIST_TO_NEXT_MAX,
                distanceToNextSentence.getMax()));
        result.add(new Feature(sentencePrefix + FEATURE_NAME + FN_DIST_TO_NEXT_AVG,
                distanceToNextSentence.getMean()));
    }
    if (distanceToPreviousSentence.getN() > 0) {

        log.debug("Prev: " + distanceToPreviousSentence);

        result.add(new Feature(sentencePrefix + FEATURE_NAME + FN_DIST_TO_PREV_MIN,
                distanceToPreviousSentence.getMin()));
        result.add(new Feature(sentencePrefix + FEATURE_NAME + FN_DIST_TO_PREV_MAX,
                distanceToPreviousSentence.getMax()));
        result.add(new Feature(sentencePrefix + FEATURE_NAME + FN_DIST_TO_PREV_AVG,
                distanceToPreviousSentence.getMean()));
    }

    if (interSentencesCorLinks.getN() > 0) {
        result.add(new Feature(sentencePrefix + FEATURE_NAME + FN_INTER_SENT_COR_MIN,
                interSentencesCorLinks.getMin()));
        result.add(new Feature(sentencePrefix + FEATURE_NAME + FN_INTER_SENT_COR_MAX,
                interSentencesCorLinks.getMax()));
        result.add(new Feature(sentencePrefix + FEATURE_NAME + FN_INTER_SENT_COR_AVG,
                interSentencesCorLinks.getMean()));
    }

    log.debug("----");

    for (String feat : featuresAcrossAllChains.getKeys()) {
        // binary
        result.add(new Feature(sentencePrefix + FEATURE_NAME + feat, 1));
    }

    return result;
}

From source file:org.mule.devkit.doclet.Doclava.java

public static PackageInfo[] choosePackages() {
    if (sVisiblePackages != null) {
        return sVisiblePackages;
    }/*  ww  w  .ja  v  a  2s . c om*/

    ClassInfo[] classes = Converter.rootClasses();
    SortedMap<String, PackageInfo> sorted = new TreeMap<String, PackageInfo>();
    for (ClassInfo cl : classes) {
        PackageInfo pkg = cl.containingPackage();
        String name;
        if (pkg == null) {
            name = "";
        } else {
            name = pkg.name();
        }
        sorted.put(name, pkg);
    }

    ArrayList<PackageInfo> result = new ArrayList<PackageInfo>();

    for (String s : sorted.keySet()) {
        PackageInfo pkg = sorted.get(s);

        if (pkg.isHidden()) {
            continue;
        }
        Boolean allHidden = true;
        int pass = 0;
        ClassInfo[] classesToCheck = null;
        while (pass < 5) {
            switch (pass) {
            case 0:
                classesToCheck = pkg.ordinaryClasses();
                break;
            case 1:
                classesToCheck = pkg.enums();
                break;
            case 2:
                classesToCheck = pkg.errors();
                break;
            case 3:
                classesToCheck = pkg.exceptions();
                break;
            case 4:
                classesToCheck = pkg.getInterfaces();
                break;
            default:
                System.err.println("Error reading package: " + pkg.name());
                break;
            }
            for (ClassInfo cl : classesToCheck) {
                if (!cl.isHidden()) {
                    allHidden = false;
                    break;
                }
            }
            if (!allHidden) {
                break;
            }
            pass++;
        }
        if (allHidden) {
            continue;
        }

        result.add(pkg);
    }

    sVisiblePackages = result.toArray(new PackageInfo[result.size()]);
    return sVisiblePackages;
}

From source file:org.apache.accumulo.server.master.balancer.HostRegexTableLoadBalancer.java

@Override
public long balance(SortedMap<TServerInstance, TabletServerStatus> current, Set<KeyExtent> migrations,
        List<TabletMigration> migrationsOut) {
    long minBalanceTime = 5 * 1000;
    // Iterate over the tables and balance each of them
    TableOperations t = getTableOperations();
    if (t == null)
        return minBalanceTime;

    Map<String, SortedMap<TServerInstance, TabletServerStatus>> currentGrouped = splitCurrentByRegex(current);
    if ((System.currentTimeMillis() - this.lastOOBCheck) > this.oobCheckMillis) {
        try {// ww  w. j  av a 2 s.co m
            // Check to see if a tablet is assigned outside the bounds of the pool. If so, migrate it.
            for (Entry<TServerInstance, TabletServerStatus> e : current.entrySet()) {
                for (String table : poolNameToRegexPattern.keySet()) {
                    // pool names are the same as table names, except in the DEFAULT case.
                    // If this table is assigned to a pool for this host, then move on.
                    if (getPoolNamesForHost(e.getKey().host()).contains(table)) {
                        continue;
                    }
                    String tid = t.tableIdMap().get(table);
                    if (null == tid) {
                        LOG.warn(
                                "Unable to check for out of bounds tablets for table {}, it may have been deleted or renamed.",
                                table);
                        continue;
                    }
                    try {
                        List<TabletStats> outOfBoundsTablets = getOnlineTabletsForTable(e.getKey(), tid);
                        if (null == outOfBoundsTablets) {
                            continue;
                        }
                        Random random = new Random();
                        for (TabletStats ts : outOfBoundsTablets) {
                            KeyExtent ke = new KeyExtent(ts.getExtent());
                            if (migrations.contains(ke)) {
                                LOG.debug("Migration for  out of bounds tablet {} has already been requested",
                                        ke);
                                continue;
                            }
                            String poolName = getPoolNameForTable(table);
                            SortedMap<TServerInstance, TabletServerStatus> currentView = currentGrouped
                                    .get(poolName);
                            if (null != currentView) {
                                int skip = random.nextInt(currentView.size());
                                Iterator<TServerInstance> iter = currentView.keySet().iterator();
                                for (int i = 0; i < skip; i++) {
                                    iter.next();
                                }
                                TServerInstance nextTS = iter.next();
                                LOG.info(
                                        "Tablet {} is currently outside the bounds of the regex, migrating from {} to {}",
                                        ke, e.getKey(), nextTS);
                                migrationsOut.add(new TabletMigration(ke, e.getKey(), nextTS));
                                if (migrationsOut.size() > this.maxTServerMigrations) {
                                    break;
                                }
                            } else {
                                LOG.warn(
                                        "No tablet servers online for pool {}, unable to migrate out of bounds tablets",
                                        poolName);
                            }
                        }
                    } catch (TException e1) {
                        LOG.error("Error in OOB check getting tablets for table {} from server {}", tid,
                                e.getKey().host(), e);
                    }
                }
            }
        } finally {
            this.lastOOBCheck = System.currentTimeMillis();
        }
    }

    if (migrationsOut.size() > 0) {
        LOG.warn("Not balancing tables due to moving {} out of bounds tablets", migrationsOut.size());
        return minBalanceTime;
    }

    if (migrations != null && migrations.size() > 0) {
        LOG.warn("Not balancing tables due to {} outstanding migrations", migrations.size());
        return minBalanceTime;
    }

    for (String s : t.tableIdMap().values()) {
        String tableName = tableIdToTableName.get(s);
        String regexTableName = getPoolNameForTable(tableName);
        SortedMap<TServerInstance, TabletServerStatus> currentView = currentGrouped.get(regexTableName);
        if (null == currentView) {
            LOG.warn(
                    "Skipping balance for table {} as no tablet servers are online, will recheck for online tservers at {} ms intervals",
                    tableName, this.poolRecheckMillis);
            continue;
        }
        ArrayList<TabletMigration> newMigrations = new ArrayList<TabletMigration>();
        long tableBalanceTime = getBalancerForTable(s).balance(currentView, migrations, newMigrations);
        if (tableBalanceTime < minBalanceTime) {
            minBalanceTime = tableBalanceTime;
        }
        migrationsOut.addAll(newMigrations);
        if (migrationsOut.size() > this.maxTServerMigrations) {
            break;
        }
    }

    return minBalanceTime;
}

From source file:org.opencms.workplace.CmsWidgetDialogParameter.java

/**
 * Create a new Widget parameter.<p>
 * /*from   w  ww . j a v  a2 s.  com*/
 * @param base the base of the parameter
 * @param index the index of this parameter in the list
 * @param originalIndex the original index in the previous version of the list
 */
public CmsWidgetDialogParameter(CmsWidgetDialogParameter base, int index, int originalIndex) {

    this(null, base.m_defaultValue, base.getName(), base.getWidget(), base.getDialogPage(), base.getMinOccurs(),
            base.getMaxOccurs(), index);

    m_baseObject = base.m_baseObject;
    m_baseObjectProperty = base.m_baseObjectProperty;
    m_baseCollection = base.m_baseCollection;

    if (m_baseCollection != null) {
        if (m_baseCollection instanceof List) {
            // base object is a list - make sure to set possible old value 
            List<?> baseList = (List<?>) m_baseCollection;
            if (originalIndex < baseList.size()) {
                Object o = baseList.get(originalIndex);
                if (o != null) {
                    m_value = o.toString();
                }
            }
        } else if (m_baseCollection instanceof SortedMap) {
            // base object is a sorted map - make sure to set possible old value 
            SortedMap<?, ?> baseMap = (SortedMap<?, ?>) m_baseCollection;
            @SuppressWarnings({ "unchecked", "rawtypes" })
            List<?> keyList = new ArrayList(baseMap.keySet());
            if (originalIndex < keyList.size()) {
                Object key = keyList.get(originalIndex);
                Object value = baseMap.get(key);
                StringBuffer val = new StringBuffer();
                val.append(key != null ? key.toString() : "");
                val.append('=');
                val.append(value != null ? value.toString() : "");
                m_value = val.toString();
            }
        }
    }
}

From source file:com.romeikat.datamessie.core.base.util.sparsetable.SparseSingleTable.java

@Override
public synchronized List<X> getRowHeadersSorted(final Y columnHeader,
        final Comparator<? super X> rowHeaderComparator, final Comparator<? super Z> columnValueComparator) {
    final SortedMap<X, Z> columnSorted = getColumnSorted(columnHeader, rowHeaderComparator,
            columnValueComparator);/*  w w w.j a va 2 s  .co m*/
    final List<X> rowHeadersSorted = Lists.newArrayList(columnSorted.keySet());
    // Done
    return rowHeadersSorted;
}

From source file:org.web4thejob.studio.controller.impl.PropertyEditorController.java

private void refreshComponentProperties(SortedMap<String, SortedSet<Element>> propsMap) {
    ComponentDefinition componentDefinition = getDefinitionByTag(selection.getLocalName());
    List<Row> bindings = new ArrayList<>(1);

    for (String group : propsMap.keySet()) {
        Groupbox groupbox = findGroup(group);
        Row row;//from w  w w.  j  av a2 s. c  o m
        if (groupbox == null) {
            groupbox = buildGroupbox(group);
        }
        Grid grid = (Grid) groupbox.getLastChild();

        int num = 0;
        for (Element property : propsMap.get(group)) {
            String propertyName = property.getAttributeValue("name");
            if (isEvent(propertyName))
                continue;

            Object val = null;
            Attribute attribute = selection.getAttribute(propertyName);
            if (attribute != null) {
                val = attribute.getValue();
            }

            InputElement editor = findEditor(selection, propertyName);
            if (editor == null) {
                row = new Row();
                row.setAttribute("property", propertyName);
                row.setWidgetAttribute("w4tjstudio-property", propertyName);
                row.setParent(grid.getRows());

                Label name = new Label(propertyName);
                name.setParent(row);

                name.setValue(propertyName);

                editor = createEditor(componentDefinition, property, val);
                editor.setAttribute("property", propertyName);
                editor.setAttribute("element", selection);
                editor.addEventListener(Events.ON_OK, OK_HANDLER);
                editor.setParent(row);
            } else {
                editor.setAttribute("element", selection);
                editor.setRawValue(val);
                row = (Row) editor.getParent();
            }

            if (val instanceof String) {
                String s = (String) val;
                if (s.contains("@bind(") || s.contains("@load(") || s.contains("@save(")) {
                    Row brow = (Row) row.clone();
                    ((Label) brow.getFirstChild()).setSclass("label label-primary");
                    String bval = ((InputElement) brow.getLastChild()).getRawValue().toString();
                    brow.getLastChild().detach();
                    new Html("<span class=\"label label-success z-label\">" + bval + "</span>").setParent(brow);
                    bindings.add(brow);
                }
            }

            num++;
        }

        if (num > 0) {
            groupbox.setParent(properties);
        } //else discard

    }

    if (!bindings.isEmpty()) {
        Groupbox groupbox = findGroup("bindings");
        Grid grid;
        if (groupbox == null) {
            groupbox = buildGroupbox("bindings");
            properties.insertBefore(groupbox, properties.getFirstChild());
            groupbox.setOpen(true);
        }
        grid = (Grid) groupbox.getLastChild();
        grid.getRows().getChildren().clear();
        for (Row row : bindings) {
            row.setParent(grid.getRows());
        }
    } else {
        Groupbox groupbox = findGroup("bindings");
        if (groupbox != null)
            groupbox.detach();
    }

    Clients.evalJavaScript("w4tjStudioDesigner.decoratePropertyCaptions();");
}

From source file:org.mule.devkit.doclet.Doclava.java

public static PackageInfo[] chooseModulePackages() {
    ClassInfo[] classes = Converter.rootClasses();
    SortedMap<String, PackageInfo> sorted = new TreeMap<String, PackageInfo>();
    for (ClassInfo cl : classes) {
        if (!cl.isModule()) {
            continue;
        }//from www .j a  v  a2 s  .  c  o  m

        PackageInfo pkg = cl.containingPackage();
        String name;
        if (pkg == null) {
            name = "";
        } else {
            name = pkg.name();
        }
        sorted.put(name, pkg);
    }

    ArrayList<PackageInfo> result = new ArrayList<PackageInfo>();

    for (String s : sorted.keySet()) {
        PackageInfo pkg = sorted.get(s);

        result.add(pkg);
    }

    return result.toArray(new PackageInfo[result.size()]);
}

From source file:com.aurel.track.fieldType.runtime.matchers.run.CompositeSelectMatcherRT.java

/**
 * Whether the value matches or not// w w w .ja va2s.  co  m
 * @param attributeValue
 * @return
 */
@Override
public boolean match(Object attributeValue) {
    Boolean nullMatch = nullMatcher(attributeValue);
    if (nullMatch != null) {
        return nullMatch.booleanValue();
    }
    if (attributeValue == null || matchValue == null) {
        return false;
    }
    Map<Integer, Object> attributeValueMap = null;
    try {
        attributeValueMap = (Map<Integer, Object>) attributeValue;
    } catch (Exception e) {
        LOGGER.warn("Converting the attribute value of type " + attributeValue.getClass().getName()
                + " to Map<Integer, Object failed with " + e.getMessage());
        LOGGER.debug(ExceptionUtils.getStackTrace(e));
    }
    SortedMap<Integer, Object> matcherValueMap = null;
    try {
        matcherValueMap = (SortedMap<Integer, Object>) matchValue;
    } catch (Exception e) {
        LOGGER.warn("Converting the matcher value of type " + matchValue.getClass().getName()
                + " to SortedMap<Integer, Object> failed with " + e.getMessage());
        LOGGER.debug(ExceptionUtils.getStackTrace(e));
    }
    if (attributeValueMap == null || matcherValueMap == null) {
        return false;
    }
    Iterator<Integer> iterator = matcherValueMap.keySet().iterator();
    while (iterator.hasNext()) {
        Integer parameterCode = iterator.next();
        Object[] attributeValueCustomOption = null;
        try {
            attributeValueCustomOption = (Object[]) attributeValueMap.get(parameterCode);
        } catch (Exception e) {
            LOGGER.warn("Converting the attribute value for part " + parameterCode + " to Object[] failed with "
                    + e.getMessage());
            LOGGER.debug(ExceptionUtils.getStackTrace(e));
            return false;
        }
        Integer[] matcherValueCustomOption = null;
        try {
            matcherValueCustomOption = (Integer[]) matcherValueMap.get(parameterCode);
        } catch (Exception e) {
            LOGGER.error("Converting the matcher value for part " + parameterCode + " to Integer[] failed with "
                    + e.getMessage());
            LOGGER.debug(ExceptionUtils.getStackTrace(e));
            return false;
        }

        if (attributeValueCustomOption == null) {
            attributeValueCustomOption = new Object[0];
        }
        if (matcherValueCustomOption == null) {
            matcherValueCustomOption = new Integer[0];
        }
        if (attributeValueCustomOption.length != matcherValueCustomOption.length) {
            return false;
        }

        if (matcherValueCustomOption.length == 0) {
            return matcherValueCustomOption.length == 0;
        }
        Integer matcherValueAtLevel = matcherValueCustomOption[0];
        switch (relation) {
        case MatchRelations.EQUAL:
            if (!containsValue(matcherValueAtLevel, attributeValueCustomOption)) {
                return false;
            }
            break;
        case MatchRelations.NOT_EQUAL:
            if (!containsValue(matcherValueAtLevel, attributeValueCustomOption)) {
                return true;
            }
            break;
        case MatchRelations.PARTIAL_MATCH:
            if (matcherValueAtLevel.equals(ANY_FROM_LEVEL)) {
                return true;
            } else {
                if (!containsValue(matcherValueAtLevel, attributeValueCustomOption)) {
                    return false;
                }
            }
            break;
        case MatchRelations.PARTIAL_NOTMATCH:
            if (!containsValue(matcherValueAtLevel, attributeValueCustomOption)
                    && !matcherValueCustomOption[0].equals(NONE_FROM_LEVEL)) {
                return true;
            }
            break;
        default:
            return false;
        }
    }
    if (relation == MatchRelations.NOT_EQUAL || relation == MatchRelations.PARTIAL_NOTMATCH) {
        return false;
    } else {
        return true;
    }
}