/** * Writes a list of URIs referring to sub repositories */ protected void writeChildren(URI[] children) { if (children == null || children.length == 0) return; start(CHILDREN_ELEMENT); attribute(COLLECTION_SIZE_ATTRIBUTE, children.length); for (int i = 0; i < children.length; i++) writeChild(children[i]); end(CHILDREN_ELEMENT); }
/** * Write the given composite repository to the output stream. */ public void write(CompositeRepositoryState 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()); writeChildren(repository.getChildren()); end(REPOSITORY_ELEMENT); flush(); }
/** * Writes the given repository to the stream. * This method performs buffering, and closes the stream when finished. */ public void write(CompositeRepositoryState repository, OutputStream output, String type) { OutputStream bufferedOutput = null; try { try { bufferedOutput = new BufferedOutputStream(output); CompositeWriter repositoryWriter = new CompositeWriter(bufferedOutput, type); repositoryWriter.write(repository); } finally { if (bufferedOutput != null) { bufferedOutput.close(); } } } catch (IOException ioe) { // TODO shouldn't this throw a core exception? ioe.printStackTrace(); } }
/** * Write the given composite repository to the output stream. */ public void write(CompositeRepositoryState 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()); writeChildren(repository.getChildren()); end(REPOSITORY_ELEMENT); flush(); }
/** * Writes the given repository to the stream. * This method performs buffering, and closes the stream when finished. */ public void write(CompositeRepositoryState repository, OutputStream output, String type) { OutputStream bufferedOutput = null; try { try { bufferedOutput = new BufferedOutputStream(output); CompositeWriter repositoryWriter = new CompositeWriter(bufferedOutput, type); repositoryWriter.write(repository); } finally { if (bufferedOutput != null) { bufferedOutput.close(); } } } catch (IOException ioe) { // TODO shouldn't this throw a core exception? ioe.printStackTrace(); } }
/** * Writes a list of URIs referring to sub repositories */ protected void writeChildren(URI[] children) { if (children == null || children.length == 0) return; start(CHILDREN_ELEMENT); attribute(COLLECTION_SIZE_ATTRIBUTE, children.length); for (int i = 0; i < children.length; i++) writeChild(children[i]); end(CHILDREN_ELEMENT); }