List of usage examples for org.apache.commons.lang3 StringUtils stripToEmpty
public static String stripToEmpty(final String str)
Strips whitespace from the start and end of a String returning an empty String if null input.
This is similar to #trimToEmpty(String) but removes whitespace.
From source file:com.inkubator.hrm.web.approval.ApprovalDefinitionPopupFormController.java
public List<HrmUser> doAutoCompleteUser(String param) { List<HrmUser> users = new ArrayList<HrmUser>(); try {/*from w ww .j a v a 2 s . c o m*/ users = hrmUserService.getAllDataByNameOrNik(StringUtils.stripToEmpty(param)); } catch (Exception e) { LOGGER.error("Error", e); } return users; }
From source file:com.inkubator.hrm.web.approval.ApprovalDefinitionPopupFormController.java
public List<Jabatan> doAutoCompleteJabatan(String param) { List<Jabatan> jabatans = new ArrayList<Jabatan>(); try {// ww w . j a v a2 s . com jabatans = jabatanService.getAllDataByCodeOrName(StringUtils.stripToEmpty(param)); } catch (Exception e) { LOGGER.error("Error", e); } return jabatans; }
From source file:com.opendesign.service.ProjectService.java
/** * <pre>/* w w w . ja va 2 s. c om*/ * ? / ?? ? * ?? . * </pre> * * @param workVO * @param request * @return */ public boolean selectIsProjectWorkAuthUser(String workSeq, HttpServletRequest request) { boolean result = false; UserVO userVO = CmnUtil.getLoginUser(request); ProjectWorkVO workVO = dao.selectProjectWork(workSeq); if (userVO != null && workVO != null) { String memberSeq = StringUtils.stripToEmpty(workVO.getMemberSeq()); // ?? if (memberSeq.equals(userVO.getSeq())) { result = true; } } return result; }
From source file:gobblin.source.extractor.extract.QueryBasedSource.java
/** * Initialize the logger.// www . j a v a 2 s . c om * * @param state * Source state */ private static void initLogger(SourceState state) { StringBuilder sb = new StringBuilder(); sb.append("["); sb.append(StringUtils.stripToEmpty(state.getProp(ConfigurationKeys.SOURCE_QUERYBASED_SCHEMA))); sb.append("_"); sb.append(StringUtils.stripToEmpty(state.getProp(ConfigurationKeys.SOURCE_ENTITY))); sb.append("]"); MDC.put("sourceInfo", sb.toString()); }
From source file:info.novatec.testit.livingdoc.server.LivingDocPersistenceService.java
/** * SECURED//w w w . j a v a2 s . c om */ public List<SpecificationLocation> getListOfSpecificationLocations(String repositoryUID, String systemUnderTestName) throws LivingDocServerException { try { sessionService.startSession(); Repository repository = loadRepository(repositoryUID); List<SpecificationLocation> locations = new ArrayList<>(); SystemUnderTest systemUnderTest = systemUnderTestDao.getByName(repository.getProject().getName(), systemUnderTestName); if (systemUnderTest == null) { log.warn("System under test not found : " + systemUnderTestName); throw new LivingDocServerException(SUT_NOT_FOUND, "System under test not found : " + systemUnderTestName); } List<Specification> specifications = documentDao.getSpecifications(systemUnderTest, repository); for (Specification specification : specifications) { SpecificationLocation specificationLocation = new SpecificationLocation(); specificationLocation .setRepositoryTypeClassName(specification.getRepository().getType().getClassName()); specificationLocation.setBaseTestUrl(specification.getRepository().getBaseTestUrl()); specificationLocation .setUsername(StringUtils.stripToEmpty(specification.getRepository().getUsername())); specificationLocation .setPassword(StringUtils.stripToEmpty(specification.getRepository().getPassword())); specificationLocation.setSpecificationName(specification.getName()); locations.add(specificationLocation); } log.debug("Retrieved specification list: " + repository.getName()); return locations; } catch (Exception ex) { throw handleException(SPECIFICATIONS_NOT_FOUND, ex); } finally { sessionService.closeSession(); } }
From source file:info.novatec.testit.livingdoc.server.LivingDocServerServiceImpl.java
/** * SECURED//from www .ja v a 2 s.co m */ @Override public Vector<Object> getListOfSpecificationLocations(String repositoryUID, String systemUnderTestName) throws LivingDocServerException { try { sessionService.startSession(); Repository repository = loadRepository(repositoryUID); Vector<Object> locations = new Vector<Object>(); SystemUnderTest systemUnderTest = sutDao.getByName(repository.getProject().getName(), systemUnderTestName); List<Specification> specifications = documentDao.getSpecifications(systemUnderTest, repository); for (Specification specification : specifications) { Vector<String> specsDefinition = new Vector<String>(); specsDefinition.add(specification.getRepository().getType().getClassName()); specsDefinition.add(specification.getRepository().getBaseTestUrl()); specsDefinition.add(StringUtils.stripToEmpty(specification.getRepository().getUsername())); specsDefinition.add(StringUtils.stripToEmpty(specification.getRepository().getPassword())); specsDefinition.add(specification.getName()); locations.add(specsDefinition); } log.debug("Retrieved specification list: " + repository.getName()); return locations; } catch (Exception ex) { throw handleException(SPECIFICATIONS_NOT_FOUND, ex); } finally { sessionService.closeSession(); } }
From source file:net.sourceforge.pmd.docs.RuleDocGenerator.java
/** * Shortens and escapes (for markdown) some special characters. Otherwise the shortened text * could contain some unfinished sequences. * @param rule/*from ww w . j a va2 s . c om*/ * @return */ private static String getShortRuleDescription(Rule rule) { return StringEscapeUtils .escapeHtml4( StringUtils.abbreviate( StringUtils.stripToEmpty(rule.getDescription().replaceAll("\n|\r", "") .replaceAll("\\|", "\\\\|").replaceAll("`", "'").replaceAll("\\*", "")), 100)); }
From source file:net.sourceforge.pmd.docs.RuleDocGenerator.java
private static String getRuleSetDescriptionSingleLine(RuleSet ruleset) { String description = ruleset.getDescription(); description = StringEscapeUtils.escapeHtml4(description); description = description.replaceAll("\\n|\\r", " "); description = StringUtils.stripToEmpty(description); return description; }
From source file:net.sourceforge.pmd.docs.RuleDocGenerator.java
/** * Generates for each ruleset a page. The page contains the details for each rule. * * @param rulesets all rulesets/*from w w w . j a v a2 s . c o m*/ * @throws IOException */ private void generateRuleSetIndex(Map<Language, List<RuleSet>> rulesets) throws IOException { for (Map.Entry<Language, List<RuleSet>> entry : rulesets.entrySet()) { Language language = entry.getKey(); String languageTersename = language.getTerseName(); String languageName = language.getName(); for (RuleSet ruleset : entry.getValue()) { String rulesetFilename = RuleSetUtils.getRuleSetFilename(ruleset); String filename = RULESET_INDEX_FILENAME_PATTERN.replace("${language.tersename}", languageTersename) .replace("${ruleset.name}", rulesetFilename); Path path = getAbsoluteOutputPath(filename); String permalink = RULESET_INDEX_PERMALINK_PATTERN .replace("${language.tersename}", languageTersename) .replace("${ruleset.name}", rulesetFilename); String ruleSetSourceFilepath = "../" + getRuleSetSourceFilepath(ruleset); List<String> lines = new LinkedList<>(); lines.add("---"); lines.add("title: " + ruleset.getName()); lines.add("summary: " + getRuleSetDescriptionSingleLine(ruleset)); lines.add("permalink: " + permalink); lines.add("folder: pmd/rules/" + languageTersename); lines.add("sidebaractiveurl: /" + LANGUAGE_INDEX_PERMALINK_PATTERN.replace("${language.tersename}", languageTersename)); lines.add("editmepath: " + ruleSetSourceFilepath); lines.add("keywords: " + getRuleSetKeywords(ruleset)); lines.add("language: " + languageName); lines.add("---"); lines.add(GENERATED_WARNING.replace("${source}", ruleSetSourceFilepath)); for (Rule rule : getSortedRules(ruleset)) { lines.add("## " + rule.getName()); lines.add(""); if (rule instanceof RuleReference) { RuleReference ref = (RuleReference) rule; if (ruleset.getFileName().equals(ref.getRuleSetReference().getRuleSetFileName())) { // rule renamed within same ruleset lines.add(DEPRECATION_LABEL); lines.add(""); lines.add("This rule has been renamed. Use instead: [" + ref.getRule().getName() + "](" + "#" + ref.getRule().getName().toLowerCase(Locale.ROOT) + ")"); lines.add(""); } else { // rule moved to another ruleset String otherLink = RULESET_INDEX_PERMALINK_PATTERN .replace("${language.tersename}", languageTersename) .replace("${ruleset.name}", RuleSetUtils .getRuleSetFilename(ref.getRuleSetReference().getRuleSetFileName())); lines.add(DEPRECATION_LABEL); lines.add(""); lines.add("The rule has been moved to another ruleset. Use instead: [" + ref.getRule().getName() + "](" + otherLink + "#" + ref.getRule().getName().toLowerCase(Locale.ROOT) + ")"); lines.add(""); } } if (rule.isDeprecated()) { lines.add(DEPRECATION_LABEL); lines.add(""); } if (rule.getSince() != null) { lines.add("**Since:** PMD " + rule.getSince()); lines.add(""); } lines.add( "**Priority:** " + rule.getPriority() + " (" + rule.getPriority().getPriority() + ")"); lines.add(""); if (rule.getMinimumLanguageVersion() != null) { lines.add("**Minimum Language Version:** " + rule.getLanguage().getName() + " " + rule.getMinimumLanguageVersion().getVersion()); lines.add(""); } lines.addAll(EscapeUtils.escapeLines(toLines(stripIndentation(rule.getDescription())))); lines.add(""); if (rule instanceof XPathRule || rule instanceof RuleReference && ((RuleReference) rule).getRule() instanceof XPathRule) { lines.add("**This rule is defined by the following XPath expression:**"); lines.add("``` xpath"); lines.addAll( toLines(StringUtils.stripToEmpty(rule.getProperty(XPathRule.XPATH_DESCRIPTOR)))); lines.add("```"); } else { lines.add("**This rule is defined by the following Java class:** " + "[" + rule.getRuleClass() + "](" + GITHUB_SOURCE_LINK + getRuleClassSourceFilepath(rule.getRuleClass()) + ")"); } lines.add(""); if (!rule.getExamples().isEmpty()) { lines.add("**Example(s):**"); lines.add(""); for (String example : rule.getExamples()) { lines.add("``` " + mapLanguageForHighlighting(languageTersename)); lines.addAll(toLines(StringUtils.stripToEmpty(example))); lines.add("```"); lines.add(""); } } List<PropertyDescriptor<?>> properties = new ArrayList<>(rule.getPropertyDescriptors()); // filter out standard properties properties.remove(Rule.VIOLATION_SUPPRESS_REGEX_DESCRIPTOR); properties.remove(Rule.VIOLATION_SUPPRESS_XPATH_DESCRIPTOR); properties.remove(XPathRule.XPATH_DESCRIPTOR); properties.remove(XPathRule.VERSION_DESCRIPTOR); if (!properties.isEmpty()) { lines.add("**This rule has the following properties:**"); lines.add(""); lines.add("|Name|Default Value|Description|Multivalued|"); lines.add("|----|-------------|-----------|-----------|"); for (PropertyDescriptor<?> propertyDescriptor : properties) { String description = propertyDescriptor.description(); final boolean isDeprecated = isDeprecated(propertyDescriptor); if (isDeprecated) { description = description.substring(DEPRECATED_RULE_PROPERTY_MARKER.length()); } String defaultValue = determineDefaultValueAsString(propertyDescriptor, rule, true); String multiValued = "no"; if (propertyDescriptor.isMultiValue()) { MultiValuePropertyDescriptor<?> multiValuePropertyDescriptor = (MultiValuePropertyDescriptor<?>) propertyDescriptor; multiValued = "yes. Delimiter is '" + multiValuePropertyDescriptor.multiValueDelimiter() + "'."; } lines.add("|" + EscapeUtils.escapeMarkdown( StringEscapeUtils.escapeHtml4(propertyDescriptor.name())) + "|" + EscapeUtils.escapeMarkdown(StringEscapeUtils.escapeHtml4(defaultValue)) + "|" + EscapeUtils.escapeMarkdown((isDeprecated ? DEPRECATION_LABEL_SMALL : "") + StringEscapeUtils.escapeHtml4(description)) + "|" + EscapeUtils.escapeMarkdown(StringEscapeUtils.escapeHtml4(multiValued)) + "|"); } lines.add(""); } if (properties.isEmpty()) { lines.add("**Use this rule by referencing it:**"); } else { lines.add("**Use this rule with the default properties by just referencing it:**"); } lines.add("``` xml"); lines.add("<rule ref=\"category/" + languageTersename + "/" + rulesetFilename + ".xml/" + rule.getName() + "\" />"); lines.add("```"); lines.add(""); if (properties.stream().anyMatch(it -> !isDeprecated(it))) { lines.add("**Use this rule and customize it:**"); lines.add("``` xml"); lines.add("<rule ref=\"category/" + languageTersename + "/" + rulesetFilename + ".xml/" + rule.getName() + "\">"); lines.add(" <properties>"); for (PropertyDescriptor<?> propertyDescriptor : properties) { if (!isDeprecated(propertyDescriptor)) { String defaultValue = determineDefaultValueAsString(propertyDescriptor, rule, false); lines.add(" <property name=\"" + propertyDescriptor.name() + "\" value=\"" + defaultValue + "\" />"); } } lines.add(" </properties>"); lines.add("</rule>"); lines.add("```"); lines.add(""); } } writer.write(path, lines); System.out.println("Generated " + path); } } }
From source file:nl.knaw.huygens.timbuctoo.model.neww.WWPerson.java
@Override @VirtualProperty(propertyName = "name") public String getIdentificationName() { String name = defaultName().getShortName(); return StringUtils.stripToEmpty(name).isEmpty() ? "[TEMP] " + tempName : name; }