org.apache.commons.lang3.StringUtils#trimToEmpty ( )源码实例Demo

下面列出了org.apache.commons.lang3.StringUtils#trimToEmpty ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: localization_nifi   文件: AbstractAWSProcessor.java
protected void initializeRegionAndEndpoint(ProcessContext context) {
    // if the processor supports REGION, get the configured region.
    if (getSupportedPropertyDescriptors().contains(REGION)) {
        final String region = context.getProperty(REGION).getValue();
        if (region != null) {
            this.region = Region.getRegion(Regions.fromName(region));
            client.setRegion(this.region);
        } else {
            this.region = null;
        }
    }

    // if the endpoint override has been configured, set the endpoint.
    // (per Amazon docs this should only be configured at client creation)
    final String urlstr = StringUtils.trimToEmpty(context.getProperty(ENDPOINT_OVERRIDE).getValue());
    if (!urlstr.isEmpty()) {
        this.client.setEndpoint(urlstr);
    }

}
 
源代码2 项目: o2oa   文件: Item.java
public void onPersist() throws Exception {
	this.path0 = StringUtils.trimToEmpty(this.path0);
	this.path1 = StringUtils.trimToEmpty(this.path1);
	this.path2 = StringUtils.trimToEmpty(this.path2);
	this.path3 = StringUtils.trimToEmpty(this.path3);
	this.path4 = StringUtils.trimToEmpty(this.path4);
	this.path5 = StringUtils.trimToEmpty(this.path5);
	this.path6 = StringUtils.trimToEmpty(this.path6);
	this.path7 = StringUtils.trimToEmpty(this.path7);
	this.path0Location = NumberUtils.toInt(this.path0, -1);
	this.path1Location = NumberUtils.toInt(this.path1, -1);
	this.path2Location = NumberUtils.toInt(this.path2, -1);
	this.path3Location = NumberUtils.toInt(this.path3, -1);
	this.path4Location = NumberUtils.toInt(this.path4, -1);
	this.path5Location = NumberUtils.toInt(this.path5, -1);
	this.path6Location = NumberUtils.toInt(this.path6, -1);
	this.path7Location = NumberUtils.toInt(this.path7, -1);
}
 
源代码3 项目: sakai   文件: ResourceHelper.java
public boolean isDescCustom(String itemDescription)
{
    String resDesc = StringUtils.trimToEmpty(getResourceProperties().getProperty(ResourceProperties.PROP_DESCRIPTION));
    String itemDesc = StringUtils.trimToEmpty(itemDescription);
    
    // if the descriptions are not equal, the item description is assumed to be custom
    return !resDesc.equalsIgnoreCase(itemDesc);
}
 
源代码4 项目: o2oa   文件: TimerExpiredTaskApplicationStubs.java
private String getApplicationName(Business business, DateRange dateRange, String applicationId) throws Exception {
	String value = this.getApplicationNameFromTask(business, dateRange, applicationId);
	if (null == value) {
		value = this.getApplicationNameFromTaskCompleted(business, dateRange, applicationId);
	}
	return StringUtils.trimToEmpty(value);
}
 
源代码5 项目: sakai   文件: BaseHibernateManager.java
public Long createUngradedAssignmentForCategory(final Long gradebookId, final Long categoryId, final String name, final Date dueDate, final Boolean isNotCounted,
                                                final Boolean isReleased) throws ConflictingAssignmentNameException, StaleObjectModificationException, IllegalArgumentException {

    if (gradebookId == null || categoryId == null) {
        throw new IllegalArgumentException("gradebookId or categoryId is null in BaseHibernateManager.createUngradedAssignmentForCategory");
	}
	final HibernateCallback<Long> hc = session -> {
        final Gradebook gb = (Gradebook) session.load(Gradebook.class, gradebookId);
        final Category cat = (Category) session.load(Category.class, categoryId);

        // trim the name before the validation
        final String trimmedName = StringUtils.trimToEmpty(name);

        if (assignmentNameExists(trimmedName, gb)) {
            throw new ConflictingAssignmentNameException("You can not save multiple assignments in a gradebook with the same name");
        }

        final GradebookAssignment asn = new GradebookAssignment();
        asn.setGradebook(gb);
        asn.setCategory(cat);
        asn.setName(trimmedName);
        asn.setDueDate(dueDate);
        asn.setUngraded(true);
        if (isNotCounted != null) {
            asn.setNotCounted(isNotCounted);
        }
        if (isReleased != null) {
            asn.setReleased(isReleased);
        }

        return (Long) session.save(asn);
    };

	return getHibernateTemplate().execute(hc);
}
 
