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


Java EFactory.convertToString方法代码示例

本文整理汇总了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);
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:33,代码来源:ADParameterUtils.java

示例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);
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:24,代码来源:ADParameterUtils.java

示例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('\'');
  }
}
 
开发者ID:LangleyStudios,项目名称:eclipse-avro,代码行数:30,代码来源:BasicEObjectImpl.java

示例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");
}
 
开发者ID:LangleyStudios,项目名称:eclipse-avro,代码行数:14,代码来源:EStructuralFeatureImpl.java


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