|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.pmstation.spss.SPSSWriter
public class SPSSWriter
This class should be used to create a formatted data structure
(in an SPSS format). It writes to defined output out
SPSS stuctured data.
At first must be added dictionary section by calling
addDictionarySection()
method. Then it can be added
a number of variable difinitions (the number of it should be lower
than defined in addDictionarySection()
. If method was
called without this parameter definition it means that number of
variables undefined).
After variable declaration there should be added a data section
by calling addDataSection()
method. Then can be added
values of variable in the order of variable declaration (if there is
wrong format type detecing method throws IOExceptin).
To finish data output should be called addFinishSection()
method.
In different order of method calling throws IOException.
OutputStream
,
Locale
Field Summary |
---|
Constructor Summary | |
---|---|
SPSSWriter(java.io.File file,
java.lang.String charsetName)
Constructs object based on an File object to
write data in an SPSS format into a file. |
|
SPSSWriter(java.io.OutputStream out,
java.lang.String charsetName)
Constructs object based on an OutputStream object to
write data in an SPSS format into a stream. |
|
SPSSWriter(java.lang.String fileName,
java.lang.String charsetName)
Constructs object that writes data in an SPSS format into a file. |
Method Summary | |
---|---|
void |
addCommaVar(java.lang.String name,
int width,
int decimals,
java.lang.String label)
Add comma variable without formatting parameters to the variable list in dictionary section. |
void |
addCommaVar(java.lang.String name,
int width,
int decimals,
java.lang.String label,
int columns,
int align,
int measure)
Add comma variable with formatting parameters to the variable list in dictionary section. |
void |
addData(java.util.Date data)
Add new variable value to the current variable defined by currentVar variable that is internally increase
in each data adding operation. |
void |
addData(java.lang.Double data)
Add new variable value to the current variable defined by currentVar variable that is internally increase
in each data adding operation. |
void |
addData(java.lang.Long data)
Add new variable value to the current variable defined by currentVar variable that is internally increase
in each data adding operation. |
void |
addData(java.lang.String data)
Add new variable value to the current variable defined by currentVar variable that is internally increase
in each data adding operation. |
void |
addDataSection()
Write start of the data section (section of values of variables) into the defined in a constructor or with a setOut() method
out . |
void |
addDateVar(java.lang.String name,
int dateCode,
java.lang.String label)
Add date variable without formatting parameters to the variable list in dictionary section. |
void |
addDateVar(java.lang.String name,
int dateCode,
java.lang.String label,
int columns,
int align,
int measure)
Add date variable with formatting parameters to the variable list in dictionary section. |
void |
addDateVar(java.lang.String name,
java.lang.String dateType,
java.lang.String label)
Add date variable without formatting parameters to the variable list in dictionary section. |
void |
addDateVar(java.lang.String name,
java.lang.String dateType,
java.lang.String label,
int columns,
int align,
int measure)
Add date variable with formatting parameters to the variable list in dictionary section. |
void |
addDictionarySection()
Deprecated. use addDictionarySection(int numberOfCases) becouse of SPSS v14.0 |
void |
addDictionarySection(int numberOfCases)
Write start of the dictionary section (section of variable declaration) into the defined in a constructor or with a setOut() method
out . |
void |
addDictionarySection(java.lang.String header,
int numberOfVars,
int numberOfCases,
int caseWeightVar,
int compressionSwitch,
java.lang.String fileLabel,
java.util.Date date,
boolean storeFormat)
Write start of the dictionary section (section of variable declaration) into the defined in a constructor or with a setOut() method
out . |
void |
addDictionarySection(java.lang.String header,
int numberOfVars,
int numberOfCases,
java.lang.String fileLabel,
boolean storeFormat)
Write start of the dictionary section (section of variable declaration) into the defined in a constructor or with a setOut() method
out . |
void |
addDictionarySection(java.lang.String header,
java.lang.String fileLabel)
Write start of the dictionary section (section of variable declaration) into the defined in a constructor or with a setOut() method
out . |
void |
addDollarVar(java.lang.String name,
int width,
int decimals,
java.lang.String label)
Add dollar variable without formatting parameters to the variable list in dictionary section. |
void |
addDollarVar(java.lang.String name,
int width,
int decimals,
java.lang.String label,
int columns,
int align,
int measure)
Add dollar variable with formatting parameters to the variable list in dictionary section. |
void |
addDotVar(java.lang.String name,
int width,
int decimals,
java.lang.String label)
Add dot variable without formatting parameters to the variable list in dictionary section. |
void |
addDotVar(java.lang.String name,
int width,
int decimals,
java.lang.String label,
int columns,
int align,
int measure)
Add dot variable with formatting parameters to the variable list in dictionary section. |
void |
addFinishSection()
Write end of the data section (section of values of variables) and of all of the file into the defined in a constructor or with a setOut() method out . |
void |
addNumericVar(java.lang.String name,
int width,
int decimals,
java.lang.String label)
Add numeric variable without formatting parameters to the variable list in dictionary section. |
void |
addNumericVar(java.lang.String name,
int width,
int decimals,
java.lang.String label,
int columns,
int align,
int measure)
Add numeric variable with formatting parameters to the variable list in dictionary section. |
void |
addNumericVar(java.lang.String name,
int width,
int decimals,
java.lang.String label,
int columns,
int align,
int measure,
MissingValue mv)
Add numeric variable with formatting parameters to the variable list in dictionary section. |
void |
addNumericVar(java.lang.String name,
int width,
int decimals,
java.lang.String label,
MissingValue mv)
Add numeric variable without formatting parameters to the variable list in dictionary section. |
void |
addStringVar(java.lang.String name,
int length,
java.lang.String label)
Add string variable without formatting parameters to the variable list in dictionary section. |
void |
addStringVar(java.lang.String name,
int length,
java.lang.String label,
int columns,
int align,
int measure)
Add string variable with formatting parameters to the variable list in dictionary section. |
void |
addValueLabels(int varNumber,
ValueLabels valueLabels)
Add value labels for variable number varNumber Note : Only for number variables |
void |
finishCurrentLine()
Fills from current position to the end of current line with empty values. |
java.lang.String |
getCharset()
Returns the value of the string format charset. |
java.io.OutputStream |
getOut()
Returns the value of the stream that this object writes into as an OutputStream . |
void |
setCharset(java.lang.String charset)
Set the charset name of the strings to out. |
void |
setOut(java.io.OutputStream out)
Set the OutputStream object that this object writes into. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SPSSWriter(java.lang.String fileName, java.lang.String charsetName) throws java.lang.NullPointerException, java.io.IOException
fileName
- name of the output file.charsetName
- the charset name or null if default.
java.lang.NullPointerException
- if the out
parameter
is null
.
java.io.IOException
public SPSSWriter(java.io.File file, java.lang.String charsetName) throws java.lang.NullPointerException, java.io.IOException
File
object to
write data in an SPSS format into a file.
file
- an File
object to write into.charsetName
- the charset name or null if default.
java.lang.NullPointerException
- if the out
parameter
is null
.
java.io.IOException
public SPSSWriter(java.io.OutputStream out, java.lang.String charsetName) throws java.lang.NullPointerException
OutputStream
object to
write data in an SPSS format into a stream.
out
- an OutputStream
object to write into.charsetName
- the charset name or null if default.
java.lang.NullPointerException
- if the out
parameter
is null
.Method Detail |
---|
public java.io.OutputStream getOut()
OutputStream
.
public void setOut(java.io.OutputStream out) throws java.lang.NullPointerException
OutputStream
object that this object writes into.
This method resets all of the predefined variables and its values.
out
- the new OutputStream
to write into.
java.lang.NullPointerException
- if the out
parameter
is null
.public java.lang.String getCharset()
public void setCharset(java.lang.String charset)
charset
- the new charset name or null if default.public void addDictionarySection() throws java.io.IOException
setOut()
method
out
.
java.io.IOException
- if defined OutputStream
object
unable to write to this out
.public void addDictionarySection(int numberOfCases) throws java.io.IOException
setOut()
method
out
.
numberOfCases
- number of cases (a block of a single values
of the variables)
java.io.IOException
- if defined OutputStream
object
unable to write data.public void addDictionarySection(java.lang.String header, java.lang.String fileLabel) throws java.io.IOException
setOut()
method
out
.
header
- the header name of the filefileLabel
- discriptive label of the file
java.io.IOException
- if defined OutputStream
object
unable to write data.public void addDictionarySection(java.lang.String header, int numberOfVars, int numberOfCases, java.lang.String fileLabel, boolean storeFormat) throws java.io.IOException
setOut()
method
out
.
header
- the header name of the filenumberOfVars
- number of variablesnumberOfCases
- number of cases (a block of a single values
of the variables)fileLabel
- discriptive label of the filestoreFormat
- true if there is a need to create a formatting
section with a columns
, align
and
measure
fields.
java.io.IOException
- if defined OutputStream
object
unable to write data.public void addDictionarySection(java.lang.String header, int numberOfVars, int numberOfCases, int caseWeightVar, int compressionSwitch, java.lang.String fileLabel, java.util.Date date, boolean storeFormat) throws java.io.IOException
setOut()
method
out
.
header
- the header name of the filenumberOfVars
- number of variablesnumberOfCases
- number of cases (a block of a single values
of the variables)caseWeightVar
- index of the case-weight variablecompressionSwitch
- value of 0 - not compressedfileLabel
- discriptive label of the filedate
- date of file creation or null
if currentstoreFormat
- true if there is a need to create a formatting
section with a columns
, align
and
measure
fields.
java.io.IOException
- if defined OutputStream
object
unable to write data.public void addNumericVar(java.lang.String name, int width, int decimals, java.lang.String label) throws java.io.IOException
name
- the name of the variable.width
- number of the digits before point.decimals
- number of decimal digits after point.label
- label of the variable or null
if there is
no label.
java.io.IOException
- if defined OutputStream
object
unable to write data.public void addNumericVar(java.lang.String name, int width, int decimals, java.lang.String label, MissingValue mv) throws java.io.IOException
name
- the name of the variable.width
- number of the digits before point.decimals
- number of decimal digits after point.label
- label of the variable or null
if there is
no label.mv
- missing values
java.io.IOException
- if defined OutputStream
object
unable to write data.public void addNumericVar(java.lang.String name, int width, int decimals, java.lang.String label, int columns, int align, int measure) throws java.io.IOException
name
- the name of the variable.width
- number of the digits before point.decimals
- number of decimal digits after point.label
- label of the variable or null
if there is
no label.columns
- number of columns to print variable value to display.align
- horizontal align of the variable value.measure
- the measure of this variable.
java.io.IOException
- if defined OutputStream
object
unable to write data.public void addNumericVar(java.lang.String name, int width, int decimals, java.lang.String label, int columns, int align, int measure, MissingValue mv) throws java.io.IOException
name
- the name of the variable.width
- number of the digits before point.decimals
- number of decimal digits after point.label
- label of the variable or null
if there is
no label.columns
- number of columns to print variable value to display.align
- horizontal align of the variable value.measure
- the measure of this variable.mv
- missing values
java.io.IOException
- if defined OutputStream
object
unable to write data.public void addCommaVar(java.lang.String name, int width, int decimals, java.lang.String label) throws java.io.IOException
name
- the name of the variable.width
- number of the digits before point.decimals
- number of decimal digits after point.label
- label of the variable or null
if there is
no label.
java.io.IOException
- if defined OutputStream
object
unable to write data.public void addCommaVar(java.lang.String name, int width, int decimals, java.lang.String label, int columns, int align, int measure) throws java.io.IOException
name
- the name of the variable.width
- number of the digits before point.decimals
- number of decimal digits after point.label
- label of the variable or null
if there is
no label.columns
- number of columns to print variable value to display.align
- horizontal align of the variable value.measure
- the measure of this variable.
java.io.IOException
- if defined OutputStream
object
unable to write data.public void addDotVar(java.lang.String name, int width, int decimals, java.lang.String label) throws java.io.IOException
name
- the name of the variable.width
- number of the digits before point.decimals
- number of decimal digits after point.label
- label of the variable or null
if there is
no label.
java.io.IOException
- if defined OutputStream
object
unable to write data.public void addDotVar(java.lang.String name, int width, int decimals, java.lang.String label, int columns, int align, int measure) throws java.io.IOException
name
- the name of the variable.width
- number of the digits before point.decimals
- number of decimal digits after point.label
- label of the variable or null
if there is
no label.columns
- number of columns to print variable value to display.align
- horizontal align of the variable value.measure
- the measure of this variable.
java.io.IOException
- if defined OutputStream
object
unable to write data.public void addDollarVar(java.lang.String name, int width, int decimals, java.lang.String label) throws java.io.IOException
name
- the name of the variable.width
- number of the digits before point.decimals
- number of decimal digits after point.label
- label of the variable or null
if there is
no label.
java.io.IOException
- if defined OutputStream
object
unable to write data.public void addDollarVar(java.lang.String name, int width, int decimals, java.lang.String label, int columns, int align, int measure) throws java.io.IOException
name
- the name of the variable.width
- number of the digits before point.decimals
- number of decimal digits after point.label
- label of the variable or null
if there is
no label.columns
- number of columns to print variable value to display.align
- horizontal align of the variable value.measure
- the measure of this variable.
java.io.IOException
- if defined OutputStream
object
unable to write data.public void addStringVar(java.lang.String name, int length, java.lang.String label) throws java.io.IOException
name
- the name of the variable.length
- maximum length of the value of this variable.label
- label of the variable or null
if there is
no label.
java.io.IOException
- if defined OutputStream
object
unable to write data.public void addStringVar(java.lang.String name, int length, java.lang.String label, int columns, int align, int measure) throws java.io.IOException
name
- the name of the variable.length
- maximum length of the value of this variable.label
- label of the variable or null
if there is
no label.columns
- number of columns to print variable value to display.align
- horizontal align of the variable value.measure
- the measure of this variable.
java.io.IOException
- if defined OutputStream
object
unable to write data.public void addDateVar(java.lang.String name, int dateCode, java.lang.String label) throws java.io.IOException
name
- the name of the variable.dateCode
- some of the DATE_CODE_NN
values that
has a text interpretation in DATE_TYPE_NN
constants.label
- label of the variable or null
if there is
no label.
java.io.IOException
- if defined OutputStream
object
unable to write data.public void addDateVar(java.lang.String name, int dateCode, java.lang.String label, int columns, int align, int measure) throws java.io.IOException
name
- the name of the variable.dateCode
- some of the DATE_CODE_NN
values that
has a text interpretation in DATE_TYPE_NN
constants.label
- label of the variable or null
if there is
no label.columns
- number of columns to print variable value to display.align
- horizontal align of the variable value.measure
- the measure of this variable.
java.io.IOException
- if defined OutputStream
object
unable to write data.public void addDateVar(java.lang.String name, java.lang.String dateType, java.lang.String label) throws java.io.IOException
name
- the name of the variable.dateType
- some of the DATE_TYPE_NN
text
interpretation constants.label
- label of the variable or null
if there is
no label.
java.io.IOException
- if defined OutputStream
object
unable to write data.public void addDateVar(java.lang.String name, java.lang.String dateType, java.lang.String label, int columns, int align, int measure) throws java.io.IOException
name
- the name of the variable.dateType
- some of the DATE_TYPE_NN
text
interpretation constants.label
- label of the variable or null
if there is
no label.columns
- number of columns to print variable value to display.align
- horizontal align of the variable value.measure
- the measure of this variable.
java.io.IOException
- if defined OutputStream
object
unable to write data.public void addDataSection() throws java.io.IOException
setOut()
method
out
.
java.io.IOException
- if defined OutputStream
object
unable to write data.public void addData(java.lang.Long data) throws java.io.IOException
currentVar
variable that is internally increase
in each data adding operation.
data
- value of the current variable.
java.io.IOException
- if system unable to write to a stream
or type of variable mismatches with a
Long
data type;public void addData(java.lang.Double data) throws java.io.IOException
currentVar
variable that is internally increase
in each data adding operation.
data
- value of the current variable.
java.io.IOException
- if system unable to write to a stream
or type of variable mismatches with a
Double
data type;public void addData(java.lang.String data) throws java.io.IOException
currentVar
variable that is internally increase
in each data adding operation.
data
- value of the current variable.
java.io.IOException
- if system unable to write to a stream
or type of variable mismatches with a
String
data type;public void addData(java.util.Date data) throws java.io.IOException
currentVar
variable that is internally increase
in each data adding operation.
data
- value of the current variable.
java.io.IOException
- if system unable to write to a stream
or type of variable mismatches with a
Date
data type;public void finishCurrentLine() throws java.io.IOException
java.io.IOException
- if system unable to write to a streampublic void addFinishSection() throws java.io.IOException
setOut()
method out
.
java.io.IOException
- if defined OutputStream
object
unable to write data.public void addValueLabels(int varNumber, ValueLabels valueLabels) throws java.io.IOException
varNumber
- variable number, starts from 1valueLabels
- - ValueLabel object
java.io.IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |