Class Encoding
- java.lang.Object
-
- org.apache.pdfbox.pdmodel.font.encoding.Encoding
-
- All Implemented Interfaces:
COSObjectable
- Direct Known Subclasses:
BuiltInEncoding
,DictionaryEncoding
,MacExpertEncoding
,MacRomanEncoding
,StandardEncoding
,SymbolEncoding
,Type1Encoding
,WinAnsiEncoding
,ZapfDingbatsEncoding
public abstract class Encoding extends java.lang.Object implements COSObjectable
A PostScript encoding vector, maps character codes to glyph names.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Map<java.lang.Integer,java.lang.String>
codeToName
protected java.util.Map<java.lang.String,java.lang.Integer>
inverted
private java.util.Set<java.lang.String>
names
-
Constructor Summary
Constructors Constructor Description Encoding()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
add(int code, java.lang.String name)
This will add a character encoding.boolean
contains(int code)
Determines if the encoding has a mapping for the given code value.boolean
contains(java.lang.String name)
Determines if the encoding has a mapping for the given name value.java.util.Map<java.lang.Integer,java.lang.String>
getCodeToNameMap()
Returns an unmodifiable view of the code -> name mapping.abstract java.lang.String
getEncodingName()
Returns the name of this encoding.static Encoding
getInstance(COSName name)
This will get an encoding by name.java.lang.String
getName(int code)
This will take a character code and get the name from the code.java.util.Map<java.lang.String,java.lang.Integer>
getNameToCodeMap()
Returns an unmodifiable view of the name -> code mapping.protected void
overwrite(int code, java.lang.String name)
This will add a character encoding.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.pdfbox.pdmodel.common.COSObjectable
getCOSObject
-
-
-
-
Method Detail
-
getInstance
public static Encoding getInstance(COSName name)
This will get an encoding by name. May return null.- Parameters:
name
- The name of the encoding to get.- Returns:
- The encoding that matches the name.
-
getCodeToNameMap
public java.util.Map<java.lang.Integer,java.lang.String> getCodeToNameMap()
Returns an unmodifiable view of the code -> name mapping.- Returns:
- the code -> name map
-
getNameToCodeMap
public java.util.Map<java.lang.String,java.lang.Integer> getNameToCodeMap()
Returns an unmodifiable view of the name -> code mapping. More than one name may map to the same code.- Returns:
- the name -> code map
-
add
protected void add(int code, java.lang.String name)
This will add a character encoding. An already existing mapping is preservered when creating the reverse mapping.- Parameters:
code
- character codename
- PostScript glyph name- See Also:
overwrite(int, String)
-
overwrite
protected void overwrite(int code, java.lang.String name)
This will add a character encoding. An already existing mapping is overwritten when creating the reverse mapping.- Parameters:
code
- character codename
- PostScript glyph name- See Also:
add(int, String)
-
contains
public boolean contains(java.lang.String name)
Determines if the encoding has a mapping for the given name value.- Parameters:
name
- PostScript glyph name
-
contains
public boolean contains(int code)
Determines if the encoding has a mapping for the given code value.- Parameters:
code
- character code
-
getName
public java.lang.String getName(int code)
This will take a character code and get the name from the code.- Parameters:
code
- character code- Returns:
- PostScript glyph name
-
getEncodingName
public abstract java.lang.String getEncodingName()
Returns the name of this encoding.
-
-