List of usage examples for org.apache.commons.lang StringUtils trimToEmpty
public static String trimToEmpty(String str)
Removes control characters (char <= 32) from both ends of this String returning an empty String ("") if the String is empty ("") after the trim or if it is null
.
From source file:mitm.common.util.DomainUtils.java
/** * Returns the upper level domain. //from w w w . j ava2s. com * * Example: sub.example.com returns example.com */ public static String getUpperLevelDomain(String domain) { return StringUtils.substringAfter(StringUtils.trimToEmpty(domain), "."); }
From source file:com.prowidesoftware.swift.model.field.Field22K.java
/** * Serializes the fields' components into the single string value (SWIFT format) *///from w w w . ja v a2 s.c o m @Override public String getValue() { final StringBuilder result = new StringBuilder(); result.append(StringUtils.trimToEmpty(getComponent1())); if (StringUtils.isNotEmpty(getComponent2())) { result.append("/"); result.append(StringUtils.trimToEmpty(getComponent2())); } return result.toString(); }
From source file:com.edgenius.wiki.Shell.java
public static void save() { try {/* w w w . j av a 2s . c om*/ filelock.writeLock().lock(); //write this key to shell.properties String root = DataRoot.getDataRoot(); Properties props = FileUtil.loadProperties(root + Shell.FILE); props.setProperty("shell.key", StringUtils.trimToEmpty(Shell.key)); props.setProperty("shell.enabled", Boolean.toString(Shell.enabled)); //fix to add end slash if (!Shell.rootUrl.endsWith("/")) Shell.rootUrl += "/"; props.setProperty("shell.url", StringUtils.trimToEmpty(Shell.rootUrl)); props.setProperty("connection.timeout", String.valueOf(Shell.timeout)); updateUrl(); FileOutputStream os = FileUtil.getFileOutputStream(root + Shell.FILE); props.store(os, "Shell is update by system."); } catch (Exception e) { log.error("Unable to save shell.properties", e); } finally { filelock.writeLock().unlock(); } }
From source file:com.prowidesoftware.swift.model.field.Field37S.java
/** * Serializes the fields' components into the single string value (SWIFT format) *///from ww w.ja v a2s.c om @Override public String getValue() { final StringBuilder result = new StringBuilder(); result.append(StringUtils.trimToEmpty(getComponent1())); if (org.apache.commons.lang.StringUtils.isNotEmpty(getComponent2())) { result.append("/"); result.append(StringUtils.trimToEmpty(getComponent2())); } return result.toString(); }
From source file:com.prowidesoftware.swift.model.field.Field29A.java
/** * Serializes the fields' components into the single string value (SWIFT format) *//*from ww w.j av a 2 s .c om*/ @Override public String getValue() { final StringBuilder result = new StringBuilder(); result.append(StringUtils.trimToEmpty(getComponent1())); appendInLines(result, 2, 5); return result.toString(); }
From source file:com.prowidesoftware.swift.model.field.Field165.java
/** * Serializes the fields' components into the single string value (SWIFT format) *///from ww w . java 2 s . c o m @Override public String getValue() { final StringBuilder result = new StringBuilder(); result.append("/"); result.append(StringUtils.trimToEmpty(getComponent1())); result.append("/"); result.append(StringUtils.trimToEmpty(getComponent2())); return result.toString(); }
From source file:com.bluexml.xforms.generator.forms.renderable.common.association.selection.multiple.RenderableSMultipleActionsOrder.java
/** * Common function for the UP and DOWN features. Specifies the condition for triggering the * action, the manipulations of the instance document and possibly, updates the index of the * highlighted item.//from ww w . j a v a2s . co m * * @param bindActions * the bind actions * @param moveUp * the move up * @param image * the image * @param rootPath * the root path * * @return the trigger move */ private Element getTriggerMove(ModelElementBindSimple bindActions, boolean moveUp, String image, String altText, String rootPath) { Element trigger = XFormsGenerator.createTriggerWithLabelImage(image, altText); Element action = XFormsGenerator.createElement("action", XFormsGenerator.NAMESPACE_XFORMS); String realActionsNodeset = "instance('minstance')/" + StringUtils.trimToEmpty(rootPath) + bindActions.getNodeset(); String indexStr = "index('" + repeaterId + "')"; String ifCondition = indexStr + (moveUp ? " > 1" : (" < (count(" + realActionsNodeset + ") - 1)")); // #1157 // ifCondition += "not(" + realActionsNodeset + "[" + notMovableIndex + "] is " // + realActionsNodeset + "[index('" + repeaterId + "')])"; // ifCondition += "(" + indexStr + " != " + notMovableIndex + "))"; action.setAttribute("if", ifCondition); action.setAttribute("event", "DOMActivate", XFormsGenerator.NAMESPACE_EVENTS); Element insert = XFormsGenerator.createElement("insert", XFormsGenerator.NAMESPACE_XFORMS); Element delete = XFormsGenerator.createElement("delete", XFormsGenerator.NAMESPACE_XFORMS); if (moveUp) { insert.setAttribute("at", indexStr + " - 1"); insert.setAttribute("position", "before"); delete.setAttribute("at", indexStr + " + 2"); } else { insert.setAttribute("at", indexStr + " + 1"); insert.setAttribute("position", "after"); delete.setAttribute("at", indexStr + " - 2"); } insert.setAttribute("origin", realActionsNodeset + "[" + indexStr + "]"); bindActions.addLinkedElement(insert); bindActions.addLinkedElement(delete); action.addContent(insert); action.addContent(delete); if (!moveUp) { Element setindex = XFormsGenerator.createElement("setindex", XFormsGenerator.NAMESPACE_XFORMS); setindex.setAttribute("repeat", repeaterId); setindex.setAttribute("index", indexStr + " - 1"); action.addContent(setindex); } trigger.addContent(action); return trigger; }
From source file:com.haulmont.cuba.web.security.ConnectionImpl.java
@Nullable protected String getUserRemoteAddress() { VaadinRequest currentRequest = VaadinService.getCurrentRequest(); String userRemoteAddress = null; if (currentRequest != null) { String xForwardedFor = currentRequest.getHeader("X_FORWARDED_FOR"); if (StringUtils.isNotBlank(xForwardedFor)) { String[] strings = xForwardedFor.split(","); String userAddressFromHeader = StringUtils.trimToEmpty(strings[strings.length - 1]); if (StringUtils.isNotEmpty(userAddressFromHeader)) { userRemoteAddress = userAddressFromHeader; } else { userRemoteAddress = currentRequest.getRemoteAddr(); }/* w w w. j a v a2 s. c o m*/ } else { userRemoteAddress = currentRequest.getRemoteAddr(); } } return userRemoteAddress; }
From source file:ch.entwine.weblounge.contentrepository.impl.ContentRepositoryServiceFactory.java
/** * {@inheritDoc}// w w w . j a va 2s . c o m * * @see org.osgi.service.cm.ManagedService#updated(java.util.Dictionary) */ public void updated(Dictionary properties) throws ConfigurationException { String repositoryType = (String) properties.get(OPT_TYPE); if (StringUtils.isBlank(repositoryType)) repositoryType = DEFAULT_REPOSITORY_TYPE; if (!StringUtils.trimToEmpty(this.repositoryType).equals(repositoryType)) { logger.info("Default content repository implementation is {}", repositoryType); this.repositoryType = repositoryType; } }
From source file:com.prowidesoftware.swift.model.field.Field343.java
/** * Serializes the fields' components into the single string value (SWIFT format) *//*from ww w . j av a 2 s.c o m*/ @Override public String getValue() { final StringBuilder result = new StringBuilder(); result.append(StringUtils.trimToEmpty(getComponent1())); result.append(" "); result.append(StringUtils.trimToEmpty(getComponent2())); result.append(" "); result.append(StringUtils.trimToEmpty(getComponent3())); result.append(" "); result.append(StringUtils.trimToEmpty(getComponent4())); return result.toString(); }