use of org.eclipse.che.api.git.shared.Branch in project che by eclipse.
the class BranchListWriter method writeTo.
/**
* @see MessageBodyWriter#writeTo(Object, Class, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType,
* javax.ws.rs.core.MultivaluedMap, java.io.OutputStream)
*/
@Override
public void writeTo(Iterable<Branch> branches, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException, WebApplicationException {
Writer writer = new OutputStreamWriter(entityStream);
for (Branch branch : branches) {
if (branch.isActive()) {
writer.write('*');
} else {
writer.write(' ');
}
writer.write(' ');
if (branch.getName().startsWith("refs/remotes")) {
// trim leading 'refs/'
writer.write(branch.getName().substring(5));
} else {
writer.write(branch.getDisplayName());
}
writer.write('\n');
}
writer.flush();
}
Aggregations