tcl.lang
Class TclIO

java.lang.Object
  extended by tcl.lang.TclIO

public class TclIO
extends Object


Field Summary
static int APPEND
          Append to end of file when writing
static int BUFF_FULL
          Do full buffering up to size of buffer
static int BUFF_LINE
          Flush at end of line; buffer only one line on input
static int BUFF_NONE
          Flush after every write; don't buffer any input
static int CREAT
          Create a new file
static int EXCL
           
static int RDONLY
          Open read-only
static int RDWR
          Open for reading and writing
static int READ_ALL
          Read all available input, until EOF
static int READ_LINE
          Read up to end of line
static int READ_N_BYTES
          Read a specified number of bytes
static int SEEK_CUR
          Seek relative to the current position in the file
static int SEEK_END
          Seek relative to the end of the file
static int SEEK_SET
          Seek relative to the beginning of the file
static int TRANS_AUTO
          Translate \n, \r, \r\n to \n on input; translate \n to platform-specific end of line on output
static int TRANS_BINARY
          Don't translate end of line characters
static int TRANS_CR
          \n -> \r on output; \r -> \n on input
static int TRANS_CRLF
          \n to \r\n on output; \r\n -> \n on input
static int TRANS_LF
          Don't translate end of line characters
static int TRANS_PLATFORM
          End-of-line translation for the current platform
static int TRUNC
           
static int WRONLY
          Open write-only
 
Constructor Summary
TclIO()
           
 
Method Summary
static void flushAllOpenChannels(Interp interp)
          Call flush() for each currently registered open channel, ignoring exceptions.
static int getBufferingID(String buffering)
           
static String getBufferingString(int buffering)
           
static Channel getChannel(Interp interp, String chanName)
          Return a registered Channel object, given its name.
static void getChannelNames(Interp interp, TclObject pattern)
          Put all the channel names into the interpreter's result, as a list
static String getNextDescriptor(Interp interp, String prefix)
          Given a prefix for a channel name (such as "file") returns the next available channel name (such as "file5").
static Channel getStdChannel(int type)
           
static int getTranslationID(String translation)
           
static String getTranslationString(int translation)
           
static void giveChannel(Interp master, Interp slave, String chanName, boolean removeFromMaster)
          Give a channel to another interpreter, in exactly the same form it exists in the master
static void registerChannel(Interp interp, Channel chan)
          Register a channel in this interpreter's channel table.
static void unregisterChannel(Interp interp, Channel chan)
          Unregister a channel and it's FileEventScripts in this interpreter's channel table, and call close() on that channel.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

READ_ALL

public static final int READ_ALL
Read all available input, until EOF

See Also:
Constant Field Values

READ_LINE

public static final int READ_LINE
Read up to end of line

See Also:
Constant Field Values

READ_N_BYTES

public static final int READ_N_BYTES
Read a specified number of bytes

See Also:
Constant Field Values

SEEK_SET

public static final int SEEK_SET
Seek relative to the beginning of the file

See Also:
Constant Field Values

SEEK_CUR

public static final int SEEK_CUR
Seek relative to the current position in the file

See Also:
Constant Field Values

SEEK_END

public static final int SEEK_END
Seek relative to the end of the file

See Also:
Constant Field Values

RDONLY

public static final int RDONLY
Open read-only

See Also:
Constant Field Values

WRONLY

public static final int WRONLY
Open write-only

See Also:
Constant Field Values

RDWR

public static final int RDWR
Open for reading and writing

See Also:
Constant Field Values

APPEND

public static final int APPEND
Append to end of file when writing

See Also:
Constant Field Values

CREAT

public static final int CREAT
Create a new file

See Also:
Constant Field Values

EXCL

public static final int EXCL
See Also:
Constant Field Values

TRUNC

public static final int TRUNC
See Also:
Constant Field Values

BUFF_FULL

public static final int BUFF_FULL
Do full buffering up to size of buffer

See Also:
Constant Field Values

BUFF_LINE

public static final int BUFF_LINE
Flush at end of line; buffer only one line on input

See Also:
Constant Field Values

