List of usage examples for org.apache.commons.lang3 StringUtils trimToNull
public static String trimToNull(final String str)
Removes control characters (char <= 32) from both ends of this String returning null if the String is empty ("") after the trim or if it is null .
From source file:org.mitre.mpf.wfm.data.entities.persistent.StreamingJobStatus.java
public static StreamingJobStatusType parse(String input, StreamingJobStatusType defaultValue) { String trimmed = StringUtils.trimToNull(input); for (StreamingJobStatusType jobStatus : StreamingJobStatusType.values()) { if (StringUtils.equalsIgnoreCase(jobStatus.name(), trimmed)) { return jobStatus; }/*from ww w . j a v a2 s . c om*/ } return defaultValue; }
From source file:org.mitre.mpf.wfm.data.entities.transients.Track.java
/** * Creates a new track instance with the given immutable parameters. * * @param jobId The job with which this track is associated. * @param mediaId The medium with which this track is associated. * @param stageIndex The stage of the pipeline containing the action with which this track is associated. * @param actionIndex The index of the action in the stage of the pipeline which created this track. * @param startOffsetFrameInclusive The zero-based index where the track begins in the medium. Frame number is relevant for image and video files. * @param endOffsetFrameInclusive The zero-based and inclusive stop index where the track ends in the medium. Frame number is relevant for image and video files. * @param startOffsetTimeInclusive The zero-based index where the track begins in the medium. Time is given in milliseconds, and is relevant for video and audio files. * @param endOffsetTimeInclusive The zero-based and inclusive stop index where the track ends in the medium. Time is given in milliseconds, and is relevant for video and audio files. * @param type The type of object associated with this track. This value is trimmed (to null) and converted to uppercase for convenience. *//*from w w w . j a va2 s. co m*/ @JsonCreator public Track(@JsonProperty("jobId") long jobId, @JsonProperty("mediaId") long mediaId, @JsonProperty("stageIndex") int stageIndex, @JsonProperty("actionIndex") int actionIndex, @JsonProperty("startOffsetFrameInclusive") int startOffsetFrameInclusive, @JsonProperty("endOffsetFrameInclusive") int endOffsetFrameInclusive, @JsonProperty("startOffsetTimeInclusive") int startOffsetTimeInclusive, @JsonProperty("endOffsetTimeInclusive") int endOffsetTimeInclusive, @JsonProperty("type") String type) { this.jobId = jobId; this.mediaId = mediaId; this.stageIndex = stageIndex; this.actionIndex = actionIndex; this.startOffsetFrameInclusive = startOffsetFrameInclusive; this.endOffsetFrameInclusive = endOffsetFrameInclusive; this.startOffsetTimeInclusive = startOffsetTimeInclusive; this.endOffsetTimeInclusive = endOffsetTimeInclusive; this.type = StringUtils.upperCase(StringUtils.trimToNull(type)); this.detections = new TreeSet<Detection>(); }
From source file:org.mitre.mpf.wfm.enums.ArtifactExtractionPolicy.java
/** * Retrieves the enum value with the given name. If an enum value with the given name does not exist, the defaultValue * parameter is used.//w w w . ja va2s. com * * @param name The named enum value to retrieve. Leading/trailing whitespace is ignored, and case is not important. */ public static ArtifactExtractionPolicy parse(String name, ArtifactExtractionPolicy defaultValue) { name = StringUtils.trimToNull(name); for (ArtifactExtractionPolicy artifactExtractionPolicy : ArtifactExtractionPolicy.values()) { if (artifactExtractionPolicy.name().equals(name)) { return artifactExtractionPolicy; } } // Failed to find a matching name. Use the default. return defaultValue; }
From source file:org.mitre.mpf.wfm.enums.BatchJobStatusType.java
public static BatchJobStatusType parse(String input, BatchJobStatusType defaultValue) { String trimmed = StringUtils.trimToNull(input); for (BatchJobStatusType jobStatus : BatchJobStatusType.values()) { if (StringUtils.equalsIgnoreCase(jobStatus.name(), trimmed)) { return jobStatus; }//from ww w . j av a2 s. c om } return defaultValue; }
From source file:org.mitre.mpf.wfm.enums.JobStatus.java
public static JobStatus parse(String input, JobStatus defaultValue) { String trimmed = StringUtils.trimToNull(input); for (JobStatus jobStatus : JobStatus.values()) { if (StringUtils.equalsIgnoreCase(jobStatus.name(), trimmed)) { return jobStatus; }/*from ww w . j a v a 2 s . c o m*/ } return defaultValue; }
From source file:org.mitre.mpf.wfm.util.TextUtils.java
/** Null-safe trim operation that returns the trimmed input or {@literal null} if 1) the input is null, or 2) no characters remain after trimming. */ public static String trim(String input) { return StringUtils.trimToNull(input); }
From source file:org.mitre.mpf.wfm.util.TextUtils.java
/** Null-safe trim operation that returns the trimmed, uppercase input or {@literal null} if 1) the input is null, or 2) no characters remain after trimming. */ public static String trimAndUpper(String input) { return StringUtils.upperCase(StringUtils.trimToNull(input)); }
From source file:org.mitre.mpf.wfm.util.TextUtils.java
/** Null-safe trim operation that returns the trimmed, lowercase input or {@literal null} if 1) the input is null, or 2) no characters remain after trimming. */ public static String trimAndLower(String input) { return StringUtils.lowerCase(StringUtils.trimToNull(input)); }
From source file:org.opendaylight.periodic.table.impl.PeriodicTableProviderTest.java
@UseDataProvider("csvColumnSeparators") @Test/*from w w w . j a v a2 s . c om*/ public void testReadPeriodicTableFromCsv(String csvColumnSeparator) throws IOException { //Setup PeriodicTableProvider periodicTableProvider = new PeriodicTableProvider(null); //Given String csvLineForHydrogen = getCsvLineForHydrogen(csvColumnSeparator); InputStream inputStream = IOUtils.toInputStream(csvLineForHydrogen, DEFAULT_CHARSET); //When PeriodicTable periodicTable = periodicTableProvider.readPeriodicTableFrom(inputStream); //Then assertThat(periodicTable.getElements()).hasSize(1).containsExactly(getHydrogenElement()) .extracting("atomicNumber", "symbol", "name", "atomicMass", "color", "electronicConfiguration", "electroNegativity", "atomicRadius", "ionRadius", "vanDerWaalsRadius", "ie1", "ea", "standardState", "bondingType", "meltingPoint", "boilingPoint", "density", "metal", "yearDiscovered") .contains(tuple(Hydrogen.ATOMIC_NUMBER, Hydrogen.SYMBOL, Hydrogen.NAME, Hydrogen.ATOMIC_MASS, Hydrogen.COLOR, Hydrogen.ELECTRONIC_CONFIG, Hydrogen.ELECTRO_NEGATIVITY, Hydrogen.ATOMIC_RADIUS, StringUtils.trimToNull(Hydrogen.ION_RADIUS), Hydrogen.VAN_DER_WAALS_RADIUS, Hydrogen.IE1, Hydrogen.EA, Hydrogen.STANDARD_STATE, Hydrogen.BONDING_TYPE, Hydrogen.MELTING_POINT, Hydrogen.BOILING_POINT, Hydrogen.DENSITY, Hydrogen.METAL, Hydrogen.YEAR_DISCOVERED)); }
From source file:org.opendaylight.periodic.table.impl.PeriodicTableProviderTest.java
private Element getHydrogenElement() { Element element = new Element(); element.setAtomicNumber(Hydrogen.ATOMIC_NUMBER); element.setSymbol(Hydrogen.SYMBOL);/*from w w w .j a va 2 s .c om*/ element.setName(Hydrogen.NAME); element.setAtomicMass(Hydrogen.ATOMIC_MASS); element.setColor(Hydrogen.COLOR); element.setElectronicConfiguration(Hydrogen.ELECTRONIC_CONFIG); element.setElectroNegativity(Hydrogen.ELECTRO_NEGATIVITY); element.setAtomicRadius(Hydrogen.ATOMIC_RADIUS); //Empty String will be mapped to null by the CSV reader element.setIonRadius(StringUtils.trimToNull(Hydrogen.ION_RADIUS)); element.setVanDerWaalsRadius(Hydrogen.VAN_DER_WAALS_RADIUS); element.setIe1(Hydrogen.IE1); element.setEa(Hydrogen.EA); element.setStandardState(Hydrogen.STANDARD_STATE); element.setBondingType(Hydrogen.BONDING_TYPE); element.setMeltingPoint(Hydrogen.MELTING_POINT); element.setBoilingPoint(Hydrogen.BOILING_POINT); element.setDensity(Hydrogen.DENSITY); element.setMetal(Hydrogen.METAL); element.setYearDiscovered(Hydrogen.YEAR_DISCOVERED); return element; }