Example usage for org.apache.commons.lang StringUtils defaultString

List of usage examples for org.apache.commons.lang StringUtils defaultString

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils defaultString.

Prototype

public static String defaultString(String str, String defaultStr) 

Source Link

Document

Returns either the passed in String, or if the String is null, the value of defaultStr.

Usage

From source file:com.autonomy.aci.client.services.impl.AbstractStAXProcessor.java

/**
 * This constructor gets a new {@link XMLInputFactory} instance that is reused every time
 * {@link #process(com.autonomy.aci.client.transport.AciResponseInputStream)} is called, this
 * should be faster than creating a new instance every time this method is called.
 * <p>//  w ww.  j  ava2  s  .  com
 * The properties are set to the following defaults if they are not specified as system properties:
 * <table summary="">
 * <tr><th>Property</th><th>Default</th></tr>
 * <tr><td>XMLInputFactory.IS_NAMESPACE_AWARE</td><td><tt>false</tt></td></tr>
 * <tr><td>XMLInputFactory.IS_VALIDATING<tt>false</tt></td></tr>
 * <tr><td>XMLInputFactory.IS_COALESCING<tt>false</tt></td></tr>
 * <tr><td>XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES<tt>true</tt></td></tr>
 * <tr><td>XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES<tt>false</tt></td></tr>
 * <tr><td>XMLInputFactory.SUPPORT_DTD<tt>true</tt></td></tr>
 * </table>
 */
protected AbstractStAXProcessor() {
    // See if the various XMLInputFactory properties are set as system properties...
    namespaceAware = BooleanUtils.toBoolean(
            StringUtils.defaultString(System.getProperty(XMLInputFactory.IS_NAMESPACE_AWARE), "false"));
    validating = BooleanUtils
            .toBoolean(StringUtils.defaultString(System.getProperty(XMLInputFactory.IS_VALIDATING), "false"));
    coalescing = BooleanUtils
            .toBoolean(StringUtils.defaultString(System.getProperty(XMLInputFactory.IS_COALESCING), "false"));
    replacingEntityReferences = BooleanUtils.toBoolean(StringUtils
            .defaultString(System.getProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES), "true"));
    supportingExternalEntities = BooleanUtils.toBoolean(StringUtils
            .defaultString(System.getProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES), "false"));
    supportDtd = BooleanUtils
            .toBoolean(StringUtils.defaultString(System.getProperty(XMLInputFactory.SUPPORT_DTD), "true"));

    // Create the XMLStreamReader factory...
    xmlInputFactory = XMLInputFactory.newInstance();
}

From source file:hudson.tasks.BuildTrigger.java

@DataBoundConstructor
public BuildTrigger(String childProjects, String threshold) {
    this(childProjects, Result.fromString(StringUtils.defaultString(threshold, Result.SUCCESS.toString())));
}

From source file:com.predic8.membrane.core.interceptor.authentication.session.AccountBlocker.java

@Override
protected void parseAttributes(XMLStreamReader token) throws Exception {
    blockWholeSystemAfter = Integer.parseInt(
            StringUtils.defaultString(token.getAttributeValue("", "blockWholeSystemAfter"), "1000000"));
    afterFailedLogins = Integer/*from ww  w .j av  a2 s . c  o m*/
            .parseInt(StringUtils.defaultString(token.getAttributeValue("", "afterFailedLogins"), "5"));
    afterFailedLoginsWithin = Long.parseLong(StringUtils
            .defaultString(token.getAttributeValue("", "afterFailedLoginsWithin"), "" + Long.MAX_VALUE));
    blockFor = Integer.parseInt(StringUtils.defaultString(token.getAttributeValue("", "blockFor"), "3600000"));
}

From source file:com.axelor.apps.base.service.administration.SequenceService.java

/**
 * Fonction retournant une numro de squence depuis une squence gnrique, et une date
 *
 * @param seq/*from w w  w  .  j av a  2s. co m*/
 * @param todayYear
 * @param todayMoy
 * @param todayDom
 * @param todayWoy
 * @return
 */
