org.foray.ps
Class PsDictionary

java.lang.Object
  extended by org.foray.ps.PsObjectComposite
      extended by org.foray.ps.PsDictionary
All Implemented Interfaces:
PsObject
Direct Known Subclasses:
PsSystemDict4a

public class PsDictionary
extends PsObjectComposite

A PostScript dictionary.


Field Summary
static byte DEFAULT_FONT_DICTIONARY_SIZE
          Constant indicating the default size of a new dictionary.
 
Constructor Summary
PsDictionary(int initialSize)
          Constructor.
 
Method Summary
 void addItem(PsInterpreter4a interpreter, PsObject key, PsObject value)
          Add an entry to the dictonary.
 PsObject duplicate()
          This is a shallow copy.
protected  boolean execute(PsInterpreter4a interpreter, PsName nameObject)
          Tries to process a name object.
protected  boolean executeOperator(PsOperator operatorEnum)
          Override this method in subclasses that have procedures.
 Boolean getBoolean(String key)
          Returns a value expected to be a Boolean from this dictionary.
 PsObject getItem(PsObject key)
          Return the value for a given key.
 PsObject getItem(String key)
          Return the value for a given key.
 Map<PsObject,PsObject> getMap()
          Return the encapsulated Map.
 String getName(String key)
          Returns a value expected to be a Name from this dictionary.
 BigDecimal getNumber(String key)
          Returns a value expected to be a Number from this dictionary.
 String getString(String key)
          Returns a value expected to be a String from this dictionary.
 PsName getTypeName()
          Needed for the "type" operator.
 boolean isComparable(PsObject object)
          Test the comparability of two PSObjects.
 boolean isComposite()
          The method should be overridden by composite objects.
 boolean isExecutable()
          Indicates whether this object is executable.
 boolean isValidFontDictionary()
          The conditions tested here are the "Required" entries as defined in PLRM2, Section 5.2, especially Tables 5.1, 5.2, and 5.3.
 int maxLength()
          See maxLength() operator for details.
 int size()
          Return the size of this dictionary.
 
Methods inherited from class org.foray.ps.PsObjectComposite
getAccess, setAccess
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_FONT_DICTIONARY_SIZE

public static final byte DEFAULT_FONT_DICTIONARY_SIZE
Constant indicating the default size of a new dictionary.

See Also:
Constant Field Values
Constructor Detail

PsDictionary

public PsDictionary(int initialSize)
Constructor.

Parameters:
initialSize - The number of elements that this dictionary should be sized for as it is created.
Method Detail

execute

protected boolean execute(PsInterpreter4a interpreter,
                          PsName nameObject)
                   throws PsOperatorException,
                          PsInterpreterException4a
Tries to process a name object.

Parameters:
interpreter - The parent interpreter.
nameObject - The PsName instance that should be executed.
Returns:
True if the operation was found and executed, otherwise, false.
Throws:
PsOperatorException - For errors executing operators.
PsInterpreterException4a - For any PostScript error.

executeOperator

protected boolean executeOperator(PsOperator operatorEnum)
                           throws PsOperatorException,
                                  PsInterpreterException4a
Override this method in subclasses that have procedures.

Parameters:
operatorEnum - The integral ID that identifies which operator should be executed
Returns:
True if the operator is found and executed, otherwise, false.
Throws:
PsOperatorException - For errors executing operators.
PsInterpreterException4a - For any PostScript error.

duplicate

public PsObject duplicate()
Description copied from interface: PsObject
This is a shallow copy. Specifically, composite objects should generally return themselves. Simple objects should return copies of themselves.

Returns:
A duplicate of this that conforms to what is expected by the "dup" operator.

isComposite

public boolean isComposite()
Description copied from interface: PsObject
The method should be overridden by composite objects.

Returns:
True iff this object is a composite PostScript object.

addItem

public void addItem(PsInterpreter4a interpreter,
                    PsObject key,
                    PsObject value)
             throws PsInterpreterException4a
Add an entry to the dictonary.

Parameters:
interpreter - The parent interpreter.
key - The key to the dictionary entry.
value - The value of the dictionary entry.
Throws:
PsInterpreterException4a - A typecheck error if the object is null.

getItem

public PsObject getItem(PsObject key)
Return the value for a given key.

Parameters:
key - The key whose value should be retrieved.
Returns:
The value.

getItem

public PsObject getItem(String key)
Return the value for a given key.

Parameters:
key - The key whose value should be retrieved.
Returns:
The value.

isExecutable

public boolean isExecutable()
Description copied from interface: PsObject
Indicates whether this object is executable.

Returns:
True iff this object is executable.

isValidFontDictionary

public boolean isValidFontDictionary()
The conditions tested here are the "Required" entries as defined in PLRM2, Section 5.2, especially Tables 5.1, 5.2, and 5.3.

Returns:
True if this is a valid font dictionary, false otherwise.

isComparable

public boolean isComparable(PsObject object)
Description copied from interface: PsObject
Test the comparability of two PSObjects. Used in the eq, ne, lt, etc. operators.

Parameters:
object - The object that should be tested for comparability.
Returns:
True if this is comparable to object, false otherwise.

getTypeName

public PsName getTypeName()
Description copied from interface: PsObject
Needed for the "type" operator.

Returns:
The type name as defined in PSRM2, Chapter 8, "type" operator.

getMap

public Map<PsObject,PsObject> getMap()
Return the encapsulated Map.

Returns:
The encapsulated Map.

size

public int size()
Return the size of this dictionary.

Returns:
The number of elements in this dictionary.

maxLength

public int maxLength()
See maxLength() operator for details.

Returns:
For level 2 PS implementations, returns the current capacity of the dictionary. Note that this may be greater than or equal to the initial capacity of the dictionary.

getString

public String getString(String key)
Returns a value expected to be a String from this dictionary.

Parameters:
key - The key to the expected String value.
Returns:
The value for key, if it is found and is a PsString, or null otherwise.

getName

public String getName(String key)
Returns a value expected to be a Name from this dictionary.

Parameters:
key - The key to the expected Name value.
Returns:
The value for key, if it is found and is a PsName, or null otherwise.

getNumber

public BigDecimal getNumber(String key)
Returns a value expected to be a Number from this dictionary.

Parameters:
key - The key to the expected Number value.
Returns:
The value for key, if it is found and is a PsNumber, or null otherwise.

getBoolean

public Boolean getBoolean(String key)
Returns a value expected to be a Boolean from this dictionary.

Parameters:
key - The key to the expected Boolean value.
Returns:
The value for key, if it is found and is a PsBoolean, or null otherwise.


Copyright © 2017. All rights reserved.