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


Java EStructuralFeature.isMany方法代码示例

本文整理汇总了Java中org.eclipse.emf.ecore.EStructuralFeature.isMany方法的典型用法代码示例。如果您正苦于以下问题:Java EStructuralFeature.isMany方法的具体用法?Java EStructuralFeature.isMany怎么用?Java EStructuralFeature.isMany使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.emf.ecore.EStructuralFeature的用法示例。


在下文中一共展示了EStructuralFeature.isMany方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processObject

import org.eclipse.emf.ecore.EStructuralFeature; //导入方法依赖的package包/类
public void processObject(IdEObject originObject, Map<Integer, IdEObject> result) {
	if (result.containsValue(originObject)) {
		return;
	}
	result.put(originObject.getExpressId(), originObject);
	for (EStructuralFeature feature : originObject.eClass().getEAllStructuralFeatures()) {
		if (getPackageMetaData().useForDatabaseStorage(originObject.eClass(), feature)) {
			if (feature.isMany()) {
				processList(originObject, feature, result);
			} else {
				Object value = originObject.eGet(feature);
				if (feature.getEType() instanceof EClass) {
					if (value != null) {
						IdEObject referencedObject = (IdEObject) value;
						processObject(referencedObject, result);
					}
				} 
			}
		}
	}
}
 
开发者ID:shenan4321,项目名称:BIMplatform,代码行数:22,代码来源:SplitIfcModel.java

示例2: writeEClass

import org.eclipse.emf.ecore.EStructuralFeature; //导入方法依赖的package包/类
private void writeEClass(IdEObject object, EStructuralFeature feature) throws SerializerException, IOException {
	Object referencedObject = object.eGet(feature);
	if (referencedObject instanceof IdEObject && ((IdEObject)referencedObject).eClass().getEAnnotation("wrapped") != null) {
		writeWrappedValue(object, feature, ((EObject)referencedObject).eClass());
	} else {
		if (referencedObject instanceof EObject && model.contains((IdEObject) referencedObject)) {
			print(DASH);
			print(String.valueOf(getExpressId((IdEObject) referencedObject)));
		} else {
			EntityDefinition entityBN = getPackageMetaData().getSchemaDefinition().getEntityBN(object.eClass().getName());
			if (entityBN != null && entityBN.isDerived(feature.getName())) {
				print(ASTERISK);
			} else if (feature.isMany()) {
				writeList(object, feature);
			} else {
				writeObject(object, feature);
			}
		}
	}
}
 
开发者ID:shenan4321,项目名称:BIMplatform,代码行数:21,代码来源:IfcStepSerializer.java

示例3: writeEDataType

import org.eclipse.emf.ecore.EStructuralFeature; //导入方法依赖的package包/类
private void writeEDataType(VirtualObject object, EntityDefinition entityBN, EStructuralFeature feature)
		throws SerializerException, IOException {
	if (entityBN != null && entityBN.isDerived(feature.getName())) {
		print(ASTERISK);
	} else if (feature.isMany()) {
		writeList(object, feature);
	} else {
		writeObject(object, feature);
	}
}
 
开发者ID:shenan4321,项目名称:BIMplatform,代码行数:11,代码来源:IfcStepStreamingSerializer.java

示例4: writeEClass

import org.eclipse.emf.ecore.EStructuralFeature; //导入方法依赖的package包/类
private void writeEClass(VirtualObject object, EStructuralFeature feature) throws SerializerException, IOException {
	Object referencedObject = object.eGet(feature);
	if (referencedObject instanceof VirtualObject) {
		EClass referencedObjectEClass = ((VirtualObject) referencedObject).eClass();
		if (referencedObjectEClass.getEAnnotation("wrapped") != null) {
			writeWrappedValue(object, feature, referencedObjectEClass);
		}
	} else {
		if (referencedObject instanceof Long) {
			if (object.useFeatureForSerialization(feature)) {
				print(DASH);
				print(String.valueOf(getExpressId((Long) referencedObject)));
			} else {
				print(DOLLAR);
			}
		} else {
			EClass objectEClass = platformService.getEClassForCid(object.getEClassId());
			EntityDefinition entityBN = getSchemaDefinition().getEntityBN(objectEClass.getName());
			if (entityBN != null && entityBN.isDerived(feature.getName())) {
				print(ASTERISK);
			} else if (feature.isMany()) {
				writeList(object, feature);
			} else {
				writeObject(object, feature);
			}
		}
	}
}
 
