Java Code Examples for org.apache.commons.lang3.StringUtils.startsWithIgnoreCase()

The following are Jave code examples for showing how to use startsWithIgnoreCase() of the org.apache.commons.lang3.StringUtils class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: ProjectAltaria   File: MessageUtils.java   View Source Code Vote up 7 votes
public static boolean isMyCommand(String message, @NotNull ICommand thiz) {
    message = message.trim();
    @NotNull final String prefix = Prefixes.getInstance().current();
    if (!message.startsWith(prefix)) {
        return false;
    }
    if (StringUtils.startsWithIgnoreCase(message, prefix + thiz.command())) {
        return true;
    }

    for (String alias : thiz.aliases()) {
        if (StringUtils.startsWithIgnoreCase(message, prefix + alias)) {
            return true;
        }
    }
    return false;
}
 
Example 2
Project: Phoenicia   File: MigrationHelper.java   View Source Code Vote up 6 votes
public List<String> getRelationTableNames(String table) {
	List<String> result = new ArrayList<String>();
	String sql = "SELECT name FROM sqlite_master WHERE type='table' AND (name LIKE '" + table + "#_%' OR name LIKE '%#_" + table +"' ESCAPE '#')";
	
	Cursor c = getCursor(sql);
	
	while(c.moveToNext()) {
		String name = c.getString(c.getColumnIndexOrThrow("name"));
	
		if(!name.equalsIgnoreCase(table) && (
				StringUtils.startsWithIgnoreCase(name, table) || 
				StringUtils.endsWithIgnoreCase(name, table)
			)) {
			
			result.add(name);
		}
	}
	
	close(c);
	return result;
}
 
Example 3
Project: alexa-utterance-generator   File: SkillBuilderModel.java   View Source Code Vote up 6 votes
public void addSample(final String sample) {
    final String[] words = sample.split(" ");
    final String intentName = words.length < 1 || StringUtils.isBlank(words[0]) ? DEFAULT_INTENT_NAME : words[0];
    final String sampleUtterance = words.length > 1 ? sample.substring(sample.indexOf(" ") + 1).trim() : "";

    // skip blank utterances except for builtin-intents that can exist without samples
    if (StringUtils.isBlank(sampleUtterance) && !StringUtils.startsWithIgnoreCase(intentName, "AMAZON.")) return;

    final Optional<Intent> intent = intents.stream().filter(i -> i.getName().equals(intentName)).findFirst();
    if (intent.isPresent()) {
        intent.get().addSample(sampleUtterance);
    } else {
        intents.add(new Intent(intentName, sampleUtterance));
    }

    final Matcher slotsInUtterance = Pattern.compile("\\{(.*?)\\}").matcher(sampleUtterance);
    // for any of the placeholder ...
    while (slotsInUtterance.find()) {
        final String slotName = slotsInUtterance.group(1);
        if (!StringUtils.startsWithIgnoreCase(slotName,"AMAZON.") && types.stream().noneMatch(t -> t.getName().equals(slotName))) {
            types.add(new SlotType(slotName));
        }
    }
}
 
Example 4
Project: cyberduck   File: RequestEntityRestStorageService.java   View Source Code Vote up 5 votes
@Override
protected boolean isXmlContentType(final String contentType) {
    if(null == contentType) {
        return false;
    }
    if(StringUtils.startsWithIgnoreCase(contentType, "application/xml")) {
        return true;
    }
    if(StringUtils.startsWithIgnoreCase(contentType, "text/xml")) {
        return true;
    }
    return false;
}
 
Example 5
Project: spring-cloud-samples   File: WebUtils.java   View Source Code Vote up 5 votes
public static String getPathWithinApplication(HttpServletRequest request) {
    String contextPath = getContextPath(request);
    String requestUri = getRequestUri(request);
    if (StringUtils.startsWithIgnoreCase(requestUri, contextPath)) {
        // Normal case: URI contains context path.
        String path = requestUri.substring(contextPath.length());
        return (StringUtils.isNotBlank(path) ? path : "/");
    } else {
        return requestUri;
    }
}
 
