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.openestate.io.is24_csv.types.DateiSuffix.java
public static DateiSuffix parse(String value) { value = StringUtils.trimToNull(value); if (value == null) return null; for (DateiSuffix t : DateiSuffix.values()) { if (t.value.equalsIgnoreCase(value) || t.name().equalsIgnoreCase(value)) { return t; }//from w w w . ja v a2 s . com } return null; }
From source file:org.openestate.io.is24_csv.types.DateiTyp.java
public static DateiTyp parse(String value) { value = StringUtils.trimToNull(value); if (value == null) return null; for (DateiTyp t : DateiTyp.values()) { if (t.value.equalsIgnoreCase(value)) return t; }//from w w w .j a v a2s. c o m return null; }
From source file:org.openestate.io.is24_csv.types.EnergieausweisTyp.java
public static EnergieausweisTyp parse(String value) { value = StringUtils.trimToNull(value); if (value == null) return null; for (EnergieausweisTyp s : EnergieausweisTyp.values()) { if (String.valueOf(s.value).equalsIgnoreCase(value)) return s; }//w w w. j av a 2 s . c om return KEINE_ANGABE; }
From source file:org.openestate.io.is24_csv.types.Erschliessung.java
public static Erschliessung parse(String value) { value = StringUtils.trimToNull(value); if (value == null) return null; for (Erschliessung s : Erschliessung.values()) { if (String.valueOf(s.value).equalsIgnoreCase(value)) return s; }//from ww w . j ava 2 s . c o m return null; }
From source file:org.openestate.io.is24_csv.types.Geschlecht.java
public static Geschlecht parse(String value) { value = StringUtils.trimToNull(value); if (value == null) return null; for (Geschlecht s : Geschlecht.values()) { if (String.valueOf(s.value).equalsIgnoreCase(value)) return s; }//from w ww . jav a 2 s . c o m return null; }
From source file:org.openestate.io.is24_csv.types.Heizungsart.java
public static Heizungsart parse(String value) { value = StringUtils.trimToNull(value); if (value == null) return null; for (Heizungsart s : Heizungsart.values()) { if (String.valueOf(s.value).equalsIgnoreCase(value)) return s; }//from ww w . j av a2 s .c o m return KEINE_ANGABE; }
From source file:org.openestate.io.is24_csv.types.HeizungsartWohnenAufZeit.java
public static HeizungsartWohnenAufZeit parse(String value) { value = StringUtils.trimToNull(value); if (value == null) return null; for (HeizungsartWohnenAufZeit s : HeizungsartWohnenAufZeit.values()) { if (String.valueOf(s.value).equalsIgnoreCase(value)) return s; }// w w w . j a v a2s .c o m return null; }
From source file:org.openestate.io.is24_csv.types.Immobilienart.java
public static Immobilienart parse(String value) { value = StringUtils.trimToNull(value); if (value == null) return null; for (Immobilienart s : Immobilienart.values()) { if (String.valueOf(s.value).equalsIgnoreCase(value)) return s; }/* w w w. j a va 2s. co m*/ return null; }
From source file:org.openestate.io.is24_csv.types.Importmodus.java
public static Importmodus parse(String value) { value = StringUtils.trimToNull(value); if (value == null) return null; for (Importmodus s : Importmodus.values()) { if (s.value.equalsIgnoreCase(value)) return s; }//w w w . j a v a 2 s .c o m return null; }
From source file:org.rm3l.ddwrt.tiles.status.router.StatusRouterCPUTile.java
/** * Instantiate and return a new Loader for the given ID. * * @param id The ID whose loader is to be created. * @param args Any arguments supplied by the caller. * @return Return a new Loader instance that is ready to start loading. */// www. java 2 s. co m @Override protected Loader<NVRAMInfo> getLoader(final int id, final Bundle args) { return new AsyncTaskLoader<NVRAMInfo>(this.mParentFragmentActivity) { @Nullable @Override public NVRAMInfo loadInBackground() { try { Log.d(LOG_TAG, "Init background loader for " + StatusRouterCPUTile.class + ": routerInfo=" + mRouter + " / this.mAutoRefreshToggle= " + mAutoRefreshToggle + " / nbRunsLoader=" + nbRunsLoader); if (nbRunsLoader > 0 && !mAutoRefreshToggle) { //Skip run Log.d(LOG_TAG, "Skip loader run"); return new NVRAMInfo().setException(new DDWRTTileAutoRefreshNotAllowedException()); } nbRunsLoader++; @NotNull final NVRAMInfo nvramInfo = new NVRAMInfo(); NVRAMInfo nvramInfoTmp = null; try { nvramInfoTmp = SSHUtils.getNVRamInfoFromRouter(mRouter, mGlobalPreferences, NVRAMInfo.CPU_CLOCK_FREQ); } finally { if (nvramInfoTmp != null) { nvramInfo.putAll(nvramInfoTmp); } List<String> strings = Splitter.on(",").omitEmptyStrings().trimResults() .splitToList(nullToEmpty(nvramInfo.getProperty(NVRAMInfo.CPU_CLOCK_FREQ))); Log.d(LOG_TAG, "strings for cpu clock: " + strings); if (strings != null && strings.size() > 0) { nvramInfo.setProperty(NVRAMInfo.CPU_CLOCK_FREQ, strings.get(0)); } @Nullable final String[] otherCmds = SSHUtils.getManualProperty(mRouter, mGlobalPreferences, "uptime | awk -F'average:' '{ print $2}'", GREP_MODEL_NAME_PROC_CPUINFO + "| uniq", GREP_MODEL_NAME_PROC_CPUINFO + "| wc -l"); if (otherCmds != null) { if (otherCmds.length >= 1) { //Load Avg nvramInfo.setProperty(NVRAMInfo.LOAD_AVERAGE, StringUtils.trimToNull(otherCmds[0])); //Removed: computation done on the router: // strings = Splitter.on("load average").omitEmptyStrings() // .trimResults().splitToList(otherCmds[0]); // Log.d(LOG_TAG, "strings for load avg: " + strings); // if (strings != null && strings.size() >= 2) { // final String loadAvg = strings.get(1); // if (loadAvg != null) { // nvramInfo.setProperty(NVRAMInfo.LOAD_AVERAGE, // loadAvg.replace(":", "").trim()); // } // } } if (otherCmds.length >= 2) { //Model final String modelNameLine = otherCmds[1]; if (modelNameLine != null) { nvramInfo.setProperty(NVRAMInfo.CPU_MODEL, modelNameLine.replace(":", "").replace("model name", "").trim()); } } if (otherCmds.length >= 3) { //Nb Cores nvramInfo.setProperty(NVRAMInfo.CPU_CORES_COUNT, otherCmds[2]); } } } if (nvramInfo.isEmpty()) { throw new DDWRTNoDataException("No Data!"); } return nvramInfo; } catch (@NotNull final Exception e) { e.printStackTrace(); return new NVRAMInfo().setException(e); } } }; }