本文整理汇总了Java中org.eclipse.emf.ecore.util.BasicExtendedMetaData类的典型用法代码示例。如果您正苦于以下问题:Java BasicExtendedMetaData类的具体用法?Java BasicExtendedMetaData怎么用?Java BasicExtendedMetaData使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BasicExtendedMetaData类属于org.eclipse.emf.ecore.util包,在下文中一共展示了BasicExtendedMetaData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: lazyMetamodelRegistration
import org.eclipse.emf.ecore.util.BasicExtendedMetaData; //导入依赖的package包/类
private String lazyMetamodelRegistration(String metamodelPath){
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("ecore", new EcoreResourceFactoryImpl());
ResourceSet rs = new ResourceSetImpl();
// Enables extended meta-data, weird we have to do this but well...
final ExtendedMetaData extendedMetaData = new BasicExtendedMetaData(EPackage.Registry.INSTANCE);
rs.getLoadOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, extendedMetaData);
Resource r = rs.getResource(URI.createFileURI(metamodelPath), true);
EObject eObject = r.getContents().get(0);
// A meta-model might have multiple packages we assume the main package is the first one listed
if (eObject instanceof EPackage) {
EPackage p = (EPackage)eObject;
System.out.println(p.getNsURI());
EPackage.Registry.INSTANCE.put(p.getNsURI(), p);
return p.getNsURI();
}
return null;
}
示例2: getJavaObjectFromTrimmed
import org.eclipse.emf.ecore.util.BasicExtendedMetaData; //导入依赖的package包/类
/**
* @throws ParseException
*/
@Override
protected Object getJavaObjectFromTrimmed(String string, Object defaultObject) throws ParseException {
try {
if (eDataType.getInstanceClassName() != null
&& eDataType.getInstanceClassName().equalsIgnoreCase(BigDecimal.class.getName())) {
double value = Double.parseDouble(string);
BasicExtendedMetaData bemd = new BasicExtendedMetaData();
int factionDigits = bemd.getFractionDigitsFacet(eDataType);
String minInclusiveString = bemd.getMinInclusiveFacet(eDataType);
if (minInclusiveString != null) {
int minInclusive = Integer.parseInt(minInclusiveString);
if (value < minInclusive) {
value = 360 - Math.abs(value); // See SPF-9712
}
}
return eFactoryInstance.createFromString(eDataType, String.format("%." + factionDigits + "f", value));
}
return eFactoryInstance.createFromString(eDataType, string);
} catch (Exception e) {
if (e instanceof ParseException) {
throw (ParseException) e;
}
throw new ParseException(e.getMessage(), 0);
}
}
示例3: registerEPackageFromEcore
import org.eclipse.emf.ecore.util.BasicExtendedMetaData; //导入依赖的package包/类
/**
* Registers a EPackage in {@link Registry} according to its {@code prefix} and {@code uri}, from an Ecore file.
* <p>
* The targeted Ecore file must be present in {@code /resources/ecore}.
*/
protected static void registerEPackageFromEcore(String prefix, String uri) {
File file = getResourceFile(ECORE_PATH.replaceAll("\\{name\\}", prefix));
EPackage ePackage = null;
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(ECORE, new EcoreResourceFactoryImpl());
ResourceSet rs = new ResourceSetImpl();
final ExtendedMetaData extendedMetaData = new BasicExtendedMetaData(rs.getPackageRegistry());
rs.getLoadOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, extendedMetaData);
Resource r = rs.getResource(URI.createFileURI(file.toString()), true);
EObject eObject = r.getContents().get(0);
if (eObject instanceof EPackage) {
ePackage = (EPackage) eObject;
rs.getPackageRegistry().put(ePackage.getNsURI(), ePackage);
}
assertThat(ePackage).isNotNull(); // "EPackage does not exist"
Registry.INSTANCE.put(uri, ePackage);
}
示例4: persistenceResourceFactoryImpl
import org.eclipse.emf.ecore.util.BasicExtendedMetaData; //导入依赖的package包/类
/**
* Creates an instance of the resource factory. <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
public persistenceResourceFactoryImpl() {
super();
extendedMetaData =
new BasicExtendedMetaData(new EPackageRegistryImpl(EPackage.Registry.INSTANCE));
extendedMetaData.putPackage(null, persistencePackage.eINSTANCE);
}
示例5: ModelLoader
import org.eclipse.emf.ecore.util.BasicExtendedMetaData; //导入依赖的package包/类
public ModelLoader()
{
resourceSet = new ResourceSetImpl();
final ExtendedMetaData extendedMetaData =
new BasicExtendedMetaData(resourceSet.getPackageRegistry());
resourceSet.getLoadOptions().put(XMLResource.OPTION_EXTENDED_META_DATA,
extendedMetaData);
}
示例6: init
import org.eclipse.emf.ecore.util.BasicExtendedMetaData; //导入依赖的package包/类
public static void init(ResourceSet resourceSet, String path) {
Resource_Set = resourceSet;
Extended_Meta_Data = new BasicExtendedMetaData(resourceSet.getPackageRegistry());
Package_Map = new HashMap<String, EPackage>();
Text_Attribute = (EAttribute) XMLTypeFactory.eINSTANCE.createXMLTypeDocumentRoot().eClass().getEStructuralFeature("text");
Path = path;
}
示例7: readEcore
import org.eclipse.emf.ecore.util.BasicExtendedMetaData; //导入依赖的package包/类
public static EPackage readEcore (String ecorePath)
{
ResourceSet ecoreResourceSet = new ResourceSetImpl();
URI ecoreURI = URI.createFileURI(ecorePath);
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("ecore", new EcoreResourceFactoryImpl());
ecoreResourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecore", new EcoreResourceFactoryImpl());
ecoreResourceSet.getPackageRegistry().put(EcorePackage.eNS_URI, EcorePackage.eINSTANCE);
final ExtendedMetaData extendedMetaData = new BasicExtendedMetaData(ecoreResourceSet.getPackageRegistry());
ecoreResourceSet.getLoadOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, extendedMetaData);
Resource ecoreResource = ecoreResourceSet.getResource(ecoreURI,true);
EPackage ecoremodel = (EPackage) ecoreResource.getContents().get(0);
ecoreResource.getResourceSet().getPackageRegistry().put(ecoremodel.getNsURI(),ecoremodel);
EPackage.Registry.INSTANCE.put(ecoremodel.getNsURI(), ecoremodel);
return ecoremodel;
}
示例8: loadSimulinkModel
import org.eclipse.emf.ecore.util.BasicExtendedMetaData; //导入依赖的package包/类
/**
* Loads the EMF representation of a Simulink model.
*
* @param fileNameWithoutExtension
* the file to load specified by its name
* @return the loaded SimulinkModel root EMF model object
* @throws SimulinkApiException
*/
public SimulinkModel loadSimulinkModel(String fileNameWithoutExtension) throws SimulinkApiException {
// Register a resource factory for the extension "simulink"
Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE;
Map<String, Object> m = reg.getExtensionToFactoryMap();
m.put("simulink", new XMIResourceFactoryImpl());
// Obtain a new resource set
ResourceSet rs = new ResourceSetImpl();
final ExtendedMetaData extendedMetaData = new BasicExtendedMetaData(rs.getPackageRegistry());
rs.getLoadOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, extendedMetaData);
// The model will be saved to the root of the project for now under the
// given name.
// TODO save path may come from an extension or properties file
String path = fileNameWithoutExtension + ".simulink";
// Load the resource
Resource loadResource = rs.getResource(URI.createURI(path), true);
Object resourceContent = loadResource.getContents().get(0);
// Make a log entry if the root object isn't a SimulinkModel
if (!(resourceContent instanceof SimulinkModel))
logger.error("The given resource contained no SimulinkModel as a root element!");
// Return the root EMF model object
// Also throws an exception when invalid cast occurs
return (SimulinkModel) resourceContent;
}
示例9: setup
import org.eclipse.emf.ecore.util.BasicExtendedMetaData; //导入依赖的package包/类
@Before
public void setup() {
// We need the TOGAF model for some of the tests, but the plugin has no update site.
// Instead, we use the Ecore file in resources/metamodels. However, while EMFViews works
// with the Ecore file, the code in EclDelegate assumes that metamodels are registered in
// the EMF package registry.
//
// To work around this issue, we load the EPackage from the Ecore file into the package registry.
//
// See: https://stackoverflow.com/a/9389901
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap()
.put("ecore", new EcoreResourceFactoryImpl());
ResourceSet rs = new ResourceSetImpl();
// enable extended metadata
final ExtendedMetaData extendedMetaData = new BasicExtendedMetaData(rs.getPackageRegistry());
rs.getLoadOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, extendedMetaData);
Resource r = rs.getResource(resourceURI("metamodels/contentfwk.ecore"), true);
EObject eObject = r.getContents().get(0);
if (eObject instanceof EPackage) {
EPackage p = (EPackage) eObject;
EPackage.Registry.INSTANCE.put(p.getNsURI(), p);
} else {
throw new IllegalStateException("Error loading TOGAF metamodel for testing");
}
}
示例10: getExtendedMetaData
import org.eclipse.emf.ecore.util.BasicExtendedMetaData; //导入依赖的package包/类
public BasicExtendedMetaData.EPackageExtendedMetaData getExtendedMetaData()
{
return ePackageExtendedMetaData;
}
示例11: setExtendedMetaData
import org.eclipse.emf.ecore.util.BasicExtendedMetaData; //导入依赖的package包/类
public void setExtendedMetaData(BasicExtendedMetaData.EPackageExtendedMetaData ePackageExtendedMetaData)
{
this.ePackageExtendedMetaData = ePackageExtendedMetaData;
}
示例12: getExtendedMetaData
import org.eclipse.emf.ecore.util.BasicExtendedMetaData; //导入依赖的package包/类
public BasicExtendedMetaData.EClassifierExtendedMetaData getExtendedMetaData()
{
return eClassifierExtendedMetaData;
}
示例13: setExtendedMetaData
import org.eclipse.emf.ecore.util.BasicExtendedMetaData; //导入依赖的package包/类
public void setExtendedMetaData(BasicExtendedMetaData.EClassifierExtendedMetaData eClassifierExtendedMetaData)
{
this.eClassifierExtendedMetaData = eClassifierExtendedMetaData;
}
示例14: getExtendedMetaData
import org.eclipse.emf.ecore.util.BasicExtendedMetaData; //导入依赖的package包/类
public BasicExtendedMetaData.EStructuralFeatureExtendedMetaData getExtendedMetaData()
{
return eStructuralFeatureExtendedMetaData;
}
示例15: setExtendedMetaData
import org.eclipse.emf.ecore.util.BasicExtendedMetaData; //导入依赖的package包/类
public void setExtendedMetaData(BasicExtendedMetaData.EStructuralFeatureExtendedMetaData eStructuralFeatureExtendedMetaData)
{
this.eStructuralFeatureExtendedMetaData = eStructuralFeatureExtendedMetaData;
}