Skip to main content



      Home
Home » Modeling » EMF » EEnum value serialization in xml file(EEnum value serialization in xml file)
EEnum value serialization in xml file [message #1866696] Wed, 05 June 2024 04:26 Go to next message
Eclipse UserFriend
Hello,

I would like to know that is there a way to serialize EEnum value instead of literal in xml file(model file). I believe EEnum literal are serialized in xml file. I am wondering if this is possible with some workaround or with api. Since I need to have this EEnum value to be available in xml file.

I would really appreciate if someone can suggest to achieve this. Thanks in advance!!

Thanks,
Mishal
Re: EEnum value serialization in xml file [message #1866705 is a reply to message #1866696] Wed, 05 June 2024 06:55 Go to previous messageGo to next message
Eclipse UserFriend
In your generated XyzFactoryImpl, you could specialize the createAbcFromString/convertAbcToString to do anything you wish
  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public ChangeKind createChangeKindFromString(EDataType eDataType, String initialValue)
  {
    ChangeKind result = ChangeKind.get(initialValue);
    if (result == null) throw new IllegalArgumentException("The value '" + initialValue + "' is not a valid enumerator of '" + eDataType.getName() + "'");
    return result;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String convertChangeKindToString(EDataType eDataType, Object instanceValue)
  {
    return instanceValue == null ? null : instanceValue.toString();
  }
To impact only serialization you can specialize org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.createFromString(EFactory, EDataType, String) and org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.convertToString(EFactory, EDataType, Object).
Re: EEnum value serialization in xml file [message #1866750 is a reply to message #1866705] Thu, 06 June 2024 05:17 Go to previous message
Eclipse UserFriend
Thanks a lot!! It works
Previous Topic:How to get a localized name of EEnumLiteral
Next Topic:Setting unchangeable features at object creation
Goto Forum:
  


Current Time: Sun Aug 31 03:57:21 EDT 2025

Powered by FUDForum. Page generated in 0.06681 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top