Example usage for java.lang String CASE_INSENSITIVE_ORDER

List of usage examples for java.lang String CASE_INSENSITIVE_ORDER

Introduction

In this page you can find the example usage for java.lang String CASE_INSENSITIVE_ORDER.

Prototype

Comparator CASE_INSENSITIVE_ORDER

To view the source code for java.lang String CASE_INSENSITIVE_ORDER.

Click Source Link

Document

A Comparator that orders String objects as by compareToIgnoreCase .

Usage

From source file:org.apache.usergrid.persistence.Schema.java

public synchronized void registerEntity(Class<? extends Entity> entityClass) {
    logger.info("Registering {}", entityClass);
    EntityInfo e = registeredEntityClasses.get(entityClass);
    if (e != null) {
        return;/*from  w  w w  .  j  a  v a  2 s.  c  o  m*/
    }

    Map<String, PropertyDescriptor> propertyDescriptors = entityClassPropertyToDescriptor.get(entityClass);
    if (propertyDescriptors == null) {
        EntityInfo entity = new EntityInfo();

        String type = getEntityType(entityClass);

        propertyDescriptors = new LinkedHashMap<String, PropertyDescriptor>();
        Map<String, PropertyInfo> properties = new TreeMap<String, PropertyInfo>(String.CASE_INSENSITIVE_ORDER);
        Map<String, CollectionInfo> collections = new TreeMap<String, CollectionInfo>(
                String.CASE_INSENSITIVE_ORDER);
        Map<String, DictionaryInfo> sets = new TreeMap<String, DictionaryInfo>(String.CASE_INSENSITIVE_ORDER);

        PropertyDescriptor[] descriptors = PropertyUtils.getPropertyDescriptors(entityClass);

        for (PropertyDescriptor descriptor : descriptors) {
            String name = descriptor.getName();

            EntityProperty propertyAnnotation = getAnnotation(entityClass, descriptor, EntityProperty.class);
            if (propertyAnnotation != null) {
                if (isNotBlank(propertyAnnotation.name())) {
                    name = propertyAnnotation.name();
                }
                propertyDescriptors.put(name, descriptor);

                PropertyInfo propertyInfo = new PropertyInfo(propertyAnnotation);
                propertyInfo.setName(name);
                propertyInfo.setType(descriptor.getPropertyType());

                properties.put(name, propertyInfo);
                // logger.info(propertyInfo);
            }

            EntityCollection collectionAnnotation = getAnnotation(entityClass, descriptor,
                    EntityCollection.class);
            if (collectionAnnotation != null) {
                CollectionInfo collectionInfo = new CollectionInfo(collectionAnnotation);
                collectionInfo.setName(name);
                collectionInfo.setContainer(entity);

                collections.put(name, collectionInfo);
                // logger.info(collectionInfo);
            }

            EntityDictionary setAnnotation = getAnnotation(entityClass, descriptor, EntityDictionary.class);
            if (setAnnotation != null) {
                DictionaryInfo setInfo = new DictionaryInfo(setAnnotation);
                setInfo.setName(name);
                // setInfo.setType(descriptor.getPropertyType());
                sets.put(name, setInfo);
                // logger.info(setInfo);
            }
        }

        if (!DynamicEntity.class.isAssignableFrom(entityClass)) {
            entity.setProperties(properties);
            entity.setCollections(collections);
            entity.setDictionaries(sets);
            entity.mapCollectors(this, type);

            entityMap.put(type, entity);

            allProperties.putAll(entity.getProperties());

            Set<String> propertyNames = entity.getIndexedProperties();
            for (String propertyName : propertyNames) {
                PropertyInfo property = entity.getProperty(propertyName);
                if ((property != null) && !allIndexedProperties.containsKey(propertyName)) {
                    allIndexedProperties.put(propertyName, property);
                }
            }
        }

        entityClassPropertyToDescriptor.put(entityClass, propertyDescriptors);

        registeredEntityClasses.put(entityClass, entity);
    }
}

From source file:edu.unc.lib.dl.services.BatchIngestTask.java

