Example usage for org.apache.commons.lang3 StringUtils lowerCase

List of usage examples for org.apache.commons.lang3 StringUtils lowerCase

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringUtils lowerCase.

Prototype

public static String lowerCase(final String str) 

Source Link

Document

Converts a String to lower case as per String#toLowerCase() .

A null input String returns null .

 StringUtils.lowerCase(null)  = null StringUtils.lowerCase("")    = "" StringUtils.lowerCase("aBc") = "abc" 

Note: As described in the documentation for String#toLowerCase() , the result of this method is affected by the current locale.

Usage

From source file:org.elasticsearch.index.mapper.core.TypeParsers.java

/**
 * Parse common field attributes such as {@code doc_values} or {@code store}.
 *///from www.  j a  v a 2s .  c  o m
public static void parseField(FieldMapper.Builder builder, String name, Map<String, Object> fieldNode,
        Mapper.TypeParser.ParserContext parserContext) {
    Version indexVersionCreated = parserContext.indexVersionCreated();
    for (Iterator<Map.Entry<String, Object>> iterator = fieldNode.entrySet().iterator(); iterator.hasNext();) {
        Map.Entry<String, Object> entry = iterator.next();
        final String propName = Strings.toUnderscoreCase(entry.getKey());
        final Object propNode = entry.getValue();
        if (propName.equals("index_name") && indexVersionCreated.before(Version.V_2_0_0_beta1)) {
            builder.indexName(propNode.toString());
            iterator.remove();
        } else if (propName.equals("store")) {
            builder.store(parseStore(name, propNode.toString()));
            iterator.remove();
        } else if (propName.equals("index")) {
            parseIndex(name, propNode.toString(), builder);
            iterator.remove();
        } else if (propName.equals(DOC_VALUES)) {
            builder.docValues(nodeBooleanValue(propNode));
            iterator.remove();
        } else if (propName.equals("boost")) {
            builder.boost(nodeFloatValue(propNode));
            iterator.remove();
        } else if (propName.equals("omit_norms")) {
            builder.omitNorms(nodeBooleanValue(propNode));
            iterator.remove();
        } else if (propName.equals("norms")) {
            final Map<String, Object> properties = nodeMapValue(propNode, "norms");
            for (Iterator<Entry<String, Object>> propsIterator = properties.entrySet().iterator(); propsIterator
                    .hasNext();) {
                Entry<String, Object> entry2 = propsIterator.next();
                final String propName2 = Strings.toUnderscoreCase(entry2.getKey());
                final Object propNode2 = entry2.getValue();
                if (propName2.equals("enabled")) {
                    builder.omitNorms(!nodeBooleanValue(propNode2));
                    propsIterator.remove();
                } else if (propName2.equals(Loading.KEY)) {
                    builder.normsLoading(Loading.parse(nodeStringValue(propNode2, null), null));
                    propsIterator.remove();
                }
            }
            DocumentMapperParser.checkNoRemainingFields(propName, properties,
                    parserContext.indexVersionCreated());
            iterator.remove();
        } else if (propName.equals("omit_term_freq_and_positions")) {
            final IndexOptions op = nodeBooleanValue(propNode) ? IndexOptions.DOCS
                    : IndexOptions.DOCS_AND_FREQS_AND_POSITIONS;
            if (indexVersionCreated.onOrAfter(Version.V_1_0_0_RC2)) {
                throw new ElasticsearchParseException(
                        "'omit_term_freq_and_positions' is not supported anymore - use ['index_options' : 'docs']  instead");
            }
            // deprecated option for BW compat
            builder.indexOptions(op);
            iterator.remove();
        } else if (propName.equals("index_options")) {
            builder.indexOptions(nodeIndexOptionValue(propNode));
            iterator.remove();
        } else if (propName.equals("include_in_all")) {
            builder.includeInAll(nodeBooleanValue(propNode));
            iterator.remove();
        } else if (propName.equals("postings_format") && indexVersionCreated.before(Version.V_2_0_0_beta1)) {
            // ignore for old indexes
            iterator.remove();
        } else if (propName.equals("doc_values_format") && indexVersionCreated.before(Version.V_2_0_0_beta1)) {
            // ignore for old indexes
            iterator.remove();
        } else if (propName.equals("similarity")) {
            builder.similarity(parserContext.similarityLookupService().similarity(propNode.toString()));
            iterator.remove();
        } else if (propName.equals("fielddata")) {
            final Settings settings = Settings.builder()
                    .put(SettingsLoader.Helper.loadNestedFromMap(nodeMapValue(propNode, "fielddata"))).build();
            builder.fieldDataSettings(settings);
            iterator.remove();
        } else if (propName.equals("copy_to")) {
            if (parserContext.isWithinMultiField()) {
                if (indexVersionCreated.after(Version.V_2_1_0) || (indexVersionCreated.after(Version.V_2_0_1)
                        && indexVersionCreated.before(Version.V_2_1_0))) {
                    throw new MapperParsingException(
                            "copy_to in multi fields is not allowed. Found the copy_to in field [" + name
                                    + "] which is within a multi field.");
                } else {
                    ESLoggerFactory.getLogger("mapping [" + parserContext.type() + "]")
                            .warn("Found a copy_to in field [" + name
                                    + "] which is within a multi field. This feature has been removed and the copy_to will be ignored.");
                    // we still parse this, otherwise the message will only appear once and the copy_to removed. After that it will appear again. Better to have it always.
                }
            }
            parseCopyFields(propNode, builder);
            iterator.remove();
        } else if (propName.equals(TypeParsers.CQL_MANDATORY)) {
            builder.cqlPartialUpdate((boolean) propNode);
            iterator.remove();
        } else if (propName.equals(TypeParsers.CQL_PARTITION_KEY)) {
            builder.cqlPartitionKey((boolean) propNode);
            iterator.remove();
        } else if (propName.equals(TypeParsers.CQL_STATIC_COLUMN)) {
            builder.cqlStaticColumn((Boolean) propNode);
            iterator.remove();
        } else if (propName.equals(TypeParsers.CQL_PRIMARY_KEY_ORDER)) {
            builder.cqlPrimaryKeyOrder((Integer) propNode);
            iterator.remove();
        } else if (propName.equals(TypeParsers.CQL_COLLECTION)) {
            String value = StringUtils.lowerCase(propNode.toString());
            switch (value) {
            case "list":
                builder.cqlCollection(CqlCollection.LIST);
                break;
            case "set":
                builder.cqlCollection(CqlCollection.SET);
                break;
            case "singleton":
                builder.cqlCollection(CqlCollection.SINGLETON);
                break;
            }
            iterator.remove();
        } else if (propName.equals(TypeParsers.CQL_STRUCT)) {
            String value = StringUtils.lowerCase(propNode.toString());
            switch (value) {
            case "tuple":
                builder.cqlStruct(CqlStruct.TUPLE);
                break;
            case "map":
                builder.cqlStruct(CqlStruct.MAP);
                break;
            case "udt":
                builder.cqlStruct(CqlStruct.UDT);
                break;
            }
            iterator.remove();
        }
    }
    if (indexVersionCreated.before(Version.V_2_2_0)) {
        // analyzer, search_analyzer, term_vectors were accepted on all fields
        // before 2.2, even though it made little sense
        parseAnalyzersAndTermVectors(builder, name, fieldNode, parserContext);
    }
}

From source file:org.gerzog.jstataggr.core.utils.FieldUtils.java

private static String getAggregationPostfix(final AggregationType aggregationType) {
    return StringUtils.capitalize(StringUtils.lowerCase(aggregationType.name()));
}

From source file:org.goko.controller.tinyg.controller.TinyGControllerUtility.java

/**
 * Transform a GCode command to a JsonValue
 * @param command the command to transform
 * @return {@link JsonValue}/*from w  ww.j a  v  a2s  .co  m*/
 */
protected static JsonValue toJson(String command) {
    JsonObject value = new JsonObject();
    value.add(TinyGJsonUtils.GCODE_COMMAND, StringUtils.lowerCase(command));
    return value;
}

From source file:org.guess.generate.Generate.java

public static void main(String[] args) {

    // ==========  ?? ====================

    // ??????//from www. j a  v  a 2 s. c  om
    // ?{packageName}/{moduleName}/{dao,entity,service,web}/{subModuleName}/{className}

    // packageName
    // ????applicationContext.xmlsrping-mvc.xml?base-package?packagesToScan?4?
    String packageName = "net.iharding.modulesmeta";

    String moduleName = "meta"; // ???sys
    String className = "project"; // ??user
    String classAuthor = "Joe.zhang"; // 
    String functionName = "??"; // ??

    List<Field> fields = new ArrayList<Field>();
    fields.add(new Field("projectCode", "?", "String"));
    fields.add(new Field("projectName", "??", "String"));
    fields.add(new Field("remark", "", "String"));
    fields.add(new Field("createDate", "", "Date"));
    fields.add(new Field("updateDate", "", "Date"));
    fields.add(new Field("createId", "", "createId"));
    fields.add(new Field("updateId", "", "updateId"));

    // ???
    Boolean isEnable = true;

    // ==========  ?? ====================

    if (!isEnable) {
        logger.error("????isEnable = true");
        return;
    }

    if (StringUtils.isBlank(moduleName) || StringUtils.isBlank(moduleName) || StringUtils.isBlank(className)
            || StringUtils.isBlank(functionName)) {
        logger.error("??????????????");
        return;
    }

    // ?
    String separator = File.separator;

    // ?
    File projectPath = null;
    try {
        projectPath = new DefaultResourceLoader().getResource("").getFile();
        //         File projectPath = new File("D:/template");
        while (!new File(projectPath.getPath() + separator + "src" + separator + "main").exists()) {
            projectPath = projectPath.getParentFile();
        }
        logger.info("Project Path: {}", projectPath);

        // ?
        String tplPath = StringUtils.replace(
                projectPath.getAbsolutePath() + "/src/test/java/org/guess/generate/temp", "/", separator);
        logger.info("Template Path: {}", tplPath);

        // Java
        String javaPath = StringUtils.replaceEach(
                projectPath.getAbsolutePath() + "/src/main/java/" + StringUtils.lowerCase(packageName),
                new String[] { "/", "." }, new String[] { separator, separator });
        //         String javaPath = "D:/template";
        logger.info("Java Path: {}", javaPath);

        String viewPath = StringUtils.replace(
                projectPath + "/src/main/webapp/WEB-INF/content/" + moduleName + "/" + className, "/",
                separator);
        //         String viewPath = "D:/template";

        // ???
        Configuration cfg = new Configuration();
        FileUtils.isFolderExitAndCreate(tplPath);
        cfg.setDirectoryForTemplateLoading(new File(tplPath));

        // ???
        Map<String, Object> model = Maps.newHashMap();
        model.put("packageName", StringUtils.lowerCase(packageName));
        model.put("moduleName", StringUtils.lowerCase(moduleName));
        model.put("className", StringUtils.uncapitalize(className));
        model.put("ClassName", StringUtils.capitalize(className));
        model.put("classAuthor", StringUtils.isNotBlank(classAuthor) ? classAuthor : "Generate Tools");
        model.put("classVersion", DateUtil.getCurrenDate());
        model.put("functionName", functionName);
        model.put("tableName", model.get("moduleName") + "_" + model.get("className"));

        model.put("fields", fields);

        // ? Entity
        Template template = cfg.getTemplate("entity.ftl");
        String content = FreeMarkers.renderTemplate(template, model);
        String filePath = javaPath + separator + model.get("moduleName") + separator + "model" + separator
                + model.get("ClassName") + ".java";
        //         writeFile(content, filePath);
        logger.info("Entity: {}", filePath);

        // ? Dao
        template = cfg.getTemplate("dao.ftl");
        content = FreeMarkers.renderTemplate(template, model);
        filePath = javaPath + separator + model.get("moduleName") + separator + "dao" + separator
                + model.get("ClassName") + "Dao.java";
        writeFile(content, filePath);
        logger.info("Dao: {}", filePath);

        // ? DaoImpl
        template = cfg.getTemplate("daoImpl.ftl");
        content = FreeMarkers.renderTemplate(template, model);
        filePath = javaPath + separator + model.get("moduleName") + separator + "dao" + separator + "impl"
                + separator + model.get("ClassName") + "DaoImpl.java";
        writeFile(content, filePath);
        logger.info("Dao: {}", filePath);

        // ? Service
        template = cfg.getTemplate("service.ftl");
        content = FreeMarkers.renderTemplate(template, model);
        filePath = javaPath + separator + model.get("moduleName") + separator + "service" + separator
                + model.get("ClassName") + "Service.java";
        writeFile(content, filePath);
        logger.info("Service: {}", filePath);

        // ? Service
        template = cfg.getTemplate("serviceImpl.ftl");
        content = FreeMarkers.renderTemplate(template, model);
        filePath = javaPath + separator + model.get("moduleName") + separator + "service" + separator + "impl"
                + separator + model.get("ClassName") + "ServiceImpl.java";
        writeFile(content, filePath);
        logger.info("Service: {}", filePath);

        // ? Controller
        template = cfg.getTemplate("controller.ftl");
        content = FreeMarkers.renderTemplate(template, model);
        filePath = javaPath + separator + model.get("moduleName") + separator + "controller" + separator
                + model.get("ClassName") + "Controller.java";
        writeFile(content, filePath);
        logger.info("Controller: {}", filePath);

        /*   // ? list.jsp
           template = cfg.getTemplate("list.ftl");
           content = FreeMarkers.renderTemplate(template, model);
           filePath = viewPath + separator + "list.jsp";
           writeFile(content, filePath);
           logger.info("Controller: {}", filePath);
                   
           // ? edit.jsp
           template = cfg.getTemplate("edit.ftl");
           content = FreeMarkers.renderTemplate(template, model);
           filePath = viewPath + separator + "edit.jsp";
           writeFile(content, filePath);
           logger.info("Controller: {}", filePath);*/

        logger.info("Generate Success.");
    } catch (IOException e) {
        e.printStackTrace();
    }

}

