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

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

Introduction

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

Prototype

public static boolean isAllLowerCase(final CharSequence cs) 

Source Link

Document

Checks if the CharSequence contains only lowercase characters.

null will return false .

Usage

From source file:org.talend.components.azurestorage.blob.runtime.AzureStorageContainerRuntime.java

@Override
public ValidationResult initialize(RuntimeContainer runtimeContainer, ComponentProperties properties) {
    // init/*from  w  ww .  j a v  a2 s .co  m*/
    AzureStorageContainerProperties componentProperties = (AzureStorageContainerProperties) properties;

    this.containerName = componentProperties.container.getValue();

    // validate
    ValidationResult validationResult = super.initialize(runtimeContainer, properties);
    if (validationResult.getStatus() == ValidationResult.Result.ERROR) {
        return validationResult;
    }

    String errorMessage = "";
    // not empty
    if (StringUtils.isEmpty(containerName)) {
        errorMessage = messages.getMessage("error.ContainerEmpty");
    }
    // valid characters 0-9 a-z and -
    else if (!StringUtils.isAlphanumeric(containerName.replaceAll("-", ""))) {

        errorMessage = messages.getMessage("error.IncorrectName");
    }
    // all lowercase
    else if (!StringUtils.isAllLowerCase(containerName.replaceAll("(-|\\d)", ""))) {
        errorMessage = messages.getMessage("error.UppercaseName");
    }
    // length range : 3-63
    else if ((containerName.length() < 3) || (containerName.length() > 63)) {
        errorMessage = messages.getMessage("error.LengthError");
    }

    if (errorMessage.isEmpty()) {
        return ValidationResult.OK;
    } else {
        return new ValidationResult(ValidationResult.Result.ERROR, errorMessage);
    }
}

From source file:org.talend.components.azurestorage.blob.runtime.AzureStorageSource.java

@Override
public ValidationResult validate(RuntimeContainer container) {
    // checks that account name and key are not empty
    ValidationResult superRes = super.validate(container);
    if (superRes != ValidationResult.OK)
        return superRes;
    // No validation for listing containers
    if (this.properties instanceof TAzureStorageContainerListProperties) {
        return ValidationResult.OK;
    }/*ww  w.  ja va  2 s. c o m*/
    // Checks that container name follows MS naming rules
    if (this.properties instanceof AzureStorageContainerProperties) {
        String cnt = ((AzureStorageContainerProperties) this.properties).container.getValue();
        // not empty
        if (StringUtils.isEmpty(cnt)) {
            ValidationResult vr = new ValidationResult();
            vr.setMessage(messages.getMessage("error.ContainerEmpty")); //$NON-NLS-1$
            vr.setStatus(ValidationResult.Result.ERROR);
            return vr;
        }
        // valid characters 0-9 a-z and -
        if (!StringUtils.isAlphanumeric(cnt.replaceAll("-", ""))) {
            ValidationResult vr = new ValidationResult();
            vr.setMessage(messages.getMessage("error.IncorrectName")); //$NON-NLS-1$
            vr.setStatus(ValidationResult.Result.ERROR);
            return vr;
        }
        // all lowercase
        if (!StringUtils.isAllLowerCase(cnt.replaceAll("(-|\\d)", ""))) {
            ValidationResult vr = new ValidationResult();
            vr.setMessage(messages.getMessage("error.UppercaseName")); //$NON-NLS-1$
            vr.setStatus(ValidationResult.Result.ERROR);
            return vr;
        }
        // length range : 3-63
        int cntl = cnt.length();
        if ((cntl < 3) || (cntl > 63)) {
            ValidationResult vr = new ValidationResult();
            vr.setMessage(messages.getMessage("error.LengthError")); //$NON-NLS-1$
            vr.setStatus(ValidationResult.Result.ERROR);
            return vr;
        }
    }
    // Operations on CloudBlob(s)
    if (this.properties instanceof AzureStorageBlobProperties) {
        // Put operation has different properties
        if (this.properties instanceof TAzureStoragePutProperties) {
            TAzureStoragePutProperties p = (TAzureStoragePutProperties) this.properties;
            String folder = p.localFolder.getValue();
            // checks local folder
            if (!new File(folder).exists()) {
                ValidationResult vr = new ValidationResult();
                vr.setMessage(messages.getMessage("error.EmptyLocalFolder")); //$NON-NLS-1$
                vr.setStatus(ValidationResult.Result.ERROR);
                return vr;
            }
            // checks file list if set.
            if (p.useFileList.getValue() && p.files.fileMask.getValue().size() == 0) {
                ValidationResult vr = new ValidationResult();
                vr.setMessage(messages.getMessage("error.EmptyFileList")); //$NON-NLS-1$
                vr.setStatus(ValidationResult.Result.ERROR);
                return vr;
            }
            // everything is OK.
            return ValidationResult.OK;
        }
        // Get operation needs some additional properties
        if (this.properties instanceof TAzureStorageGetProperties) {
            //
            if (((TAzureStorageGetProperties) this.properties).remoteBlobsGet.prefix.getValue().size() == 0) {
                ValidationResult vr = new ValidationResult();
                vr.setMessage(messages.getMessage("error.EmptyBlobs")); //$NON-NLS-1$
                vr.setStatus(ValidationResult.Result.ERROR);
                return vr;
            }
            String folder = ((TAzureStorageGetProperties) this.properties).localFolder.getValue();
            if (!new File(folder).exists()) {
                ValidationResult vr = new ValidationResult();
                vr.setMessage(messages.getMessage("error.NonentityLocal")); //$NON-NLS-1$
                vr.setStatus(ValidationResult.Result.ERROR);
                return vr;
            }
            // everything is OK.
            return ValidationResult.OK;
        }
        // We need at least one blob filter
        if (((AzureStorageBlobProperties) this.properties).remoteBlobs.prefix.getValue().size() == 0) {
            ValidationResult vr = new ValidationResult();
            vr.setMessage(messages.getMessage("error.EmptyBlobs")); //$NON-NLS-1$
            vr.setStatus(ValidationResult.Result.ERROR);
            return vr;
        }
    }
    return ValidationResult.OK;
}

