Skip to content

Commit

Permalink
Move META_FLAG constant to MetaData
Browse files Browse the repository at this point in the history
  • Loading branch information
lenhard committed Dec 1, 2015
1 parent 18b39f7 commit 459a211
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 16 deletions.
9 changes: 5 additions & 4 deletions src/main/java/net/sf/jabref/MetaData.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import java.util.*;

import net.sf.jabref.groups.GroupTreeNode;
import net.sf.jabref.gui.GUIGlobals;
import net.sf.jabref.migrations.VersionHandling;
import net.sf.jabref.logic.labelPattern.AbstractLabelPattern;
import net.sf.jabref.logic.labelPattern.DatabaseLabelPattern;
Expand All @@ -29,6 +28,8 @@

public class MetaData implements Iterable<String> {

public static final String META_FLAG = "jabref-meta: ";
public static final String META_FLAG_OLD = "bibkeeper-meta: ";

This comment has been minimized.

Copy link
@simonharrer

simonharrer Dec 1, 2015

Contributor

This is related to #379

This comment has been minimized.

Copy link
@lenhard

lenhard Dec 1, 2015

Author Member

Thanks, I wasn't aware of that. It will be pretty easy to move these constants somewhere else, although MetaData is a good fit in my opinion.

This comment has been minimized.

Copy link
@koppor

koppor Dec 2, 2015

Member

Don't we have somewhere an update method? We should move "META_FLAG_OLD"-handling to there. Or just remove that code completely. Bibkeeper is outdated since November 2003 and therefore should not be used by anyone any more.

This comment has been minimized.

Copy link
@lenhard

lenhard Dec 2, 2015

Author Member

I'm very much for removing. Will do that in this PR.

private static final String PREFIX_KEYPATTERN = "keypattern_";
private static final String KEYPATTERNDEFAULT = "keypatterndefault";

Expand Down Expand Up @@ -258,7 +259,7 @@ public void writeMetaData(Writer out) throws IOException {
for (String key : sortedKeys) {
StringBuffer sb = new StringBuffer();
Vector<String> orderedData = metaData.get(key);
sb.append("@comment{").append(GUIGlobals.META_FLAG).append(key).append(":");
sb.append("@comment{").append(META_FLAG).append(key).append(":");
for (int j = 0; j < orderedData.size(); j++) {
sb.append(StringUtil.quote(orderedData.elementAt(j), ";", '\\')).append(";");
}
Expand All @@ -273,7 +274,7 @@ public void writeMetaData(Writer out) throws IOException {
if ((groupsRoot != null) && (groupsRoot.getChildCount() > 0)) {
StringBuffer sb = new StringBuffer();
// write version first
sb.append("@comment{").append(GUIGlobals.META_FLAG).append("groupsversion:");
sb.append("@comment{").append(META_FLAG).append("groupsversion:");
sb.append("" + VersionHandling.CURRENT_VERSION + ";");
sb.append("}");
sb.append(Globals.NEWLINE);
Expand All @@ -282,7 +283,7 @@ public void writeMetaData(Writer out) throws IOException {

// now write actual groups
sb = new StringBuffer();
sb.append("@comment{").append(GUIGlobals.META_FLAG).append("groupstree:");
sb.append("@comment{").append(META_FLAG).append("groupstree:");
sb.append(Globals.NEWLINE);
// GroupsTreeNode.toString() uses "\n" for separation
StringTokenizer tok = new StringTokenizer(groupsRoot.getTreeAsString(), Globals.NEWLINE);
Expand Down
3 changes: 0 additions & 3 deletions src/main/java/net/sf/jabref/gui/GUIGlobals.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,6 @@ public class GUIGlobals {
public static Color activeBackground;
public static Color invalidFieldBackgroundColor;

public static final String META_FLAG = "jabref-meta: ";
public static final String META_FLAG_OLD = "bibkeeper-meta: ";

// some fieldname constants
public static final double DEFAULT_FIELD_WEIGHT = 1;
public static final double MAX_FIELD_WEIGHT = 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import net.sf.jabref.*;
import net.sf.jabref.bibtex.EntryTypes;
import net.sf.jabref.logic.CustomEntryTypesManager;
import net.sf.jabref.gui.GUIGlobals;
import net.sf.jabref.model.database.KeyCollisionException;
import net.sf.jabref.importer.ParserResult;
import net.sf.jabref.model.entry.IdGenerator;
Expand Down Expand Up @@ -302,18 +301,18 @@ private void parseJabRefComment(HashMap<String, String> meta) throws IOException
*/
String comment = buffer.toString().replaceAll("[\\x0d\\x0a]", "");
if (comment.substring(0,
Math.min(comment.length(), GUIGlobals.META_FLAG.length())).equals(
GUIGlobals.META_FLAG)
Math.min(comment.length(), MetaData.META_FLAG.length())).equals(
MetaData.META_FLAG)
|| comment.substring(0,
Math.min(comment.length(), GUIGlobals.META_FLAG_OLD.length()))
.equals(GUIGlobals.META_FLAG_OLD)) {
Math.min(comment.length(), MetaData.META_FLAG_OLD.length()))
.equals(MetaData.META_FLAG_OLD)) {

String rest;
if (comment.substring(0, GUIGlobals.META_FLAG.length()).equals(
GUIGlobals.META_FLAG)) {
rest = comment.substring(GUIGlobals.META_FLAG.length());
if (comment.substring(0, MetaData.META_FLAG.length()).equals(
MetaData.META_FLAG)) {
rest = comment.substring(MetaData.META_FLAG.length());
} else {
rest = comment.substring(GUIGlobals.META_FLAG_OLD.length());
rest = comment.substring(MetaData.META_FLAG_OLD.length());
}

int pos = rest.indexOf(':');
Expand Down

0 comments on commit 459a211

Please sign in to comment.