public void init() throws BatchFailedException {
    log.info("Ingest task created for " + baseDir.getAbsolutePath());
    try {/*w w  w .  j  a v a  2s  .c  o  m*/
        dataDir = new File(this.getBaseDir(), "data");
        premisDir = new File(this.getBaseDir(), "premisEvents");
        ingestLog = new File(this.getBaseDir(), INGEST_LOG);
        ingestProperties = new IngestProperties(this.getBaseDir());
        foxmlFiles = this.getBaseDir().listFiles(new FilenameFilter() {
            @Override
            public boolean accept(File dir, String name) {
                return name.endsWith(".foxml");
            }
        });
        Arrays.sort(foxmlFiles, new Comparator<File>() {
            @Override
            public int compare(File o1, File o2) {
                return String.CASE_INSENSITIVE_ORDER.compare(o1.getName(), o2.getName());
            }
        });

        HashSet<PID> cSet = new HashSet<PID>();
        for (ContainerPlacement p : ingestProperties.getContainerPlacements().values()) {
            cSet.add(p.parentPID);
        }
        containers = cSet.toArray(new PID[] {});
        Arrays.sort(containers);

        this.eventLogger = new PremisEventLogger(
                ContentModelHelper.Administrative_PID.REPOSITORY_MANAGEMENT_SOFTWARE.getPID().getURI());

        this.state = STATE.CHECK;
        if (ingestLog.exists()) { // this is a resume, find next foxml
            BufferedReader r = new BufferedReader(new FileReader(ingestLog));
            String lastLine = null;
            for (String line = r.readLine(); line != null; line = r.readLine()) {
                lastLine = line;
            }
            r.close();
            if (lastLine != null) {
                // format is tab separated: <pid>\t<filename>\t<label>
                String[] l = lastLine.split("\\t");
                if (CONTAINER_UPDATED_CODE.equals(l[1])) {
                    this.state = STATE.CONTAINER_UPDATES;
                    this.lastIngestPID = new PID(l[0]);
                } else {
                    this.lastIngestFilename = l[1];
                    this.lastIngestPID = new PID(l[0]);
                    this.state = STATE.INGEST_WAIT;
                    log.info("Resuming ingest from " + this.lastIngestFilename + " in "
                            + this.getBaseDir().getName());
                }
            }
        }
        this.ingestLogWriter = new BufferedWriter(new FileWriter(ingestLog, true));
    } catch (Exception e) {
        throw fail("Cannot initialize the ingest task.", e);
    }
}

From source file:com.wordnik.swaggersocket.server.SwaggerSocketProtocolInterceptor.java

protected final static AtmosphereRequest toAtmosphereRequest(AtmosphereRequest r, ProtocolBase request) {
    AtmosphereRequest.Builder b = new AtmosphereRequest.Builder();
    Map<String, String> hdrs = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER);
    if (request.getHeaders() != null) {
        for (Header h : request.getHeaders()) {
            hdrs.put(h.getName(), h.getValue());
        }/*from  w w  w.j  a  v a2s  .c  om*/
    }

    Map<String, String[]> queryStrings = new HashMap<String, String[]>();
    if (request.getQueryString() != null) {
        for (QueryString h : request.getQueryString()) {
            String[] s = queryStrings.get(h.getName());
            if (s != null) {
                String[] s1 = new String[s.length];
                System.arraycopy(s, 0, s1, 0, s.length);
                s1[s.length] = h.getValue();
                queryStrings.put(h.getName(), s1);
            } else {
                queryStrings.put(h.getName(), new String[] { h.getValue() });
            }
        }
    }

    String p = request.getPath().replaceAll("\\s+", "%20").trim();
    String requestURL = r.getRequestURL() + p;
    if (r.getRequestURL().toString().endsWith("/") && p.startsWith("/")) {
        requestURL = r.getRequestURL().toString() + p.substring(1);
    }

    String requestURI = r.getRequestURI() + p;
    if (r.getRequestURI().endsWith("/") && p.startsWith("/")) {
        requestURI = r.getRequestURI() + p.substring(1);
    }

    if (!p.startsWith("/")) {
        p = "/" + p;
    }

    // get the content-type
    String contentType = request.getDataFormat();
    if (contentType == null) {
        contentType = hdrs.get("Content-Type");
    }
    b.pathInfo(p).contentType(contentType).headers(hdrs).method(request.getMethod()).queryStrings(queryStrings)
            .requestURI(requestURI).requestURL(requestURL).request(r);
    // add the body only if it is present
    if (request.getMessageBody() != null) {
        b.body(request.getMessageBody().toString());
    }

    return b.build();
}

From source file:org.knime.ext.textprocessing.nodes.source.parser.tika.TikaParser.java

/**
 * @return the list of all supported extensions in Tika.
 *///from   w  w  w  .  j av  a2s .  c om
public static String[] getExtensions() {
    List<String> result = new ArrayList<String>();
    MimeTypes allTypes = MimeTypes.getDefaultMimeTypes();
    Iterator<MediaType> mimeTypes = TikaParserConfig.VALID_TYPES.iterator();
    while (mimeTypes.hasNext()) {
        String mime = mimeTypes.next().toString();

        try {
            List<String> extList = allTypes.forName(mime).getExtensions();
            if (!extList.isEmpty()) {
                for (String s : extList) {
                    String withoutDot = s.substring(1, s.length());
                    if (!result.contains(withoutDot)) {
                        result.add(withoutDot);
                    }
                }
            }
        } catch (MimeTypeException e) {
            LOGGER.error("Could not fetch MIME type: " + mime,
                    new MimeTypeException("Fetching MIME type failed!"));
        }
    }
    Collections.sort(result, String.CASE_INSENSITIVE_ORDER);
    return result.toArray(new String[result.size()]);
}

