Example usage for org.apache.commons.lang StringUtils isBlank

List of usage examples for org.apache.commons.lang StringUtils isBlank

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils isBlank.

Prototype

public static boolean isBlank(String str) 

Source Link

Document

Checks if a String is whitespace, empty ("") or null.

Usage

From source file:com.alibaba.napoli.metamorphosis.network.StatsCommand.java

@Override
public IoBuffer encode() {
    if (StringUtils.isBlank(this.item)) {
        return IoBuffer.wrap((MetaEncodeCommand.STATS_CMD + " " + " " + this.getOpaque() + "\r\n").getBytes());
    } else {//w ww .j  a v a 2 s .  co m
        final IoBuffer buf = IoBuffer.allocate(9 + this.item.length() + ByteUtils.stringSize(this.getOpaque()));
        ByteUtils.setArguments(buf, MetaEncodeCommand.STATS_CMD, this.item, this.getOpaque());
        buf.flip();
        return buf;
    }
}

From source file:com.vsct.dt.hesperides.templating.models.annotation.HesperidesDefaultAnnotation.java

@Override
public boolean isValid() {
    final String value = getValue();

    return !(StringUtils.isEmpty(value) || StringUtils.isBlank(value));
}

From source file:com.vsct.dt.hesperides.templating.models.annotation.HesperidesPasswordAnnotation.java

@Override
public boolean isValid() {
    final String value = getValue();

    return (StringUtils.isEmpty(value) || StringUtils.isBlank(value));
}

From source file:com.prowidesoftware.swift.model.field.Field93BTest.java

/**
 * ':S/[S]/S/[c]N//w w  w  .  j  av a 2 s .co m
 */