源代码6 项目: vscrawler   文件: ExpressionParser.java
private SyntaxNode parseFunction(StringFunctionTokenQueue tokenQueue) {
    String functionString = tokenQueue.consumeFunction();
    StringFunctionTokenQueue tempTokenQueue = new StringFunctionTokenQueue(functionString);
    String functionName = tempTokenQueue.consumeIdentify();
    StringFunction function = StringFunctionEnv.findFunction(functionName);
    if (function == null) {
        throw new IllegalStateException("not such function: " + functionName);
    }
    tempTokenQueue.consumeWhitespace();
    if (tempTokenQueue.isEmpty() || tempTokenQueue.peek() != '(') {
        throw new IllegalStateException(
                "can not parse token: " + functionString + "  ,it is not same to a function");
    }

    String paramsStr = StringUtils.trimToEmpty(tempTokenQueue.chompBalanced('(', ')'));

    StringFunctionTokenQueue paramTokenQueue = new StringFunctionTokenQueue(paramsStr);

    String parameter;
    List<SyntaxNode> params = Lists.newLinkedList();
    while ((parameter = paramTokenQueue.consumeIgnoreQuote(',')) != null) {
        params.add(new ExpressionParser(new StringFunctionTokenQueue(parameter)).parse());
    }
    paramTokenQueue.consumeWhitespace();
    if (!paramTokenQueue.isEmpty()) {
        params.add(new ExpressionParser(new StringFunctionTokenQueue(paramTokenQueue.remainder())).parse());
    }
    return new FunctionSyntaxNode(function, params);
}
 
源代码7 项目: hub-detect   文件: DetectOverrideableFilter.java
private Set<String> createSetFromString(final String s) {
    final Set<String> set = new HashSet<>();
    final StringTokenizer stringTokenizer = new StringTokenizer(StringUtils.trimToEmpty(s), ",");
    while (stringTokenizer.hasMoreTokens()) {
        set.add(StringUtils.trimToEmpty(stringTokenizer.nextToken()));
    }
    return set;
}
 
源代码8 项目: o2oa   文件: TimerStartWorkApplicationStubs.java
private String getApplicationName(Business business, DateRange dateRange, String applicationId) throws Exception {
	String value = this.getApplicationNameFromWork(business, dateRange, applicationId);
	if (null == value) {
		value = this.getApplicationNameFromWorkCompleted(business, dateRange, applicationId);
	}
	return StringUtils.trimToEmpty(value);
}
 
源代码9 项目: OpenEstate-IO   文件: XmlUtils.java
/**
 * Create a {@link XPath} expression.
 *
 * @param expression      string with the XPath expression to create
 * @param doc             the document, whose namespace is bound to the XPath expression
 * @param namespacePrefix prefix of the document namespace, that is bound to the XPath expression
 * @return the created XPath expression
 * @throws JaxenException if the XPath is not creatable
 */
public static XPath newXPath(String expression, Document doc, String namespacePrefix) throws JaxenException {
    DOMXPath xpath = new DOMXPath(expression);
    //LOGGER.debug( "new xpath: " + xpath.debug() );
    if (doc != null && namespacePrefix != null) {
        Element root = XmlUtils.getRootElement(doc);
        String uri = StringUtils.trimToEmpty(root.getNamespaceURI());
        xpath.addNamespace(namespacePrefix, uri);
    }
    return xpath;
}
 
源代码10 项目: cuba   文件: EntityStatistics.java
@Override
public String toString() {
    StringBuilder sb = new StringBuilder(StringUtils.trimToEmpty(name));
    sb.append(": instanceCount=").append(instanceCount != null ? instanceCount : 0);
    if (lazyCollectionThreshold != null)
        sb.append(", lazyCollectionThreshold=").append(lazyCollectionThreshold);
    if (maxFetchUI != null)
        sb.append(", maxFetchUI=").append(maxFetchUI);
    return sb.toString();
}
 
