Top Description Inners Fields Constructors Methods
org.python.modules

public Class cStringIO

extends Object
Class Inheritance
Imports
org.python.core.Py, .PyArray, .PyIterator, .PyList, .PyObject, .PyString, .PyUnicode, .PyType

This module implements a file-like class, StringIO, that reads and writes a string buffer (also known as memory files). See the description on file objects for operations.
Author
Finn Bock, bckfnn@pipmail.dknet.dk
Version
cStringIO.java,v 1.10 1999/05/20 18:03:20 fb Exp

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
public static class
cStringIO.StringIO

The StringIO object

Field Summary

Modifier and TypeField and Description
public static final String
public static final String
public static PyType
public static PyType
private static String[]

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
pack-priv static String
getString(char ch)

public static cStringIO.StringIO
public static cStringIO.StringIO

Returns:

a new StringIO object.
StringIO
(CharSequence
The initial value.
buffer
)

Create a StringIO object, initialized by the value.

public static cStringIO.StringIO

Returns:

a new StringIO object.
StringIO
(PyArray
The initial value, from an array.
array
)

Create a StringIO object, initialized by an array's byte stream.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

__doc__back to summary
public static final String __doc__
__doc__StringIOback to summary
public static final String __doc__StringIO
InputTypeback to summary
public static PyType InputType
OutputTypeback to summary
public static PyType OutputType
stringsback to summary
private static String[] strings

Constructor Detail

cStringIOback to summary
public cStringIO()

Method Detail

getStringback to summary
pack-priv static String getString(char ch)
StringIOback to summary
public static cStringIO.StringIO StringIO()
StringIOback to summary
public static cStringIO.StringIO StringIO(CharSequence buffer)

Create a StringIO object, initialized by the value.

Parameters
buffer:CharSequence

The initial value.

Returns:cStringIO.StringIO

a new StringIO object.

StringIOback to summary
public static cStringIO.StringIO StringIO(PyArray array)

Create a StringIO object, initialized by an array's byte stream.

Parameters
array:PyArray

The initial value, from an array.

Returns:cStringIO.StringIO

a new StringIO object.

org.python.modules back to summary

private Class cStringIO.os

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final int
public static final int
public static final int

Constructor Summary

AccessConstructor and Description
private
os()

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

SEEK_CURback to summary
public static final int SEEK_CUR
SEEK_ENDback to summary
public static final int SEEK_END
SEEK_SETback to summary
public static final int SEEK_SET

Constructor Detail

osback to summary
private os()
org.python.modules back to summary

public Class cStringIO.StringIO

extends PyIterator
Class Inheritance

The StringIO object
See Also
cStringIO#StringIO(), cStringIO#StringIO(CharSequence)

Field Summary

Modifier and TypeField and Description
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
private final StringBuilder
public boolean
public int
public boolean
Inherited from org.python.core.PyIterator:
__doc__nextstopException

Constructor Summary

AccessConstructor and Description
public
public
public

Method Summary

Modifier and TypeMethod and Description
public PyObject
__iternext__()

Implements abstract org.python.core.PyIterator.__iternext__.

Return the next element of the sequence that this is an iterator for.

public void
__setattr__(String
the name whose value will be set - must be an interned string .
name
,
PyObject
the value to set this name to
value
)

Overrides org.python.core.PyObject.__setattr__.

A variant of the __setattr__ method which accepts a String as the key.

private void
private int
_convert_to_int(long val)

public void
close()

Free the memory buffer.

public void
flush()

Flush the internal buffer.

public synchronized PyString

Returns:

the contents of the StringIO.
getvalue
()

Retrieve the entire contents of the ``file'' at any time before the StringIO object's close() method is called.

public boolean

Returns:

false.
isatty
()

Return false.

public PyString

Returns:

A string containing the data.
read
()

Read all data until EOF is reached.

public synchronized PyString

Returns:

A string containing the data read.
read
(long
the number of characters to read.
size
)

Read at most size bytes from the file (less if the read hits EOF).

public PyString

Returns:

data from the file up to and including the newline.
readline
()

Read one entire line from the file.

public synchronized PyString

Returns:

data from the file up to and including the newline.
readline
(long size)

Read one entire line from the file.

public synchronized PyString
readlineNoNl()

Read and return a line without the trailing newline.

public PyObject

Returns:

a list of the lines.
readlines
()

Read until EOF using readline() and return a list containing the lines thus read.

public PyObject

Returns:

a list of the lines.
readlines
(long sizehint)

Read until EOF using readline() and return a list containing the lines thus read.

public synchronized void
reset()

Reset the file position to the beginning of the file.

public void
seek(long
the position in the file.
pos
)

Position the file pointer to the absolute position.

public synchronized void
seek(long
the position in the file.
pos
,
int
0=from the start, 1=relative, 2=from the end.
mode
)

Position the file pointer to the position in the .

public synchronized int

Returns:

the position in the file.
tell
()

Return the file position.

public synchronized void
truncate()

truncate the file at the current position.

public synchronized void
truncate(long pos)

truncate the file at the position pos.

public void
write(PyObject
The data to write.
obj
)

Write a string to the file.