@Transactional(rollbackOn = { AxelorException.class, Exception.class })
public String getSequenceNumber(Sequence sequence) {

    SequenceVersion sequenceVersion = getVersion(sequence);

    String seqPrefixe = StringUtils.defaultString(sequence.getPrefixe(), ""),
            seqSuffixe = StringUtils.defaultString(sequence.getSuffixe(), ""), padLeft = StringUtils
                    .leftPad(sequenceVersion.getNextNum().toString(), sequence.getPadding(), PADDING_STRING);

    String nextSeq = (seqPrefixe + padLeft + seqSuffixe)
            .replaceAll(PATTERN_YEAR, Integer.toString(refDate.getYearOfCentury()))
            .replaceAll(PATTERN_MONTH, Integer.toString(refDate.getMonthOfYear()))
            .replaceAll(PATTERN_FULL_MONTH, refDate.toString("MM"))
            .replaceAll(PATTERN_DAY, Integer.toString(refDate.getDayOfMonth()))
            .replaceAll(PATTERN_WEEK, Integer.toString(refDate.getWeekOfWeekyear()));

    log.debug("nextSeq : : : : {}", nextSeq);

    sequenceVersion.setNextNum(sequenceVersion.getNextNum() + sequence.getToBeAdded());
    sequenceVersionRepository.save(sequenceVersion);
    return nextSeq;
}

From source file:com.bstek.dorado.config.xml.DispatchableXmlParser.java

/**
 * ??????/*from  w  w  w .  j  a v a  2  s  . co m*/
 * 
 * @param constraint
 *            ?? ??????WILDCARD??
 */
protected XmlParser findSubParser(String constraint) {
    constraint = StringUtils.defaultString(constraint, WILDCARD);
    XmlParser parser = subParsers.get(constraint);
    if (parser == null && !WILDCARD.equals(constraint)) {
        parser = subParsers.get(WILDCARD);
    }
    return parser;
}

From source file:info.magnolia.cms.filters.CommonsFileUploadMultipartRequestFilter.java

/**
 * Add the <code>FileItem</code> as a paramter into the <code>MultipartForm</code>.
 *///from  www .  j  ava 2  s  .  c  o m
private void addField(HttpServletRequest request, FileItem item, MultipartForm form) {
    String name = item.getFieldName();

    String value;
    try {
        String encoding = StringUtils.defaultString(request.getCharacterEncoding(), "UTF-8");
        value = item.getString(encoding);
    } catch (UnsupportedEncodingException ex) {
        value = item.getString();
    }
    form.addParameter(name, value);

    String[] values = request.getParameterValues(name);
    if (values != null) {
        form.addparameterValues(name, values);
    }
}

From source file:com.bstek.dorado.config.text.DispatchableTextParser.java

/**
 * ??????/*from w w w  .ja  va 2  s. c  om*/
 * @param constraint ??
 *            ??????WILDCARD??\\
 * @param context
 * @return ???
 * @throws Exception
 */
protected TextParser findSubParser(String constraint, TextParseContext context) throws Exception {
    constraint = StringUtils.defaultString(constraint, WILDCARD);
    TextParser parser = subParsers.get(constraint);
    if (parser == null && !WILDCARD.equals(constraint)) {
        parser = subParsers.get(WILDCARD);
    }
    return parser;
}

From source file:de.janrieke.contractmanager.ext.hibiscus.UmsatzImportListDialog.java

/**
 * @see de.willuhn.jameica.gui.dialogs.AbstractDialog#paint(org.eclipse.swt.widgets.Composite)
 *///  ww  w.  jav  a  2s. c  o m
