當前位置: 首頁>>代碼示例>>Java>>正文


Java EFactory.createFromString方法代碼示例

本文整理匯總了Java中org.eclipse.emf.ecore.EFactory.createFromString方法的典型用法代碼示例。如果您正苦於以下問題:Java EFactory.createFromString方法的具體用法?Java EFactory.createFromString怎麽用?Java EFactory.createFromString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.emf.ecore.EFactory的用法示例。


在下文中一共展示了EFactory.createFromString方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: fromEnum

import org.eclipse.emf.ecore.EFactory; //導入方法依賴的package包/類
private static Object fromEnum(final EFactory eFactory, final EClass eClass,
		final EObject eObject, final AttributeSlot slot,
		final EStructuralFeature feature, final EEnum enumType)
		throws IOException {
	if (!slot.value.isSetVStrings() && !slot.value.isSetVString()) {
		throw new IOException(
			String.format(
				"Expected to receive strings for feature '%s' in type '%s' with many='%s', but did not",
				feature.getName(), eClass.getName(), feature.isMany()));
	} else if (feature.isMany()) {
		final List<Object> literals = new ArrayList<>();
		if (slot.value.isSetVStrings()) {
			for (final String s : slot.value.getVStrings()) {
				literals.add(eFactory.createFromString(enumType, s));
			}
		} else {
			literals.add(eFactory.createFromString(enumType, slot.value.getVString()));
		}
		eObject.eSet(feature, literals);
		return literals;
	} else {
		final Object enumLiteral = eFactory.createFromString(enumType, slot.value.getVString());
		eObject.eSet(feature, enumLiteral);
		return enumLiteral;
	}
}
 
開發者ID:mondo-project,項目名稱:mondo-integration,代碼行數:27,代碼來源:SlotDecodingUtils.java

示例2: setScalarAttribute

import org.eclipse.emf.ecore.EFactory; //導入方法依賴的package包/類
private static Object setScalarAttribute(final EFactory eFactory, final EObject eObject, final Object value,
		final EStructuralFeature feature) {
	final Object singleValue = normalizeIntoScalar(value);
	if (singleValue == null) {
		eObject.eUnset(feature);
		return null;
	}

	final EClassifier eType = feature.getEType();
	if (eType instanceof EEnum) {
		final EEnum enumType = (EEnum)eType;
		final Object literal = eFactory.createFromString(enumType, singleValue.toString());
		eObject.eSet(feature, literal);
		return literal;
	} else {
		eObject.eSet(feature, singleValue);
		return singleValue;
	}
}
 
開發者ID:mondo-project,項目名稱:mondo-hawk,代碼行數:20,代碼來源:AttributeUtils.java

示例3: setParameterStringInData

import org.eclipse.emf.ecore.EFactory; //導入方法依賴的package包/類
/** Use setParameterString instead, unless calling from an XML loader that has not yet created the plan element. */
public static void setParameterStringInData(EObject data, String parameterName, String newValue) throws UndefinedParameterException {
	EStructuralFeature feature = getParameterFeature(data, parameterName);
	EClassifier type = feature.getEType();
	Object object;
	if (type instanceof EEnum) {
		EEnum enumType = (EEnum) type;
		object = enumType.getEEnumLiteral(newValue);
	} else if (type instanceof EDataType) {
		EDataType dataType = (EDataType) type;
		EPackage typePackage = dataType.getEPackage();
		EFactory factory = typePackage.getEFactoryInstance();
		object = factory.createFromString(dataType, newValue);
	} else {
		Logger logger = Logger.getLogger(ADParameterUtils.class);
		logger.warn("feature type '" + type + "'is not EDataType: " + parameterName);
		object = newValue;
	}
	data.eSet(feature, object);
}
 
開發者ID:nasa,項目名稱:OpenSPIFe,代碼行數:21,代碼來源:ADParameterUtils.java

示例4: addParameterStringToList

import org.eclipse.emf.ecore.EFactory; //導入方法依賴的package包/類
/**
 * Add a value to a named AD multi-select EEnum parameter for the activity
 * @param element
 * @param parameterName
 * @param newValue
 * @throws UndefinedParameterException
 */
@SuppressWarnings("unchecked")
public static void addParameterStringToList(EPlanElement element, String parameterName, String newValue) throws UndefinedParameterException {
	EObject data = element.getData();
	EStructuralFeature feature = getParameterFeature(data, parameterName);
	EClassifier type = feature.getEType();
	Object object;
	if (type instanceof EEnum) {
		EEnum enumType = (EEnum) type;
		object = enumType.getEEnumLiteral(newValue);
	} else if (type instanceof EDataType) {
		EDataType dataType = (EDataType) type;
		EPackage typePackage = dataType.getEPackage();
		EFactory factory = typePackage.getEFactoryInstance();
		object = factory.createFromString(dataType, newValue);
	} else {
		Logger logger = Logger.getLogger(ADParameterUtils.class);
		logger.warn("feature type '" + type + "'is not EDataType: " + parameterName);
		object = newValue;
	}
	addParameterObjectToList(element, parameterName, object);
}
 
