当前位置: 首页>>代码示例>>Java>>正文


Java ObjectUtils.toString方法代码示例

本文整理汇总了Java中org.apache.commons.lang.ObjectUtils.toString方法的典型用法代码示例。如果您正苦于以下问题:Java ObjectUtils.toString方法的具体用法?Java ObjectUtils.toString怎么用?Java ObjectUtils.toString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.lang.ObjectUtils的用法示例。


在下文中一共展示了ObjectUtils.toString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: bestName

import org.apache.commons.lang.ObjectUtils; //导入方法依赖的package包/类
/**
 * Gets the best name for the object from the specified link.
 * <p>
 * This will return a name extracted from the external bundle or object identifier.
 * 
 * @param link  the link, not null
 * @return the best representative name, not null
 */
public static String bestName(Link<?> link) {
  ArgumentChecker.notNull(link, "link");
  ObjectId objectId = link.getObjectId();
  ExternalIdBundle bundle = link.getExternalId();
  if (bundle != null && bundle.size() > 0) {
    if (bundle.getValue(ExternalSchemes.BLOOMBERG_TICKER) != null) {
      return bundle.getValue(ExternalSchemes.BLOOMBERG_TICKER);
    } else if (bundle.getValue(ExternalSchemes.RIC) != null) {
      return bundle.getValue(ExternalSchemes.RIC);
    } else if (bundle.getValue(ExternalSchemes.ACTIVFEED_TICKER) != null) {
      return bundle.getValue(ExternalSchemes.ACTIVFEED_TICKER);
    } else {
      return bundle.getExternalIds().iterator().next().getValue();
    }
  }
  return ObjectUtils.toString(objectId);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:26,代码来源:LinkUtils.java

示例2: setDatapointValue

import org.apache.commons.lang.ObjectUtils; //导入方法依赖的package包/类
@Override
public void setDatapointValue(HmDatapoint dp, String datapointName, Object value) throws HomematicClientException {
	HmInterface hmInterface = dp.getChannel().getDevice().getHmInterface();
	if (hmInterface == HmInterface.VIRTUALDEVICES) {
		String groupName = HmInterface.VIRTUALDEVICES + "." + dp.getChannel().getAddress() + "." + datapointName;
		if (dp.isIntegerValue() && value instanceof Double) {
			value = ((Number) value).intValue();
		}
		String strValue = ObjectUtils.toString(value);
		if (dp.isStringValue()) {
			strValue = "\"" + strValue + "\"";
		}

		HmResult result = sendScriptByName("setVirtualGroup", HmResult.class, new String[] { "group_name",
				"group_state" }, new String[] { groupName, strValue });
		if (!result.isValid()) {
			throw new HomematicClientException("Unable to set CCU group " + groupName);
		}
	} else {
		super.setDatapointValue(dp, datapointName, value);
	}
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:23,代码来源:CcuClient.java

示例3: replaceConfig

import org.apache.commons.lang.ObjectUtils; //导入方法依赖的package包/类
/**
 * Replaces the token with properties of the weather LocationConfig object.
 */
private String replaceConfig(Token token) {
	LocationConfig locationConfig = WeatherContext.getInstance().getConfig().getLocationConfig(locationId);
	if (locationConfig == null) {
		throw new RuntimeException("Weather locationId '" + locationId + "' does not exist");
	}

	if ("latitude".equals(token.name)) {
		return locationConfig.getLatitude().toString();
	} else if ("longitude".equals(token.name)) {
		return locationConfig.getLongitude().toString();
	} else if ("name".equals(token.name)) {
		return locationConfig.getName();
	} else if ("language".equals(token.name)) {
		return locationConfig.getLanguage();
	} else if ("updateInterval".equals(token.name)) {
		return ObjectUtils.toString(locationConfig.getUpdateInterval());
	} else if ("locationId".equals(token.name)) {
		return locationConfig.getLocationId();
	} else if ("providerName".equals(token.name)) {
		return ObjectUtils.toString(locationConfig.getProviderName());
	} else {
		throw new RuntimeException("Invalid weather token: " + token.full);
	}
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:28,代码来源:WeatherTokenResolver.java

示例4: escapeColumnValue

import org.apache.commons.lang.ObjectUtils; //导入方法依赖的package包/类
protected String escapeColumnValue(Object rawValue) {
	if (rawValue == null) {
		return null;
	}
	String returnString = ObjectUtils.toString(rawValue);
	// escape the String to get the tabs, returns, newline explicit as \t \r
	// \n
	returnString = StringEscapeUtils.escapeJava(StringUtils.trimToEmpty(returnString));
	// remove tabs, insert four whitespaces instead
	returnString = StringUtils.replace(StringUtils.trim(returnString), "\\t", "    ");
	// remove the return, only newline valid in excel
	returnString = StringUtils.replace(StringUtils.trim(returnString), "\\r", " ");
	// unescape so that \n gets back to newline
	returnString = StringEscapeUtils.unescapeJava(returnString);

	// return returnString;

	Pattern p = Pattern.compile("</?[div|span|a|font|b][^>]*>", Pattern.CASE_INSENSITIVE);
	Matcher m = p.matcher(returnString);
	return m.replaceAll("");
}
 
开发者ID:8090boy,项目名称:gomall.la,代码行数:22,代码来源:SimpleChineseExcelView.java

示例5: escapeColumnValue

import org.apache.commons.lang.ObjectUtils; //导入方法依赖的package包/类
protected String escapeColumnValue(Object rawValue) {
	if (rawValue == null) {
		return null;
	}
	String returnString = ObjectUtils.toString(rawValue);
	// escape the String to get the tabs, returns, newline explicit as \t \r
	// \n
	returnString = StringEscapeUtils.escapeJava(StringUtils.trimToEmpty(returnString));
	// remove tabs, insert four whitespaces instead
	returnString = StringUtils.replace(StringUtils.trim(returnString), "\\t", "    ");
	// remove the return, only newline valid in excel
	returnString = StringUtils.replace(StringUtils.trim(returnString), "\\r", " ");
	// unescape so that \n gets back to newline
	returnString = StringEscapeUtils.unescapeJava(returnString);

	// return returnString;

	Pattern p = Pattern.compile("</?[div|span|a|font][^>]*>", Pattern.CASE_INSENSITIVE);
	Matcher m = p.matcher(returnString);
	return m.replaceAll("");
}
 
开发者ID:8090boy,项目名称:gomall.la,代码行数:22,代码来源:SimpleChineseCsvView.java

示例6: getKey

import org.apache.commons.lang.ObjectUtils; //导入方法依赖的package包/类
/**
 * 取得对应的key String
 * 
 * @param key
 * @return
 */
private String getKey(Object key) {
    if (key == null) {
        throw new IllegalArgumentException("Cache key not be null");
    }

    return ObjectUtils.toString(key);
}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:14,代码来源:RefreshMemoryMirror.java

示例7: getStringArray

import org.apache.commons.lang.ObjectUtils; //导入方法依赖的package包/类
@Override
public String[] getStringArray(String key) {
	Object value = getProperty(key);

	String[] array;

	if (value instanceof String) {
		array = new String[1];

		array[0] = (String) value;
	} else if (value instanceof List) {
		List<?> list = (List<?>) value;
		array = new String[list.size()];

		for (int i = 0; i < array.length; i++) {
			array[i] = ObjectUtils.toString(list.get(i), null);
		}
	} else if (value == null) {
		array = new String[0];
	} else if (isScalarValue(value)) {
		array = new String[1];
		array[0] = value.toString();
	} else {
		throw new ConversionException('\'' + key
				+ "' doesn't map to a String/List object");
	}
	return array;
}
 
开发者ID:lodsve,项目名称:lodsve-framework,代码行数:29,代码来源:AbstractConfiguration.java

示例8: join

import org.apache.commons.lang.ObjectUtils; //导入方法依赖的package包/类
public static String join(Iterator iterator, String separator, StringJoinCursor cursor) {
	// handle null, zero and one elements before building a buffer
	if (iterator == null) {
		return null;
	}
	if (!iterator.hasNext()) {
		return EMPTY;
	}
	Object first = iterator.next();
	if (!iterator.hasNext()) {
		return ObjectUtils.toString(cursor.getValue(first));
	}

	// two or more elements
	StrBuilder buf = new StrBuilder(256); // Java default is 16, probably
	// too small
	if (first != null) {
		buf.append(cursor.getValue(first));
	}

	while (iterator.hasNext()) {
		if (separator != null) {
			buf.append(separator);
		}
		Object obj = iterator.next();
		if (obj != null) {
			buf.append(cursor.getValue(obj));
		}
	}
	return buf.toString();
}
 
开发者ID:Pardus-LiderAhenk,项目名称:lider,代码行数:32,代码来源:LiderCoreUtils.java

示例9: ensureActive

import org.apache.commons.lang.ObjectUtils; //导入方法依赖的package包/类
public void ensureActive(Object... values) {
    Row row = null;
    ListIterator<Row> iterator = rows.listIterator();
    while(iterator.hasNext()) {
        Row current = iterator.next();
        boolean found = true;
        for(int i = 0; i < fieldCount; i++) {
            if(!ObjectUtils.equals(values[i], current.getValues()[i])) {
                found = false;
                break;
            }
        }
        if(found) {
            row = new Row(values, current.getLabels(), true);
            iterator.set(row);
            break;
        }
    }
    if(row == null) {
        String[] labels = new String[fieldCount];
        for(int i = 0; i < fieldCount; i++) {
            labels[i] = ObjectUtils.toString(values[i]);
        }
        row = new Row(values, labels, true);
        rows.add(row);
    }
}
 
开发者ID:ManyDesigns,项目名称:Portofino,代码行数:28,代码来源:DefaultSelectionProvider.java

示例10: lookup

import org.apache.commons.lang.ObjectUtils; //导入方法依赖的package包/类
@Override
public String lookup(String key) {
    try {
        PropertyAccessor property = accessor.getProperty(key);
        return ObjectUtils.toString(property.get(bean));
    } catch (NoSuchFieldException e) {
        logger.warn("Cannot access property '{}' on class '{}'",
                key,
                accessor.getName());
        return null;
    }
}
 
开发者ID:ManyDesigns,项目名称:Portofino,代码行数:13,代码来源:BeanLookup.java

示例11: setVariable

import org.apache.commons.lang.ObjectUtils; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void setVariable(HmValueItem hmValueItem, Object value) throws HomematicClientException {
	String strValue = ObjectUtils.toString(value);
	if (hmValueItem.isStringValue()) {
		strValue = "\"" + strValue + "\"";
	}
	logger.debug("Sending {} with value '{}' to CCU", hmValueItem.getName(), strValue);
	HmResult result = sendScriptByName("setVariable", HmResult.class, new String[] { "variable_name",
			"variable_state" }, new String[] { hmValueItem.getName(), strValue });
	if (!result.isValid()) {
		throw new HomematicClientException("Unable to set CCU variable " + hmValueItem.getName());
	}
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:17,代码来源:CcuClient.java

示例12: parseDatapoint

import org.apache.commons.lang.ObjectUtils; //导入方法依赖的package包/类
/**
 * Parses the datapoint informations into the binding model.
 */
private HmDatapoint parseDatapoint(HmChannel channel, String name, Map<String, ?> dpData)
		throws IllegalAccessException {
	HmDatapoint dp = new HmDatapoint();
	dp.setName(name);
	FieldUtils.writeField(dp, "channel", channel, true);
	FieldUtils.writeField(dp, "writeable", dpData.get("WRITEABLE"), true);

	Object valueList = dpData.get("VALUE_LIST");
	if (valueList != null && valueList instanceof Object[]) {
		Object[] vl = (Object[]) valueList;
		String[] stringArray = new String[vl.length];
		for (int i = 0; i < vl.length; i++) {
			stringArray[i] = vl[i].toString();
		}
		FieldUtils.writeField(dp, "valueList", stringArray, true);
	}

	Object value = dpData.get("VALUE");

	String type = (String) dpData.get("TYPE");
	boolean isString = StringUtils.equals("STRING", type);
	if (isString && value != null && !(value instanceof String)) {
		value = ObjectUtils.toString(value);
	}
	setValueType(dp, type, value);

	if (dp.isNumberValueType()) {
		FieldUtils.writeField(dp, "minValue", dpData.get("MIN"), true);
		FieldUtils.writeField(dp, "maxValue", dpData.get("MAX"), true);
	}

	dp.setValue(value);
	return dp;
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:38,代码来源:HomegearClient.java

示例13: replaceWeather

import org.apache.commons.lang.ObjectUtils; //导入方法依赖的package包/类
/**
 * Replaces the token with a property of the weather object.
 */
private String replaceWeather(Token token, Weather instance) throws Exception {
	if (!PropertyUtils.hasProperty(instance, token.name)) {
		throw new RuntimeException("Invalid weather token: " + token.full);
	}
	return ObjectUtils.toString(PropertyUtils.getPropertyValue(instance, token.name));
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:10,代码来源:WeatherTokenResolver.java

示例14: buildComparativeCondition

import org.apache.commons.lang.ObjectUtils; //导入方法依赖的package包/类
private static String buildComparativeCondition(String key, Object value) {
    String type = "s";
    if (value instanceof Number) {
        type = "l";
    }
    return key + "=" + ObjectUtils.toString(value) + ":" + type;
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:8,代码来源:HintRouter.java

示例15: chooseIndex

import org.apache.commons.lang.ObjectUtils; //导入方法依赖的package包/类
private static boolean chooseIndex(Map<String, Object> extraCmd) {
    String ifChooseIndex = ObjectUtils.toString(GeneralUtil.getExtraCmdString(extraCmd,
        ExtraCmd.CHOOSE_INDEX));
    // 默认返回true
    if (StringUtils.isEmpty(ifChooseIndex)) {
        return true;
    } else {
        return BooleanUtils.toBoolean(ifChooseIndex);
    }
}
 
开发者ID:beebeandwer,项目名称:TDDL,代码行数:11,代码来源:IndexChooser.java


注:本文中的org.apache.commons.lang.ObjectUtils.toString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。