开发者ID:shenan4321,项目名称:BIMplatform,代码行数:29,代码来源:IfcStepStreamingSerializer.java

示例5: writeObject

import org.eclipse.emf.ecore.EStructuralFeature; //导入方法依赖的package包/类
private void writeObject(VirtualObject object, EStructuralFeature feature) throws SerializerException, IOException {
	Object ref = object.eGet(feature);
	if (ref == null || (feature.isUnsettable() && !object.eIsSet(feature))) {
		EClassifier type = feature.getEType();
		if (type instanceof EClass) {
			EStructuralFeature structuralFeature = ((EClass) type).getEStructuralFeature(WRAPPED_VALUE);
			if (structuralFeature != null) {
				String name = structuralFeature.getEType().getName();
				if (name.equals(IFC_BOOLEAN) || name.equals(IFC_LOGICAL)
						|| structuralFeature.getEType() == EcorePackage.eINSTANCE.getEBoolean()) {
					print(BOOLEAN_UNDEFINED);
				} else {
					print(DOLLAR);
				}
			} else {
				print(DOLLAR);
			}
		} else {
			if (type == EcorePackage.eINSTANCE.getEBoolean()) {
				print(BOOLEAN_UNDEFINED);
			} else if (feature.isMany()) {
				print("()");
			} else {
				print(DOLLAR);
			}
		}
	} else {
		if (ref instanceof WrappedVirtualObject) {
			writeEmbedded((WrappedVirtualObject) ref);
		} else if (feature.getEType() == ECORE_PACKAGE_INSTANCE.getEDouble()) {
			EStructuralFeature asStringFeature = object.eClass().getEStructuralFeature(feature.getName() + "AsString");
			String asString = (String) object.eGet(asStringFeature);
			writeDoubleValue((Double) ref, asString, feature);
		} else {
			IfcParserWriterUtils.writePrimitive(ref, printWriter);
		}
	}
}
 
开发者ID:shenan4321,项目名称:BIMplatform,代码行数:39,代码来源:IfcStepStreamingSerializer.java

示例6: writeEDataType

import org.eclipse.emf.ecore.EStructuralFeature; //导入方法依赖的package包/类
private void writeEDataType(IdEObject object, EntityDefinition entityBN, EStructuralFeature feature) throws SerializerException, IOException {
	if (entityBN != null && entityBN.isDerived(feature.getName())) {
		print(ASTERISK);
	} else if (feature.isMany()) {
		writeList(object, feature);
	} else {
		writeObject(object, feature);
	}
}
 
开发者ID:shenan4321,项目名称:BIMplatform,代码行数:10,代码来源:IfcStepSerializer.java

示例7: writeObject