public synchronized void
public synchronized void
writeChar(char
The data to write.
ch
)

Write a char to the file.

public void
writelines(PyObject lines)

Write a list of strings to the file.

Inherited from org.python.core.PyIterator:
__iter____tojava__doNextiteratornextrefersDirectlyTotraverse

Field Detail

__doc__closeback to summary
public static final String __doc__close
__doc__flushback to summary
public static final String __doc__flush
__doc__getvalueback to summary
public static final String __doc__getvalue
__doc__isattyback to summary
public static final String __doc__isatty
__doc__readback to summary
public static final String __doc__read
__doc__readlineback to summary
public static final String __doc__readline
__doc__readlinesback to summary
public static final String __doc__readlines
__doc__resetback to summary
public static final String __doc__reset
__doc__seekback to summary
public static final String __doc__seek
__doc__tellback to summary
public static final String __doc__tell
__doc__truncateback to summary
public static final String __doc__truncate
__doc__writeback to summary
public static final String __doc__write
__doc__writelinesback to summary
public static final String __doc__writelines
bufback to summary
private final StringBuilder buf
closedback to summary
public boolean closed
posback to summary
public int pos
softspaceback to summary
public boolean softspace

Constructor Detail

StringIOback to summary
public StringIO()
StringIOback to summary
public StringIO(CharSequence buffer)
StringIOback to summary
public StringIO(PyArray array)

Method Detail

__iternext__back to summary
public PyObject __iternext__()

Implements abstract org.python.core.PyIterator.__iternext__.

Doc from org.python.core.PyObject.__iternext__.

Return the next element of the sequence that this is an iterator for. Returns null when the end of the sequence is reached.

Annotations
@Override
__setattr__back to summary
public void __setattr__(String name, PyObject value)

Overrides org.python.core.PyObject.__setattr__.

Doc from org.python.core.PyObject.__setattr__.

A variant of the __setattr__ method which accepts a String as the key. This String must be interned.

Parameters
name:String

the name whose value will be set - must be an interned string .

value:PyObject

the value to set this name to

Annotations
@Override
_complain_ifclosedback to summary
private void _complain_ifclosed()
_convert_to_intback to summary
private int _convert_to_int(long val)
closeback to summary
public void close()

Free the memory buffer.

flushback to summary
public void flush()

Flush the internal buffer. Does nothing.

getvalueback to summary
public synchronized PyString getvalue()

Retrieve the entire contents of the ``file'' at any time before the StringIO object's close() method is called.

Returns:PyString

the contents of the StringIO.

isattyback to summary
public boolean isatty()

Return false.

Returns:boolean

false.

readback to summary
public PyString read()

Read all data until EOF is reached. An empty string is returned when EOF is encountered immediately.

Returns:PyString

A string containing the data.

readback to summary
public synchronized PyString read(long size)

Read at most size bytes from the file (less if the read hits EOF). If the size argument is negative, read all data until EOF is reached. An empty string is returned when EOF is encountered immediately.

Parameters
size:long

the number of characters to read.

Returns:PyString

A string containing the data read.

readlineback to summary
public PyString readline()

Read one entire line from the file. A trailing newline character is kept in the string (but may be absent when a file ends with an incomplete line). An empty string is returned when EOF is hit immediately.

Returns:PyString

data from the file up to and including the newline.

readlineback to summary
public synchronized PyString readline(long size)

Read one entire line from the file. A trailing newline character is kept in the string (but may be absent when a file ends with an incomplete line). If the size argument is non-negative, it is a maximum byte count (including the trailing newline) and an incomplete line may be returned.

Returns:PyString

data from the file up to and including the newline.

readlineNoNlback to summary
public synchronized PyString readlineNoNl()

Read and return a line without the trailing newline. Usind by cPickle as an optimization.

readlinesback to summary
public PyObject readlines()

Read until EOF using readline() and return a list containing the lines thus read.

Returns:PyObject

a list of the lines.

readlinesback to summary
public PyObject readlines(long sizehint)

Read until EOF using readline() and return a list containing the lines thus read.

Returns:PyObject

a list of the lines.

resetback to summary
public synchronized void reset()

Reset the file position to the beginning of the file.

seekback to summary
public void seek(long pos)

Position the file pointer to the absolute position.

Parameters
pos:long

the position in the file.

seekback to summary
public synchronized void seek(long pos, int mode)

Position the file pointer to the position in the .

Parameters
pos:long

the position in the file.

mode:int

0=from the start, 1=relative, 2=from the end.

tellback to summary
public synchronized int tell()

Return the file position.

Returns:int

the position in the file.

truncateback to summary
public synchronized void truncate()

truncate the file at the current position.

truncateback to summary
public synchronized void truncate(long pos)

truncate the file at the position pos.

writeback to summary
public void write(PyObject obj)

Write a string to the file.

Parameters
obj:PyObject

The data to write.

writeback to summary
public synchronized void write(String s)
writeCharback to summary
public synchronized void writeChar(char ch)

Write a char to the file. Used by cPickle as an optimization.

Parameters
ch:char

The data to write.

writelinesback to summary
public void writelines(PyObject lines)

Write a list of strings to the file.