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