From source file:org.gvnix.web.datatables.util.DatatablesUtils.java

/**
 * Constructs the {@code HtmlTable} used to export the data.
 * <p />/*  w w w.  ja va 2 s  .c o m*/
 * It uses the parameters of the request to check if the column is
 * exportable or not, these parameters are named:
 * <ul>
 * <li>{@code [export_type_extension]ExportColumns}, where
 * <emp>[export_type_extension]</emp> is the extension of the format to
 * export, for example: {@code csvExportColumns}</li>
 * <li>{@code allExportColumns}</li>
 * </ul>
 * <p />
 * Also uses the parameter {@code columnsTitle} to indicate the title of
 * each column, this parameter has as value a {@code String} with the format
 * of a Map as follows:
 * 
 * <pre>
 * {property1||value1, property2||value2, ... , propertyN||valueN}
 * </pre>
 * 
 * @param data the data to make the {@code HtmlTable}.
 * @param criterias the {@code DatatablesCriterias}.
 * @param exportConf the {@code ExportConf}.
 * @param request the {@code HttpServletRequest}.
 * @return the {@code HtmlTable} used to export the data.
 */
public static HtmlTable makeHtmlTable(List<Map<String, String>> data, DatatablesCriterias criterias,
        ExportConf exportConf, HttpServletRequest request) {

    ColumnStep tableBuilder = new HtmlTableBuilder<Map<String, String>>().newBuilder("tableId", data, request);

    // Obtain exportable columns
    String exportTypeExtension = StringUtils.lowerCase(exportConf.getType().getExtension());
    String thisFormatExportColumnsStr = request.getParameter(exportTypeExtension.concat("ExportColumns"));
    if (StringUtils.isEmpty(thisFormatExportColumnsStr)) {
        thisFormatExportColumnsStr = "";
    }
    String allFormatExportColumnsStr = request.getParameter("allExportColumns");
    if (StringUtils.isEmpty(allFormatExportColumnsStr)) {
        allFormatExportColumnsStr = "";
    }
    List<String> thisFormatExporColumns = Arrays.asList(StringUtils.split(thisFormatExportColumnsStr, ","));
    List<String> allFormatExportColumns = Arrays.asList(StringUtils.split(allFormatExportColumnsStr, ","));

    BeforeEndStep columns = null;
    if (!allFormatExportColumns.isEmpty() || !thisFormatExporColumns.isEmpty()) {

        // Obtain the column titles
        Map<String, String> columnsTitleMap = new HashMap<String, String>();
        String columnsTitleStr = request.getParameter("columnsTitle");
        columnsTitleStr = StringUtils.substring(columnsTitleStr, 1, (columnsTitleStr.length() - 1));
        List<String> columnsTitleList = Arrays.asList(StringUtils.split(columnsTitleStr, ","));
        for (String columnsTitle : columnsTitleList) {
            String[] columsTitleArray = StringUtils.split(columnsTitle, "||");
            if (columsTitleArray.length == 2) {
                columnsTitleMap.put(columsTitleArray[0].trim(), columsTitleArray[1].trim());
            }
        }

        List<ColumnDef> columnDefs = criterias.getColumnDefs();
        for (ColumnDef columnDef : columnDefs) {
            String columnProperty = columnDef.getName();
            if (allFormatExportColumns.contains(columnProperty)
                    || thisFormatExporColumns.contains(columnProperty)) {
                String columnTitle = columnsTitleMap.get(columnProperty);
                if (StringUtils.isBlank(columnTitle)) {
                    columnTitle = columnProperty;
                }
                columnTitle = StringUtils.replace(columnTitle, "~~", ",");
                columns = tableBuilder.column().fillWithProperty(columnProperty).title(columnTitle);
            }
        }
    }
    if (columns == null) {
        columns = tableBuilder.column().fillWithProperty("-").title("---");
    }

    return columns.configureExport(exportConf).build();
}

From source file:org.gvnix.web.datatables.util.impl.DatatablesUtilsBeanImpl.java

/**
 * {@inheritDoc}//  w w  w  .  ja v a  2  s  .com
 */
@Override
public HtmlTable makeHtmlTable(List<Map<String, String>> data, DatatablesCriterias criterias,
        ExportConf exportConf, HttpServletRequest request) {

    ColumnStep tableBuilder = new HtmlTableBuilder<Map<String, String>>().newBuilder("tableId", data, request);

    // Obtain exportable columns
    String exportTypeExtension = StringUtils.lowerCase(exportConf.getType().getExtension());
    String thisFormatExportColumnsStr = request.getParameter(exportTypeExtension.concat("ExportColumns"));
    if (StringUtils.isEmpty(thisFormatExportColumnsStr)) {
        thisFormatExportColumnsStr = "";
    }
    String allFormatExportColumnsStr = request.getParameter("allExportColumns");
    if (StringUtils.isEmpty(allFormatExportColumnsStr)) {
        allFormatExportColumnsStr = "";
    }
    List<String> thisFormatExporColumns = Arrays.asList(StringUtils.split(thisFormatExportColumnsStr, ","));
    List<String> allFormatExportColumns = Arrays.asList(StringUtils.split(allFormatExportColumnsStr, ","));

    BeforeEndStep columns = null;
    if (!allFormatExportColumns.isEmpty() || !thisFormatExporColumns.isEmpty()) {

        // Obtain the column titles
        Map<String, String> columnsTitleMap = new HashMap<String, String>();
        String columnsTitleStr = request.getParameter("columnsTitle");
        columnsTitleStr = StringUtils.substring(columnsTitleStr, 1, (columnsTitleStr.length() - 1));
        List<String> columnsTitleList = Arrays.asList(StringUtils.split(columnsTitleStr, ","));
        for (String columnsTitle : columnsTitleList) {
            String[] columsTitleArray = StringUtils.split(columnsTitle, "||");
            if (columsTitleArray.length == 2) {
                columnsTitleMap.put(columsTitleArray[0].trim(), columsTitleArray[1].trim());
            }
        }

        List<ColumnDef> columnDefs = criterias.getColumnDefs();
        for (ColumnDef columnDef : columnDefs) {
            String columnProperty = columnDef.getName();
            if (allFormatExportColumns.contains(columnProperty)
                    || thisFormatExporColumns.contains(columnProperty)) {
                String columnTitle = columnsTitleMap.get(columnProperty);
                if (StringUtils.isBlank(columnTitle)) {
                    columnTitle = columnProperty;
                }
                columnTitle = StringUtils.replace(columnTitle, "~~", ",");
                columns = tableBuilder.column().fillWithProperty(columnProperty).title(columnTitle);
            }
        }
    }
    if (columns == null) {
        columns = tableBuilder.column().fillWithProperty("-").title("---");
    }

    return columns.configureExport(exportConf).build();
}

