List of usage examples for org.apache.commons.lang3 StringUtils strip
public static String strip(final String str)
Strips whitespace from the start and end of a String.
This is similar to #trim(String) but removes whitespace.
From source file:org.totschnig.myexpenses.model.Category.java
/** * we currently do not need a full representation of a category as an object * when we create an instance with an id, we only want to alter its label * and are not interested in its parentId * when we create an instance with a parentId, it is a new instance * @param id//from w w w. jav a2s . c o m * @param label * @param parentId */ public Category(Long id, String label, Long parentId) { this.setId(id); this.label = StringUtils.strip(label); this.parentId = parentId; }
From source file:org.totschnig.myexpenses.model.Category.java
/** * Looks for a cat with a label under a given parent * @param label// w w w . jav a 2 s. com * @param parentId * @return id or -1 if not found */ public static long find(String label, Long parentId) { label = StringUtils.strip(label); String selection; String[] selectionArgs; if (parentId == null) { selection = KEY_PARENTID + " is null"; selectionArgs = new String[] { label }; } else { selection = KEY_PARENTID + " = ?"; selectionArgs = new String[] { String.valueOf(parentId), label }; } selection += " and " + KEY_LABEL + " = ?"; Cursor mCursor = cr().query(CONTENT_URI, new String[] { KEY_ROWID }, selection, selectionArgs, null); if (mCursor.getCount() == 0) { mCursor.close(); return -1; } else { mCursor.moveToFirst(); long result = mCursor.getLong(0); mCursor.close(); return result; } }
From source file:org.versly.rest.wsdoc.AnnotationProcessor.java
private String fixCommentWhitespace(String desc) { return desc == null ? null : StringUtils.strip(desc.replace("\n", " ").replace("\r", " ").replaceAll(" {2,}", " ")); }
From source file:org.wise.portal.domain.project.impl.Projectcode.java
/** * Constructor * * @param projectcode */ public Projectcode(String projectcode) { this.projectcode = StringUtils.strip(projectcode); }
From source file:org.wise.portal.domain.project.impl.Projectcode.java
/** * Constructor/*w w w . jav a 2 s . c o m*/ * * @param runcode * @param periodname */ public Projectcode(String runcode, String periodname) { this.projectcode = StringUtils.strip(runcode + SEPARATOR + periodname); }
From source file:org.wise.portal.domain.project.impl.Projectcode.java
/** * @param projectcode the projectcode to set */ public void setProjectcode(String projectcode) { this.projectcode = StringUtils.strip(projectcode); }
From source file:org.xlrnet.metadict.core.util.FormatUtils.java
@NotNull private static String formatLanguage(@NotNull Language language) { String displayName = StringUtils.strip(language.getDisplayName()); String dialectDisplayName = StringUtils.stripToEmpty(language.getDialectDisplayName()); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append(WordUtils.capitalize(displayName)); if (StringUtils.isNotEmpty(dialectDisplayName)) stringBuilder.append(" (").append(WordUtils.capitalize(dialectDisplayName)).append(")"); return stringBuilder.toString(); }
From source file:org.xlrnet.metadict.engines.heinzelnisse.HeinzelnisseEngine.java
/** * Extracts information from the "other"-fields of the response. This field may contain information about plural * forms or irregular verb forms./*from ww w . ja va 2 s. c o m*/ * <p> * Examples: * <ul> * <li>Plural: Mtter</li> * <li>fl.: mdre</li> * <li>syn.: tschs</li> * <li>Dialekt (sddeutsch/sterreichisch)</li> * <li>presens: kommer, preteritum: kom, partisipp perfekt: kommet</li> * <li>bestemt form: lille, intetkjnn: lite, flertall: sm</li> * <li>komparativ: frre, superlativ: frrest</li> * <li>Komparativ: weniger, Superlativ: am wenigsten</li> * </ul> * * @param otherInformation * The source string * @param builder * The target builder to write into. */ protected void extractOtherInformation(@NotNull String otherInformation, @NotNull DictionaryObjectBuilder builder) { // Try to extract plural forms if (StringUtils.startsWith(otherInformation, "Plural:") || StringUtils.startsWith(otherInformation, "fl.:")) { String pluralForm = StringUtils.substringAfter(otherInformation, ":"); builder.setAdditionalForm(GrammaticalNumber.PLURAL, StringUtils.strip(pluralForm)); } // Try to extract verb forms else if (StringUtils.startsWith(otherInformation, "presens")) { extractVerbForms(otherInformation, builder); } // Try to extract adjective comparisons else if (StringUtils.startsWithIgnoreCase(otherInformation, "komparativ")) { extractComparisonForms(otherInformation, builder); } // Try to extract adjective forms else if (StringUtils.startsWithIgnoreCase(otherInformation, "bestemt form")) { extractAdjectiveForms(otherInformation, builder); } // Write to description string otherwise... else if (StringUtils.isNotEmpty(otherInformation)) { builder.setDescription(StringUtils.strip(otherInformation)); } }
From source file:org.xlrnet.metadict.engines.heinzelnisse.HeinzelnisseEngine.java
private void extractAdjectiveForms(@NotNull String otherInformation, @NotNull DictionaryObjectBuilder builder) { for (String s : StringUtils.split(otherInformation, ',')) { String flectedForm = StringUtils.strip(StringUtils.substringAfter(s, ":")); if (StringUtils.containsIgnoreCase(s, "bestemt form:")) { builder.setAdditionalForm(GrammaticalCase.DEFINITE_FORM, flectedForm); }// ww w . j a va 2 s . c o m if (StringUtils.containsIgnoreCase(s, "intetkjnn:")) { builder.setAdditionalForm(GrammaticalGender.NEUTER, flectedForm); } if (StringUtils.containsIgnoreCase(s, "flertall:")) { builder.setAdditionalForm(GrammaticalNumber.PLURAL, flectedForm); } } }
From source file:org.xlrnet.metadict.engines.heinzelnisse.HeinzelnisseEngine.java
private void extractComparisonForms(@NotNull String otherInformation, @NotNull DictionaryObjectBuilder builder) { for (String s : StringUtils.split(otherInformation, ',')) { String flectedForm = StringUtils.strip(StringUtils.substringAfter(s, ":")); if (StringUtils.containsIgnoreCase(s, "komparativ:")) { builder.setAdditionalForm(GrammaticalComparison.COMPARATIVE, flectedForm); }// www . ja v a 2s . com if (StringUtils.containsIgnoreCase(s, "superlativ:")) { builder.setAdditionalForm(GrammaticalComparison.SUPERLATIVE, flectedForm); } } }