public void writeToEcore(File file) { ResourceSet resourceSet = new ResourceSetImpl(); resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecore", new EcoreResourceFactoryImpl()); Resource resource = resourceSet.createResource(URI.createFileURI(file.getAbsolutePath())); for (EPackage ePackage : packages.values()) { resource.getContents().add(ePackage); } try { resource.save(null); } catch (IOException e) { LOGGER.error("", e); } }
public URI getBuilderStateURI() { File location = getBuilderStateLocation(); if (location == null) return null; URI fileURI = URI.createFileURI(location.getAbsolutePath()); return fileURI; }
private URI createURI(String uriString) { if (hasProtocol(uriString)) return URI.createURI(uriString); else return URI.createFileURI(uriString); }
private URI createURI(String path) { if (path == null) { throw new IllegalArgumentException(); } URI uri = URI.createURI(path); if (uri.isRelative()) { URI resolvedURI = URI.createFileURI(new File(path).getAbsolutePath()); return resolvedURI; } return uri; }
/** * Default Constructor * * @throws XmlException * @throws IOException * @throws ConfigurationException */ public Hive () throws IOException, ConfigurationException { this ( new XmlConfigurator ( URI.createFileURI ( "configuration.xml" ) ) ); }
/** * @return resource with security object and package */ public static Resource loadSecurityModel(final String securityFile) { // Get the URI of the model file. final File secFile = new File(securityFile); final URI securityFileURI = URI.createFileURI(secFile.getAbsolutePath()); return loadSecurityModel(securityFileURI); }
/** * In contrast to {@link URI#createFileURI(String)}, this appends a trailing path separator. This ensures * the resulting URI can be used with methods like {@link #isPrefixOf(URI, URI)}, {@link URI#resolve(URI)} and * {@link URI#deresolve(URI)} */ public static URI createFolderURI(File file) { URI uri = URI.createFileURI(file.getAbsolutePath()); return toFolderURI(uri); }
private static URI createURI(String uriString) { if (hasProtocol(uriString)) return URI.createURI(uriString); else return URI.createFileURI(uriString); }
private URI getRestFileURI(Description description) { String sampleRestFilePath = getSampleRestName(description); URI modelURI = URI.createFileURI(Resources.getResource("models/dsl").getFile()); for (String nextSegment : sampleRestFilePath.split("/")) { modelURI = modelURI.appendSegment(nextSegment); } return modelURI; }
private Resource createResource() { if (saveAndRestore) { URI saveLocation = URI.createFileURI(getWorkbenchSaveLocation().getAbsolutePath()); return resourceSetImpl.createResource(saveLocation); } return resourceSetImpl.createResource(URI.createURI("workbench.xmi")); //$NON-NLS-1$ }
private void processFile ( final File file, final Hive hive ) throws ConfigurationException { try { final RootType subRoot = parse ( URI.createFileURI ( file.getAbsolutePath () ) ); configure ( subRoot, hive ); } catch ( final IOException e ) { throw new ConfigurationException ( "Failed to parse sub xml document: " + file, e ); } }
private void processFile ( final File file, final Hive hive ) throws ConfigurationException { try { final RootType subRoot = parse ( URI.createFileURI ( file.getAbsolutePath () ) ); configure ( subRoot, hive ); } catch ( final IOException e ) { throw new ConfigurationException ( "Failed to parse sub xml document: " + file, e ); } }
public static URI getUriForPackageFragmentRoot(IPackageFragmentRoot root) { IResource underlyingResource = root.getResource(); if (underlyingResource == null) { return URI.createFileURI(root.getPath().toString()); } else { return URI.createPlatformResourceURI(underlyingResource.getFullPath().toString(), true); } }
private void processProfile ( final File output ) throws IOException { final Profile profile = makeProfile ( this.app ); final File profileFile = new File ( output, this.app.getName () + ".profile.xml" ); //$NON-NLS-1$ final ResourceSet rs = new ResourceSetImpl (); final Resource r = rs.createResource ( URI.createFileURI ( profileFile.toString () ) ); r.getContents ().add ( EcoreUtil.copy ( profile ) ); final Map<Object, Object> options = new HashMap<> (); options.put ( XMLResource.OPTION_ENCODING, "UTF-8" ); //$NON-NLS-1$ r.save ( options ); }
private void processProfile ( final File output ) throws IOException { final Profile profile = makeProfile ( this.app ); final File profileFile = new File ( output, this.app.getName () + ".profile.xml" ); //$NON-NLS-1$ final ResourceSet rs = new ResourceSetImpl (); final Resource r = rs.createResource ( URI.createFileURI ( profileFile.toString () ) ); r.getContents ().add ( EcoreUtil.copy ( profile ) ); final Map<Object, Object> options = new HashMap<> (); options.put ( XMLResource.OPTION_ENCODING, "UTF-8" ); //$NON-NLS-1$ r.save ( options ); }
public static void save(final SecurityModel model, final String fileName) throws IOException { final File file = new File(fileName); final URI fileURI = URI.createFileURI(file.getAbsolutePath()); final ResourceSet resourceSet = new ResourceSetImpl(); final Resource secResource = resourceSet.createResource(fileURI); model.setName(getModelName(fileURI)); secResource.getContents().add(model); save(secResource); }
@Deprecated private URI deprecatedToBaseDir(final InitializeParams params) { String _rootPath = params.getRootPath(); boolean _tripleNotEquals = (_rootPath != null); if (_tripleNotEquals) { return this._uriExtensions.toUri(this._uriExtensions.toUriString(URI.createFileURI(params.getRootPath()))); } return null; }
private static Ast initialiseAstModel() { final Ast astModel = AntlrAstFactory.eINSTANCE.createAst(); final ResourceSet resourceSet = new ResourceSetImpl(); resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("*", new EcoreResourceFactoryImpl()); final Resource resource = resourceSet.createResource(URI.createFileURI("default.ecore")); resource.getContents().add(astModel); return astModel; }
private ZenModel loadDslModel(String path) { URI uri = URI.createFileURI(path); return new DslRestModelLoader(new RepreZenXtextResourceSet()).load(uri); }
@Test void testCreateLocalUriWithUri() throws IOException { final URI uri = factory.createLocalUri(URI.createFileURI(currentTempFile().getAbsolutePath())); assertThat(uri.isFile()).isTrue(); assertThat(uri.scheme()).isEqualTo(SCHEME); assertThat(new File(uri.toFileString())).isEqualTo(currentTempFile()); }