Example 6
Project: vscrawler   File: StartsWith.java   View Source Code Vote up 5 votes
@Override
protected boolean handle(String input, String searchString, boolean ignoreCase) {
    if (ignoreCase) {
        return StringUtils.startsWithIgnoreCase(input, searchString);
    } else {
        return StringUtils.startsWith(input, searchString);
    }
}
 
Example 7
Project: nixmash-blog   File: AdminPostsController.java   View Source Code Vote up 4 votes
private PostDTO getPagePreviewImage(PagePreviewDTO page, String sourceLink, Integer imageIndex) {
    String postSource = PostUtils.createPostSource(sourceLink);
    PostDTO tmpDTO = new PostDTO();
    String imageUrl = null;
    Boolean hasImages = true;

    if (imageIndex == null) {

        // populating the postDTO image contents for addLink form

        if (page.twitterDTO != null) {
            imageUrl = page.getTwitterDTO().getTwitterImage();
            if (imageUrl != null) {
                if (!StringUtils.startsWithIgnoreCase(imageUrl, "http"))
                    imageUrl = null;
            }
        } else {
            if (page.getImages().size() > 1) {
                imageUrl = page.getImages().get(1).getSrc();
            } else
                hasImages = false;
        }
        // if twitter image url missing or page contains single image

        if (StringUtils.isEmpty(imageUrl)) {
            hasImages = false;
            imageUrl = null;
        }
    } else {
        // determining the final postDTO from addLink form carousel index

        imageUrl = page.getImages().get(imageIndex).getSrc();
    }

    // At some future point may require a database lookup approach:
    // if getNoImageSources(postSource) != null, imageUrl = "/images...{postSource}.png"

    if (postSource != null) {
        switch (postSource.toLowerCase()) {
            case "stackoverflow.com":
                imageUrl = "/images/posts/stackoverflow.png";
                hasImages = false;
                break;
            case "spring.io":
            case "docs.spring.io":
                imageUrl = "/images/posts/spring.png";
                hasImages = false;
                break;
            case "github.com":
                imageUrl = "/images/posts/github.png";
                hasImages = false;
                break;
            default:
                break;
        }
    }

    tmpDTO.setPostImage(imageUrl);
    tmpDTO.setHasImages(hasImages);

    return tmpDTO;
}
 
Example 8
Project: remittanceparse   File: RemittancePdf.java   View Source Code Vote up 4 votes
private void handleDate(File tempTsvFileForDate) throws IOException, ParserException {

        String date=null;
        try(BufferedReader reader=new BufferedReader(new FileReader(tempTsvFileForDate)))
        {
            for(String line=reader.readLine();line!=null;line=reader.readLine())
            {
                line=line.trim();
                if(!StringUtils.startsWithIgnoreCase(line,"Date"))
                    continue;

                final String[] split = StringUtils.splitByWholeSeparator(line, " ");
                if(split.length!=2)
                    throw new ParserException("Could not parse date field: "+line);

                date=split[1];
                break;
            }
        }

        if(date==null)
            throw new ParserException("Never found date field");

        //start guessing at the date format
        boolean isEuroDate=isEuroDate(date);
        boolean isUSDate=isUSDate(date);

        if(!isEuroDate && !isUSDate)
            throw new ParserException("Could not parse date field: "+date);

        if(isEuroDate && !isUSDate) {
            dateParser = Format.euroDateFormatter;
            return;
        }

        if(!isEuroDate) {
            dateParser = Format.usDateFormatter;
            return;
        }

        //hmmm.... date is valid in both formats. Use the filename instead

        try {
            final String[] array = StringUtils.splitByWholeSeparator(inputPdfFile.getName(), "-");
            int year = Integer.parseInt(array[0]);
            int month = Integer.parseInt(array[1]);
            if (year < 2017 || month <= 6)
                dateParser = Format.euroDateFormatter;
            else
                dateParser = Format.usDateFormatter;

            remittanceDate=dateParser.parse(date);

        }
        catch (Throwable t)
        {
            throw new ParserException("Can not determine date format to use.",t);
        }

    }
 
Example 9
Project: vscrawler   File: PreffixSeedRouter.java   View Source Code Vote up 4 votes
@Override
public boolean matchSeed(Seed seed) {
    return StringUtils.startsWithIgnoreCase(seed.getData(), prefix);
}