Top Description Fields Constructors Methods
org.apache.pdfbox.pdmodel.font.encoding

public abstract Class Encoding

extends Object
implements COSObjectable
Class Inheritance
All Implemented Interfaces
org.apache.pdfbox.pdmodel.common.COSObjectable
Known Direct Subclasses
org.apache.pdfbox.pdmodel.font.encoding.MacExpertEncoding, org.apache.pdfbox.pdmodel.font.encoding.MacRomanEncoding, org.apache.pdfbox.pdmodel.font.encoding.StandardEncoding, org.apache.pdfbox.pdmodel.font.encoding.SymbolEncoding, org.apache.pdfbox.pdmodel.font.encoding.Type1Encoding, org.apache.pdfbox.pdmodel.font.encoding.WinAnsiEncoding, org.apache.pdfbox.pdmodel.font.encoding.ZapfDingbatsEncoding, org.apache.pdfbox.pdmodel.font.encoding.BuiltInEncoding, org.apache.pdfbox.pdmodel.font.encoding.DictionaryEncoding
Imports
java.util.Collections, .HashMap, .Map, org.apache.pdfbox.cos.COSName, org.apache.pdfbox.pdmodel.common.COSObjectable

A PostScript encoding vector, maps character codes to glyph names.
Author
Ben Litchfield

Field Summary

Modifier and TypeField and Description
protected static final int
protected static final int
protected final Map<Integer, String>
codeToName

code-to-name map.

protected final Map<String, Integer>
inverted

name-to-code map.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected void
add(int
character code
code
,
String
PostScript glyph name
name
)

This will add a character encoding.

public boolean

Returns:

true if the encoding has a mapping for the given name value
contains
(String
PostScript glyph name
name
)

Determines if the encoding has a mapping for the given name value.

public boolean

Returns:

if the encoding has a mapping for the given code value
contains
(int
character code
code
)

Determines if the encoding has a mapping for the given code value.

public Map<Integer, String>

Returns:

the code -> name map
getCodeToNameMap
()

Returns an unmodifiable view of the code -> name mapping.

public abstract String

Returns:

the name of the encoding
getEncodingName
()

Returns the name of this encoding.

public static Encoding

Returns:

The encoding that matches the name.
getInstance
(COSName
The name of the encoding to get.
name
)

This will get an encoding by name.

public String

Returns:

PostScript glyph name
getName
(int
character code
code
)

This will take a character code and get the name from the code.

public Map<String, Integer>

Returns:

the name -> code map
getNameToCodeMap
()

Returns an unmodifiable view of the name -> code mapping.

protected void
overwrite(int
character code
code
,
String
PostScript glyph name
name
)

This will add a character encoding.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CHAR_CODEback to summary
protected static final int CHAR_CODE
CHAR_NAMEback to summary
protected static final int CHAR_NAME
codeToNameback to summary
protected final Map<Integer, String> codeToName

code-to-name map. Derived classes should not modify the map after class construction.

invertedback to summary
protected final Map<String, Integer> inverted

name-to-code map. Derived classes should not modify the map after class construction.

Constructor Detail

Encodingback to summary
public Encoding()

Method Detail

addback to summary
protected void add(int code, String name)

This will add a character encoding. An already existing mapping is preserved when creating the reverse mapping. Should only be used during construction of the class.

Parameters
code:int

character code

name:String

PostScript glyph name

See Also
overwrite(int, String)
containsback to summary
public boolean contains(String name)

Determines if the encoding has a mapping for the given name value.

Parameters
name:String

PostScript glyph name

Returns:boolean

true if the encoding has a mapping for the given name value

containsback to summary
public boolean contains(int code)

Determines if the encoding has a mapping for the given code value.

Parameters
code:int

character code

Returns:boolean

if the encoding has a mapping for the given code value

getCodeToNameMapback to summary
public Map<Integer, String> getCodeToNameMap()

Returns an unmodifiable view of the code -> name mapping.

Returns:Map<Integer, String>

the code -> name map

getEncodingNameback to summary
public abstract String getEncodingName()

Returns the name of this encoding.

Returns:String

the name of the encoding

getInstanceback to summary
public static Encoding getInstance(COSName name)

This will get an encoding by name. May return null.

Parameters
name:COSName

The name of the encoding to get.

Returns:Encoding

The encoding that matches the name.

getNameback to summary
public String getName(int code)

This will take a character code and get the name from the code.

Parameters
code:int

character code

Returns:String

PostScript glyph name

getNameToCodeMapback to summary
public Map<String, Integer> getNameToCodeMap()

Returns an unmodifiable view of the name -> code mapping. More than one name may map to the same code.

Returns:Map<String, Integer>

the name -> code map

overwriteback to summary
protected void overwrite(int code, String name)

This will add a character encoding. An already existing mapping is overwritten when creating the reverse mapping. Should only be used during construction of the class.

Parameters
code:int

character code

name:String

PostScript glyph name

See Also
Encoding#add(int, String)