import org.eclipse.emf.ecore.EStructuralFeature; //导入方法依赖的package包/类
private void writeObject(IdEObject object, EStructuralFeature feature) throws SerializerException, IOException {
	Object ref = object.eGet(feature);
	if (ref == null || (feature.isUnsettable() && !object.eIsSet(feature))) {
		EClassifier type = feature.getEType();
		if (type instanceof EClass) {
			EStructuralFeature structuralFeature = ((EClass) type).getEStructuralFeature(WRAPPED_VALUE);
			if (structuralFeature != null) {
				String name = structuralFeature.getEType().getName();
				if (name.equals(IFC_BOOLEAN) || name.equals(IFC_LOGICAL) || structuralFeature.getEType() == EcorePackage.eINSTANCE.getEBoolean()) {
					print(BOOLEAN_UNDEFINED);
				} else {
					print(DOLLAR);
				}
			} else {
				print(DOLLAR);
			}
		} else {
			if (type == EcorePackage.eINSTANCE.getEBoolean()) {
				print(BOOLEAN_UNDEFINED);
			} else if (feature.isMany()) {
				print("()");
			} else {
				print(DOLLAR);
			}
		}
	} else {
		if (ref instanceof EObject) {
			writeEmbedded((EObject) ref);
		} else if (feature.getEType() == ECORE_PACKAGE_INSTANCE.getEDouble()) {
			writeDoubleValue((Double)ref, object, feature);
		} else {
			IfcParserWriterUtils.writePrimitive(ref, outputStream);
		}
	}
}
 
开发者ID:shenan4321,项目名称:BIMplatform,代码行数:36,代码来源:IfcStepSerializer.java

示例8: convert

