diff options
author | Sasa Zivkov <sasa.zivkov@sap.com> | 2011-01-03 16:03:49 +0100 |
---|---|---|
committer | Sasa Zivkov <sasa.zivkov@sap.com> | 2011-01-05 08:24:13 +0100 |
commit | 7cd812940d25a78f71467ede0b2637211b2a12a1 (patch) | |
tree | 7bf2f1f7aea387ab05f076fd46dd0dc3e590d2b5 /org.eclipse.jgit/src/org/eclipse/jgit/notes/NoteMap.java | |
parent | b7f887f1204fc14e2ef698d6d4a24d13fa6de5e6 (diff) | |
download | jgit-7cd812940d25a78f71467ede0b2637211b2a12a1.tar.gz jgit-7cd812940d25a78f71467ede0b2637211b2a12a1.zip |
NoteMap implements Iterable<Note>
We will need to iterate over all notes of a NoteMap, at least this will be
needed for testing purposes. This change also implied making the Note class
public.
Change-Id: I9b0639f9843f457ee9de43504b2499a673cd0e77
Signed-off-by: Sasa Zivkov <sasa.zivkov@sap.com>
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/notes/NoteMap.java')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/notes/NoteMap.java | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/notes/NoteMap.java b/org.eclipse.jgit/src/org/eclipse/jgit/notes/NoteMap.java index 6a7b5cffbe..abde6db765 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/notes/NoteMap.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/notes/NoteMap.java @@ -44,6 +44,7 @@ package org.eclipse.jgit.notes; import java.io.IOException; +import java.util.Iterator; import org.eclipse.jgit.errors.CorruptObjectException; import org.eclipse.jgit.errors.IncorrectObjectTypeException; @@ -52,6 +53,7 @@ import org.eclipse.jgit.errors.MissingObjectException; import org.eclipse.jgit.lib.AbbreviatedObjectId; import org.eclipse.jgit.lib.AnyObjectId; import org.eclipse.jgit.lib.Constants; +import org.eclipse.jgit.lib.MutableObjectId; import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.ObjectInserter; import org.eclipse.jgit.lib.ObjectReader; @@ -66,7 +68,7 @@ import org.eclipse.jgit.revwalk.RevTree; * is not released by this class. The caller should arrange for releasing the * shared {@code ObjectReader} at the proper times. */ -public class NoteMap { +public class NoteMap implements Iterable<Note> { /** * Construct a new empty note map. * @@ -166,6 +168,18 @@ public class NoteMap { } /** + * @return an iterator that iterates over notes of this NoteMap. Non note + * entries are ignored by this iterator. + */ + public Iterator<Note> iterator() { + try { + return root.iterator(new MutableObjectId(), reader); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + /** * Lookup a note for a specific ObjectId. * * @param id |