-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[32] Add the ability to retrieve information during the serialization
Bug: #32 Signed-off-by: Stéphane Bégaudeau <[email protected]>
- Loading branch information
1 parent
72ac65d
commit 507db59
Showing
4 changed files
with
116 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ | |
import org.eclipse.emf.common.util.URI; | ||
import org.eclipse.emf.ecore.EObject; | ||
import org.eclipse.emf.ecore.EPackage; | ||
import org.eclipse.emf.ecore.EReference; | ||
import org.eclipse.emf.ecore.EStructuralFeature; | ||
import org.eclipse.emf.ecore.resource.Resource; | ||
|
||
|
@@ -425,6 +426,75 @@ interface IEObjectHandler { | |
*/ | ||
Object OPTION_SAVE_FEATURES_ORDER_COMPARATOR = "OPTION_SAVE_FEATURES_ORDER_COMPARATOR"; //$NON-NLS-1$ | ||
|
||
/** | ||
* An option to provide an ISerializationListener. | ||
*/ | ||
String OPTION_SERIALIZATION_LISTENER = "OPTION_SERIALIZATION_LISTENER"; //$NON-NLS-1$ | ||
|
||
/** | ||
* Used to listen to various events during the serialization. | ||
* | ||
* @author <a href="mailto:[email protected]">Stephane Begaudeau</a> | ||
*/ | ||
interface ISerializationListener { | ||
|
||
/** | ||
* Called when an entry is added to the namespace header. | ||
* | ||
* @param nsPrefix | ||
* The prefix of the ePackage added | ||
* @param nsURI | ||
* The URI of the ePackage added | ||
*/ | ||
void onNsHeaderEntryAdded(String nsPrefix, String nsURI); | ||
|
||
/** | ||
* Called when an object is serialized. | ||
* | ||
* @param eObject | ||
* The EObject serialized | ||
* @param jsonElement | ||
* The serialization of the EObject | ||
*/ | ||
void onObjectSerialized(EObject eObject, JsonElement jsonElement); | ||
|
||
/** | ||
* Called when a proxy to an object located in another resource has been created. | ||
* | ||
* @param eObject | ||
* The object for which the URI is created | ||
* @param eReference | ||
* The reference containing the object | ||
* @param uri | ||
* The uri created | ||
*/ | ||
void onCrossReferenceURICreated(EObject eObject, EReference eReference, String uri); | ||
|
||
/** | ||
* Implementation of the listener which does nothing. | ||
* | ||
* @author <a href="mailto:[email protected]">Stephane Begaudeau</a> | ||
*/ | ||
class NoOp implements ISerializationListener { | ||
|
||
@Override | ||
public void onNsHeaderEntryAdded(String nsPrefix, String nsURI) { | ||
// Do nothing | ||
} | ||
|
||
@Override | ||
public void onObjectSerialized(EObject eObject, JsonElement jsonElement) { | ||
// Do nothing | ||
} | ||
|
||
@Override | ||
public void onCrossReferenceURICreated(EObject eObject, EReference eReference, String uri) { | ||
// Do nothing | ||
} | ||
|
||
} | ||
} | ||
|
||
/** | ||
* Associate an ID to the {@link EObject}. | ||
* | ||
|
@@ -434,4 +504,5 @@ interface IEObjectHandler { | |
* the id | ||
*/ | ||
void setID(EObject eObject, String id); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters