本文整理汇总了Java中org.eclipse.emf.ecore.EModelElement.getEAnnotation方法的典型用法代码示例。如果您正苦于以下问题:Java EModelElement.getEAnnotation方法的具体用法?Java EModelElement.getEAnnotation怎么用?Java EModelElement.getEAnnotation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.emf.ecore.EModelElement
的用法示例。
在下文中一共展示了EModelElement.getEAnnotation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setDocumentation
import org.eclipse.emf.ecore.EModelElement; //导入方法依赖的package包/类
public static void setDocumentation(EModelElement eModelElement, String documentation)
{
EAnnotation eAnnotation = eModelElement.getEAnnotation(GEN_MODEL_PACKAGE_NS_URI);
if (documentation == null)
{
if (eAnnotation != null)
{
eAnnotation.getDetails().removeKey("documentation");
}
}
else
{
if (eAnnotation == null)
{
eAnnotation = EcoreFactory.eINSTANCE.createEAnnotation();
eAnnotation.setSource(GEN_MODEL_PACKAGE_NS_URI);
eModelElement.getEAnnotations().add(eAnnotation);
}
eAnnotation.getDetails().put("documentation", documentation);
}
}
示例2: getConstraints
import org.eclipse.emf.ecore.EModelElement; //导入方法依赖的package包/类
public static List<String> getConstraints(EModelElement eModelElement)
{
EAnnotation eAnnotation = eModelElement.getEAnnotation(EcorePackage.eNS_URI);
if (eAnnotation != null)
{
String constraints = eAnnotation.getDetails().get("constraints");
if (constraints != null)
{
List<String> result = new ArrayList<String>();
for (StringTokenizer stringTokenizer = new StringTokenizer(constraints); stringTokenizer.hasMoreTokens();)
{
String constraint = stringTokenizer.nextToken();
result.add(constraint);
}
return result;
}
}
return Collections.emptyList();
}
示例3: setAnnotation
import org.eclipse.emf.ecore.EModelElement; //导入方法依赖的package包/类
public static void setAnnotation(EModelElement eModelElement, String sourceURI, String key, String value)
{
EAnnotation eAnnotation = eModelElement.getEAnnotation(sourceURI);
if (value == null)
{
if (eAnnotation != null)
{
eAnnotation.getDetails().removeKey(key);
}
}
else
{
if (eAnnotation == null)
{
eAnnotation = EcoreFactory.eINSTANCE.createEAnnotation();
eAnnotation.setSource(sourceURI);
eModelElement.getEAnnotations().add(eAnnotation);
}
eAnnotation.getDetails().put(key, value);
}
}
示例4: setDocumentation
import org.eclipse.emf.ecore.EModelElement; //导入方法依赖的package包/类
public static void setDocumentation(EModelElement eModelElement, String documentation)
{
EAnnotation eAnnotation = eModelElement.getEAnnotation(GEN_MODEL_PACKAGE_NS_URI);
if (documentation == null)
{
if (eAnnotation != null)
{
eAnnotation.getDetails().remove("documentation");
}
}
else
{
if (eAnnotation == null)
{
eAnnotation = EcoreFactory.eINSTANCE.createEAnnotation();
eAnnotation.setSource(GEN_MODEL_PACKAGE_NS_URI);
eModelElement.getEAnnotations().add(eAnnotation);
}
eAnnotation.getDetails().put("documentation", documentation);
}
}
示例5: appendDocumentation
import org.eclipse.emf.ecore.EModelElement; //导入方法依赖的package包/类
/**
* keep appending to the documentation of the first model element
* @param firstEl
* @param secondEl
*/
private void appendDocumentation(EModelElement firstEl,EModelElement secondEl)
{
EAnnotation firstAnn = firstEl.getEAnnotation(ModelUtil.genModelURI());
String firstDoc = null;
if (firstAnn != null) firstDoc = firstAnn.getDetails().get("documentation");
EAnnotation secondAnn = secondEl.getEAnnotation(ModelUtil.genModelURI());
String secondDoc = null;
if (secondAnn != null) secondDoc = secondAnn.getDetails().get("documentation");
// append documentation strings if they are both non-null
String fullDoc = null;
if (firstDoc == null) fullDoc = secondDoc;
if (secondDoc == null) fullDoc = firstDoc;
if ((firstDoc != null) && (secondDoc != null)) fullDoc = firstDoc + secondDoc;
if (fullDoc != null) firstEl.getEAnnotation(ModelUtil.genModelURI()).getDetails().put("documentation",fullDoc);
}
示例6: addDocumentation
import org.eclipse.emf.ecore.EModelElement; //导入方法依赖的package包/类
/**
*
* @param mappedEobject
* @param docString
*/
private void addDocumentation(EModelElement mappedEobject,String docString)
{
EAnnotation ann = mappedEobject.getEAnnotation(javaDocURI);
// if this is the first documentation for this class or feature, add it with the preface defining the message
if (ann == null)
{
ann = EcoreFactory.eINSTANCE.createEAnnotation();
ann.setSource(javaDocURI);
ann.getDetails().put(javaDocKey, docPreface() + docString);
mappedEobject.getEAnnotations().add(ann);
}
// append any subsequent documentation on the same class or feature
else if (ann != null)
{
String previousDoc = ann.getDetails().get(javaDocKey);
String newDoc = previousDoc + docString;
ann.getDetails().put(javaDocKey, newDoc);
}
}
示例7: copyAnnotation
import org.eclipse.emf.ecore.EModelElement; //导入方法依赖的package包/类
/**
* copy an ECore annotation from one object to another -
* maybe overwriting the values of existing annotations with the same
* source and the same key
* @param toObject
* @param note
*/
public static void copyAnnotation(EModelElement toObject, EAnnotation note)
{
String source = note.getSource();
// if the target does not have an annotation with this source, make one
EAnnotation existing = toObject.getEAnnotation(source);
if (existing == null)
{
existing = EcoreFactory.eINSTANCE.createEAnnotation();
existing.setSource(source);
toObject.getEAnnotations().add(existing);
}
// transfer values for all keys, overwriting if values already exist
for (Iterator<String> it = note.getDetails().keySet().iterator();it.hasNext();)
{
String key = it.next();
existing.getDetails().put(key, note.getDetails().get(key));
}
}
示例8: addAnnotation
import org.eclipse.emf.ecore.EModelElement; //导入方法依赖的package包/类
public static void addAnnotation(EModelElement eNamedElement, String source, String... details) {
EAnnotation eAnnotation = eNamedElement.getEAnnotation(source);
if (eAnnotation == null) {
eAnnotation = EcoreFactory.eINSTANCE.createEAnnotation();
eAnnotation.setSource(source);
eNamedElement.getEAnnotations().add(eAnnotation);
}
EMap<String, String> theDetails = eAnnotation.getDetails();
for (int i = 1; i < details.length; i += 2) {
theDetails.put(details[i - 1], details[i]);
}
}
示例9: getAnnotation
import org.eclipse.emf.ecore.EModelElement; //导入方法依赖的package包/类
public static String getAnnotation(EModelElement eNamedElement, String source, String key) {
if (eNamedElement != null) {
EAnnotation annotation = eNamedElement.getEAnnotation(source);
if (annotation != null) {
return annotation.getDetails().get(key);
}
}
return null;
}
示例10: getOclAnnotation
import org.eclipse.emf.ecore.EModelElement; //导入方法依赖的package包/类
public static EAnnotation getOclAnnotation(EModelElement c) {
EAnnotation ann = c.getEAnnotation("http://www.eclipse.org/emf/2002/Ecore/OCL");
if ( ann == null ) {
ann = c.getEAnnotation("http://www.eclipse.org/ocl/examples/OCL");
if ( ann == null ) {
ann = c.getEAnnotation("http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot");
}
}
return ann;
}
示例11: setConstraints
import org.eclipse.emf.ecore.EModelElement; //导入方法依赖的package包/类
public static void setConstraints(EModelElement eModelElement, List<String> constraints)
{
EAnnotation eAnnotation = eModelElement.getEAnnotation(EcorePackage.eNS_URI);
if (constraints == null || constraints.isEmpty())
{
if (eAnnotation != null)
{
eAnnotation.getDetails().removeKey("constraints");
}
}
else
{
if (eAnnotation == null)
{
eAnnotation = EcoreFactory.eINSTANCE.createEAnnotation();
eAnnotation.setSource(EcorePackage.eNS_URI);
eModelElement.getEAnnotations().add(eAnnotation);
}
StringBuffer value = new StringBuffer();
for (Iterator<String> i = constraints.iterator(); i.hasNext();)
{
value.append(i.next());
if (i.hasNext())
{
value.append(' ');
}
}
eAnnotation.getDetails().put("constraints", value.toString());
}
}
示例12: setConstraints
import org.eclipse.emf.ecore.EModelElement; //导入方法依赖的package包/类
public static void setConstraints(EModelElement eModelElement, List<String> constraints)
{
EAnnotation eAnnotation = eModelElement.getEAnnotation(EcorePackage.eNS_URI);
if (constraints == null || constraints.isEmpty())
{
if (eAnnotation != null)
{
eAnnotation.getDetails().remove("constraints");
}
}
else
{
if (eAnnotation == null)
{
eAnnotation = EcoreFactory.eINSTANCE.createEAnnotation();
eAnnotation.setSource(EcorePackage.eNS_URI);
eModelElement.getEAnnotations().add(eAnnotation);
}
StringBuffer value = new StringBuffer();
for (Iterator<String> i = constraints.iterator(); i.hasNext();)
{
value.append(i.next());
if (i.hasNext())
{
value.append(' ');
}
}
eAnnotation.getDetails().put("constraints", value.toString());
}
}
示例13: setAnnotation
import org.eclipse.emf.ecore.EModelElement; //导入方法依赖的package包/类
public static void setAnnotation(EModelElement eModelElement, String sourceURI, String key, String value)
{
EAnnotation eAnnotation = eModelElement.getEAnnotation(sourceURI);
if (eAnnotation == null)
{
eAnnotation = EcoreFactory.eINSTANCE.createEAnnotation();
eAnnotation.setSource(sourceURI);
eModelElement.getEAnnotations().add(eAnnotation);
}
eAnnotation.getDetails().put(key, value);
}
示例14: addAnnotation
import org.eclipse.emf.ecore.EModelElement; //导入方法依赖的package包/类
protected void addAnnotation(EModelElement targetObject, String key, String value) {
EAnnotation annotation = targetObject.getEAnnotation(ANNOTATION_SOURCE);
if (annotation == null) {
EcoreFactory factory = EcoreFactory.eINSTANCE;
annotation = factory.createEAnnotation();
annotation.setSource(ANNOTATION_SOURCE);
targetObject.getEAnnotations().add(annotation);
}
annotation.getDetails().put(key, value);
}
示例15: addMicroITSAnnotation
import org.eclipse.emf.ecore.EModelElement; //导入方法依赖的package包/类
/**
*
* @param toObj a Ecore model element to which an annotation is either to be added,
* or extended with a new String key and value
* @param key the key (new or possibly already existing)
* @param value the new value for the key
*/
public static void addMicroITSAnnotation(EModelElement toObj, String key, String value)
{
EAnnotation ann = toObj.getEAnnotation(microITSURI());
if (ann == null)
{
ann = EcoreFactory.eINSTANCE.createEAnnotation();
ann.setSource(microITSURI());
toObj.getEAnnotations().add(ann);
}
ann.getDetails().put(key, value);
}