本文整理汇总了Java中org.apache.commons.lang.builder.ToStringStyle类的典型用法代码示例。如果您正苦于以下问题:Java ToStringStyle类的具体用法?Java ToStringStyle怎么用?Java ToStringStyle使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ToStringStyle类属于org.apache.commons.lang.builder包,在下文中一共展示了ToStringStyle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCreateFilter
import org.apache.commons.lang.builder.ToStringStyle; //导入依赖的package包/类
/**
* Test create filter.
*
* @throws IpRangeException
* the ip range exception
*/
@Test
public void testCreateFilter() throws IpRangeException {
AuthenticationTestUtils.setManagerContext();
try {
IpRangeFilterVO filter = ipRangeFilterManagement.createFilter(IP_FILTER_EMPTY, "", "");
Assert.assertNotNull(filter, "got no filter");
filter = ipRangeFilterManagement.createFilter(IP_FILTER_INCLUDING_CURRENT_IP,
"127.0.0.1", "3.4.5.6");
LOG.debug("filter: \n"
+ ToStringBuilder.reflectionToString(filter, ToStringStyle.MULTI_LINE_STYLE));
filter = ipRangeFilterManagement.createFilter("IncludeFilter", "168.0.0.1", "");
LOG.debug("filter: \n"
+ ToStringBuilder.reflectionToString(filter, ToStringStyle.MULTI_LINE_STYLE));
filter = ipRangeFilterManagement.createFilter("IncludeFilter_2",
"::168.0.0.1-::168.0.5.0", "");
LOG.debug("filter: \n"
+ ToStringBuilder.reflectionToString(filter, ToStringStyle.MULTI_LINE_STYLE));
} catch (IpRangeException e) {
LOG.error(e + ", ip: '" + e.getIp() + "'", e);
throw e;
}
}
示例2: findDistinctLang
import org.apache.commons.lang.builder.ToStringStyle; //导入依赖的package包/类
@Override
public List<String> findDistinctLang() {
if (this.availableLanguages == null) {
LOG.info("Initialize available Languages.");
List<String> locales = new ArrayList<>();
List<MessageResource> messages = this.findAll();
for (MessageResource resource : messages) {
String locale = resource.getLang();
if (!locales.contains(locale)) {
locales.add(locale);
}
}
this.availableLanguages = locales;
LOG.info("Available locales are: " + ToStringBuilder.reflectionToString(locales, ToStringStyle.SHORT_PREFIX_STYLE));
}
return this.availableLanguages;
}
示例3: renderValue
import org.apache.commons.lang.builder.ToStringStyle; //导入依赖的package包/类
private String renderValue(Object value) {
String str;
if(value == null)
str = "null";
else if(value.getClass().isArray()) {
// recursive string join
str = "[";
for(Object o: toArray(value)) {
str += renderValue(o) + ", ";
}
str = (str.length() > 1 ? str.substring(0, str.length()-2) : "") + "]";
}
else {
try {
if(value.getClass().getMethod("toString").getDeclaringClass() == Object.class) {
str = ToStringBuilder.reflectionToString(value, ToStringStyle.SHORT_PREFIX_STYLE);
}
else str = value.toString();
} catch (NoSuchMethodException e) {
str = value.toString();
}
}
return showTypes && value != null ? str + " (" + value.getClass().getName() + ")" : str;
}
示例4: toString
import org.apache.commons.lang.builder.ToStringStyle; //导入依赖的package包/类
/**
* 对象转字符串
* @param obj
* 目标对象
*
* @param style
* @see org.apache.commons.lang.builder.ToStringStyle
*
* @return
*/
public static String toString(Object obj, ToStringStyle style){
if(null == obj){
return "";
}
StringBuilder defaultObjReg = new StringBuilder();
defaultObjReg.append("^[\\w\\.]*");
defaultObjReg.append(obj.getClass().getSimpleName());
defaultObjReg.append("@");
defaultObjReg.append("[a-zA-Z0-9]+");
defaultObjReg.append("$");
// 未重写toString
if(String.valueOf(obj).matches(defaultObjReg.toString())){
return ReflectionToStringBuilder.toString(obj,
style);
}
return obj.toString();
}
示例5: checkTagCategoryData
import org.apache.commons.lang.builder.ToStringStyle; //导入依赖的package包/类
/**
* Checks if the given tag category entity equals to the tag category value object.
*
* @param expected
* the expected values
* @param actual
* the actual values
*/
private void checkTagCategoryData(GlobalTagCategoryVO expected, GlobalTagCategory actual) {
ToStringBuilder s1 = new ToStringBuilder(ToStringStyle.MULTI_LINE_STYLE)
.append("description", actual.getDescription()).append("name", actual.getName())
.append("prefix", actual.getPrefix());
boolean result = true;
result = result && StringUtils.equals(expected.getDescription(), actual.getDescription());
result = result && StringUtils.equals(expected.getName(), actual.getName());
result = result && StringUtils.equals(expected.getPrefix(), actual.getPrefix());
Assert.assertEquals(
result,
true,
"value object and entity not equal, entity: "
+ s1.toString()
+ ", source vo: "
+ ToStringBuilder.reflectionToString(expected,
ToStringStyle.MULTI_LINE_STYLE));
}
示例6: toString
import org.apache.commons.lang.builder.ToStringStyle; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public String toString() {
ToStringBuilder tsb = new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE);
tsb.append("address", address).append("channel", channel).append("parameter", parameter);
if (converter != null) {
tsb.append("converter", converter);
}
if (action != null) {
tsb.append("action", action);
}
if (forceUpdate) {
tsb.append("forceUpdate", forceUpdate);
}
if (delay > 0.0) {
tsb.append("delay", delay);
}
return tsb.toString();
}
示例7: toString
import org.apache.commons.lang.builder.ToStringStyle; //导入依赖的package包/类
public String toString() {
final ToStringBuilder toStringBuilder = new ToStringBuilder(null, ToStringStyle.SHORT_PREFIX_STYLE);
toStringBuilder.append("id", this.id);
toStringBuilder.append("name", this.name);
toStringBuilder.append("description", this.description);
toStringBuilder.append("serviceId", this.serviceId);
toStringBuilder.append("usernameAttribute", this.usernameAttribute);
toStringBuilder.append("attributes", this.allowedAttributes.toArray());
return toStringBuilder.toString();
}
示例8: find
import org.apache.commons.lang.builder.ToStringStyle; //导入依赖的package包/类
@Override
public Rule find(RuleQuery query) {
Collection<Rule> all = findAll(query);
if (all.size() > 1) {
throw new IllegalArgumentException("Non unique result for rule query: " + ReflectionToStringBuilder.toString(query, ToStringStyle.SHORT_PREFIX_STYLE));
} else if (all.isEmpty()) {
return null;
} else {
return all.iterator().next();
}
}
示例9: parseContentBodyRow
import org.apache.commons.lang.builder.ToStringStyle; //导入依赖的package包/类
/**
* Method parses a row of the body content and puts the related entry into the result list (entries).
* If the row is invalid in any kind, no modification happens. If any of the parameters provided is null or invalid,
* no modification happens.
*
* @param entries the list of entries, where the result of the row should be put in
* @param langKeys the language information to parse the row correctly
* @param row the row to be processed.
*/
private void parseContentBodyRow( List<MessageResourceEntry> entries,
Map<Integer, Locale> langKeys,
Row row,
String type)
{
if (entries == null || row == null || langKeys == null || langKeys.isEmpty())
{
return;
}
MessageResourceEntry entry = new MessageResourceEntry();
String code = getCellStringValue(row.getCell(this.keyColumn));
if (!StringUtils.isBlank(code))
{
entry.setCodeId(StringUtils.trim(code));
for (int nameIndex = this.firstLanguageColumn; nameIndex <= langKeys.size(); nameIndex++)
{
Cell cell = row.getCell(nameIndex);
String name = getCellStringValue(cell);
if (!StringUtils.isBlank(name))
{
Locale lang = langKeys.get(nameIndex);
entry.addLang(lang, name);
}
}
if (entry.size() > 0)
{
entry.setType(type);
entries.add(entry);
}
}
if (LOG.isDebugEnabled())
{
LOG.debug(ToStringBuilder.reflectionToString(entry, ToStringStyle.SHORT_PREFIX_STYLE));
}
}
示例10: getLanguageInformation
import org.apache.commons.lang.builder.ToStringStyle; //导入依赖的package包/类
/**
* Extracts the language information form the data.
* This method iterates all MessagaResourceEntries to get all available languages used in the data.
*
* @param entries the entries to extract the used langs
* @return the Map to map a certain language to a special column in the process of content row writing
*/
private Map<Locale, Integer> getLanguageInformation(List<MessageResourceEntry> entries)
{
LOG.info("Extract language information");
SortedSet<Locale> locales = new TreeSet<Locale>(new LocaleComparator());
for (MessageResourceEntry entry : entries)
{
Map<Locale, String> mappings = entry.getNameMappings();
if (mappings != null && !mappings.isEmpty())
{
for (Locale key : mappings.keySet())
{
locales.add(key);
}
}
}
Map<Locale, Integer> result = new HashMap<Locale, Integer>();
int colIndex = this.firstLanguageColumn; // calculate the index column for new languages
for (Locale locale : locales)
{
result.put(locale, colIndex);
colIndex++;
}
if (LOG.isDebugEnabled())
{
LOG.debug("Extracted languages " + ToStringBuilder.reflectionToString(result, ToStringStyle.SHORT_PREFIX_STYLE));
}
return result;
}
示例11: toString
import org.apache.commons.lang.builder.ToStringStyle; //导入依赖的package包/类
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("PostId", getPostId())
.append("PostName", getPostName())
.append("Remark", getRemark())
.append("PostType", getPostType())
.append("ParentPostid", getParentPostid()).toString();
}
示例12: toString
import org.apache.commons.lang.builder.ToStringStyle; //导入依赖的package包/类
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("AppId",getAppId())
.append("AppName",getAppName())
.append("AppIcon",getAppIcon())
.append("OrderNo",getOrderNo())
.append("AppPath",getAppPath())
.append("AppShortname",getAppShortname())
.toString();
}
示例13: toStringBuilder
import org.apache.commons.lang.builder.ToStringStyle; //导入依赖的package包/类
protected ToStringBuilder toStringBuilder() {
return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
.append(this.getSchema())
.append(this.getChangeName())
.append(this.getObjectName())
.append(this.getChangeType())
.append(this.getContent())
.append(this.getContentHash())
.append(this.getOrderWithinObject())
;
}
示例14: toString
import org.apache.commons.lang.builder.ToStringStyle; //导入依赖的package包/类
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
.append("username", getUsername())
.append("userId", userId)
.append("role", role)
.toString();
}
示例15: toString
import org.apache.commons.lang.builder.ToStringStyle; //导入依赖的package包/类
@Override
public String toString() {
if (this.messageType == Constants.MESSAGE_TYPE_SERVICE) {
return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append("serialize", serialize)
.append("seq", seq).append("messageType", messageType).toString();
} else {
return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append("serialize", serialize)
.append("seq", seq).append("messageType", messageType).append("return", returnVal).toString();
}
}