源代码11 项目: o2oa   文件: TimerCompletedTaskApplicationStubs.java
private String getActivityName(Business business, DateRange dateRange, String activityId) throws Exception {
	String value = this.getActivityNameFromTaskCompleted(business, dateRange, activityId);
	return StringUtils.trimToEmpty(value);
}
 
源代码12 项目: sakai   文件: EmbeddedItemData.java
/**
 * Constructor
 * @param description an optional description for the items (as shown on the page in Lessons)
 * @param parentPage the page the item is embedded into
 */
public EmbeddedItemData(String description, PageData parentPage)
{
	desc = StringUtils.trimToEmpty(description);
	this.parentPage = parentPage;
}
 
源代码13 项目: o2oa   文件: TimerCompletedWorkApplicationStubs.java
private String getProcessName(Business business, DateRange dateRange, String processId) throws Exception {
	String value = this.getProcessNameFromWorkCompleted(business, dateRange, processId);
	return StringUtils.trimToEmpty(value);
}
 
源代码14 项目: o2oa   文件: TemplatePage.java
public void onPersist() throws Exception {
	this.category = StringUtils.trimToEmpty(this.category);
}
 
源代码15 项目: OpenEstate-IO   文件: OpenImmoFeedbackDocument.java
@Override
public void setDocumentVersion(OpenImmoVersion version) {
    try {
        Document doc = this.getDocument();

        String currentVersion = StringUtils.trimToEmpty(XmlUtils
                .newXPath("/io:openimmo/io:uebertragung/@version", doc)
                .stringValueOf(doc));
        String[] ver = StringUtils.split(currentVersion, "/", 2);

        Element node = (Element) XmlUtils
                .newXPath("/io:openimmo_feedback/io:version", doc)
                .selectSingleNode(doc);

        // versions older then 1.2.4 do not support the <version> element
        if (OpenImmoVersion.V1_2_4.isNewerThen(version)) {
            if (node != null) {
                Element root = XmlUtils.getRootElement(doc);
                root.removeChild(node);
            }
            return;
        }

        if (node == null) {
            Element parentNode = (Element) XmlUtils
                    .newXPath("/io:openimmo_feedback", doc)
                    .selectSingleNode(doc);
            if (parentNode == null) {
                LOGGER.warn("Can't find an <openimmo_feedback> element in the document!");
                return;
            }
            node = doc.createElement("version");
            parentNode.insertBefore(node, parentNode.getFirstChild());
        }

        String newVersion = version.toReadableVersion();
        if (ver.length > 1) newVersion += "/" + ver[1];
        node.setTextContent(newVersion);
    } catch (JaxenException ex) {
        LOGGER.error("Can't evaluate XPath expression!");
        LOGGER.error("> " + ex.getLocalizedMessage(), ex);
    }
}
 
源代码16 项目: sakai   文件: DbUserService.java
/**
 * Get the fields for the database from the edit for this id, and the id again at the end if needed
 *
 * @param id
 *        The resource id
 * @param edit
 *        The edit (may be null in a new)
 * @param idAgain
 *        If true, include the id field again at the end, else don't.
 * @return The fields for the database.
 */
protected Object[] fields(String id, UserEdit edit, boolean idAgain)
{
	Object[] rv = new Object[idAgain ? 12 : 11];
	rv[0] = caseId(id);
	if (idAgain)
	{
		rv[11] = rv[0];
	}

	if (edit == null)
	{
		String attribUser = sessionManager().getCurrentSessionUserId();

		// if no current user, since we are working up a new user record, use the user id as creator...
		if ((attribUser == null) || (attribUser.length() == 0)) attribUser = (String) rv[0];

		Time now = timeService().newTime();
		rv[1] = "";
		rv[2] = "";
		rv[3] = "";
		rv[4] = "";
		rv[5] = "";
		rv[6] = "";
		rv[7] = attribUser;
		rv[8] = attribUser;
		rv[9] = now;
		rv[10] = now;
	}

	else
	{
		rv[1] = StringUtils.trimToEmpty(edit.getEmail());
		rv[2] = StringUtils.trimToEmpty(edit.getEmail().toLowerCase());
		rv[3] = StringUtils.trimToEmpty(edit.getFirstName());
		rv[4] = StringUtils.trimToEmpty(edit.getLastName());
		rv[5] = StringUtils.trimToEmpty(edit.getType());
		rv[6] = StringUtils.trimToEmpty(((BaseUserEdit) edit).m_pw);

		// for creator and modified by, if null, make it the id
		rv[7] = StringUtils.trimToNull(((BaseUserEdit) edit).m_createdUserId);
		if (rv[7] == null)
		{
			rv[7] = rv[0];
		}
		rv[8] = StringUtils.trimToNull(((BaseUserEdit) edit).m_lastModifiedUserId);
		if (rv[8] == null)
		{
			rv[8] = rv[0];
		}

		rv[9] = edit.getCreatedDate();
		rv[10] = edit.getModifiedDate();
	}

	return rv;
}
 
源代码17 项目: sailfish-core   文件: BigButtonSettings.java
public void setEmailSubject(String emailSubject) {
    this.emailSubject = StringUtils.trimToEmpty(emailSubject);
}
 
源代码18 项目: openemm   文件: ComWorkflowEQLHelper.java
private String generateRuleEQL(String resolvedFieldName, String field, String type, List<WorkflowRule> rules, String dateFormat, boolean disableThreeValuedLogic) throws EQLCreationException {
  List<String> expressions = new ArrayList<>();
     
     for (WorkflowRule rule : rules) {
         
         int operator = rule.getPrimaryOperator();
         String value = rule.getPrimaryValue();
         StringBuilder expression = new StringBuilder();
         
         if(!expressions.isEmpty()) {
             expression.append(EqlUtils.convertChainOperator(rule.getChainOperator())).append(" ");
         }
         
         if(rule.getParenthesisOpened() == 1) {
             expression.append("(");
         }
 
         switch (StringUtils.trimToEmpty(DbColumnType.dbType2String(type))) {
	case GENERIC_TYPE_VARCHAR:
	case GENERIC_TYPE_CHAR:
		expression.append(generateStringEQL(resolvedFieldName, operator, value, disableThreeValuedLogic));
		break;
	case GENERIC_TYPE_INTEGER:
	case GENERIC_TYPE_DOUBLE:
		expression.append(generateNumericEQL(resolvedFieldName, operator, value, disableThreeValuedLogic));
		break;
	case GENERIC_TYPE_DATE:
		expression.append(generateDateEQL(resolvedFieldName, field, operator, dateFormat, value, disableThreeValuedLogic));
		break;
	default:
		//nothing to do
}

if(rule.getParenthesisClosed() == 1) {
             expression.append(")");
         }
         
         expressions.add(expression.toString());
     }
     
     return StringUtils.join(expressions, " ");
 }
 
源代码19 项目: o2oa   文件: Portal.java
public void onPersist() throws Exception {
	this.portalCategory = StringUtils.trimToEmpty(this.portalCategory);
	this.firstPage = StringUtils.trimToEmpty(this.firstPage);
}
 
源代码20 项目: cryptotrader   文件: CoincheckContext.java
@VisibleForTesting
String executePrivate(RequestType type, String url, Map<String, String> parameters, String data) throws Exception {

    String apiKey = getStringProperty("api.id", null);
    String secret = getStringProperty("api.secret", null);

    if (StringUtils.isEmpty(apiKey) || StringUtils.isEmpty(secret)) {
        return null;
    }

    String result;

    synchronized (lastNonce) {

        long currNonce = 0;

        while (currNonce <= lastNonce.get()) {

            TimeUnit.MILLISECONDS.sleep(1);

            currNonce = getNow().toEpochMilli();

        }

        lastNonce.set(currNonce);

        String path = url + buildQueryParameter(parameters);
        String nonce = String.valueOf(currNonce);
        String message = nonce + path + StringUtils.trimToEmpty(data);
        String hash = computeHash("HmacSHA256", secret.getBytes(), message.getBytes());

        Map<String, String> headers = new LinkedHashMap<>();
        headers.put("Content-Type", "application/json");
        headers.put("ACCESS-KEY", apiKey);
        headers.put("ACCESS-NONCE", nonce);
        headers.put("ACCESS-SIGNATURE", hash);

        result = request(type, path, headers, data);


    }

    return result;

}
 
 同类方法