List of usage examples for org.apache.commons.lang StringUtils defaultString
public static String defaultString(String str)
Returns either the passed in String, or if the String is null
, an empty String ("").
From source file:org.axiom_tools.context.SpringContext.java
/** * Returns a specific named context.// ww w . j a v a 2 s .co m * * @param contextName a context (file) name * @return a specific named context */ public static SpringContext named(String contextName) { if (StringUtils.defaultString(contextName).isEmpty()) { return null; // no such context } if (ContextMap.containsKey(contextName)) { // already cached context return ContextMap.get(contextName); } // cache the named context SpringContext result = new SpringContext(); result.contextName = contextName; ContextMap.put(contextName, result); return result; }
From source file:org.axiom_tools.context.SpringContext.java
/** * Returns a specific named bean./*from ww w. java 2 s. c o m*/ * * @param <BeanType> a bean type * @param beanType a kind of bean * @param beanName a bean name * @return a bean, or null */ @SuppressWarnings("unchecked") public <BeanType> BeanType getBean(Class<BeanType> beanType, String beanName) { if (beanType == null) { return null; // unknown class } if (StringUtils.defaultString(beanName).isEmpty()) { beanName = getStandardBeanName(beanType); } // try locating with bean name if (getContext().containsBean(beanName)) { return (BeanType) getContext().getBean(beanName); } // report missing bean String className = beanType.getName(); reportMissing(className, beanName); // try locating with simple class name String simpleName = beanType.getSimpleName(); if (className.contains(Dollar)) { if (getContext().containsBean(simpleName)) { return (BeanType) getContext().getBean(simpleName); } } // report total failure to locate bean reportMissing(className, simpleName); return null; }
From source file:org.axiom_tools.crypto.Symmetric.java
@SuppressWarnings("unused") private static String checkLength(String value, String failMessage) { String result = StringUtils.defaultString(value).trim(); if (result.length() != VectorSize) { throw new IllegalArgumentException(failMessage); }//w ww . java 2 s . c o m try { // test hex conversion byte[] bytes = Hex.decodeHex(result.toCharArray()); int size = bytes.length; } catch (Exception e) { throw new IllegalArgumentException(failMessage); } return result; }
From source file:org.axiom_tools.storage.Surrogated.java
/** * Normalizes text with full capitalization, without punctuation, and without extraneous whitespace. * * @param text some text/* ww w .j a va2 s . co m*/ * @return normalized text */ public static String normalizeWords(String text) { return WordUtils.capitalizeFully(StringUtils.defaultString(text).trim()) .replaceAll(PunctuationFilter, Empty).replaceAll(MultipleSpaceFilter, Blank); }
From source file:org.axiom_tools.storage.Surrogated.java
/** * Normalizes code as upper case.//from w w w .ja v a 2 s . co m * * @param codeText code text * @return a normalized code */ public static String normalizeCode(String codeText) { return StringUtils.defaultString(codeText).trim().toUpperCase(); }
From source file:org.bdval.DAVMode.java
protected void setupClassifier(final JSAPResult result, final DAVOptions options) { options.classiferClass = result.getClass("classifier"); final String[] parameters = result.getStringArray("classifier-parameters"); // combine multiple occurences of --classifier-parameters on the command line into one parameter string, // separating occurences by a comma. final StringBuffer parameterCollected = new StringBuffer(); int i = 0;//w w w .ja v a 2s.com for (final String params : parameters) { parameterCollected.append(params); if (i != parameters.length - 1) { parameterCollected.append(","); } i++; } LOG.info("collected classifier parameters: " + parameterCollected.toString()); final String classifierParametersResult = StringUtils.defaultString(parameterCollected.toString()); options.classifierParameters = classifierParametersResult.split("[,]"); options.scaleFeatures = result.getBoolean("scale-features"); options.percentileScaling = result.getBoolean("percentile-scaling"); if (result.contains("scaler-class-name")) { options.scalerClassName = result.getString("scaler-class-name"); options.percentileScaling = false; } else { options.scalerClassName = null; } options.normalizeFeatures = result.getBoolean("normalize-features"); if (options.scaleFeatures) { LOG.info("Features will be scaled."); } else { LOG.info("Features will not be scaled."); } }
From source file:org.caleydo.core.view.opengl.layout2.manage.GLElementFactoryContext.java
/** * returns a view on the current context with an addition prefix to all keyss * * @param prefix/* w w w .j a va 2 s . c om*/ * @return */ public GLElementFactoryContext sub(String prefix) { prefix = StringUtils.defaultString(prefix); prefix = StringUtils.trimToEmpty(prefix); if (!prefix.isEmpty()) prefix += "."; return new GLElementFactoryContext(datas, this.prefix + prefix, objects, namedObjects); }
From source file:org.caleydo.view.bicluster.internal.loading.BiClusterStartupAddon.java
protected File onOpenFile(Text xFileUI) { FileDialog fileDialog = new FileDialog(xFileUI.getShell()); fileDialog.setText("Open"); // fileDialog.setFilterPath(filePath); String[] filterExt = { "*.csv" }; fileDialog.setFilterExtensions(filterExt); fileDialog.setFileName(xFileUI.getText()); String inputFileName = fileDialog.open(); if (inputFileName == null) return StringUtils.isBlank(xFileUI.getText()) ? null : new File(xFileUI.getText()); xFileUI.setText(StringUtils.defaultString(inputFileName)); return new File(inputFileName); }
From source file:org.carewebframework.cal.ui.patientselection.PatientDetailRenderer.java
protected void renderDemographics(Patient patient, Component root) { root.appendChild(new Separator()); Image photo = new Image(); photo.setStyle("max-height:300px;max-width:300px"); photo.setContent(Util.getImage(patient.getPhoto(), Util.SILHOUETTE_IMAGE)); root.appendChild(photo);/*from ww w .ja v a 2 s . co m*/ addDemographic(root, null, FhirUtil.formatName(patient.getName()), "font-weight: bold"); addDemographic(root, "mrn", FhirUtil.getMRNString(patient)); addDemographic(root, "gender", patient.getGender().getText()); //addDemographic(root, "race", org.springframework.util.StringUtils.collectionToCommaDelimitedString(patient.getRace())); addDemographic(root, "age", DateUtil.formatAge(patient.getBirthDate().getValue())); addDemographic(root, "dob", patient.getBirthDate()); addDemographic(root, "dod", patient.getDeceased()); //addDemographic(root, "mother", patient.getMothersFirstName()); addDemographic(root, "language", patient.getLanguage()); addContact(root, patient.getTelecom(), "home:phone", null); addContact(root, patient.getTelecom(), "home:email", null); addContact(root, patient.getTelecom(), "home:fax", "home fax"); addContact(root, patient.getTelecom(), "work:phone", null); addContact(root, patient.getTelecom(), "work:email", null); addContact(root, patient.getTelecom(), "work:fax", "work fax"); AddressDt address = FhirUtil.getAddress(patient.getAddress(), AddressUseEnum.HOME); if (address != null) { root.appendChild(new Separator()); for (StringDt line : address.getLine()) { addDemographic(root, null, line.getValue()); } String city = StringUtils.defaultString(address.getCity().getValue()); String state = StringUtils.defaultString(address.getState().getValue()); String zip = StringUtils.defaultString(address.getZip().getValue()); String sep = city.isEmpty() || state.isEmpty() ? "" : ", "; addDemographic(root, null, city + sep + state + " " + zip); } }
From source file:org.carewebframework.maven.plugin.core.ConfigTemplate.java
/** * Adds an entry to the config file./*from w w w . j a va2s . co m*/ * * @param placeholder Placeholder identifying insertion point for entry. * @param params Parameters to be applied to the template. */ public void addEntry(String placeholder, String... params) { ConfigEntry entry = entries.get(placeholder); String line = entry.template; for (int i = 0; i < params.length; i++) { line = line.replace("{" + i + "}", StringUtils.defaultString(params[i])); } entry.buffer.add(line); }