From source file:org.trnltk.morphology.contextless.parser.PredefinedPathBuilder.java

/**
 * Adds given suffix to current path with the given suffix form application.
 */// ww w  .  j a v a  2  s  . co  m
public PredefinedPathBuilder s(Suffix suffix, String suffixFormStr) {
    Validate.notNull(suffix);
    if (StringUtils.isNotEmpty(suffixFormStr))
        Validate.isTrue(StringUtils.isAllLowerCase(suffixFormStr),
                "SuffixForm str should be lower case! See suffix :" + suffix.getName() + " and suffixFormStr : "
                        + suffixFormStr);
    this.followPath(suffix, suffixFormStr);
    return this;
}

From source file:se.trixon.mapollage.Operation.java

private String getImagePath(File file) {
    String imageSrc;/*from  w w  w. jav  a2  s.  co  m*/

    switch (mProfilePhoto.getReference()) {
    case ABSOLUTE:
        imageSrc = String.format("file:///%s", file.getAbsolutePath());
        break;

    case ABSOLUTE_PATH:
        imageSrc = String.format("%s%s", mProfilePhoto.getBaseUrlValue(), file.getName());
        break;

    case RELATIVE:
        Path relativePath = mDestinationFile.toPath().relativize(file.toPath());
        imageSrc = StringUtils.replace(relativePath.toString(), "..", ".", 1);
        break;

    case THUMBNAIL:
        Path thumbPath = mDestinationFile.toPath().relativize(mFileThumbMap.get(file).toPath());
        imageSrc = StringUtils.replace(thumbPath.toString(), "..", ".", 1);
        break;

    default:
        throw new AssertionError();
    }

    if (SystemUtils.IS_OS_WINDOWS) {
        imageSrc = imageSrc.replace("\\", "/");
    }

    if (mProfilePhoto.isForceLowerCaseExtension()) {
        String ext = FilenameUtils.getExtension(imageSrc);
        if (!StringUtils.isBlank(ext) && !StringUtils.isAllLowerCase(ext)) {
            String noExt = FilenameUtils.removeExtension(imageSrc);
            imageSrc = String.format("%s.%s", noExt, ext.toLowerCase());
        }
    }

    return imageSrc;
}