@Test
public void testField93BString() {
    Field93B f = null;

    f = new Field93B("");
    assertTrue(StringUtils.isBlank(f.getComponent1()));
    assertTrue(StringUtils.isBlank(f.getComponent2()));
    assertTrue(StringUtils.isBlank(f.getComponent3()));
    assertTrue(StringUtils.isBlank(f.getComponent4()));
    assertTrue(StringUtils.isBlank(f.getComponent5()));

    f = new Field93B(":");
    assertTrue(StringUtils.isBlank(f.getComponent1()));
    assertTrue(StringUtils.isBlank(f.getComponent2()));
    assertTrue(StringUtils.isBlank(f.getComponent3()));
    assertTrue(StringUtils.isBlank(f.getComponent4()));
    assertTrue(StringUtils.isBlank(f.getComponent5()));

    f = new Field93B(":/");
    assertTrue(StringUtils.isBlank(f.getComponent1()));
    assertTrue(StringUtils.isBlank(f.getComponent2()));
    assertTrue(StringUtils.isBlank(f.getComponent3()));
    assertTrue(StringUtils.isBlank(f.getComponent4()));
    assertTrue(StringUtils.isBlank(f.getComponent5()));

    f = new Field93B("://");
    assertTrue(StringUtils.isBlank(f.getComponent1()));
    assertTrue(StringUtils.isBlank(f.getComponent2()));
    assertTrue(StringUtils.isBlank(f.getComponent3()));
    assertTrue(StringUtils.isBlank(f.getComponent4()));
    assertTrue(StringUtils.isBlank(f.getComponent5()));

    f = new Field93B(":///");
    assertTrue(StringUtils.isBlank(f.getComponent1()));
    assertTrue(StringUtils.isBlank(f.getComponent2()));
    assertTrue(StringUtils.isBlank(f.getComponent3()));
    assertTrue(StringUtils.isBlank(f.getComponent4()));
    assertTrue(StringUtils.isBlank(f.getComponent5()));

    f = new Field93B(":////");
    assertTrue(StringUtils.isBlank(f.getComponent1()));
    assertTrue(StringUtils.isBlank(f.getComponent2()));
    assertTrue(StringUtils.isBlank(f.getComponent3()));
    assertTrue(StringUtils.isBlank(f.getComponent4()));
    assertTrue(StringUtils.isBlank(f.getComponent5()));

    f = new Field93B(":DDDD");
    assertEquals("DDDD", f.getComponent1());
    assertTrue(StringUtils.isBlank(f.getComponent2()));
    assertTrue(StringUtils.isBlank(f.getComponent3()));
    assertTrue(StringUtils.isBlank(f.getComponent4()));
    assertTrue(StringUtils.isBlank(f.getComponent5()));

    f = new Field93B(":DDDD/");
    assertEquals("DDDD", f.getComponent1());
    assertTrue(StringUtils.isBlank(f.getComponent2()));
    assertTrue(StringUtils.isBlank(f.getComponent3()));
    assertTrue(StringUtils.isBlank(f.getComponent4()));
    assertTrue(StringUtils.isBlank(f.getComponent5()));

    f = new Field93B(":DDDD/EEEEEEEE");
    assertEquals("DDDD", f.getComponent1());
    assertEquals("EEEEEEEE", f.getComponent2());
    assertTrue(StringUtils.isBlank(f.getComponent3()));
    assertTrue(StringUtils.isBlank(f.getComponent4()));
    assertTrue(StringUtils.isBlank(f.getComponent5()));

    f = new Field93B(":DDDD/EEEEEEEE/");
    assertEquals("DDDD", f.getComponent1());
    assertEquals("EEEEEEEE", f.getComponent2());
    assertTrue(StringUtils.isBlank(f.getComponent3()));
    assertTrue(StringUtils.isBlank(f.getComponent4()));
    assertTrue(StringUtils.isBlank(f.getComponent5()));

    f = new Field93B(":DDDD//");
    assertEquals("DDDD", f.getComponent1());
    assertTrue(StringUtils.isBlank(f.getComponent2()));
    assertTrue(StringUtils.isBlank(f.getComponent3()));
    assertTrue(StringUtils.isBlank(f.getComponent4()));
    assertTrue(StringUtils.isBlank(f.getComponent5()));

    f = new Field93B(":DDDD/EEEEEEEE/FFFF");
    assertEquals("DDDD", f.getComponent1());
    assertEquals("EEEEEEEE", f.getComponent2());
    assertEquals("FFFF", f.getComponent3());
    assertTrue(StringUtils.isBlank(f.getComponent4()));
    assertTrue(StringUtils.isBlank(f.getComponent5()));

    f = new Field93B(":DDDD//FFFF");
    assertEquals("DDDD", f.getComponent1());
    assertTrue(StringUtils.isBlank(f.getComponent2()));
    assertEquals("FFFF", f.getComponent3());
    assertTrue(StringUtils.isBlank(f.getComponent4()));
    assertTrue(StringUtils.isBlank(f.getComponent5()));

    f = new Field93B(":DDDD/EEEEEEEE/FFFF/E");
    assertEquals("DDDD", f.getComponent1());
    assertEquals("EEEEEEEE", f.getComponent2());
    assertEquals("FFFF", f.getComponent3());
    assertEquals("E", f.getComponent4());
    assertTrue(StringUtils.isBlank(f.getComponent5()));

    f = new Field93B(":DDDD/EEEEEEEE/FFFF/E1234");
    assertEquals("DDDD", f.getComponent1());
    assertEquals("EEEEEEEE", f.getComponent2());
    assertEquals("FFFF", f.getComponent3());
    assertEquals("E", f.getComponent4());
    assertEquals("1234", f.getComponent5());
}

From source file:de.hybris.platform.acceleratorstorefrontcommons.forms.validation.RestoreSaveCartFormValidator.java

@Override
public void validate(final Object object, final Errors errors) {
    final RestoreSaveCartForm restoreSaveCartForm = (RestoreSaveCartForm) object;
    if (restoreSaveCartForm.getCartName() != null && !restoreSaveCartForm.isPreventSaveActiveCart()) {
        final String cartName = restoreSaveCartForm.getCartName();

        if (StringUtils.isBlank(cartName)) {
            errors.rejectValue("cartName", "basket.save.cart.validation.name.notBlank");
            return;
        }//from  w w w.j  a  v a  2 s.  co m

        if (!StringUtils.isAlphanumericSpace(cartName)) {
            errors.rejectValue("cartName", "basket.save.cart.validation.name.charset");
            return;
        }

        if (StringUtils.length(cartName) > 255) {
            errors.rejectValue("cartName", "basket.save.cart.validation.name.size");
            return;
        }
    }
}

From source file:ch.cyberduck.ui.action.ChecksumWorker.java

@Override
public List<String> run() {
    List<String> checksum = new ArrayList<String>();
    for (Path file : files) {
        if (StringUtils.isBlank(file.attributes().getChecksum())) {
            file.readChecksum();//from w w w .  j av  a2s. c o  m
        }
        checksum.add(file.attributes().getChecksum());
    }
    return checksum;
}

