[
https://issues.apache.org/jira/browse/PDFBOX-4987?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17219803#comment-17219803
]
Maruan Sahyoun commented on PDFBOX-4987:
----------------------------------------
[~lehmi] let's wait what [~ssteiner] thinks about it. We could make the key
being a part of the Enum like so
{code:java}
public enum Type2KeyWord
{
HSTEM(new Key(1)); // Others omitted
final Key key;
private Type2KeyWord(Key key)
{
this.key = key;
}
private static final Map<Key, Type2KeyWord> BY_KEY = new HashMap<>();
static
{
for (Type2KeyWord e : values())
{
BY_KEY.put(e.key, e);
}
}
public static Type2KeyWord valueOfKey(Key key)
{
return BY_KEY.get(key);
}
}
{code}
As a result {{public static final Map<Key, String> TYPE1_VOCABULARY;}} and
{{public static final Map<Key, String> TYPE2_VOCABULARY;}} are no longer needed
as the Enum holds the map internally.
wrt 2.0 - I don't think that we can replace in the same way. We could add the
enum based version to the current one and create the enum from string keeping
the string signatures to create/return just in case. So the external signature
remains. If we go with the \{{Key}} being part of the Enum both versions can
coexist with us using the Enum based internally I'd think
> CharStringCommand should use referenced string
> ----------------------------------------------
>
> Key: PDFBOX-4987
> URL: https://issues.apache.org/jira/browse/PDFBOX-4987
> Project: PDFBox
> Issue Type: Improvement
> Components: Parsing
> Affects Versions: 3.0.0 PDFBox
> Reporter: Simon Steiner
> Assignee: Andreas Lehmkühler
> Priority: Major
> Fix For: 3.0.0 PDFBox
>
>
> CharStringCommand, Type2CharString and Type1CharString use duplicate string
> instances, could they use enum or final strings so its easier to debug the
> code
> eg
> static final x =new key(1, {color:#008000}"hstem");{color}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]