List of usage examples for org.springframework.util StringUtils hasText
public static boolean hasText(@Nullable String str)
From source file:com.joyveb.dbpimpl.cass.prepare.util.ParsingUtils.java
public static void setPropertyValue(BeanDefinitionBuilder builder, Element element, String attrName, String propertyName) {/*w w w . j a v a2s. c o m*/ Assert.notNull(builder, "BeanDefinitionBuilder must not be null"); Assert.notNull(element, "Element must not be null"); Assert.hasText(attrName, "Attribute name must not be null"); Assert.hasText(propertyName, "Property name must not be null"); String attr = element.getAttribute(attrName); if (StringUtils.hasText(attr)) { builder.addPropertyValue(propertyName, attr); } }
From source file:biz.deinum.jxl.util.JxlUtils.java
/** * Checks if the given cell is emtpy. The cell is empty if it contains no characters, it will trim spaces. /*from w w w . ja va 2 s .com*/ * @param cell to check * @return true/false * @see StringUtils#hasText(String) */ public static boolean isEmpty(final Cell cell) { return cell == null || !StringUtils.hasText(cell.getContents()); }
From source file:fr.univlorraine.mondossierweb.utils.PropertyUtils.java
/** Retourne l'url de l'application */ public static String getAppUrl() { String value = System.getProperty("context.app.url"); if (!StringUtils.hasText(value)) throw new NullPointerException("app.url cannot be null !"); return value; }
From source file:se.alingsas.alfresco.repo.utils.CommonFileUtil.java
/** * Get mimetype by a files extension/*from w w w . java 2 s . c o m*/ * * @param extension * @return */ public static String getMimetypeByExtension(final String extension) { String mimetype; if (!StringUtils.hasText(extension)) { mimetype = "application/octet-stream"; } else if (extension.equalsIgnoreCase("pdf")) { mimetype = "application/pdf"; } else if (extension.equalsIgnoreCase("ppt")) { mimetype = "application/vnd.ms-powerpoint"; } else if (extension.equalsIgnoreCase("doc")) { mimetype = "application/msword"; } else if (extension.equalsIgnoreCase("vsd")) { mimetype = "application/visio"; } else if (extension.equalsIgnoreCase("bmp")) { mimetype = "image/bmp"; } else if (extension.equalsIgnoreCase("htm")) { mimetype = "text/html"; } else if (extension.equalsIgnoreCase("html")) { mimetype = "text/html"; } else if (extension.equalsIgnoreCase("dot")) { mimetype = "application/msword"; } else if (extension.equalsIgnoreCase("xls")) { mimetype = "application/vnd.ms-excel"; } else if (extension.equalsIgnoreCase("jpg")) { mimetype = "image/jpeg"; } else if (extension.equalsIgnoreCase("pot")) { mimetype = "application/vnd.ms-powerpoint"; } else if (extension.equalsIgnoreCase("rtf")) { mimetype = "application/rtf"; } else if (extension.equalsIgnoreCase("eps")) { mimetype = "application/eps"; } else if (extension.equalsIgnoreCase("zip")) { mimetype = "application/zip"; } else if (extension.equalsIgnoreCase("txt")) { mimetype = "text/plain"; } else if (extension.equalsIgnoreCase("text")) { mimetype = "text/plain"; } else if (extension.equalsIgnoreCase("log")) { mimetype = "text/plain"; } else if (extension.equalsIgnoreCase("odt")) { mimetype = "application/vnd.oasis.opendocument.text"; } else if (extension.equalsIgnoreCase("ods")) { mimetype = "application/vnd.oasis.opendocument.spreadsheet"; } else if (extension.equalsIgnoreCase("odp")) { mimetype = "application/vnd.oasis.opendocument.presentation"; } else if (extension.equalsIgnoreCase("ott")) { mimetype = "application/vnd.oasis.opendocument.formula-template"; } else if (extension.equalsIgnoreCase("tif")) { mimetype = "image/tiff"; } else if (extension.equalsIgnoreCase("tiff")) { mimetype = "image/tiff"; } else if (extension.equalsIgnoreCase("pcx")) { mimetype = "image/pcx"; } else if (extension.equalsIgnoreCase("docx")) { mimetype = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; } else if (extension.equalsIgnoreCase("xlsx")) { mimetype = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; } else if (extension.equalsIgnoreCase("pptx")) { mimetype = "application/vnd.openxmlformats-officedocument.presentationml.presentation"; } else if (extension.equalsIgnoreCase("nal")) { mimetype = "application/octet-stream"; } else if (extension.equalsIgnoreCase("indd")) { mimetype = "application/ocet-stream"; } else if (extension.equalsIgnoreCase("pmd")) { mimetype = "application/ocet-stream"; } else if (extension.equalsIgnoreCase("mht")) { mimetype = "application/ocet-stream"; } else if (extension.equalsIgnoreCase("lnk")) { mimetype = "application/ocet-stream"; } else { throw new RuntimeException("The extension '" + extension + "' has no configured mimetype."); } return mimetype; }
From source file:org.codehaus.mojo.hibernate3.processor.ProcessorUtil.java
public static String compressCode(String in) { String matches[] = wsPattern.split(in); StringBuffer bu = new StringBuffer(); for (String s : matches) { if (StringUtils.hasText(s)) { bu.append(s).append(" "); }//from w ww. j ava 2 s .c o m } return bu.toString().trim(); }
From source file:cat.albirar.framework.utilities.StringUtilities.java
/** * Check that strings is not null, have at least one item and all items have text. * @param strings The string or strings to check * @return true if not null, greather than 0 and all items {@link StringUtils#hasText(String)} * @see StringUtils#hasText(String)/* w w w. jav a 2 s . c o m*/ */ public static final boolean hasText(String... strings) { if (strings != null && strings.length > 0) { for (String s : strings) { if (!StringUtils.hasText(s)) { return false; } } return true; } return false; }
From source file:model.fileloader.FileLoader.java
protected List<String> getFileContent(String filename) throws IOException { if (!StringUtils.hasText(filename)) throw new IOException(); String workDir = System.getProperty("user.dir"); File file = new File(workDir, filename); Path path = file.toPath();/* w w w .j a v a2s . c o m*/ return Files.readAllLines(path); }
From source file:de.olivergierke.whoops.customer.CustomerNumber.java
/** * Returns whether the given {@link String} is a valid {@link CustomerNumber}. * //from w ww .j av a 2s . co m * @param number * @return */ public static boolean isValid(String number) { return StringUtils.hasText(number) && number.matches(REGEX); }
From source file:example.springdata.redis.test.util.RequiresRedisServer.java
public static RequiresRedisServer listeningAt(String host, int port) { return new RequiresRedisServer(StringUtils.hasText(host) ? host : "127.0.0.1", port); }
From source file:com.github.notizklotz.derbunddownloader.settings.TimePickerPreference.java
public static Integer[] toHourMinuteIntegers(String timeString) { if (!StringUtils.hasText(timeString)) { throw new IllegalArgumentException("timeString must not be blank"); }/*w w w .j a va2s. c om*/ String[] values = timeString.split(":|/"); Integer hour = Integer.valueOf(values[0]); Integer minute = Integer.valueOf(values[1]); return new Integer[] { hour, minute }; }