開發者ID:nasa,項目名稱:OpenSPIFe,代碼行數:29,代碼來源:ADParameterUtils.java

示例5: parseValue

import org.eclipse.emf.ecore.EFactory; //導入方法依賴的package包/類
private Object parseValue(Profile profile, String valueLiteral) throws ParseException {
	Object value = null;
	if (valueLiteral == null) {
		return null;
	} else {
		EDataType dataType = profile.getDataType();
		try {
			if (dataType != null) {
				EPackage ePackage = dataType.getEPackage();
				EFactory eFactory = ePackage.getEFactoryInstance();
				value = eFactory.createFromString(dataType, valueLiteral);
			}
		} catch (Exception x) {
			if (EcorePackage.Literals.EINT == dataType
					|| EcorePackage.Literals.EINTEGER_OBJECT == dataType) {
				try {
					Double doubleValue = Double.parseDouble(valueLiteral);
					int intValue = doubleValue.intValue();
					if (doubleValue == intValue) {
						return intValue;
					}
				} catch (Exception e) {
					// tried to parse double as an integer
				}
			}
		}
		if (value == null) {
			throw new ParseException("Cannot parse "+valueLiteral, 0);
		}
	}
	return value;
}
 
開發者ID:nasa,項目名稱:OpenSPIFe,代碼行數:33,代碼來源:ProfileConstraintPlanAdvisor.java

示例6: getComboBoxObjects

import org.eclipse.emf.ecore.EFactory; //導入方法依賴的package包/類
private Collection<Object> getComboBoxObjects(EStructuralFeature feature) {
  Collection<Object> comboBoxObjects = null;
  if (feature instanceof EAttributeParameter) {
  	boolean allValues = true;
  	List<String> choiceValues = new ArrayList<String>();
  	EAttributeParameter pDef = (EAttributeParameter) feature;
  	EDataType eDataType = (EDataType) pDef.getEType();
  	if (eDataType == null) {
  		LogUtil.error("null EDataType for parameter: " + pDef.getName());
  		return null;
  	}
  	EPackage ePackage = eDataType.getEPackage();
EFactory eFactory = ePackage.getEFactoryInstance();
  	for (EChoice choice : pDef.getChoices()) {
  		String choiceValue = choice.getValue();
  		if (choiceValue != null) {
  			choiceValues.add(choiceValue);
  		} else {
  			allValues = false;
  			break;
  		}
  	}
  	if (allValues && !choiceValues.isEmpty()) {
  		comboBoxObjects = new ArrayList<Object>();
  		for (String valueLiteral : choiceValues) {
  			Object value = eFactory.createFromString(eDataType, valueLiteral);
  			comboBoxObjects.add(value);
  		}
  	}
  }
  return comboBoxObjects;
 }
 
開發者ID:nasa,項目名稱:OpenSPIFe,代碼行數:33,代碼來源:ADParameterObjectItemProvider.java

示例7: getDefaultValue

import org.eclipse.emf.ecore.EFactory; //導入方法依賴的package包/類
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated modifiable
 */
public Object getDefaultValue()
{
  EClassifier eType = getEType();
  String literal = getDefaultValueLiteral();

  if (literal == null && eType != null)
  {
    return isMany()? null : eType.getDefaultValue();
  }
  else if (eType instanceof EDataType)
  {
    EFactory factory = eType.getEPackage().getEFactoryInstance();
    if (factory != defaultValueFactory)
    {
      EDataType eDataType = (EDataType)eType;
      if (eDataType.isSerializable())
      {
        try
        {
          defaultValue = factory.createFromString(eDataType, literal);
        }
        catch (Throwable e)
        {
          // At development time, the real factory may not be available. Just return null.
          //
          defaultValue = null;
        }
      }
      defaultValueFactory = factory;
    }
    return defaultValue;
  }
  return null;
}
 
開發者ID:LangleyStudios,項目名稱:eclipse-avro,代碼行數:40,代碼來源:EStructuralFeatureImpl.java

示例8: eDecodeValue

import org.eclipse.emf.ecore.EFactory; //導入方法依賴的package包/類
private static Object eDecodeValue(String encodedValue, EFactory eFactory, EDataType eDataType)
{
  String literal = URI.decode(encodedValue);
  Object value = eFactory.createFromString(eDataType, literal);
  return value;
}
 
開發者ID:LangleyStudios,項目名稱:eclipse-avro,代碼行數:7,代碼來源:BasicEObjectImpl.java


注:本文中的org.eclipse.emf.ecore.EFactory.createFromString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。