/** * */ public void write(IMetadataRepository repository, OutputStream output) throws IOException { OutputStream bufferedOutput = null; try { bufferedOutput = new BufferedOutputStream(output); Writer repositoryWriter = new Writer(bufferedOutput, repository.getClass()); repositoryWriter.write(repository); } finally { if (bufferedOutput != null) { bufferedOutput.close(); } } }
/** * Writes a list of {@link IRepositoryReference}. * @param references An Iterator of {@link IRepositoryReference}. * @param size The number of references to write */ protected void writeRepositoryReferences(Iterator<IRepositoryReference> references, int size) { if (size == 0) return; start(REPOSITORY_REFERENCES_ELEMENT); attribute(COLLECTION_SIZE_ATTRIBUTE, size); while (references.hasNext()) writeRepositoryReference(references.next()); end(REPOSITORY_REFERENCES_ELEMENT); }
/** * Write the given metadata repository to the output stream. */ public void write(IMetadataRepository repository) { start(REPOSITORY_ELEMENT); attribute(NAME_ATTRIBUTE, repository.getName()); attribute(TYPE_ATTRIBUTE, repository.getType()); attribute(VERSION_ATTRIBUTE, repository.getVersion()); attributeOptional(PROVIDER_ATTRIBUTE, repository.getProvider()); attributeOptional(DESCRIPTION_ATTRIBUTE, repository.getDescription()); // TODO: could be cdata? writeProperties(repository.getProperties()); if (repository instanceof LocalMetadataRepository) { Set<IRepositoryReference> references = ((LocalMetadataRepository) repository).repositories; writeRepositoryReferences(references.iterator(), references.size()); } // The size attribute is a problematic since it forces the use of a collection. Set<IInstallableUnit> units = repository.query(QueryUtil.createIUAnyQuery(), null).toUnmodifiableSet(); writeInstallableUnits(units.iterator(), units.size()); end(REPOSITORY_ELEMENT); flush(); }
/** * Write the given metadata repository to the output stream. */ public void write(IMetadataRepository repository) { start(REPOSITORY_ELEMENT); attribute(NAME_ATTRIBUTE, repository.getName()); attribute(TYPE_ATTRIBUTE, repository.getType()); attribute(VERSION_ATTRIBUTE, repository.getVersion()); attributeOptional(PROVIDER_ATTRIBUTE, repository.getProvider()); attributeOptional(DESCRIPTION_ATTRIBUTE, repository.getDescription()); // TODO: could be cdata? writeProperties(repository.getProperties()); if (repository instanceof LocalMetadataRepository) { Set<IRepositoryReference> references = ((LocalMetadataRepository) repository).repositories; writeRepositoryReferences(references.iterator(), references.size()); } // The size attribute is a problematic since it forces the use of a collection. Set<IInstallableUnit> units = repository.query(QueryUtil.createIUAnyQuery(), null).toUnmodifiableSet(); writeInstallableUnits(units.iterator(), units.size()); end(REPOSITORY_ELEMENT); flush(); }
/** * Write the given metadata repository to the output stream. */ public void write(IMetadataRepository repository) { start(REPOSITORY_ELEMENT); attribute(NAME_ATTRIBUTE, repository.getName()); attribute(TYPE_ATTRIBUTE, repository.getType()); attribute(VERSION_ATTRIBUTE, repository.getVersion()); attributeOptional(PROVIDER_ATTRIBUTE, repository.getProvider()); attributeOptional(DESCRIPTION_ATTRIBUTE, repository.getDescription()); // TODO: could be cdata? writeProperties(repository.getProperties()); if (repository instanceof LocalMetadataRepository) { Set<IRepositoryReference> references = ((LocalMetadataRepository) repository).repositories; writeRepositoryReferences(references.iterator(), references.size()); } // The size attribute is a problematic since it forces the use of a collection. Set<IInstallableUnit> units = repository.query(QueryUtil.createIUAnyQuery(), null).toUnmodifiableSet(); writeInstallableUnits(units.iterator(), units.size()); end(REPOSITORY_ELEMENT); flush(); }
/** * */ public void write(IMetadataRepository repository, OutputStream output) throws IOException { OutputStream bufferedOutput = null; try { bufferedOutput = new BufferedOutputStream(output); Writer repositoryWriter = new Writer(bufferedOutput, repository.getClass()); repositoryWriter.write(repository); } finally { if (bufferedOutput != null) { bufferedOutput.close(); } } }
private void writeRepositoryReference(IRepositoryReference reference) { start(REPOSITORY_REFERENCE_ELEMENT); attribute(URI_ATTRIBUTE, reference.getLocation().toString()); try { // we write the URL attribute for backwards compatibility with 3.4.x // this attribute should be removed if we make a breaking format change. attribute(URL_ATTRIBUTE, URIUtil.toURL(reference.getLocation()).toExternalForm()); } catch (MalformedURLException e) { attribute(URL_ATTRIBUTE, reference.getLocation().toString()); } attribute(TYPE_ATTRIBUTE, Integer.toString(reference.getType())); attribute(OPTIONS_ATTRIBUTE, Integer.toString(reference.getOptions())); end(REPOSITORY_REFERENCE_ELEMENT); } }
private void writeRepositoryReference(IRepositoryReference reference) { start(REPOSITORY_REFERENCE_ELEMENT); attribute(URI_ATTRIBUTE, reference.getLocation().toString()); try { // we write the URL attribute for backwards compatibility with 3.4.x // this attribute should be removed if we make a breaking format change. attribute(URL_ATTRIBUTE, URIUtil.toURL(reference.getLocation()).toExternalForm()); } catch (MalformedURLException e) { attribute(URL_ATTRIBUTE, reference.getLocation().toString()); } attribute(TYPE_ATTRIBUTE, Integer.toString(reference.getType())); attribute(OPTIONS_ATTRIBUTE, Integer.toString(reference.getOptions())); end(REPOSITORY_REFERENCE_ELEMENT); } }
/** * */ public void write(IMetadataRepository repository, OutputStream output) throws IOException { OutputStream bufferedOutput = null; try { bufferedOutput = new BufferedOutputStream(output); Writer repositoryWriter = new Writer(bufferedOutput, repository.getClass()); repositoryWriter.write(repository); } finally { if (bufferedOutput != null) { bufferedOutput.close(); } } }
/** * Writes a list of {@link IRepositoryReference}. * @param references An Iterator of {@link IRepositoryReference}. * @param size The number of references to write */ protected void writeRepositoryReferences(Iterator<IRepositoryReference> references, int size) { if (size == 0) return; start(REPOSITORY_REFERENCES_ELEMENT); attribute(COLLECTION_SIZE_ATTRIBUTE, size); while (references.hasNext()) writeRepositoryReference(references.next()); end(REPOSITORY_REFERENCES_ELEMENT); }
private void writeRepositoryReference(IRepositoryReference reference) { start(REPOSITORY_REFERENCE_ELEMENT); attribute(URI_ATTRIBUTE, reference.getLocation().toString()); try { // we write the URL attribute for backwards compatibility with 3.4.x // this attribute should be removed if we make a breaking format change. attribute(URL_ATTRIBUTE, URIUtil.toURL(reference.getLocation()).toExternalForm()); } catch (MalformedURLException e) { attribute(URL_ATTRIBUTE, reference.getLocation().toString()); } attribute(TYPE_ATTRIBUTE, Integer.toString(reference.getType())); attribute(OPTIONS_ATTRIBUTE, Integer.toString(reference.getOptions())); end(REPOSITORY_REFERENCE_ELEMENT); } }
/** * Writes a list of {@link IRepositoryReference}. * @param references An Iterator of {@link IRepositoryReference}. * @param size The number of references to write */ protected void writeRepositoryReferences(Iterator<IRepositoryReference> references, int size) { if (size == 0) return; start(REPOSITORY_REFERENCES_ELEMENT); attribute(COLLECTION_SIZE_ATTRIBUTE, size); while (references.hasNext()) writeRepositoryReference(references.next()); end(REPOSITORY_REFERENCES_ELEMENT); }