本文整理汇总了Java中org.eclipse.emf.ecore.EStructuralFeature.getName方法的典型用法代码示例。如果您正苦于以下问题:Java EStructuralFeature.getName方法的具体用法?Java EStructuralFeature.getName怎么用?Java EStructuralFeature.getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.emf.ecore.EStructuralFeature
的用法示例。
在下文中一共展示了EStructuralFeature.getName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addUseForSerialization
import org.eclipse.emf.ecore.EStructuralFeature; //导入方法依赖的package包/类
public void addUseForSerialization(EStructuralFeature eStructuralFeature) {
if (eStructuralFeature.getEContainingClass().isSuperTypeOf(eClass)) {
useForSerializationFeatures.put(eStructuralFeature, true);
} else {
throw new IllegalArgumentException(eStructuralFeature.getName() + " does not exist in " + eClass.getName());
}
}
示例2: instanceToString
import org.eclipse.emf.ecore.EStructuralFeature; //导入方法依赖的package包/类
/**
* Returns the text of element which given from Instance
*/
public static String instanceToString(final EObject element) {
final EClass clazz = element.eClass();
String text = clazz.getName() + " ";
final EList<EStructuralFeature> structuralFeatures = clazz.getEStructuralFeatures();
for (final EStructuralFeature eStructuralFeature : structuralFeatures) {
if (!(eStructuralFeature instanceof EReference)) {
text += eStructuralFeature.getName() + " = " + element.eGet(eStructuralFeature) + " ";
}
}
return text == null ? "" : text;
}
示例3: readList
import org.eclipse.emf.ecore.EStructuralFeature; //导入方法依赖的package包/类
private boolean readList(String val, VirtualObject object, EStructuralFeature structuralFeature) throws DeserializeException, MetaDataException, DatabaseException {
int index = 0;
if (!structuralFeature.isMany()) {
throw new DeserializeException(lineNumber, "Field " + structuralFeature.getName() + " of " + structuralFeature.getEContainingClass().getName() + " is no aggregation");
}
boolean isDouble = structuralFeature.getEType() == EcorePackage.eINSTANCE.getEDouble();
EStructuralFeature doubleStringFeature = null;
if (isDouble) {
doubleStringFeature = structuralFeature.getEContainingClass().getEStructuralFeature(structuralFeature.getName() + "AsString");
if (doubleStringFeature == null) {//linfujun, i change the code here to fix the bug
doubleStringFeature = structuralFeature.getEContainingClass().getEStructuralFeature(structuralFeature.getFeatureID());
}
if (doubleStringFeature == null) {
throw new DeserializeException(lineNumber, "Field not found: " + structuralFeature.getName() + "AsString");
}
}
String realData = val.substring(1, val.length() - 1);
int lastIndex = 0;
// object.startList(structuralFeature);
// TODO not always instantiate
List<String> doubles = new ArrayList<>();
boolean complete = true;
while (lastIndex != realData.length() + 1) {
int nextIndex = StringUtils.nextString(realData, lastIndex);
String stringValue = realData.substring(lastIndex, nextIndex - 1).trim();
lastIndex = nextIndex;
if (stringValue.length() > 0) {
if (stringValue.charAt(0) == '#') {
Integer referenceId = Integer.parseInt(stringValue.substring(1));
if (mappedObjects.containsKey(referenceId)) {
Long referencedOid = mappedObjects.get(referenceId);
if (referencedOid != null) {
EClass referenceEClass = catalogService.getEClassForOid(referencedOid);
if (((EClass) structuralFeature.getEType()).isSuperTypeOf(referenceEClass)) {
// TODO unique checking?
object.setListItemReference(structuralFeature, index, referencedOid);
} else {
throw new DeserializeException(lineNumber, referenceEClass.getName() + " cannot be stored in " + structuralFeature.getName());
}
}
} else {
// int pos = object.reserveSpaceForListReference();
waitingList.add(referenceId, new ListWaitingVirtualObject(lineNumber, object, structuralFeature, index));
complete = false;
}
} else if (stringValue.charAt(0) == '(') {
// Two dimensional list
EClass newObjectEClass = (EClass) structuralFeature.getEType();
VirtualObject newObject = newVirtualObject((EClass) structuralFeature.getEType());
readList(stringValue, newObject, newObjectEClass.getEStructuralFeature("List"));
// TODO unique?
object.setListItemReference(structuralFeature, index, newObject.getOid());
} else {
Object convert = convert(structuralFeature.getEType(), stringValue);
if (convert != null) {
object.setListItem(structuralFeature, index, convert);
if (isDouble) {
doubles.add(stringValue);
}
}
}
}
index++;
}
// object.endList();
// TODO make more efficient
if (isDouble) {
// object.startList(doubleStringFeature);
int i=0;
for (String d : doubles) {
if (doubleStringFeature.getEType() == EcorePackage.eINSTANCE.getEDouble()) {//linfujun, i change the code here to fix the bug
object.setListItem(doubleStringFeature, i++, Double.parseDouble(d));
} else {
object.setListItem(doubleStringFeature, i++, d);
}
}
// object.endList();
}
return complete;
}