org.foray.ps
Class PsFile

java.lang.Object
  extended by org.foray.ps.PsObjectComposite
      extended by org.foray.ps.PsFile
All Implemented Interfaces:
PsObject
Direct Known Subclasses:
PsFileFilter, PsFileReal

public abstract class PsFile
extends PsObjectComposite

Abstract superclass for PostScript "file" objects. A subclass instance can be a wrapper around one of several things: 1) a real file, 2) an input source, like standard input, or 3) a filter that sits on top of another PsFile instance.


Constructor Summary
PsFile()
          Constructor.
 
Method Summary
 void close()
          Closes this file.
protected  void closeFile(PsInterpreter4a interpreter)
          Close the input file.
 PsObject duplicate()
          This is a shallow copy.
protected abstract  byte[] getNextChunk()
          Returns the next chunk of content for this file.
protected  byte[] getRemainingChunk()
          Return the last chunk for this file.
 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 isOpen()
          Indicates whether this file is open.
protected  byte provideInput(PsInterpreter4a interpreter)
          Returns the next byte from this file.
 void setPopDictionaryStack(boolean popDictionary)
          Sets the pop dictionary stack property.
 
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
 

Constructor Detail

PsFile

public PsFile()
Constructor.

Method Detail

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.

isExecutable

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

Returns:
True iff this object is executable.

provideInput

protected byte provideInput(PsInterpreter4a interpreter)
                     throws IOException,
                            PsOperatorException
Returns the next byte from this file.

Parameters:
interpreter - The parent interpreter.
Returns:
The next byte from this file.
Throws:
IOException - For I/O Errors.
PsOperatorException - For PostScript error closing the file.

getNextChunk

protected abstract byte[] getNextChunk()
                                throws IOException
Returns the next chunk of content for this file.

Returns:
The next byte array for this file.
Throws:
IOException - For I/O Errors.

closeFile

protected void closeFile(PsInterpreter4a interpreter)
                  throws PsOperatorException
Close the input file.

Parameters:
interpreter - The parent interpreter.
Throws:
PsOperatorException - For error popping the dictionary stack.

getRemainingChunk

protected byte[] getRemainingChunk()
Return the last chunk for this file.

Returns:
The last chunk for this file.

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.

isOpen

public boolean isOpen()
Indicates whether this file is open.

Returns:
True iff this file is open.

setPopDictionaryStack

public void setPopDictionaryStack(boolean popDictionary)
Sets the pop dictionary stack property. Indicates whether the dictionary stack should be popped when this file has been completely read.

Parameters:
popDictionary - Set to true if the dictionary stack should be popped when this file has been completely read.

close

public void close()
Closes this file.



Copyright © 2017. All rights reserved.