Class CMap


  • public class CMap
    extends java.lang.Object
    This class represents a CMap file.
    Author:
    Ben Litchfield (ben@benlitchfield.com)
    • Constructor Summary

      Constructors 
      Constructor Description
      CMap()
      Creates a new instance of CMap.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addCIDMapping​(int src, java.lang.String dest)
      This will add a CID mapping.
      void addCIDRange​(char from, char to, int cid)
      This will add a CID Range.
      void addCodespaceRange​(CodespaceRange range)
      This will add a codespace range.
      void addMapping​(byte[] src, java.lang.String dest)
      This will add a mapping.
      java.util.List<CodespaceRange> getCodeSpaceRanges()
      Getter for property codeSpaceRanges.
      java.lang.String getName()
      Returns the name of the CMap.
      java.lang.String getOrdering()
      Returns the ordering of the CIDSystemInfo.
      java.lang.String getRegistry()
      Returns the registry of the CIDSystemInfo.
      int getSpaceMapping()
      Returns the mapping for the space character.
      int getSupplement()
      Returns the supplement of the CIDSystemInfo.
      int getType()
      Returns the type of the CMap.
      java.lang.String getVersion()
      Returns the version of the CMap.
      int getWMode()
      Returns the WMode of a CMap.
      boolean hasCIDMappings()
      This will tell if this cmap has any CID mappings.
      boolean hasOneByteMappings()
      This will tell if this cmap has any one byte mappings.
      boolean hasTwoByteMappings()
      This will tell if this cmap has any two byte mappings.
      boolean isInCodeSpaceRanges​(byte[] code)
      Check whether the given byte array is in codespace ranges or not.
      boolean isInCodeSpaceRanges​(byte[] code, int offset, int length)
      Check whether the given byte array is in codespace ranges or not.
      java.lang.String lookup​(byte[] code, int offset, int length)
      This will perform a lookup into the map.
      java.lang.String lookup​(int code, int length)
      This will perform a lookup into the map.
      int lookupCID​(byte[] code, int offset, int length)
      This will perform a lookup into the CID map.
      java.lang.String lookupCID​(int cid)
      This will perform a lookup into the CID map.
      void setName​(java.lang.String name)
      Sets the name of the CMap.
      void setOrdering​(java.lang.String newOrdering)
      Sets the ordering of the CIDSystemInfo.
      void setRegistry​(java.lang.String newRegistry)
      Sets the registry of the CIDSystemInfo.
      void setSupplement​(int newSupplement)
      Sets the supplement of the CIDSystemInfo.
      void setType​(int type)
      Sets the type of the CMap.
      void setVersion​(java.lang.String version)
      Sets the version of the CMap.
      void setWMode​(int newWMode)
      Sets the WMode of a CMap.
      void useCmap​(CMap cmap)
      Implementation of the usecmap operator.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CMap

        public CMap()
        Creates a new instance of CMap.
    • Method Detail

      • hasOneByteMappings

        public boolean hasOneByteMappings()
        This will tell if this cmap has any one byte mappings.
        Returns:
        true If there are any one byte mappings, false otherwise.
      • hasTwoByteMappings

        public boolean hasTwoByteMappings()
        This will tell if this cmap has any two byte mappings.
        Returns:
        true If there are any two byte mappings, false otherwise.
      • hasCIDMappings

        public boolean hasCIDMappings()
        This will tell if this cmap has any CID mappings.
        Returns:
        true If there are any CID mappings, false otherwise.
      • lookup

        public java.lang.String lookup​(byte[] code,
                                       int offset,
                                       int length)
        This will perform a lookup into the map.
        Parameters:
        code - The code used to lookup.
        offset - The offset into the byte array.
        length - The length of the data we are getting.
        Returns:
        The string that matches the lookup.
      • lookup

        public java.lang.String lookup​(int code,
                                       int length)
        This will perform a lookup into the map.
        Parameters:
        code - The code used to lookup.
        length - The length of the data we are getting.
        Returns:
        The string that matches the lookup.
      • lookupCID

        public java.lang.String lookupCID​(int cid)
        This will perform a lookup into the CID map.
        Parameters:
        cid - The CID used to lookup.
        Returns:
        The string that matches the lookup.
      • lookupCID

        public int lookupCID​(byte[] code,
                             int offset,
                             int length)
        This will perform a lookup into the CID map.
        Parameters:
        code - The code used to lookup.
        offset - the offset into the array.
        length - the length of the subarray.
        Returns:
        The CID that matches the lookup.
      • addMapping

        public void addMapping​(byte[] src,
                               java.lang.String dest)
                        throws java.io.IOException
        This will add a mapping.
        Parameters:
        src - The src to the mapping.
        dest - The dest to the mapping.
        Throws:
        java.io.IOException - if the src is invalid.
      • addCIDMapping

        public void addCIDMapping​(int src,
                                  java.lang.String dest)
                           throws java.io.IOException
        This will add a CID mapping.
        Parameters:
        src - The CID to the mapping.
        dest - The dest to the mapping.
        Throws:
        java.io.IOException - if the src is invalid.
      • addCIDRange

        public void addCIDRange​(char from,
                                char to,
                                int cid)
        This will add a CID Range.
        Parameters:
        from - starting charactor of the CID range.
        to - ending character of the CID range.
        cid - the cid to be started with.
      • addCodespaceRange

        public void addCodespaceRange​(CodespaceRange range)
        This will add a codespace range.
        Parameters:
        range - A single codespace range.
      • getCodeSpaceRanges

        public java.util.List<CodespaceRange> getCodeSpaceRanges()
        Getter for property codeSpaceRanges.
        Returns:
        Value of property codeSpaceRanges.
      • useCmap

        public void useCmap​(CMap cmap)
        Implementation of the usecmap operator. This will copy all of the mappings from one cmap to another.
        Parameters:
        cmap - The cmap to load mappings from.
      • isInCodeSpaceRanges

        public boolean isInCodeSpaceRanges​(byte[] code)
        Check whether the given byte array is in codespace ranges or not.
        Parameters:
        code - The byte array to look for in the codespace range.
        Returns:
        true if the given byte array is in the codespace range.
      • isInCodeSpaceRanges

        public boolean isInCodeSpaceRanges​(byte[] code,
                                           int offset,
                                           int length)
        Check whether the given byte array is in codespace ranges or not.
        Parameters:
        code - The byte array to look for in the codespace range.
        offset - The starting offset within the byte array.
        length - The length of the part of the array.
        Returns:
        true if the given byte array is in the codespace range.
      • getWMode

        public int getWMode()
        Returns the WMode of a CMap. 0 represents a horizontal and 1 represents a vertical orientation.
        Returns:
        the wmode
      • setWMode

        public void setWMode​(int newWMode)
        Sets the WMode of a CMap.
        Parameters:
        newWMode - the new WMode.
      • getName

        public java.lang.String getName()
        Returns the name of the CMap.
        Returns:
        the CMap name.
      • setName

        public void setName​(java.lang.String name)
        Sets the name of the CMap.
        Parameters:
        name - the CMap name.
      • getVersion

        public java.lang.String getVersion()
        Returns the version of the CMap.
        Returns:
        the CMap version.
      • setVersion

        public void setVersion​(java.lang.String version)
        Sets the version of the CMap.
        Parameters:
        version - the CMap version.
      • getType

        public int getType()
        Returns the type of the CMap.
        Returns:
        the CMap type.
      • setType

        public void setType​(int type)
        Sets the type of the CMap.
        Parameters:
        type - the CMap type.
      • getRegistry

        public java.lang.String getRegistry()
        Returns the registry of the CIDSystemInfo.
        Returns:
        the registry.
      • setRegistry

        public void setRegistry​(java.lang.String newRegistry)
        Sets the registry of the CIDSystemInfo.
        Parameters:
        newRegistry - the registry.
      • getOrdering

        public java.lang.String getOrdering()
        Returns the ordering of the CIDSystemInfo.
        Returns:
        the ordering.
      • setOrdering

        public void setOrdering​(java.lang.String newOrdering)
        Sets the ordering of the CIDSystemInfo.
        Parameters:
        newOrdering - the ordering.
      • getSupplement

        public int getSupplement()
        Returns the supplement of the CIDSystemInfo.
        Returns:
        the supplement.
      • setSupplement

        public void setSupplement​(int newSupplement)
        Sets the supplement of the CIDSystemInfo.
        Parameters:
        newSupplement - the supplement.
      • getSpaceMapping

        public int getSpaceMapping()
        Returns the mapping for the space character.
        Returns:
        the mapped code for the space character