import org.eclipse.emf.ecore.EStructuralFeature; //导入方法依赖的package包/类
@SuppressWarnings ( "unchecked" )
private EObject convert ( final SingleValue v )
{
    final ExternalValue result = ComponentFactory.eINSTANCE.createExternalValue ();

    for ( final EStructuralFeature sf : ComponentPackage.Literals.SINGLE_VALUE.getEAllStructuralFeatures () )
    {
        final Object value = v.eGet ( sf, true );

        Object nv = value;

        if ( sf instanceof EReference )
        {
            if ( ( (EReference)sf ).isContainment () )
            {
                if ( sf.isMany () )
                {
                    nv = EcoreUtil.copyAll ( (Collection<EObject>)value );
                }
                else
                {
                    nv = EcoreUtil.copy ( (EObject)value );
                }
            }
        }

        result.eSet ( sf, nv );
    }

    return result;
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:32,代码来源:ConvertToExternalHandler.java

示例9: visit

import org.eclipse.emf.ecore.EStructuralFeature; //导入方法依赖的package包/类
@Override
public void visit(TupleValue tupleval, String param) {
    if (hasElement(tupleval)) {
        return;
    }

    Tuple tuple = (Tuple) tupleval.getType();
    EClass tupleClass = this.m_typeToEcore.getTupleClass(tuple);

    EObject tupleObject = tupleClass.getEPackage()
        .getEFactoryInstance()
        .create(tupleClass);
    setElement(tupleval, tupleObject);
    this.m_eObjects.add(tupleObject);

    for (Entry<Integer,Value> entry : tupleval.getValue()
        .entrySet()) {
        String indexName = this.m_typeToEcore.getTupleElementName(tuple, entry.getKey());
        EStructuralFeature eFeature = tupleClass.getEStructuralFeature(indexName);
        Value tupValue = entry.getValue();
        if (eFeature.isMany()) {
            // Expecting a container value, which will be iterated with all elements added to the (implicit) ELIST
            ContainerValue cv = (ContainerValue) tupValue;
            @SuppressWarnings("unchecked") EList<Object> objectList =
                (EList<Object>) tupleObject.eGet(eFeature);
            for (Value subValue : cv.getValue()) {
                Object eSubValue = getElement(subValue);
                objectList.add(eSubValue);
            }
        } else {
            // Just insert the value directly
            Object eValue = getElement(tupValue);
            tupleObject.eSet(eFeature, eValue);
        }
    }
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:37,代码来源:InstanceToEcore.java

示例10: eSetStructuralFeatureByName

import org.eclipse.emf.ecore.EStructuralFeature; //导入方法依赖的package包/类
/**
 *
 * @param @EObject object to be set
 * @param name structural feature name
 * @param newVal new value
 */
@SuppressWarnings({"unchecked", "rawtypes"})
public static void eSetStructuralFeatureByName(final EObject eObject, final String name,
    final Object newVal) {
  for (final EStructuralFeature eStructuralFeature : eObject.eClass().getEAllStructuralFeatures()) {
    if (eStructuralFeature.getName().equals(name)) {
      if (eStructuralFeature.isMany()) {
        ((List) eObject.eGet(eStructuralFeature)).add(newVal);
      } else {
        eObject.eSet(eStructuralFeature, newVal);
      }
      break;
    }
  }
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:21,代码来源:EcoreUtilities.java

示例11: merge

import org.eclipse.emf.ecore.EStructuralFeature; //导入方法依赖的package包/类
private EObject merge(final EObject from, final EObject to, final Collection<Object> visitedObjects) {

		if (null == from || null == to) {
			return null;
		}

		// This is against cycles through EReferences.
		if (visitedObjects.contains(from) || visitedObjects.contains(to)) {
			return to;
		}

		visitedObjects.add(to);
		visitedObjects.add(from);

		final Collection<EStructuralFeature> fromFeatures = from.eClass().getEAllStructuralFeatures();

		for (final EStructuralFeature feature : fromFeatures) {
			if (-1 != to.eClass().getFeatureID(feature) && feature.isChangeable()) {
				if (from.eIsSet(feature)) {
					final Object fromValue = from.eGet(feature, true);
					final Object toValue = to.eGet(feature, true);
					if (null == toValue) {
						to.eSet(feature, fromValue);
					} else {
						if (feature.isMany()) {
							@SuppressWarnings("unchecked")
							final Collection<Object> toManyValue = (Collection<Object>) toValue;
							@SuppressWarnings("unchecked")
							final Collection<Object> fromManyValue = (Collection<Object>) fromValue;
							for (final Iterator<Object> itr = fromManyValue.iterator(); itr.hasNext(); /**/) {
								final Object fromElement = itr.next();
								if (!contains(toManyValue, fromElement)) {
									itr.remove();
									toManyValue.add(fromElement);
								}
							}
						} else {
							if (feature instanceof EAttribute) {
								to.eSet(feature, fromValue);
							} else if (feature instanceof EReference) {
								to.eSet(feature, merge((EObject) fromValue, (EObject) toValue, visitedObjects));
							}
						}
					}
				}
			}
		}
		return to;
	}
 
开发者ID:eclipse,项目名称:n4js,代码行数:50,代码来源:EObjectFeatureMerger.java

示例12: 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;
	}
 
开发者ID:shenan4321,项目名称:BIMplatform,代码行数:81,代码来源:IfcStepStreamingDeserializer.java

示例13: encode

import org.eclipse.emf.ecore.EStructuralFeature; //导入方法依赖的package包/类
public static void encode ( final Map<String, String> data, final String prefix, final EObject object )
{
    if ( object == null )
    {
        return;
    }

    for ( final EStructuralFeature sf : object.eClass ().getEAllStructuralFeatures () )
    {
        if ( sf.isMany () )
        {
            continue;
        }

        final EAnnotation an = sf.getEAnnotation ( "http://eclipse.org/SCADA/CA/Descriptor" ); //$NON-NLS-1$
        if ( an == null )
        {
            continue;
        }
        final String name = an.getDetails ().get ( "name" ); //$NON-NLS-1$
        if ( name == null )
        {
            continue;
        }
        final String format = an.getDetails ().get ( "format" ); //$NON-NLS-1$

        String key;
        String value;

        if ( prefix != null )
        {
            key = prefix + "." + name;
        }
        else
        {
            key = name;
        }

        final Object v = object.eGet ( sf );
        if ( v == null )
        {
            continue;
        }

        if ( format != null )
        {
            value = String.format ( format, v );
        }
        else
        {
            value = v == null ? null : v.toString ();
        }

        data.put ( key, value );
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:57,代码来源:Configurations.java


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