From source file:org.gvnix.web.datatables.util.QuerydslUtils.java

/**
 * Return where clause expression for non-String
 * {@code entityPath.fieldName} by transforming it to text before check its
 * value./*  www  .j  a v a 2 s  .  c  om*/
 * <p/>
 * Expr:
 * {@code entityPath.fieldName.as(String.class) like ('%' + searchStr + '%')}
 * <p/>
 * Like operation is case insensitive.
 * 
 * @param entityPath Full path to entity and associations. For example:
 *        {@code Pet} , {@code Pet.owner}
 * @param fieldName Property name in the given entity path. For example:
 *        {@code weight} in {@code Pet} entity, {@code age} in
 *        {@code Pet.owner} entity.
 * @param searchStr the value to find, may be null
 * @param enumClass Enumeration type. Needed to enumeration values
 * @return BooleanExpression
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
public static <T> BooleanExpression createEnumExpression(PathBuilder<T> entityPath, String fieldName,
        String searchStr, Class<? extends Enum> enumClass) {
    if (StringUtils.isEmpty(searchStr)) {
        return null;
    }
    // Filter string to search than cannot be a identifier
    if (!StringUtils.isAlphanumeric(StringUtils.lowerCase(searchStr))) {
        return null;
    }

    // TODO i18n of enum name

    // normalize search string
    searchStr = StringUtils.trim(searchStr).toLowerCase();

    // locate enums matching by name
    Set matching = new HashSet();

    Enum<?> enumValue;
    String enumStr;

    for (Field enumField : enumClass.getDeclaredFields()) {
        if (enumField.isEnumConstant()) {
            enumStr = enumField.getName();
            enumValue = Enum.valueOf(enumClass, enumStr);

            // Check enum name contains string to search
            if (enumStr.toLowerCase().contains(searchStr)) {
                // Add to matching enum
                matching.add(enumValue);
                continue;
            }

            // Check using toString
            enumStr = enumValue.toString();
            if (enumStr.toLowerCase().contains(searchStr)) {
                // Add to matching enum
                matching.add(enumValue);
            }
        }
    }
    if (matching.isEmpty()) {
        return null;
    }

    // create a enum in matching condition
    BooleanExpression expression = entityPath.get(fieldName).in(matching);
    return expression;
}

