Skip to content

Commit

Permalink
Cleanup in BibtexDatabase
Browse files Browse the repository at this point in the history
  • Loading branch information
lenhard committed Aug 18, 2015
1 parent f26c873 commit d73a67d
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/main/java/net/sf/jabref/model/BibtexDatabase.java
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ public synchronized BibtexEntry getEntryByKey(String key) {
int keyHash = key.hashCode(); // key hash for better performance

Set<String> keySet = entries.keySet();
for (String entrieID : keySet) {
BibtexEntry entry = getEntryById(entrieID);
for (String entryID : keySet) {
BibtexEntry entry = getEntryById(entryID);
if (entry != null && entry.getCiteKey() != null) {
String citeKey = entry.getCiteKey();
if (citeKey != null) {
Expand All @@ -179,15 +179,15 @@ public synchronized BibtexEntry getEntryByKey(String key) {

public synchronized BibtexEntry[] getEntriesByKey(String key) {

ArrayList<BibtexEntry> entries = new ArrayList<BibtexEntry>();
ArrayList<BibtexEntry> result = new ArrayList<>();

for (BibtexEntry entry : this.entries.values()) {
for (BibtexEntry entry : entries.values()) {
if (key.equals(entry.getCiteKey())) {
entries.add(entry);
result.add(entry);
}
}

return entries.toArray(new BibtexEntry[entries.size()]);
return result.toArray(new BibtexEntry[result.size()]);
}

/**
Expand Down Expand Up @@ -331,7 +331,7 @@ public String resolveForStrings(String content) {
if (content == null) {
throw new IllegalArgumentException("Content for resolveForStrings must not be null.");
}
return resolveContent(content, new HashSet<String>());
return resolveContent(content, new HashSet<>());
}

/**
Expand All @@ -347,10 +347,10 @@ public String resolveForStrings(String content) {
public List<BibtexEntry> resolveForStrings(Collection<BibtexEntry> entries, boolean inPlace) {

if (entries == null) {
throw new NullPointerException();
throw new IllegalArgumentException("entries must not be null");
}

List<BibtexEntry> results = new ArrayList<BibtexEntry>(entries.size());
List<BibtexEntry> results = new ArrayList<>(entries.size());

for (BibtexEntry entry : entries) {
results.add(this.resolveForStrings(entry, inPlace));
Expand Down Expand Up @@ -409,14 +409,14 @@ private String resolveString(String label, HashSet<String> usedIds) {

// Ok, we found the string. Now we must make sure we
// resolve any references to other strings in this one.
String res = string.getContent();
res = resolveContent(res, usedIds);
String result = string.getContent();
result = resolveContent(result, usedIds);

// Finished with recursing this branch, so we remove our
// ID again:
usedIds.remove(string.getId());

return res;
return result;
}
}

Expand All @@ -431,7 +431,7 @@ private String resolveString(String label, HashSet<String> usedIds) {
}

private String resolveContent(String res, HashSet<String> usedIds) {
//if (res.matches(".*#[-\\^\\:\\w]+#.*")) {

if (res.matches(".*#[^#]+#.*")) {
StringBuilder newRes = new StringBuilder();
int piv = 0;
Expand Down

0 comments on commit d73a67d

Please sign in to comment.