Example usage for java.util TreeSet TreeSet

List of usage examples for java.util TreeSet TreeSet

Introduction

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

Prototype

public TreeSet() 

Source Link

Document

Constructs a new, empty tree set, sorted according to the natural ordering of its elements.

Usage

From source file:com.alibaba.dubbo.governance.web.governance.module.screen.Applications.java

public void index(Map<String, Object> context) {
    String service = (String) context.get("service");
    if (context.get("service") != null) {
        Set<String> applications = new TreeSet<String>();
        List<String> providerApplications = providerService.findApplicationsByServiceName(service);
        if (providerApplications != null && providerApplications.size() > 0) {
            applications.addAll(providerApplications);
        }/*from   w  ww  . j  av  a 2 s  .  co m*/
        List<String> consumerApplications = consumerService.findApplicationsByServiceName(service);
        if (consumerApplications != null && consumerApplications.size() > 0) {
            applications.addAll(consumerApplications);
        }
        context.put("applications", applications);
        context.put("providerApplications", providerApplications);
        context.put("consumerApplications", consumerApplications);
        if (service != null && service.length() > 0) {
            List<Override> overrides = overrideService.findByService(service);
            Map<String, List<Override>> application2Overrides = new HashMap<String, List<Override>>();
            if (overrides != null && overrides.size() > 0 && applications != null && applications.size() > 0) {
                for (String a : applications) {
                    if (overrides != null && overrides.size() > 0) {
                        List<Override> appOverrides = new ArrayList<Override>();
                        for (Override override : overrides) {
                            if (override.isMatch(service, null, a)) {
                                appOverrides.add(override);
                            }
                        }
                        Collections.sort(appOverrides, OverrideUtils.OVERRIDE_COMPARATOR);
                        application2Overrides.put(a, appOverrides);
                    }
                }
            }
            context.put("overrides", application2Overrides);
        }
        return;
    }
    if (context.get("service") == null && context.get("application") == null
            && context.get("address") == null) {
        context.put("application", "*");
    }
    Set<String> applications = new TreeSet<String>();
    List<String> providerApplications = providerService.findApplications();
    if (providerApplications != null && providerApplications.size() > 0) {
        applications.addAll(providerApplications);
    }
    List<String> consumerApplications = consumerService.findApplications();
    if (consumerApplications != null && consumerApplications.size() > 0) {
        applications.addAll(consumerApplications);
    }

    Set<String> newList = new HashSet<String>();
    Set<String> newProviders = new HashSet<String>();
    Set<String> newConsumers = new HashSet<String>();
    context.put("applications", applications);
    context.put("providerApplications", providerApplications);
    context.put("consumerApplications", consumerApplications);

    String keyword = (String) context.get("keyword");
    if (StringUtils.isNotEmpty(keyword) && !"*".equals(keyword)) {
        keyword = keyword.toLowerCase();
        for (String o : applications) {
            if (o.toLowerCase().indexOf(keyword) != -1) {
                newList.add(o);
            }
        }
        for (String o : providerApplications) {
            if (o.toLowerCase().indexOf(keyword) != -1) {
                newProviders.add(o);
            }
        }
        for (String o : consumerApplications) {
            if (o.toLowerCase().indexOf(keyword) != -1) {
                newConsumers.add(o);
            }
        }
        context.put("applications", newList);
        context.put("providerApplications", newProviders);
        context.put("consumerApplications", newConsumers);
    }
}

From source file:fr.imag.model2roo.addon.graph.NodeIdTypeConverter.java

public boolean getAllPossibleValues(final List<Completion> completions, final Class<?> targetType,
        final String existingData, final String optionContext, final MethodTarget target) {
    final SortedSet<String> types = new TreeSet<String>();
    types.add(Long.class.getName());

    for (final String type : types) {
        if (type.startsWith(existingData) || existingData.startsWith(type)) {
            completions.add(new Completion(type));
        }//from ww w  . j a  va  2s.c o  m
    }
    return false;
}

From source file:com.googlecode.flyway.core.util.scanner.ClassPathScanner.java

/**
 * Scans the classpath for resources under the specified location, starting with the specified prefix and ending with
 * the specified suffix.//from w ww. ja va  2 s  . c  om
 *
 * @param location The location (directory) in the classpath to start searching. Subdirectories are also searched.
 * @param prefix   The prefix of the resource names to match.
 * @param suffix   The suffix of the resource names to match.
 * @return The resources that were found.
 * @throws IOException when the location could not be scanned.
 */
public ClassPathResource[] scanForResources(String location, String prefix, String suffix) throws IOException {
    Set<ClassPathResource> classPathResources = new TreeSet<ClassPathResource>();

    Set<String> resourceNames = findResourceNames(location, prefix, suffix);
    for (String resourceName : resourceNames) {
        classPathResources.add(new ClassPathResource(resourceName));
        LOG.debug("Found resource: " + resourceName);
    }

    return classPathResources.toArray(new ClassPathResource[classPathResources.size()]);
}

From source file:apriori.ItemSet.java

