Skip to content

Commit

Permalink
Tag.label(flag)
Browse files Browse the repository at this point in the history
  • Loading branch information
glorieux-f committed May 16, 2024
1 parent dc39e0e commit d0667b2
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions src/main/java/com/github/oeuvres/alix/fr/Tag.java
Original file line number Diff line number Diff line change
Expand Up @@ -231,12 +231,12 @@ public enum Tag
}

/** Array to get a tag by number */
private static final Tag[] Flag4name = new Tag[256];
private static final Tag[] Flag4tag = new Tag[256];
/** Dictionary to get number of a tag by name */
private static final Map<String, Integer> Name4flag = new HashMap<String, Integer>();
static {
for (Tag tag : Tag.values()) {
Flag4name[tag.flag] = tag;
Flag4tag[tag.flag] = tag;
Name4flag.put(tag.toString(), tag.flag);
}
}
Expand All @@ -258,7 +258,7 @@ public boolean sameParent(final int flag)
*/
static public Tag parent(final int flag)
{
Tag ret = Flag4name[flag & 0xF0];
Tag ret = Flag4tag[flag & 0xF0];
if (ret == null)
return UNKNOWN;
return ret;
Expand Down Expand Up @@ -333,7 +333,7 @@ public static Tag tag(int flag)
{
// the int may be used as a more complex bit flag
flag = flag & 0xFF;
return Flag4name[flag];
return Flag4tag[flag];
}


Expand All @@ -344,13 +344,25 @@ public static Tag tag(int flag)
*/
public static String name(int flag)
{
flag = flag & 0xFF;
Tag tag = Flag4name[flag];
Tag tag = tag(flag);
if (tag == null)
return null;
return tag.name;
}

/**
* Get Tag label by number identifier.
* @param flag Tag identifier number.
* @return Label of a Tag.
*/
public static String label(int flag)
{
Tag tag = tag(flag);
if (tag == null)
return null;
return tag.label;
}

/**
* A filter for different pos code, implemented as a boolean vector.
*/
Expand Down

0 comments on commit d0667b2

Please sign in to comment.