當前位置: 首頁>>代碼示例>>Java>>正文


Java ToStringStyle類代碼示例

本文整理匯總了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;
    }
}
 
開發者ID:Communote,項目名稱:communote-server,代碼行數:30,代碼來源:IpRangeFilterManagementTest.java

示例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;
}
 
開發者ID:namics,項目名稱:spring-i18n-support,代碼行數:18,代碼來源:SimpleJdbcMessageSourceDao.java

示例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;
}
 
開發者ID:jkschneider,項目名稱:java-power-assert,代碼行數:26,代碼來源:ExpressionRenderer.java

示例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();
}
 
開發者ID:ls960972314,項目名稱:report,代碼行數:31,代碼來源:ObjectUtil.java

示例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));
}
 
開發者ID:Communote,項目名稱:communote-server,代碼行數:26,代碼來源:TagCategoryManagementTest.java

示例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();
}
 
開發者ID:andrey-desman,項目名稱:openhab-hdl,代碼行數:22,代碼來源:DatapointConfig.java

示例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();
}
 
開發者ID:luotuo,項目名稱:cas4.0.x-server-wechat,代碼行數:12,代碼來源:AbstractRegisteredService.java

示例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();
  }
}
 
開發者ID:instalint-org,項目名稱:instalint,代碼行數:12,代碼來源:RuleFinderCompatibility.java

示例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));
	}
}
 
開發者ID:namics,項目名稱:spring-i18n-support,代碼行數:45,代碼來源:ExcelReader.java

示例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;
}
 
開發者ID:namics,項目名稱:spring-i18n-support,代碼行數:36,代碼來源:ExcelWriter.java

示例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();
}
 
開發者ID:zhangjunfang,項目名稱:jta-atomikos,代碼行數:9,代碼來源:TsysPost.java

示例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();
}
 
開發者ID:zhangjunfang,項目名稱:jta-atomikos,代碼行數:11,代碼來源:TsysApp.java

示例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())
            ;
}
 
開發者ID:goldmansachs,項目名稱:obevo,代碼行數:12,代碼來源:Change.java

示例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();
}
 
開發者ID:suomenriistakeskus,項目名稱:oma-riista-web,代碼行數:9,代碼來源:UserInfo.java

示例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();
    }
}
 
開發者ID:justimkiss,項目名稱:bee,代碼行數:11,代碼來源:DefaultResponse.java


注:本文中的org.apache.commons.lang.builder.ToStringStyle類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。