@Override
protected void paint(final Composite parent) throws Exception {
    this.list = initializeContractList();

    Container group = new SimpleContainer(parent, true);

    group.addText(Settings.i18n().tr("Transaction to assign:"), true);
    group.addText(
            Settings.i18n().tr("From/To") + ": " + StringUtils.defaultString(umsatz.getGegenkontoName(), ""),
            false);
    group.addText(Settings.i18n().tr("Reference") + ": " + VerwendungszweckUtil.toString(umsatz), true);
    group.addText(Settings.i18n().tr("Date") + ": " + Settings.dateformat(umsatz.getDatum()), false);
    group.addText(Settings.i18n().tr("Value") + ": " + Settings.formatAsCurrency(umsatz.getBetrag()), false);

    TextInput text = this.getSearch();
    group.addInput(text);
    group.addPart(this.getTable());

    // //////////////
    // geht erst nach dem Paint
    if (chosen != null) {
        getTable().select(chosen);
    }

    text.getControl().addKeyListener(new DelayedAdapter());

    if (moreImportsFollow) {
        group.addCheckbox(getApplyForAllCheckbox(),
                Settings.i18n().tr("Also assign all further transactions to this contract"));
    }

    ButtonArea buttons = new ButtonArea();
    buttons.addButton(getAssignButton());
    buttons.addButton(getCreateContractButton());
    buttons.addButton(Settings.i18n().tr("Cancel"), context -> {
        throw new OperationCanceledException();
    }, null, false, "process-stop.png");

    group.addButtonArea(buttons);

    // Replace the 'wrong' text on the assign button.
    parent.addPaintListener(new PaintListener() {
        @Override
        public void paintControl(PaintEvent e) {
            getAssignButton().setText(Settings.i18n().tr("Assign"));
            parent.removePaintListener(this);
        }
    });
}

From source file:com.frameworkset.orm.engine.model.Domain.java

/**
 * Replaces the size if the new value is not null.
 * /*from  w w  w . j  a va 2  s  . c  o  m*/
 * @param value The size to set.
 */
public void replaceScale(String value) {
    this.scale = StringUtils.defaultString(value, getScale());
}

From source file:au.org.ala.names.parser.PhraseNameParser.java

@Override
public <T> ParsedName<T> parse(String scientificName) throws UnparsableException {
    ParsedName pn = super.parse(scientificName);
    if (pn.getType() != NameType.wellformed && isPhraseRank(pn.rank) && (!pn.authorsParsed
            || pn.specificEpithet == null || SPECIES_PATTERN.matcher(pn.specificEpithet).matches())) {
        //if the rank marker is sp. and the word after the rank marker is lower case check to see if removing the marker will result is a wellformed name
        if (SPECIES_PATTERN.matcher(pn.rank).matches()) {
            Matcher m1 = POTENTIAL_SPECIES_PATTERN.matcher(scientificName);
            //System.out.println(POTENTIAL_SPECIES_PATTERN.pattern());
            if (m1.find()) {
                //now reparse without the rankMarker
                String newName = m1.group(1) + m1.group(3) + StringUtils.defaultString(m1.group(4), "");
                pn = super.parse(newName);
                if (pn.getType() == NameType.wellformed)
                    return pn;
            }//from w w w.j  ava 2  s.  com
        }
        //check to see if the name represents a phrase name
        Matcher m = PHRASE_PATTERN.matcher(scientificName);
        if (m.find()) {
            ALAParsedName alapn = new ALAParsedName(pn);
            alapn.setLocationPhraseDescription(StringUtils.trimToNull(m.group(3)));
            alapn.setPhraseVoucher(StringUtils.trimToNull(m.group(4)));
            alapn.setPhraseNominatingParty(StringUtils.trimToNull(m.group(5)));
            return alapn;
        }

    } else {
        //check for the situation where the subgenus was supplied without Title case.
        Matcher m = WRONG_CASE_INFRAGENERIC.matcher(scientificName);
        if (m.find()) {
            scientificName = WordUtils.capitalize(scientificName, '(');
            pn = super.parse(scientificName);
        }
    }

    return pn;
}