本文整理汇总了Java中org.apache.commons.lang.text.StrBuilder.appendWithSeparators方法的典型用法代码示例。如果您正苦于以下问题:Java StrBuilder.appendWithSeparators方法的具体用法?Java StrBuilder.appendWithSeparators怎么用?Java StrBuilder.appendWithSeparators使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.lang.text.StrBuilder
的用法示例。
在下文中一共展示了StrBuilder.appendWithSeparators方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: jpqlLoadList
import org.apache.commons.lang.text.StrBuilder; //导入方法依赖的package包/类
@Authenticated
@Override
public String jpqlLoadList(String queryString) {
try {
Transaction tx = persistence.createTransaction();
try {
EntityManager em = persistence.getEntityManager();
Query query = em.createQuery(queryString);
QueryParser parser = QueryTransformerFactory.createParser(queryString);
Set<String> paramNames = parser.getParamNames();
for (String paramName : paramNames) {
security.setQueryParam(query, paramName);
}
List resultList = query.getResultList();
tx.commit();
StrBuilder sb = new StrBuilder();
for (Object element : resultList) {
if (element instanceof Object[]) {
sb.appendWithSeparators((Object[]) element, " | ");
} else {
sb.append(element);
}
sb.append("\n");
}
return sb.toString();
} finally {
tx.end();
}
} catch (Throwable e) {
log.error("jpqlLoadList error", e);
return ExceptionUtils.getStackTrace(e);
}
}
示例2: toQueryString
import org.apache.commons.lang.text.StrBuilder; //导入方法依赖的package包/类
/**
* Returns a string that when fed into the query parser, produces a QueryFormat equal to this one.
* The string returned does not contain the FORMAT keyword.
*
* @return The query string.
*/
public String toQueryString() {
StrBuilder builder = new StrBuilder();
List<String> stringList = Lists.newArrayList();
for (AbstractColumn col : columnPatterns.keySet()) {
String pattern = columnPatterns.get(col);
stringList.add(col.toQueryString() + " " + Query.stringToQueryStringLiteral(pattern));
}
builder.appendWithSeparators(stringList, ", ");
return builder.toString();
}
示例3: StrBuilder
import org.apache.commons.lang.text.StrBuilder; //导入方法依赖的package包/类
/**
* Creates a comma separated string of the query strings of the given columns.
*
* @param l The list of columns.
*
* @return A comma separated string of the query strings of the given columns.
*/
/* package */ static String columnListToQueryString(List<AbstractColumn> l) {
StrBuilder builder = new StrBuilder();
List<String> stringList = Lists.newArrayList();
for (AbstractColumn col : l) {
stringList.add(col.toQueryString());
}
builder.appendWithSeparators(stringList, ", ");
return builder.toString();
}
示例4: toQueryString
import org.apache.commons.lang.text.StrBuilder; //导入方法依赖的package包/类
/**
* Returns a string that when fed to the query parser will yield an identical Query.
* Used mainly for debugging purposes.
*
* @return The query string.
*/
public String toQueryString() {
List<String> clauses = Lists.newArrayList();
if (hasSelection()) {
clauses.add("SELECT " + selection.toQueryString());
}
if (hasFilter()) {
clauses.add("WHERE " + filter.toQueryString());
}
if (hasGroup()) {
clauses.add("GROUP BY " + group.toQueryString());
}
if (hasPivot()) {
clauses.add("PIVOT " + pivot.toQueryString());
}
if (hasSort()) {
clauses.add("ORDER BY " + sort.toQueryString());
}
if (hasRowSkipping()) {
clauses.add("SKIPPING " + rowSkipping);
}
if (hasRowLimit()) {
clauses.add("LIMIT " + rowLimit);
}
if (hasRowOffset()) {
clauses.add("OFFSET " + rowOffset);
}
if (hasLabels()) {
clauses.add("LABEL " + labels.toQueryString());
}
if (hasUserFormatOptions()) {
clauses.add("FORMAT " + userFormatOptions.toQueryString());
}
if (hasOptions()) {
clauses.add("OPTIONS " + options.toQueryString());
}
StrBuilder result = new StrBuilder();
result.appendWithSeparators(clauses, " ");
return result.toString();
}
示例5: toQueryString
import org.apache.commons.lang.text.StrBuilder; //导入方法依赖的package包/类
/**
* Returns a string that when fed to the query parser would produce an equal QuerySort.
* The string returned does not contain the ORDER BY keywords.
*
* @return The query string.
*/
public String toQueryString() {
StrBuilder builder = new StrBuilder();
List<String> stringList = Lists.newArrayList();
for (ColumnSort colSort : sortColumns) {
stringList.add(colSort.toQueryString());
}
builder.appendWithSeparators(stringList, ", ");
return builder.toString();
}
示例6: toQueryString
import org.apache.commons.lang.text.StrBuilder; //导入方法依赖的package包/类
/**
* Returns a string that when fed into the query parser, produces a QueryLabels equal to this one.
* The string returned does not contain the LABEL keyword.
*
* @return The query string.
*/
public String toQueryString() {
StrBuilder builder = new StrBuilder();
List<String> stringList = Lists.newArrayList();
for (AbstractColumn col : columnLabels.keySet()) {
String label = columnLabels.get(col);
stringList.add(col.toQueryString() + " " + Query.stringToQueryStringLiteral(label));
}
builder.appendWithSeparators(stringList, ", ");
return builder.toString();
}
示例7: appendGroupByClause
import org.apache.commons.lang.text.StrBuilder; //导入方法依赖的package包/类
/**
* Appends the GROUP BY clause of the sql query to the given string builder.
*
* @param query The query.
* @param queryStringBuilder The string builder holding the string query.
*/
static void appendGroupByClause(Query query, StrBuilder queryStringBuilder) {
if (!query.hasGroup()) {
return;
}
queryStringBuilder.append("GROUP BY ");
QueryGroup queryGroup = query.getGroup();
List<String> groupColumnIds = queryGroup.getColumnIds();
List<String> newColumnIds = Lists.newArrayList();
for (String groupColumnId : groupColumnIds) {
newColumnIds.add('`' + groupColumnId + '`');
}
queryStringBuilder.appendWithSeparators(newColumnIds, ", ");
queryStringBuilder.append(" ");
}
示例8: getMessageAsString
import org.apache.commons.lang.text.StrBuilder; //导入方法依赖的package包/类
/**
* @see org.kuali.kfs.module.tem.batch.service.DataReportService#getMessageAsString(java.util.List)
*/
@Override
public String getMessageAsString(List<ErrorMessage> errorMessages){
List<String> messageList = new ArrayList<String>();
for (ErrorMessage error : errorMessages){
messageList.add(MessageUtils.getErrorMessage(error));
}
StrBuilder builder = new StrBuilder();
builder.appendWithSeparators(messageList, BusinessObjectReportHelper.LINE_BREAK);
return builder.toString();
}
示例9: getMessageAsString
import org.apache.commons.lang.text.StrBuilder; //导入方法依赖的package包/类
protected String getMessageAsString(List<ErrorMessage> errorMessages){
List<String> messageList = new ArrayList<String>();
for (ErrorMessage error : errorMessages){
messageList.add(MessageUtils.getErrorMessage(error));
}
StrBuilder builder = new StrBuilder();
builder.appendWithSeparators(messageList, BusinessObjectReportHelper.LINE_BREAK);
return builder.toString();
}
示例10: sendMessage
import org.apache.commons.lang.text.StrBuilder; //导入方法依赖的package包/类
@Override
public String sendMessage(String correlationID, String message,
ParameterResolutionContext prc) throws SenderException,
TimeOutException {
if (sessionKeys != null) {
List<String> list = new ArrayList<String>();
list.add(StringEscapeUtils.escapeCsv(message));
StringTokenizer tokenizer = new StringTokenizer(sessionKeys, ",");
while (tokenizer.hasMoreElements()) {
String sessionKey = (String)tokenizer.nextElement();
list.add(StringEscapeUtils.escapeCsv((String)prc.getSession().get(sessionKey)));
}
StrBuilder sb = new StrBuilder();
sb.appendWithSeparators(list, ",");
message = sb.toString();
}
String messageId = prc.getSession().getMessageId();
if (prc != null && paramList != null
&& paramList.findParameter("messageId") != null) {
try {
messageId = (String)prc.getValueMap(paramList).get("messageId");
} catch (ParameterException e) {
throw new SenderException("Could not resolve parameter messageId", e);
}
}
return storeMessage(messageId, correlationID, new Date(), null, null, message);
}
示例11: appendMessages
import org.apache.commons.lang.text.StrBuilder; //导入方法依赖的package包/类
private void appendMessages(Collection<String> messages, StrBuilder strBuilder, String header) {
if (messages.size() == 0) {
return;
}
if (!strBuilder.isEmpty()) {
strBuilder.appendNewLine();
}
strBuilder.append(header);
List<String> sortedMessages = Lists.newArrayList(messages);
Collections.sort(sortedMessages);
strBuilder.appendWithSeparators(sortedMessages, ", ");
}
示例12: getActionErrorsAsString
import org.apache.commons.lang.text.StrBuilder; //导入方法依赖的package包/类
private String getActionErrorsAsString() {
StrBuilder sbf = new StrBuilder();
sbf.appendWithSeparators(getActionErrors(), "; ");
for (Map.Entry<String, List<String>> entry : this.getFieldErrors().entrySet()) {
sbf.appendWithSeparators(entry.getValue(), "; ");
}
return sbf.toString();
}
示例13: applyOnColumn
import org.apache.commons.lang.text.StrBuilder; //导入方法依赖的package包/类
@Override
public void applyOnColumn(DataSetRow row, ActionContext context) {
final Map<String, String> parameters = context.getParameters();
final String columnId = context.getColumnId();
final Map<String, String> newColumns = ActionsUtils.getTargetColumnIds(context);
// Set the split values in newly created columns
final String originalValue = row.get(columnId);
if (originalValue == null) {
return;
}
Pattern pattern = context.get(PATTERN);
Matcher matcher = pattern.matcher(originalValue);
List<String> extractedValues = new ArrayList<>();
while (matcher.find()) {
for (int i = 1; i <= matcher.groupCount(); i++) {
final String matchingValue = matcher.group(i);
if (matchingValue != null) {
extractedValues.add(matchingValue);
}
}
}
if (parameters.get(MODE_PARAMETER).equals(MULTIPLE_COLUMNS_MODE)) {
for (int i = 0; i < newColumns.size(); i++) {
if (i < extractedValues.size()) {
row.set(newColumns.get("" + Integer.toString(i)), extractedValues.get(i));
} else {
// If we found less tokens than limit, we complete with empty entries
row.set(newColumns.get("" + Integer.toString(i)), EMPTY);
}
}
} else {
StrBuilder strBuilder = new StrBuilder();
strBuilder.appendWithSeparators(extractedValues, parameters.get(PARAMETER_SEPARATOR));
row.set(ActionsUtils.getTargetColumnId(context), strBuilder.toString());
}
}