@Override
public ItemSet<T> clone() {
    ItemSet<T> theClone = new ItemSet<>();
    //Sorted items
    theClone._sortedItems = new TreeSet<>();
    Iterator<T> treeIter = this._sortedItems.iterator();
    while (treeIter.hasNext()) {
        theClone._sortedItems.add(treeIter.next());
    }/*w  w w . jav a2 s .c o m*/
    //Items
    theClone._items = new ArrayList<>();
    Iterator<T> listIter = this._items.iterator();
    while (listIter.hasNext()) {
        theClone._items.add(listIter.next());
    }
    theClone._support = this._support;
    return theClone;
}

From source file:com.vaushell.superpipes.nodes.buffer.N_Buffer.java

public N_Buffer() {
    super(null, null);

    this.slots = new ArrayList<>();
    this.messageIDs = new TreeSet<>();
    this.lastWrite = null;
    this.rnd = new Random();
}

From source file:com.baidu.cc.web.filter.LoginFilter.java

@Override
protected void doInit(FilterConfig filterConfig) throws ServletException {
    excludePathv = new TreeSet<String>();
    if (excludePath != null) {
        String[] paths = excludePath.split(";");
        for (String p : paths) {
            if (p != null && p.length() > 0)
                excludePathv.add(p);// w  w  w. j av  a 2  s .  c om
        }
    }
}

From source file:gov.nih.nci.cananolab.util.StringUtils.java

public static String sortJoin(Collection<String> strings, String delimiter) {
    SortedSet<SortableName> sortableNames = new TreeSet<SortableName>();
    for (String str : strings) {
        sortableNames.add(new SortableName(str));
    }/*from   w w w. j  a  v a2  s  .  c  o  m*/
    String joinedStr = "";
    if (sortableNames == null || sortableNames.isEmpty()) {
        return joinedStr;
    }
    StringBuilder sb = new StringBuilder();
    int i = 0;
    for (SortableName sortableName : sortableNames) {
        if (i < sortableNames.size() - 1) {
            if (!StringUtils.isEmpty(sortableName.getName()))
                // joinedStr += sortableName.getName() + delimiter;
                sb.append(sortableName.getName());
            sb.append(delimiter);
        } else {
            if (!StringUtils.isEmpty(sortableName.getName()))
                // joinedStr += sortableName.getName();
                sb.append(sortableName.getName());
        }
        i++;
    }
    joinedStr = sb.toString();
    return joinedStr;
}

From source file:com.sap.research.connectivity.gw.converters.GwEntityClassConverter.java

public boolean getAllPossibleValues(List<Completion> completions, Class<?> targetType, String existingData,
        String optionContext, MethodTarget target) {

    //Retrieve all the .java files using provided option context (sub package folder)
    SortedSet<FileDetails> files = new TreeSet<FileDetails>();
    if (!optionContext.isEmpty()) {
        files = fileManager.findMatchingAntPath(getSubPackagePath(optionContext) + SEPARATOR + "*.java");
    }/*from ww  w .j  a  v a  2 s  . co  m*/

    //Iterate through each class and include only those classes which have gateway connectivity for auto completion
    for (FileDetails f : files) {

        String filePath = f.getCanonicalPath();
        String entityClass = filePath.substring(filePath.lastIndexOf(SEPARATOR) + 1, filePath.length());

        String entityName = entityClass.substring(0, entityClass.indexOf(".java"));

        JavaSourceFileEditor entityClassFile = getJavaFileEditor("domain", entityName);

        String nameSpace = GwUtils.getNamespaceFromClass(entityClassFile);

        if (!nameSpace.isEmpty())
            completions.add(new Completion(entityName));
    }

    return false;
}

From source file:com.creditcloud.ump.model.ump.base.BaseRequest.java

public String chkString() {
    Map<String, String> values = MessageUtils.getFieldValuesMap(this);
    Set<String> sets = new TreeSet<>();

    for (String key : values.keySet()) {
        String value = values.get(key);
        if (!key.equals("sign") && !key.equals("sign_type")) {
            // skip sign and sign_type field, they are not in checksum string
            if (value != null) {
                String theValue = key.equals("service") ? value.toLowerCase() : value;
                sets.add(key + "=" + theValue);
            }/*from w w w  . java2s.  co m*/
        }
    }

    return StringUtils.join(sets, "&");
}

From source file:com.nexmo.client.auth.NexmoUnacceptableAuthException.java

private String generateErrorMessage() {
    SortedSet<String> availableTypes = new TreeSet<>();
    for (AuthMethod auth : this.availableAuths) {
        availableTypes.add(auth.getClass().getSimpleName());
    }/* w  w w .j a v a2  s .c  om*/

    SortedSet<String> acceptableTypes = new TreeSet<>();
    for (Class klass : this.acceptableAuthClasses) {
        acceptableTypes.add(klass.getSimpleName());
    }

    return String.format(
            "No acceptable authentication type could be found. Acceptable types are: %s. Supplied " + "types "
                    + "were: %s",
            StringUtils.join(acceptableTypes, ", "), StringUtils.join(availableTypes, ", "));
}