private int estimateBufferSize(EClass eClass) { int size = 0; for (EStructuralFeature eStructuralFeature : eClass.getEAllStructuralFeatures()) { if (eStructuralFeature instanceof EAttribute) { EAttribute eAttribute = (EAttribute)eStructuralFeature; if (eAttribute.isMany()) { size += 2 + AVERAGE_PRIMITIVE_LIST_SIZE * getPrimitiveSize((EDataType) eAttribute.getEType()); } else { size += getPrimitiveSize((EDataType) eAttribute.getEType()); } } else if (eStructuralFeature instanceof EReference) { EReference eReference = (EReference)eStructuralFeature; if (eReference.isMany()) { size += 2 + AVERAGE_REFERENCE_LIST_SIZE * 10; } else { size += 10; } } } return size; }
System.out.println("#" + key + " " + object.eClass().getName()); for (EAttribute attribute : object.eClass().getEAllAttributes()) { System.out.println("\t" + attribute.getName() + "(" + attribute.getEType().getName() + "): " + object.eGet(attribute));
if (eAttribute.getEType() instanceof EEnum) { stringBuffer.append(eAttribute.getEType().getName()); stringBuffer.append(TEXT_37); stringBuffer.append(StringUtils.firstUpperCase(eAttribute.getName())); stringBuffer.append(StringUtils.firstUpperCase(eAttribute.getName())); stringBuffer.append(TEXT_40); stringBuffer.append(eAttribute.getEType() == EcorePackage.eINSTANCE.getEBoolean() ? "is" : "get"); stringBuffer.append(StringUtils.firstUpperCase(eAttribute.getName())); stringBuffer.append(TEXT_41); stringBuffer.append(StringUtils.firstUpperCase(eAttribute.getName())); stringBuffer.append(TEXT_42); stringBuffer.append(eAttribute.getEType() == EcorePackage.eINSTANCE.getEBoolean() ? "is" : "get"); stringBuffer.append(StringUtils.firstUpperCase(eAttribute.getName())); stringBuffer.append(TEXT_41); if (eAttribute.getEType() instanceof EEnum) { stringBuffer.append(eAttribute.getEType().getName()); stringBuffer.append(TEXT_37); stringBuffer.append(StringUtils.firstUpperCase(eAttribute.getName())); stringBuffer.append(StringUtils.firstUpperCase(eAttribute.getName())); stringBuffer.append(TEXT_40); stringBuffer.append(eAttribute.getEType() == EcorePackage.eINSTANCE.getEBoolean() ? "is" : "get"); stringBuffer.append(StringUtils.firstUpperCase(eAttribute.getName())); stringBuffer.append(TEXT_41);
@SuppressWarnings({ "rawtypes", "unchecked" }) private void setDoubleAsStringValues(IdEObject idEObject) { for (EAttribute eAttribute : idEObject.eClass().getEAllAttributes()) { if (eAttribute.getEType() == EcorePackage.eINSTANCE.getEDouble()) { EStructuralFeature asStringFeature = idEObject.eClass().getEStructuralFeature(eAttribute.getName() + "AsString"); if (asStringFeature != null) { if (eAttribute.isMany()) { List list = (List) idEObject.eGet(eAttribute); List listAsString = (List) idEObject.eGet(asStringFeature); for (int i = 0; i < list.size(); i++) { listAsString.set(i, "" + list.get(i)); } } else { idEObject.eSet(asStringFeature, "" + idEObject.eGet(eAttribute)); } } } } }
if (eStructuralFeature instanceof EAttribute) { EAttribute eAttribute = (EAttribute)eStructuralFeature; if (eAttribute.getEType() instanceof EEnum) { stringBuffer.append(eAttribute.getEType().getName()); stringBuffer.append(TEXT_16); stringBuffer.append(eAttribute.getName()); stringBuffer.append(eAttribute.getEType().getInstanceClassName()); stringBuffer.append(TEXT_19); stringBuffer.append(eAttribute.getName()); stringBuffer.append(TEXT_20); stringBuffer.append(eAttribute.getEType().getInstanceClassName()); stringBuffer.append(TEXT_21); if (eAttribute.getEType() == EcorePackage.eINSTANCE.getEByteArray() && eAttribute.getEAnnotation("file") != null) { importManager.getImport("javax.activation.DataHandler"); stringBuffer.append(eAttribute.getEType().getInstanceClassName()); stringBuffer.append(TEXT_16); stringBuffer.append(eAttribute.getName()); if (eStructuralFeature instanceof EAttribute) { EAttribute eAttribute = (EAttribute)eStructuralFeature; if (eAttribute.getEType() instanceof EEnum) { stringBuffer.append(eAttribute.getEType().getName()); stringBuffer.append(TEXT_16); stringBuffer.append(GenerateUtils.makeGetter(eAttribute));
list.clear(); List asStringList = null; if (eAttribute.getEType() == EcorePackage.eINSTANCE.getEDouble()) { asStringList = (List)object.eGet(object.eClass().getEStructuralFeature(attributeName + "AsString")); asStringList.clear(); if (eAttribute.getEType() == EcorePackage.eINSTANCE.getEDouble()) { asStringList.add(String.valueOf(o)); throw new UserException("Attribute is not of type 'single'"); if (eAttribute.getEType() instanceof EEnum) { EEnum eEnum = (EEnum) eAttribute.getEType(); object.set(eAttribute.getName(), eEnum.getEEnumLiteral(((String) value).toUpperCase()).getInstance()); } else {
list.clear(); List asStringList = null; if (eAttribute.getEType() == EcorePackage.eINSTANCE.getEDouble()) { asStringList = (List)object.eGet(object.eClass().getEStructuralFeature(attributeName + "AsString")); asStringList.clear(); if (eAttribute.getEType() == EcorePackage.eINSTANCE.getEDouble()) { asStringList.add(String.valueOf(o)); throw new UserException("Attribute is not of type 'single'"); if (eAttribute.getEType() instanceof EEnum) { EEnum eEnum = (EEnum) eAttribute.getEType(); object.setListItem(eAttribute, index, eEnum.getEEnumLiteral(((String) value).toUpperCase()).getInstance()); } else {
if (wrapperAttrib.getEType() == ePackage.getEDouble()) { EAttribute doubleStringAttribute = eFactory.createEAttribute(); doubleStringAttribute.setEType(ePackage.getEString());
protected EAttribute getNameEAttribute(final EObject target) { final Function1<EAttribute, Boolean> _function = (EAttribute it) -> { return Boolean.valueOf((Objects.equal(it.getName(), "name") && Objects.equal(it.getEType(), EcorePackage.Literals.ESTRING))); }; return IterableExtensions.<EAttribute>head(IterableExtensions.<EAttribute>filter(target.eClass().getEAllAttributes(), _function)); } }
@Override protected boolean validate_DataValueConforms(EObject eObject, EAttribute eAttribute, DiagnosticChain diagnostics, Map<Object, Object> context) { boolean result = super.validate_DataValueConforms(eObject, eAttribute, diagnostics, context); if (result && eAttribute.getEType() == GenModelPackage.Literals.PROPERTY_EDITOR_FACTORY) { String propertyEditorFactory = (String)eObject.eGet(eAttribute); result = validatePropertyEditorFactory(((GenBase)eObject).getEcoreModelElement(), propertyEditorFactory, diagnostics, context); } return result; }
if (attribute.getEType().getInstanceClass() == int.class) { Object v = event.newValue; if (v == null) {
@Override protected void copyAttribute(EAttribute eAttribute, EObject eObject, EObject copyEObject) { if (!eAttribute.isUnsettable() || eObject.eIsSet(eAttribute)) { try { if (eAttribute.getEType().eClass().getClassifierID() == EcorePackage.EENUM) { copyEEnumAttribute(eAttribute, eObject, copyEObject); } else { copyEDataTypeAttribute(eAttribute, eObject, copyEObject); } } catch (Exception e) { UMLPlugin.INSTANCE.log(e); } } }
eAttribute.getEType().getInstanceClass() == FeatureMap.Entry.class && !eAttribute.isDerived())
private String stringRepForEStructuralFeature(EObject eObject, String stringRepEClass, EStructuralFeature feature) { if (feature instanceof EAttribute) { EAttribute attribute = (EAttribute) feature; if ("EString".equals(attribute.getEType().getName())) { Object eGet = eObject.eGet(attribute); if (eGet != null) { return withType(stringRepEClass, string(eGet)); } } } else { // it can only be an EReference Object ref = eObject.eGet(feature, true); if (ref != null) { return withType(stringRepEClass, string(ref)); } } return null; }
protected EStructuralFeature getLabelFeature(EClass eClass) { EAttribute result = null; for (EAttribute eAttribute : eClass.getEAllAttributes()) { if (!eAttribute.isMany() && eAttribute.getEType().getInstanceClass() != FeatureMap.Entry.class) { if ("name".equalsIgnoreCase(eAttribute.getName())) { result = eAttribute; break; } else if (result == null) { result = eAttribute; } else if (eAttribute.getEAttributeType().getInstanceClass() == String.class && result.getEAttributeType().getInstanceClass() != String.class) { result = eAttribute; } } } return result; } }
protected void initialize(EAttribute eAttribute, XSDSimpleTypeDefinition xsdSimpleTypeDefinition) { if (XSDConstants.isOrIsDerivedFromID(xsdSimpleTypeDefinition)) { eAttribute.setID(true); } // If there is no default value but the type has enumeration facets and the value is a primitive... // if (!eAttribute.isMany() && eAttribute.getDefaultValueLiteral() == null && xsdSimpleTypeDefinition != null && xsdSimpleTypeDefinition.getEffectiveEnumerationFacet() != null && eAttribute.getEType().getDefaultValue() != null && !(eAttribute.getEType() instanceof EEnum)) { // Set the default to the first enumeration's value. // setDefaultValueLiteral (eAttribute, xsdSimpleTypeDefinition.getNormalizedLiteral ((xsdSimpleTypeDefinition. getEffectiveEnumerationFacet(). getSimpleTypeDefinition(). getEnumerationFacets(). get(0)).getLexicalValue())); } }
/** */ protected EStructuralFeature getLabelFeature(EClass eClass) { EAttribute result = null; for (EAttribute eAttribute : eClass.getEAllAttributes()) { if (!eAttribute.isMany() && eAttribute.getEType().getInstanceClass() != FeatureMap.Entry.class) { if ("name".equalsIgnoreCase(eAttribute.getName())) { result = eAttribute; break; } else if (result == null) { result = eAttribute; } else if (eAttribute.getEAttributeType().getInstanceClass() == String.class && result.getEAttributeType().getInstanceClass() != String.class) { result = eAttribute; } } } return result; }
public Object getPropertyDefaultValue(Object o) { if (feature instanceof EAttribute) { EAttribute attribute = (EAttribute)feature; if (!attribute.isMany()) { Object result = attribute.getDefaultValue(); if (result == null) { result = getDefaultValue(attribute.getEType()); } if (result == null) { return XSDEditPlugin.INSTANCE.getString("_UI_DefaultValue_label", new Object [] { "" }); } else { return XSDEditPlugin.INSTANCE.getString("_UI_DefaultValue_label", new Object [] { this.itemDelegator.getText(result) }); } } } return null; } }
protected void initialize(EAttribute eAttribute, XSDSimpleTypeDefinition xsdSimpleTypeDefinition) { if (XSDConstants.isOrIsDerivedFromID(xsdSimpleTypeDefinition)) { eAttribute.setID(true); } // If there is no default value but the type has enumeration facets and the value is a primitive... // if (!eAttribute.isMany() && eAttribute.getDefaultValueLiteral() == null && xsdSimpleTypeDefinition != null && xsdSimpleTypeDefinition.getEffectiveEnumerationFacet() != null && eAttribute.getEType().getDefaultValue() != null) { // Set the default to the first enumeration's value. // eAttribute.setDefaultValueLiteral ((xsdSimpleTypeDefinition. getEffectiveEnumerationFacet(). getSimpleTypeDefinition(). getEnumerationFacets(). get(0)).getLexicalValue()); } }
protected void createAttributeElementDeclaration(EAttribute attribute, XSDComplexTypeDefinition xsdComplexTypeDefinition) { XSDModelGroup modelGroup = getModelGroup(xsdComplexTypeDefinition); XSDElementDeclaration xsdElementDeclaration = XSDFactory.eINSTANCE.createXSDElementDeclaration(); xsdElementDeclaration.setName(getName(attribute)); // If the attribute can have a null value (primitives and enums can't), and // if the attribute can hold many nulls or // it can hold only a single value that is allowed to be null // and it can be considered set when it has the null value... // if (attribute.getEType().getDefaultValue() == null && (attribute.isMany() || (!attribute.isRequired() && (attribute.getDefaultValueLiteral() != null || attribute.isUnsettable())))) { xsdElementDeclaration.setNillable(true); } if (xsdElementDeclaration.isNillable() || attribute.isMany() || !minimizedXMI) { XSDSimpleTypeDefinition attrType = getType(attribute.getEAttributeType()); if (attrType != null) { xsdElementDeclaration.setTypeDefinition(attrType); } XSDParticle particle = XSDFactory.eINSTANCE.createXSDParticle(); particle.setContent(xsdElementDeclaration); setAttributeElementMultiplicity(attribute, particle); modelGroup.getContents().add(particle); map(particle, attribute); } }