1 package com.bonevich.erj.app;
2
3 import com.bonevich.erj.model.Schema;
4 import com.bonevich.erj.mof.interfaces.model.ErjInfoModelPackage;
5
6 public abstract class ModelConverter
7 {
8 //////////////////////////////////////////////////////////
9 // Constants
10 public static final String REPOSITORY_IMPLEMENTATION_CLASS
11 = "com.bonevich.erj.mof.impl.model.ErjErjInfoModelPackageImpl";
12
13 static class TargetType {}
14 public static final TargetType TARGET_MOF = new TargetType();
15 public static final TargetType TARGET_ERJ = new TargetType();
16
17 //////////////////////////////////////////////////////////
18 // Attributes
19 protected Schema _model;
20 protected ErjInfoModelPackage _repository;
21
22 public static ModelConverter create(TargetType target)
23 {
24 if (target == TARGET_MOF)
25 {
26 return new MofModelConverter();
27 }
28 else if (target == TARGET_ERJ)
29 {
30 return new ErjInfoModelConverter();
31 }
32 return null;
33 }
34
35 public ErjInfoModelPackage getRepository()
36 {
37 return _repository;
38 }
39
40 protected void createRepository()
41 {
42 try {
43 Class repositoryClass = Class.forName(REPOSITORY_IMPLEMENTATION_CLASS);
44 _repository = (ErjInfoModelPackage) repositoryClass.newInstance();
45 } catch (Exception e) {
46 e.printStackTrace();
47 throw new RuntimeException("Unable to create a MOF repository");
48 }
49 }
50
51 protected void createModel()
52 {
53 _model = new Schema();
54 }
55
56 public abstract Object convert(Object source);
57
58 } /* end class ModelConverter */
This page was automatically generated by Maven