From source file:org.jamwiki.db.AnsiDataHandler.java

/**
 *
 *///from   w  w w .  j  ava  2  s. c  o m
private Topic lookupTopic(String virtualWiki, Namespace namespace, String pageName, boolean deleteOK,
        Connection conn) throws DataAccessException {
    long start = System.currentTimeMillis();
    String key = this.cacheTopicKey(virtualWiki, namespace, pageName);
    if (conn == null) {
        // retrieve topic from the cache only if this call is not currently a part
        // of a transaction to avoid retrieving data that might have been updated
        // as part of this transaction and would thus now be out of date
        Integer cacheTopicId = CACHE_TOPIC_IDS_BY_NAME.retrieveFromCache(key);
        if (cacheTopicId != null || CACHE_TOPIC_IDS_BY_NAME.isKeyInCache(key)) {
            Topic cacheTopic = (cacheTopicId != null) ? this.lookupTopicById(cacheTopicId.intValue(), conn)
                    : null;
            return (cacheTopic == null || (!deleteOK && cacheTopic.getDeleteDate() != null)) ? null
                    : cacheTopic;
        }
    }
    boolean checkSharedVirtualWiki = this.useSharedVirtualWiki(virtualWiki, namespace);
    String sharedVirtualWiki = Environment.getValue(Environment.PROP_SHARED_UPLOAD_VIRTUAL_WIKI);
    if (conn == null && checkSharedVirtualWiki) {
        String sharedKey = this.cacheTopicKey(sharedVirtualWiki, namespace, pageName);
        Integer cacheTopicId = CACHE_TOPIC_IDS_BY_NAME.retrieveFromCache(sharedKey);
        if (cacheTopicId != null || CACHE_TOPIC_IDS_BY_NAME.isKeyInCache(sharedKey)) {
            Topic cacheTopic = (cacheTopicId != null) ? this.lookupTopicById(cacheTopicId.intValue(), conn)
                    : null;
            return (cacheTopic == null || (!deleteOK && cacheTopic.getDeleteDate() != null)) ? null
                    : cacheTopic;
        }
    }
    Topic topic = null;
    try {
        int virtualWikiId = this.lookupVirtualWikiId(virtualWiki);
        topic = this.queryHandler().lookupTopic(virtualWikiId, namespace, pageName, conn);
        if (topic == null && Environment.getBooleanValue(Environment.PROP_PARSER_ALLOW_CAPITALIZATION)) {
            String alternativePageName = (StringUtils.equals(pageName, StringUtils.capitalize(pageName)))
                    ? StringUtils.lowerCase(pageName)
                    : StringUtils.capitalize(pageName);
            topic = this.queryHandler().lookupTopic(virtualWikiId, namespace, alternativePageName, conn);
        }
        if (topic == null && checkSharedVirtualWiki) {
            topic = this.lookupTopic(sharedVirtualWiki, namespace, pageName, deleteOK, conn);
        }
        if (conn == null) {
            // add topic to the cache only if it is not currently a part of a transaction
            // to avoid caching something that might need to be rolled back.
            if (topic == null) {
                CACHE_TOPIC_IDS_BY_NAME.addToCache(key, null);
                CACHE_TOPIC_NAMES_BY_NAME.addToCache(key, null);
            } else {
                this.cacheTopicRefresh(topic, false, key);
            }
        }
    } catch (SQLException e) {
        throw new DataAccessException(e);
    }
    if (logger.isDebugEnabled()) {
        long execution = (System.currentTimeMillis() - start);
        if (execution > TIME_LIMIT_TOPIC_LOOKUP) {
            logger.debug("Slow topic lookup for: " + Topic.buildTopicName(virtualWiki, namespace, pageName)
                    + " (" + (execution / 1000.000) + " s)");
        }
    }
    return (topic == null || (!deleteOK && topic.getDeleteDate() != null)) ? null : topic;
}

