List of usage examples for org.apache.commons.lang3 StringUtils trimToEmpty
public static String trimToEmpty(final 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:com.th.jbp.web.vm.TrailerHeadVM.java
@Command public void save() { LOGGER.info("excute method save"); LOGGER.info("MODE : " + getMode()); String sb = StringUtils.trimToEmpty(validate()); if (StringUtils.isNotEmpty(sb)) { Clients.clearBusy();// w w w . j av a 2 s . c om showValidate(sb); return; } final boolean isModeAdd = MODE.ADD.name().equals(getMode()); String message = getMessage( MODE.ADD.name().equals(getMode()) ? MESSAGE_CONFIRM_SAVE : MESSAGE_CONFIRM_UPDATE); final String operation = isModeAdd ? getMessage("save") : getMessage("update"); execute(new MethodOperation() { @Override public void execute() { Clients.showBusy("Waiting for server..."); TrailerHeadM model = getTrailerHeadM(); Date date = new Date(); if (isModeAdd) { ClassifierValueM status = classifierValueRepository.findOne(Status.ACTIVE.getId()); model.setStatus(status); } if (isModeAdd) { model.setCreateBy(SecurityUtils.getWebUserDetails()); model.setCreateDate(new Timestamp(date.getTime())); } else { model.setUpdateBy(SecurityUtils.getWebUserDetails()); model.setUpdateDate(new Timestamp(date.getTime())); } try { // educations = removeRowNullEducation(); // model.setEducations(educations); // // workExps = removeRowNullWorkExp(); // model.setWorkExps(workExps); // // model.setDriverForm(driverForm); if (isModeAdd) { trailerHeadService.save(model); } else { trailerHeadService.update(model); } showInformation(getMessage("message.operation.success", operation)); setTrailerHeadM(new TrailerHeadM()); setMode(MODE.SEARCH.name()); setActivePage(0); loadItems(); } catch (Exception e) { LOGGER.error(e.toString(), e); showError("Error", getMessage("message.error.operation.fail", operation, e.getMessage())); } finally { Clients.clearBusy(); } BindUtils.postGlobalCommand(null, null, "refreshView", null); } }, LOGGER, message); }
From source file:com.omertron.themoviedbapi.model.Person.java
public void setBiography(String biography) { this.biography = StringUtils.trimToEmpty(biography); }
From source file:com.widowcrawler.terminator.parse.Parser.java
private String userAgentIdentifier() { //System.out.println("userAgentIdentifier()"); int start = dataPtr; while (!isEndOfFile() && !isCommentStart() && !isEndline()) { next();/*from www .ja v a2 s . c o m*/ } return StringUtils.trimToEmpty(data.substring(start, dataPtr)); }
From source file:com.threewks.thundr.googleapis.cloudstorage.GoogleCloudStorageServiceImpl.java
static String findNamedValue(Node node, String name) { Node child = findNamedChild(node, name); return child == null ? null : StringUtils.trimToEmpty(child.getTextContent()); }
From source file:com.omertron.themoviedbapi.model.Person.java
public void setBirthday(String birthday) { this.birthday = StringUtils.trimToEmpty(birthday); }
From source file:com.intuit.karate.Script.java
public static ScriptValue eval(String text, ScriptContext context) { text = StringUtils.trimToEmpty(text); if (text.isEmpty()) { logger.trace("script is empty"); return ScriptValue.NULL; }/*from www . jav a2 s. com*/ if (isCallSyntax(text)) { // special case in form "call foo arg" text = text.substring(5); int pos = text.indexOf(' '); // TODO handle read('file with spaces in the name') String arg; if (pos != -1) { arg = text.substring(pos); text = text.substring(0, pos); } else { arg = null; } return call(text, arg, context); } else if (isGetSyntax(text)) { // special case in form // get json[*].path // get /xml/path // get xpath-function(expression) text = text.substring(4); String left; String right; if (isVariableAndSpaceAndPath(text)) { int pos = text.indexOf(' '); right = text.substring(pos + 1); left = text.substring(0, pos); } else { Pair<String, String> pair = parseVariableAndPath(text); left = pair.getLeft(); right = pair.getRight(); } if (isXmlPath(right) || isXmlPathFunction(right)) { return evalXmlPathOnVarByName(left, right, context); } else { return evalJsonPathOnVarByName(left, right, context); } } else if (isJsonPath(text)) { return evalJsonPathOnVarByName(ScriptValueMap.VAR_RESPONSE, text, context); } else if (isJson(text)) { DocumentContext doc = JsonUtils.toJsonDoc(text); evalJsonEmbeddedExpressions(doc, context); return new ScriptValue(doc); } else if (isBson(text)) { text = text.substring(1); DocumentContext doc = JsonUtils.toJsonDoc(text); evalJsonEmbeddedExpressions(doc, context); JSONObject json = JSONValue.parse(doc.jsonString(), JSONObject.class); BsonDocument bson = BsonUtils.jsonToBson(json); return new ScriptValue(bson); } else if (isXml(text)) { Document doc = XmlUtils.toXmlDoc(text); evalXmlEmbeddedExpressions(doc, context); return new ScriptValue(doc); } else if (isXmlPath(text)) { return evalXmlPathOnVarByName(ScriptValueMap.VAR_RESPONSE, text, context); } else if (isStringExpression(text)) { // has to be above variableAndXml/JsonPath because of / in URL-s etc return evalInNashorn(text, context); } else if (isVariableAndJsonPath(text)) { Pair<String, String> pair = parseVariableAndPath(text); return evalJsonPathOnVarByName(pair.getLeft(), pair.getRight(), context); } else if (isVariableAndXmlPath(text)) { Pair<String, String> pair = parseVariableAndPath(text); return evalXmlPathOnVarByName(pair.getLeft(), pair.getRight(), context); } else { // js expressions e.g. foo, foo(bar), foo.bar, foo + bar, 5, true // including function declarations e.g. function() { } return evalInNashorn(text, context); } }
From source file:ke.co.tawi.babblesms.server.servlet.upload.UploadUtil.java
protected void saveContacts(File contactFile, Account account, ContactDAO contactDAO, PhoneDAO phoneDAO, List<String> groupUuids, ContactGroupDAO contactGroupDAO) { LineIterator lineIterator = null;/* ww w . ja va 2 s.com*/ Contact contact; Phone phone; List<Group> groupList = new LinkedList<>(); Group grp; for (String uuid : groupUuids) { grp = new Group(); grp.setUuid(uuid); groupList.add(grp); } try { lineIterator = FileUtils.lineIterator(contactFile, "UTF-8"); String line; String[] rowTokens, phoneTokens, networkTokens; while (lineIterator.hasNext()) { line = lineIterator.nextLine(); rowTokens = StringUtils.split(line, ','); // Extract the Contact and save contact = new Contact(); contact.setAccountUuid(account.getUuid()); contact.setName(rowTokens[0]); contact.setStatusUuid(Status.ACTIVE); contactDAO.putContact(contact); // Extract the phones and save phoneTokens = StringUtils.split(rowTokens[1], ';'); networkTokens = StringUtils.split(rowTokens[2], ';'); String network; for (int j = 0; j < phoneTokens.length; j++) { phone = new Phone(); phone.setPhonenumber(StringUtils.trimToEmpty(phoneTokens[j])); phone.setPhonenumber(StringUtils.remove(phone.getPhonenumber(), ' ')); phone.setContactUuid(contact.getUuid()); phone.setStatusuuid(Status.ACTIVE); network = StringUtils.lowerCase(StringUtils.trimToEmpty(networkTokens[j])); phone.setNetworkuuid(networkUuidArray[networkList.indexOf(network)]); phoneDAO.putPhone(phone); } // Associate the Contact to the Groups for (Group group : groupList) { contactGroupDAO.putContact(contact, group); } } // end 'while (lineIterator.hasNext())' } catch (IOException e) { logger.error("IOException when storing: " + contactFile); logger.error(e); } finally { if (lineIterator != null) { lineIterator.close(); } } }
From source file:com.omertron.slackbot.utils.GitRepositoryState.java
/** * Get the currently running YAMJ version * * @return/* ww w. j a v a 2 s . c o m*/ */ public static String getVersion() { // Populated by the manifest file return StringUtils.trimToEmpty(SlackBot.class.getPackage().getSpecificationVersion()); }
From source file:com.omertron.themoviedbapi.model.Person.java
public void setBirthplace(String birthplace) { this.birthplace = StringUtils.trimToEmpty(birthplace); }
From source file:kenh.expl.Environment.java
/** * Loop all function packages, find the first class match the function name. * @param funcName The function name.//w ww .j ava 2 s . c om * @return */ public Function getFunction(String funcName) { if (StringUtils.isBlank(funcName)) return null; funcName = StringUtils.trimToEmpty(funcName); Iterator<String> iterator = functionPackages.values().iterator(); while (iterator.hasNext()) { String funcPackage = iterator.next(); Function function = getFunction_(funcPackage, funcName); if (function != null) return function; } return null; }