@Override
public Object deserialize(EObject target, EStructuralFeature feature, String value) {
if (isDeserializer(target, feature)) {
String v = value.substring(value.indexOf("[")+1, value.lastIndexOf("]")); // White-space varies if its numeric or enum
int delim = v.lastIndexOf(',');
String dateString = v.substring(0, delim).trim();
String valueString = v.substring(delim + 1).trim();
Profile profile = (Profile) target;
EDataType dataType = profile.getDataType();
Date date = (Date)EcoreFactory.eINSTANCE.createFromString(EcorePackage.Literals.EDATE, dateString);
Object object = null;
if (valueString != null && !valueString.isEmpty() && !valueString.equals("null")) {
object = EcoreUtil.createFromString(dataType, valueString);
}
DataPoint<Object> dataPoint = JScienceFactory.eINSTANCE.createEDataPoint(date, object);
return dataPoint;
}
return null;
}
java类org.eclipse.emf.ecore.EcoreFactory的实例源码
ProfileDataPointDeserializerContributor.java 文件源码
项目:OpenSPIFe
阅读 14
收藏 0
点赞 0
评论 0
MongoHandlerSaveTest.java 文件源码
项目:emfjson-mongo
阅读 16
收藏 0
点赞 0
评论 0
@Test
public void testSaveWithUriMapping() throws IOException {
resourceSet.getURIConverter().getURIMap().put(
URI.createURI("http://resources/"),
URI.createURI("mongodb://localhost:27017/emfjson-test/models/"));
Resource resource = resourceSet.createResource(URI.createURI("http://resources/model1"));
EPackage p = EcoreFactory.eINSTANCE.createEPackage();
p.setName("p");
EClass c = EcoreFactory.eINSTANCE.createEClass();
c.setName("A");
p.getEClassifiers().add(c);
resource.getContents().add(p);
resource.save(null);
checkDocument(testURI);
}
USESolverMemory.java 文件源码
项目:anatlyzer
阅读 14
收藏 0
点赞 0
评论 0
public USESolverMemory(EPackage metamodel, List<String> constraints) throws transException {
super();
this.metamodel = metamodel;
root = (EClass) metamodel.getEClassifier("AuxiliaryClass4USE");
if ( root == null ) {
root = EcoreFactory.eINSTANCE.createEClass();
root.setName ("AuxiliaryClass4USE");
metamodel.getEClassifiers().add(root);
}
try {
StringWriter writer1 = new StringWriter();
transformEcore2use(metamodel, writer1);
writer1.append("\n\n");
writeOCLexpression(metamodel, constraints, root, writer1);
this.useSpecification = writer1.toString();
writer1.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
NoClassFoundInMetamodelQuickFix_ChangeMetamodel.java 文件源码
项目:anatlyzer
阅读 14
收藏 0
点赞 0
评论 0
@Override
public QuickfixApplication getQuickfixApplication() throws CoreException {
OclModelElement me = (OclModelElement) getProblematicElement();
String mmName = me.getModel().getName();
QuickfixApplication qfa = new QuickfixApplication(this);
Set<EPackage> packages = getAnalysisResult().getNamespace().getNamespace(mmName).getLoadedPackages();
EPackage aPackage = packages.stream().filter(p -> p.getESuperPackage() == null ).findAny().orElse(null);
if ( aPackage != null ) {
qfa.mmModify(aPackage, mmName, (pkg) -> {
EClass newClass = EcoreFactory.eINSTANCE.createEClass();
newClass.setName(me.getName());
pkg.getEClassifiers().add(newClass);
});
}
return qfa;
}
EffectiveMetamodelBuilder.java 文件源码
项目:anatlyzer
阅读 12
收藏 0
点赞 0
评论 0
public EPackage extractSource(Resource r, String name, String conceptURI, String conceptPrefix, String info) {
conceptPkg = EcoreFactory.eINSTANCE.createEPackage();
conceptPkg.setName(name);
conceptPkg.setNsURI(conceptURI);
conceptPkg.setNsPrefix(conceptPrefix);
EAnnotation ann = EcoreFactory.eINSTANCE.createEAnnotation();
//ann.getDetails().put("error", name);
ann.setSource(info);
conceptPkg.getEAnnotations().add(ann);
r.getContents().add(conceptPkg);
//copyClasses(directUsedTypes);
//copyClasses(indirectUsedTypes);
for(EAnnotation extra : data.getPackageAnnotations()) {
conceptPkg.getEAnnotations().add(extra);
}
transform(this);
// fillFeatures(directUsedTypes);
return conceptPkg;
}
SimpleBPMNCreateShortcutDecorationsCommand.java 文件源码
项目:simplified-bpmn-example
阅读 14
收藏 0
点赞 0
评论 0
/**
* @generated
*/
protected CommandResult doExecuteWithResult(IProgressMonitor monitor,
IAdaptable info) throws ExecutionException {
for (Iterator it = myDescriptors.iterator(); it.hasNext();) {
CreateViewRequest.ViewDescriptor nextDescriptor = (CreateViewRequest.ViewDescriptor) it
.next();
View view = (View) nextDescriptor.getAdapter(View.class);
if (view != null && view.getEAnnotation("Shortcut") == null) { //$NON-NLS-1$
EAnnotation shortcutAnnotation = EcoreFactory.eINSTANCE
.createEAnnotation();
shortcutAnnotation.setSource("Shortcut"); //$NON-NLS-1$
shortcutAnnotation
.getDetails()
.put("modelID", SimpleBPMN.diagram.edit.parts.BusinessProcessDiagramEditPart.MODEL_ID); //$NON-NLS-1$
view.getEAnnotations().add(shortcutAnnotation);
}
}
return CommandResult.newOKCommandResult();
}
EcoreUtil.java 文件源码
项目:eclipse-avro
阅读 22
收藏 0
点赞 0
评论 0
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);
}
}
EcoreUtil.java 文件源码
项目:eclipse-avro
阅读 18
收藏 0
点赞 0
评论 0
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);
}
}
EcoreUtil.java 文件源码
项目:eclipse-avro
阅读 15
收藏 0
点赞 0
评论 0
/**
* Sets or removes annotations on the given structural feature to prevent generation of accessor methods in its interface.
* @param eStructuralFeature the structural feature
* @param accessor the type of accessor method, one of {@link #GET}, {@link #SET}, {@link #IS_SET}, or {@link #UNSET}
* @param suppress whether the specified accessor's visibility should be suppressed
* @since 2.1
*/
public static void setSuppressedVisibility(EStructuralFeature eStructuralFeature, int accessor, boolean suppress)
{
if (accessor < GET || accessor > UNSET) throw new IllegalArgumentException("Invalid accessor identifier: " + accessor);
EAnnotation eAnnotation = eStructuralFeature.getEAnnotation(GEN_MODEL_PACKAGE_NS_URI);
if (!suppress)
{
if (eAnnotation != null)
{
eAnnotation.getDetails().removeKey(ACCESSOR_KEYS[accessor]);
}
}
else
{
if (eAnnotation == null)
{
eAnnotation = EcoreFactory.eINSTANCE.createEAnnotation();
eAnnotation.setSource(GEN_MODEL_PACKAGE_NS_URI);
eStructuralFeature.getEAnnotations().add(eAnnotation);
}
eAnnotation.getDetails().put(ACCESSOR_KEYS[accessor], TRUE);
}
}
EcoreUtil.java 文件源码
项目:eclipse-avro
阅读 19
收藏 0
点赞 0
评论 0
/**
* Sets or removes the annotation on the given operation to prevent generation of a method declaration in its interface.
* @param eOperation the operation.
* @param suppress whether the visibility should be suppressed
* @since 2.4
*/
public static void setSuppressedVisibility(EOperation eOperation, boolean suppress)
{
EAnnotation eAnnotation = eOperation.getEAnnotation(GEN_MODEL_PACKAGE_NS_URI);
if (!suppress)
{
if (eAnnotation != null)
{
eAnnotation.getDetails().removeKey(OPERATION_VISIBILITY_KEY);
}
}
else
{
if (eAnnotation == null)
{
eAnnotation = EcoreFactory.eINSTANCE.createEAnnotation();
eAnnotation.setSource(GEN_MODEL_PACKAGE_NS_URI);
eOperation.getEAnnotations().add(eAnnotation);
}
eAnnotation.getDetails().put(OPERATION_VISIBILITY_KEY, TRUE);
}
}