From source file:com.senacor.wbs.web.user.UserAdminPage.java

private boolean startsWith(final String a, final String b) {
    return StringUtils.isBlank(b) || a.startsWith(b) || a.toLowerCase().startsWith(b.toLowerCase());
}

From source file:net.sourceforge.fenixedu.domain.AppUserSession.java

public boolean matchesCode(String code) {
    if (StringUtils.isBlank(code) || StringUtils.isBlank(getCode())) {
        return false;
    }/* ww  w. j  a va 2s . c  o  m*/
    return code.equals(getCode());
}

From source file:com.google.code.rptm.metadata.pmc.CommitteeInfoParser.java

public static void parse(InputStream in, CommitteeInfoVisitor visitor) throws IOException {
    BufferedReader reader = new BufferedReader(new InputStreamReader(in, "UTF-8"));
    int state = STATE_PREAMBLE;
    int i = 0;//from w  w  w. ja  v a2s. c  om
    while (true) {
        String line = reader.readLine();
        i++;
        if (line == null) {
            if (state != STATE_COMPLETE) {
                throw new IOException("Unexpected end of file (state = " + state);
            } else {
                break;
            }
        } else if (state != STATE_PREAMBLE && END_MARKER.matcher(line).matches()) {
            if (state == STATE_PROJECT) {
                visitor.endProject();
            }
            state = STATE_COMPLETE;
            continue;
        } else if ((state == STATE_PROJECT || state == STATE_PROJECT_COMPLETE) && StringUtils.isBlank(line)) {
            if (state == STATE_PROJECT) {
                visitor.endProject();
                state = STATE_PROJECT_COMPLETE;
            }
            continue;
        } else if (state == STATE_PROJECT) {
            Matcher m = MEMBER_ENTRY.matcher(line);
            if (m.matches()) {
                visitor.member(m.group(1), m.group(3));
                continue;
            }
        } else if (state == STATE_PREAMBLE || state == STATE_PROJECT_COMPLETE) {
            Matcher m = PROJECT_HEADER.matcher(line);
            if (m.matches()) {
                visitor.startProject(m.group(1));
                state = STATE_PROJECT;
                continue;
            } else if (state == STATE_PREAMBLE) {
                continue;
            }
        } else if (state == STATE_COMPLETE && StringUtils.isBlank(line)) {
            continue;
        }
        throw new IOException("Unexpected content at line " + i + " (state = " + state + "): " + line);
    }
}

From source file:com.prowidesoftware.swift.model.field.Field90JTest.java

