當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。