BUFF_NONE

public static final int BUFF_NONE
Flush after every write; don't buffer any input

See Also:
Constant Field Values

TRANS_AUTO

public static final int TRANS_AUTO
Translate \n, \r, \r\n to \n on input; translate \n to platform-specific end of line on output

See Also:
Constant Field Values

TRANS_BINARY

public static final int TRANS_BINARY
Don't translate end of line characters

See Also:
Constant Field Values

TRANS_LF

public static final int TRANS_LF
Don't translate end of line characters

See Also:
Constant Field Values

TRANS_CR

public static final int TRANS_CR
\n -> \r on output; \r -> \n on input

See Also:
Constant Field Values

TRANS_CRLF

public static final int TRANS_CRLF
\n to \r\n on output; \r\n -> \n on input

See Also:
Constant Field Values

TRANS_PLATFORM

public static int TRANS_PLATFORM
End-of-line translation for the current platform

Constructor Detail

TclIO

public TclIO()
Method Detail

getChannel

public static Channel getChannel(Interp interp,
                                 String chanName)
Return a registered Channel object, given its name.

Parameters:
interp - Interpreter context
chanName - Name of channel
Returns:
Channel or null if chanName does not exist

getChannelNames

public static void getChannelNames(Interp interp,
                                   TclObject pattern)
                            throws TclException
Put all the channel names into the interpreter's result, as a list

Parameters:
interp - this interpreter
pattern - Return only channel names that match this patter, as in 'string match', can be null to match all channels
Throws:
TclException

registerChannel

public static void registerChannel(Interp interp,
                                   Channel chan)
Register a channel in this interpreter's channel table. Any channel opening or manipulation must be done by the caller. If one of stdin, stdout or stderr is not defined in the channel table, the channel is registered as the first non-defined standard channel.

Parameters:
interp - This interpreter
chan - channel to register

flushAllOpenChannels

public static void flushAllOpenChannels(Interp interp)
Call flush() for each currently registered open channel, ignoring exceptions. Non-blocking channels are guaranteed to be flushed after this call.

Parameters:
interp - the current interpreter

giveChannel

public static void giveChannel(Interp master,
                               Interp slave,
                               String chanName,
                               boolean removeFromMaster)
                        throws TclException
Give a channel to another interpreter, in exactly the same form it exists in the master

Parameters:
master - Interpreter giving the channel
slave - Interpreter receiving the channel
chanName - Name of channel to transfer
removeFromMaster - If true, channel is unregistered from the master after being transferred
Throws:
TclException - if channel cannot be found

unregisterChannel

public static void unregisterChannel(Interp interp,
                                     Channel chan)
Unregister a channel and it's FileEventScripts in this interpreter's channel table, and call close() on that channel.

Parameters:
interp - this interpreter
chan - channel to unregister

getStdChannel

public static Channel getStdChannel(int type)
Parameters:
type - one of StdChannel.STDIN, StdChannel.STDOUT, StdChannel.STDERR
Returns:
the requested standard channel, creating it if required

getNextDescriptor

public static String getNextDescriptor(Interp interp,
                                       String prefix)
Given a prefix for a channel name (such as "file") returns the next available channel name (such as "file5").

Parameters:
interp - current interpreter.
prefix - string portion of the channel name
Returns:
the next name to use for a channel

getTranslationString

public static String getTranslationString(int translation)
Parameters:
translation - one of the TRANS_* constances
Returns:
a string description for a translation id defined above.

getTranslationID

public static int getTranslationID(String translation)
Parameters:
translation - one the fconfigure -translation strings
Returns:
a numerical identifier for the given -translation string.

getBufferingString

public static String getBufferingString(int buffering)
Parameters:
buffering - one of TclIO.BUFF_FULL, TclIO.BUFF_LINE, TclIO.BUFF_NONE
Returns:
a string description for a -buffering id defined above.

getBufferingID

public static int getBufferingID(String buffering)
Parameters:
buffering - a buffering string used in fconfigure
Returns:
a numerical identifier for the given -buffering string.


Copyright © 2015. All rights reserved.