resourceSet.getAdapterFactories().add(adapterFactory); resourceSet.getAdapterFactories().add(adapterFactory);
resource.getResourceSet().getAdapterFactories().add(adapterFactory); return imprt;
/** * Create the java context. To be used outside of Eclipse. * Within normal Eclipse JEM usage the JEM EMF nature should be used instead. * @return * * @since 1.2.0 */ public static ResourceSet createJavaContext() { org.eclipse.jem.internal.java.init.JavaInit.init(); ResourceSet set = new ResourceSetImpl(); set.getAdapterFactories().add(createJavaReflectionAdapterFactory()); return set; }
public static final XSDSchema parse(String location, List locators, List resolvers) throws IOException { //check for case of file url, make sure it is an absolute reference if (new File(location).exists()) { location = new File(location).getCanonicalFile().toURI().toString(); //location = new File(location).getCanonicalPath(); } URI uri = URI.createURI(location); final ResourceSet resourceSet = new ResourceSetImpl(); //add the specialized schema location resolvers if ((resolvers != null) && !resolvers.isEmpty()) { AdapterFactory adapterFactory = new SchemaLocationResolverAdapterFactory(resolvers); resourceSet.getAdapterFactories().add(adapterFactory); } //add the specialized schema locators as adapters if ((locators != null) && !locators.isEmpty()) { AdapterFactory adapterFactory = new SchemaLocatorAdapterFactory(locators); resourceSet.getAdapterFactories().add(adapterFactory); } XSDResourceImpl xsdMainResource = (XSDResourceImpl) resourceSet.createResource(URI.createURI( ".xsd")); xsdMainResource.setURI(uri); xsdMainResource.load(resourceSet.getLoadOptions()); return xsdMainResource.getSchema(); }
public static final XSDSchema parse(String location, List locators, List resolvers) throws IOException { //check for case of file url, make sure it is an absolute reference if (new File(location).exists()) { location = new File(location).getCanonicalFile().toURI().toString(); //location = new File(location).getCanonicalPath(); } URI uri = URI.createURI(location); final ResourceSet resourceSet = new ResourceSetImpl(); //add the specialized schema location resolvers if ((resolvers != null) && !resolvers.isEmpty()) { AdapterFactory adapterFactory = new SchemaLocationResolverAdapterFactory(resolvers); resourceSet.getAdapterFactories().add(adapterFactory); } //add the specialized schema locators as adapters if ((locators != null) && !locators.isEmpty()) { AdapterFactory adapterFactory = new SchemaLocatorAdapterFactory(locators); resourceSet.getAdapterFactories().add(adapterFactory); } XSDResourceImpl xsdMainResource = (XSDResourceImpl) resourceSet.createResource(URI.createURI( ".xsd")); xsdMainResource.setURI(uri); xsdMainResource.load(resourceSet.getLoadOptions()); return xsdMainResource.getSchema(); }
public static final XSDSchema parse( String location, List locators, List resolvers ) throws IOException { //check for case of file url, make sure it is an absolute reference if (new File(location).exists()) { location = new File( location ).getCanonicalFile().toURI().toString(); //location = new File(location).getCanonicalPath(); } URI uri = URI.createURI(location); final ResourceSet resourceSet = new ResourceSetImpl(); //add the specialized schema location resolvers if ((resolvers != null) && !resolvers.isEmpty()) { AdapterFactory adapterFactory = new SchemaLocationResolverAdapterFactory(resolvers); resourceSet.getAdapterFactories().add(adapterFactory); } //add the specialized schema locators as adapters if ((locators != null) && !locators.isEmpty()) { AdapterFactory adapterFactory = new SchemaLocatorAdapterFactory(locators); resourceSet.getAdapterFactories().add(adapterFactory); } XSDResourceImpl xsdMainResource = (XSDResourceImpl) resourceSet .createResource(URI.createURI(".xsd")); // LOGGER.info("About to parse xsd schema: " + uri); xsdMainResource.setURI(uri); xsdMainResource.load(resourceSet.getLoadOptions()); return xsdMainResource.getSchema(); }
protected JavaJDKAdapterFactory getJavaAdapterFactory() { return (JavaJDKAdapterFactory) EcoreUtil.getAdapterFactory(getLoadStrategy().getResourceSet().getAdapterFactories(), ReadAdaptor.TYPE_KEY); }
protected boolean flushPrimaryKeyClass(JavaClass primaryKeyClass) { // ensure the primary key class is flushed and reloaded to get latest // content IProject p = ProjectUtilities.getProject(primaryKeyClass); try { List natures = EMFNature.getRegisteredRuntimes(p); EMFNature nature = null; for (int i = 0; i < natures.size(); i++) { if (natures.get(i) instanceof EMFNature) nature = (EMFNature) natures.get(i); } List adapterFactories = nature.getResourceSet().getAdapterFactories(); AdapterFactory factory = EcoreUtil.getAdapterFactory(adapterFactories, ReadAdaptor.TYPE_KEY); if (factory instanceof JavaJDOMAdapterFactory) { JavaJDOMAdapterFactory javaFactory = (JavaJDOMAdapterFactory) factory; javaFactory.flushReflectionNoNotification(primaryKeyClass.getQualifiedName()); return true; } } catch (Exception e) { // We don't really care what the exception was, we'll just bail out // and return false; } return false; } }
public void attached(EObject eObject) { super.attached(eObject); // we need to attach a XSDSchemaLocator in order to resolve inline schema locations // if there's not already one attached XSDSchemaLocator xsdSchemaLocator = (XSDSchemaLocator)EcoreUtil.getRegisteredAdapter(this, XSDSchemaLocator.class); if (xsdSchemaLocator == null) { getResourceSet().getAdapterFactories().add(new XSDSchemaLocatorAdapterFactory()); } if (eObject instanceof DefinitionImpl) { DefinitionImpl definition = (DefinitionImpl)eObject; definition.setInlineSchemaLocations(this); } } /*
/** * Returns the specified resource's adapter of the specified type. If none exists, create and * add a new adapter using a registered adapter factory if one exists for the specified type. * @param resource the adapted resource. * @param type the type of adapter. * @return an adapter associated with the specified eObject or null. */ public static Adapter getRegisteredAdapter(Resource resource, Object type) { Adapter result = getExistingAdapter(resource, type); if (result == null) { ResourceSet resourceSet = resource.getResourceSet(); if (resourceSet != null) { AdapterFactory factory = getAdapterFactory(resourceSet.getAdapterFactories(), type); if (factory != null) { result = factory.adaptNew(resource, type); } } } return result; }
/** * Returns the specified resource's adapter of the specified type. If none exists, create and * add a new adapter using a registered adapter factory if one exists for the specified type. * @param resource the adapted resource. * @param type the type of adapter. * @return an adapter associated with the specified eObject or null. */ public static Adapter getRegisteredAdapter(Resource resource, Object type) { Adapter result = getExistingAdapter(resource, type); if (result == null) { ResourceSet resourceSet = resource.getResourceSet(); if (resourceSet != null) { AdapterFactory factory = getAdapterFactory(resourceSet.getAdapterFactories(), type); if (factory != null) { result = factory.adaptNew(resource, type); } } } return result; }
/** * Returns the specified eObject's adapter of the specified type. If none exists, create and * add a new adapter using a registered adapter factory if one exists for the specified type. * @param eObject the adapted object. * @param type the type of adapter. * @return an adapter associated with the specified eObject or null. */ public static Adapter getRegisteredAdapter(EObject eObject, Object type) { Adapter result = getExistingAdapter(eObject, type); if (result == null) { Resource resource = eObject.eResource(); if (resource != null) { ResourceSet resourceSet = resource.getResourceSet(); if (resourceSet != null) { AdapterFactory factory = getAdapterFactory(resourceSet.getAdapterFactories(), type); if (factory != null) { result = factory.adaptNew(eObject, type); } } } } return result; }
/** * Returns the specified eObject's adapter of the specified type. If none exists, create and * add a new adapter using a registered adapter factory if one exists for the specified type. * @param eObject the adapted object. * @param type the type of adapter. * @return an adapter associated with the specified eObject or null. */ public static Adapter getRegisteredAdapter(EObject eObject, Object type) { Adapter result = getExistingAdapter(eObject, type); if (result == null) { Resource resource = eObject.eResource(); if (resource != null) { ResourceSet resourceSet = resource.getResourceSet(); if (resourceSet != null) { AdapterFactory factory = getAdapterFactory(resourceSet.getAdapterFactories(), type); if (factory != null) { result = factory.adaptNew(eObject, type); } } } } return result; }
resourceSet.getAdapterFactories().add(new XSDSchemaLocationResolverAdapterFactory());
rs.setURIConverter(converter); if (archive.shouldUseJavaReflection()) { rs.getAdapterFactories().add(new JavaJDKAdapterFactory());