本文整理匯總了Java中org.eclipse.emf.ecore.EFactory.convertToString方法的典型用法代碼示例。如果您正苦於以下問題:Java EFactory.convertToString方法的具體用法?Java EFactory.convertToString怎麽用?Java EFactory.convertToString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.emf.ecore.EFactory
的用法示例。
在下文中一共展示了EFactory.convertToString方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getParameterString
import org.eclipse.emf.ecore.EFactory; //導入方法依賴的package包/類
/**
* Get the value of the named AD parameter for the activity as a string.
* Works with several types, not just strings -- enums, for example.
* @param element
* @param parameterName
* @return null if the parameter is not found
*/
public static String getParameterString(EPlanElement element, String parameterName) {
EObject data = element.getData();
if (data==null) return null;
EStructuralFeature feature;
try {
feature = getParameterFeature(data, parameterName);
} catch (UndefinedParameterException e) {
return null;
}
Object object = data.eGet(feature);
if (object instanceof EEnumLiteral) {
EEnumLiteral literal = (EEnumLiteral) object;
return literal.getName();
}
EClassifier type = feature.getEType();
if (type instanceof EDataType) {
EDataType dataType = (EDataType) type;
EPackage typePackage = dataType.getEPackage();
EFactory factory = typePackage.getEFactoryInstance();
String string = factory.convertToString(dataType, object);
return string;
}
LogUtil.warnOnce("feature type '" + type + "'is not EDataType: " + parameterName);
return String.valueOf(object);
}
示例2: getObjectString
import org.eclipse.emf.ecore.EFactory; //導入方法依賴的package包/類
public static String getObjectString(EObject object, String parameterName) {
EStructuralFeature feature;
try {
feature = getParameterFeature(object, parameterName);
} catch (UndefinedParameterException e) {
return null;
}
Object value = object.eGet(feature);
if (value instanceof EEnumLiteral) {
EEnumLiteral literal = (EEnumLiteral) value;
return literal.getName();
}
EClassifier type = feature.getEType();
if (type instanceof EDataType) {
EDataType dataType = (EDataType) type;
EPackage typePackage = dataType.getEPackage();
EFactory factory = typePackage.getEFactoryInstance();
String string = factory.convertToString(dataType, value);
return string;
}
LogUtil.warnOnce("feature type '" + type + "'is not EDataType: " + parameterName);
return String.valueOf(value);
}
示例3: eEncodeValue
import org.eclipse.emf.ecore.EFactory; //導入方法依賴的package包/類
private static void eEncodeValue(StringBuilder result, EFactory eFactory, EDataType eDataType, Object value)
{
String stringValue = eFactory.convertToString(eDataType, value);
if (stringValue == null)
{
result.append("null");
}
else
{
int length = stringValue.length();
result.ensureCapacity(result.length() + length + 2);
result.append('\'');
for (int i = 0; i < length; ++i)
{
char character = stringValue.charAt(i);
if (character < ESCAPE.length)
{
String escape = ESCAPE[character];
if (escape != null)
{
result.append(escape);
continue;
}
}
result.append(character);
}
result.append('\'');
}
}
示例4: setDefaultValue
import org.eclipse.emf.ecore.EFactory; //導入方法依賴的package包/類
public void setDefaultValue(Object newDefaultValue)
{
EClassifier eType = getEType();
if (eType instanceof EDataType)
{
EFactory factory = eType.getEPackage().getEFactoryInstance();
String literal = factory.convertToString((EDataType)eType, newDefaultValue);
defaultValueFactory = null;
setDefaultValueLiteralGen(literal);
return;
}
throw new IllegalStateException("Cannot serialize value to object without an EDataType eType");
}