本文整理汇总了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");
}