From source file:org.jamwiki.parser.LinkUtil.java

/**
 * Utility method for determining if an article name corresponds to a valid
 * wiki link.  In this case an "article name" could be an existing topic, a
 * "Special:" page, a user page, an interwiki link, etc.  This method will
 * return the article name if the given name corresponds to a valid special
 * page, user page, topic, or other existing article, or <code>null</code>
 * if no valid article exists.//from w  w  w. j av a 2  s  . c o  m
 *
 * @param virtualWiki The virtual wiki for the topic being checked.
 * @param articleName The name of the article that is being checked.
 * @return The article name if the given name and virtual wiki correspond
 *  to a valid special page, user page, topic, or other existing article,
 *  or <code>null</code> if no valid article exists.
 * @throws DataAccessException Thrown if an error occurs during lookup.
 */
public static String isExistingArticle(String virtualWiki, String articleName) throws DataAccessException {
    if (StringUtils.isBlank(virtualWiki) || StringUtils.isBlank(articleName)) {
        return null;
    }
    WikiLink wikiLink = new WikiLink(null, virtualWiki, articleName);
    if (PseudoTopicHandler.isPseudoTopic(wikiLink.getDestination())) {
        return articleName;
    }
    if (wikiLink.getInterwiki() != null) {
        return articleName;
    }
    if (!Environment.isInitialized()) {
        // not initialized yet
        return null;
    }
    String topicName = WikiBase.getDataHandler().lookupTopicName(virtualWiki, wikiLink.getNamespace(),
            wikiLink.getArticle());
    if (topicName == null && Environment.getBooleanValue(Environment.PROP_PARSER_ALLOW_CAPITALIZATION)) {
        String alternativeArticleName = (StringUtils.equals(wikiLink.getArticle(),
                StringUtils.capitalize(wikiLink.getArticle()))) ? StringUtils.lowerCase(wikiLink.getArticle())
                        : StringUtils.capitalize(wikiLink.getArticle());
        topicName = WikiBase.getDataHandler().lookupTopicName(virtualWiki, wikiLink.getNamespace(),
                alternativeArticleName);
    }
    return topicName;
}

From source file:org.jboss.windup.rules.apps.java.scan.provider.DiscoverArchiveLicenseFilesRuleProvider.java

private Set<FileModel> findLicense(ArchiveModel archive) {
    Set<FileModel> licenses = new HashSet<>();

    Iterable<FileModel> files = archive.getAllFiles();
    for (FileModel model : files) {
        if (model.isDirectory()) {
            continue;
        }/*from   w  w w  . j a  v a2  s.  com*/

        String fileName = model.getFileName();
        fileName = StringUtils.lowerCase(fileName);

        if (fileName.endsWith("license.txt") || fileName.endsWith("license") || fileName.endsWith("gpl.txt")
                || fileName.endsWith("lgpl.txt") || fileName.endsWith("notice.txt")
                || fileName.endsWith("notice")) {
            licenses.add(model);
        }
    }

    return licenses;
}