From source file:gov.nih.nci.caintegrator.application.lists.UserListBeanHelper.java

public void uniteLists(List<String> listNames, String newListName, ListType listType) {
    List<String> items = new ArrayList<String>();
    for (String listName : listNames) {
        UserList list = userListBean.getList(listName);
        if (!list.getList().isEmpty()) {
            items.addAll(list.getList());
        }//from   ww  w  . j  av  a2s .com
    }
    Set<String> unitedSet = new HashSet<String>(items);
    items.clear();
    items.addAll(unitedSet);
    Collections.sort(items, String.CASE_INSENSITIVE_ORDER);
    UserList newList = new UserList(newListName, listType, items, new ArrayList<String>(), new Date());
    newList.setListOrigin(ListOrigin.Custom);
    newList.setItemCount(items.size());
    userListBean.addList(newList);
}

From source file:com.evolveum.midpoint.web.component.assignment.AssignmentEditorDto.java

@Override
public int compareTo(AssignmentEditorDto other) {
    Validate.notNull(other, "Can't compare assignment editor dto with null.");

    int value = getIndexOfType(getType()) - getIndexOfType(other.getType());
    if (value != 0) {
        return value;
    }/*from  w  w w  .  j  a v  a 2  s .c o  m*/

    String name1 = getName() != null ? getName() : "";
    String name2 = other.getName() != null ? other.getName() : "";

    return String.CASE_INSENSITIVE_ORDER.compare(name1, name2);
}

From source file:com.googlecode.fascinator.common.JsonSimpleConfig.java

@SuppressWarnings(value = { "unchecked" })
private void loadIncludedDir(JsonSimple config) {
    List<String> extList = config.getStringList(INCLUDE_DIR_KEY_EXT);
    log.trace("Inclusion directory found:'" + INCLUDE_DIR_KEY + "', merging all files in '"
            + config.getString(null, INCLUDE_DIR_KEY) + "' ending with: {}", extList);
    List<File> configFiles = new ArrayList(
            FileUtils.listFiles(new File(config.getString(null, INCLUDE_DIR_KEY)),
                    extList.toArray(new String[extList.size()]), true));

    final Comparator<File> ALPHABETICAL_ORDER = new Comparator<File>() {
        public int compare(File file1, File file2) {
            int res = String.CASE_INSENSITIVE_ORDER.compare(file1.getAbsolutePath(), file2.getAbsolutePath());
            if (res == 0) {
                res = file1.getAbsolutePath().compareTo(file2.getAbsolutePath());
            }//from  www  .j a  va  2 s  .c  o m
            return res;
        }
    };

    Collections.sort(configFiles, ALPHABETICAL_ORDER);

    for (File configFile : configFiles) {
        try {
            // log.debug("Merging included config file: {}",
            // configFile);
            JsonSimple jsonConfig = new JsonSimple(configFile);
            mergeConfig(config.getJsonObject(), jsonConfig.getJsonObject());
        } catch (IOException e) {
            log.error("Failed to load file: {}", configFile);
            e.printStackTrace();
        }
    }
}

From source file:org.apache.directory.fortress.core.model.Permission.java

/**
 * Add a Role name to list of Roles that are valid for this Permission.  This is optional attribute.
 *
 * @param role maps to 'ftRoles' attribute in 'ftOperation' object class.
 *///from w  w w.ja v  a  2s  . c  om
public void setRole(String role) {
    if (roles == null) {
        roles = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
    }

    this.roles.add(role);
}

From source file:com.evolveum.midpoint.web.component.wizard.resource.component.schemahandling.ResourceAttributeEditor.java

private List<ItemPathType> loadObjectReferences() {
    List<ItemPathType> references = new ArrayList<>();

    ResourceSchema schema = loadResourceSchema();
    if (schema == null) {
        return references;
    }//  w  w w .j a  va2 s. c om

    for (ObjectClassComplexTypeDefinition def : schema.getObjectClassDefinitions()) {
        if (objectType != null && def.getTypeName().equals(objectType.getObjectClass())) {

            for (ResourceAttributeDefinition attributeDefinition : def.getAttributeDefinitions()) {
                ItemPath itemPath = new ItemPath(attributeDefinition.getName());
                references.add(new ItemPathType(itemPath));
            }
        }
    }

    Collections.sort(references, new Comparator<ItemPathType>() {

        @Override
        public int compare(ItemPathType o1, ItemPathType o2) {
            String s1 = prepareReferenceDisplayValue(o1);
            String s2 = prepareReferenceDisplayValue(o2);

            return String.CASE_INSENSITIVE_ORDER.compare(s1, s2);
        }
    });

    return references;
}