@Test
public void testField90JString() {
    Field90J f = null;/*  w  ww. j a v  a  2  s  .  c  om*/

    f = new Field90J("");
    assertTrue(StringUtils.isBlank(f.getComponent1()));
    assertTrue(StringUtils.isBlank(f.getComponent2()));
    assertTrue(StringUtils.isBlank(f.getComponent3()));
    assertTrue(StringUtils.isBlank(f.getComponent4()));
    assertTrue(StringUtils.isBlank(f.getComponent5()));
    assertTrue(StringUtils.isBlank(f.getComponent6()));

    f = new Field90J(":");
    assertTrue(StringUtils.isBlank(f.getComponent1()));
    assertTrue(StringUtils.isBlank(f.getComponent2()));
    assertTrue(StringUtils.isBlank(f.getComponent3()));
    assertTrue(StringUtils.isBlank(f.getComponent4()));
    assertTrue(StringUtils.isBlank(f.getComponent5()));
    assertTrue(StringUtils.isBlank(f.getComponent6()));

    f = new Field90J(":/");
    //assertTrue(StringUtils.isBlank(f.getComponent1()));
    assertTrue(StringUtils.isBlank(f.getComponent2()));
    assertTrue(StringUtils.isBlank(f.getComponent3()));
    assertTrue(StringUtils.isBlank(f.getComponent4()));
    assertTrue(StringUtils.isBlank(f.getComponent5()));
    assertTrue(StringUtils.isBlank(f.getComponent6()));

    f = new Field90J("://");
    assertTrue(StringUtils.isBlank(f.getComponent1()));
    assertTrue(StringUtils.isBlank(f.getComponent2()));
    assertTrue(StringUtils.isBlank(f.getComponent3()));
    assertTrue(StringUtils.isBlank(f.getComponent4()));
    assertTrue(StringUtils.isBlank(f.getComponent5()));
    assertTrue(StringUtils.isBlank(f.getComponent6()));

    f = new Field90J(":///");
    assertTrue(StringUtils.isBlank(f.getComponent1()));
    assertTrue(StringUtils.isBlank(f.getComponent2()));
    assertTrue(StringUtils.isBlank(f.getComponent3()));
    assertTrue(StringUtils.isBlank(f.getComponent4()));
    assertTrue(StringUtils.isBlank(f.getComponent5()));
    assertTrue(StringUtils.isBlank(f.getComponent6()));

    f = new Field90J(":DDDD");
    assertEquals("DDDD", f.getComponent1());
    assertTrue(StringUtils.isBlank(f.getComponent2()));
    assertTrue(StringUtils.isBlank(f.getComponent3()));
    assertTrue(StringUtils.isBlank(f.getComponent4()));
    assertTrue(StringUtils.isBlank(f.getComponent5()));
    assertTrue(StringUtils.isBlank(f.getComponent6()));

    f = new Field90J(":DDDD//");
    assertEquals("DDDD", f.getComponent1());
    assertTrue(StringUtils.isBlank(f.getComponent2()));
    assertTrue(StringUtils.isBlank(f.getComponent3()));
    assertTrue(StringUtils.isBlank(f.getComponent4()));
    assertTrue(StringUtils.isBlank(f.getComponent5()));
    assertTrue(StringUtils.isBlank(f.getComponent6()));

    f = new Field90J(":DDDD//EEEEEEEE");
    assertEquals("DDDD", f.getComponent1());
    assertEquals("EEEEEEEE", f.getComponent2());
    assertTrue(StringUtils.isBlank(f.getComponent3()));
    assertTrue(StringUtils.isBlank(f.getComponent4()));
    assertTrue(StringUtils.isBlank(f.getComponent5()));
    assertTrue(StringUtils.isBlank(f.getComponent6()));

    f = new Field90J(":DDDD//EEEEEEEE/");
    assertEquals("DDDD", f.getComponent1());
    assertEquals("EEEEEEEE", f.getComponent2());
    assertTrue(StringUtils.isBlank(f.getComponent3()));
    assertTrue(StringUtils.isBlank(f.getComponent4()));
    assertTrue(StringUtils.isBlank(f.getComponent5()));
    assertTrue(StringUtils.isBlank(f.getComponent6()));

    f = new Field90J(":DDDD//EEEEEEEE/FFF");
    assertEquals("DDDD", f.getComponent1());
    assertEquals("EEEEEEEE", f.getComponent2());
    assertEquals("FFF", f.getComponent3());
    assertTrue(StringUtils.isBlank(f.getComponent4()));
    assertTrue(StringUtils.isBlank(f.getComponent5()));
    assertTrue(StringUtils.isBlank(f.getComponent6()));

    f = new Field90J(":DDDD//EEEEEEEE/FFF123");
    assertEquals("DDDD", f.getComponent1());
    assertEquals("EEEEEEEE", f.getComponent2());
    assertEquals("FFF", f.getComponent3());
    assertEquals("123", f.getComponent4());
    assertTrue(StringUtils.isBlank(f.getComponent5()));
    assertTrue(StringUtils.isBlank(f.getComponent6()));

    f = new Field90J(":DDDD//EEEEEEEE/FFF123/");
    assertEquals("DDDD", f.getComponent1());
    assertEquals("EEEEEEEE", f.getComponent2());
    assertEquals("FFF", f.getComponent3());
    assertEquals("123", f.getComponent4());
    assertTrue(StringUtils.isBlank(f.getComponent5()));
    assertTrue(StringUtils.isBlank(f.getComponent6()));

    f = new Field90J(":DDDD//EEEEEEEE/FFF123/GGG");
    assertEquals("DDDD", f.getComponent1());
    assertEquals("EEEEEEEE", f.getComponent2());
    assertEquals("FFF", f.getComponent3());
    assertEquals("123", f.getComponent4());
    assertEquals("GGG", f.getComponent5());
    assertTrue(StringUtils.isBlank(f.getComponent6()));

    f = new Field90J(":DDDD//EEEEEEEE/FFF123/GGG456");
    assertEquals("DDDD", f.getComponent1());
    assertEquals("EEEEEEEE", f.getComponent2());
    assertEquals("FFF", f.getComponent3());
    assertEquals("123", f.getComponent4());
    assertEquals("GGG", f.getComponent5());
    assertEquals("456", f.getComponent6());
}