|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.billpringle.utils.WrpFixedCols
public class WrpFixedCols
This class encapsulates a record using fixed length fields. The WrpCSV class handles CSV formatted fields, while this class handles files with fixed length columns.
![]() |
![]() |
Unless noted otherwise, all materials available for download from my site are copyrighted by Bill Pringle, and are licensed under a Creative Commons License. |
Field Summary | |
---|---|
static int |
ALIGN_CENTER
center alignment flag |
static int |
ALIGN_LEFT
left alignment flag |
static int |
ALIGN_RIGHT
right alignment flag |
private int |
alignmentFlag
alignment flag |
private char |
padChar
padding character |
private java.lang.StringBuffer |
sbuf
string buffer containing record data |
Constructor Summary | |
---|---|
WrpFixedCols(int recsize)
Create empty fixed record of a given size. |
|
WrpFixedCols(int recsize,
int alignFlg,
char padchar)
Create new record and set alignment and padding. |
|
WrpFixedCols(java.lang.String str)
Create fixed size record and initialize to the specified string. |
Method Summary | |
---|---|
java.lang.String |
buildField(int fldSize,
java.lang.String str)
Build fixed length field, using alignment and padding defaults. |
java.lang.String |
buildField(int fldSize,
java.lang.String str,
int alignFlg,
char padchar)
Create a fixed-length field. |
java.lang.String |
buildFieldLeft(int fldSize,
java.lang.String str)
Build left aligned field. |
java.lang.String |
buildFieldRight(int fldSize,
java.lang.String str)
Build right aligned field. |
java.lang.String |
dump()
Dump contents of record. |
java.lang.String |
dump(java.lang.String str)
Dump the specified string. |
int |
getAlignmentFlag()
Get the default alignment flag. |
java.lang.String |
getField(int beg,
int end)
Get specified field. |
char |
getPadChar()
Get the default padding character. |
private void |
init(int recsize)
Initialize an empty WrpFixedCols object. |
int |
length()
Return the length of the record. |
static void |
main(java.lang.String[] args)
Test driver. |
java.lang.String |
replace(int start,
int end,
java.lang.String str)
Replace the existing substring from start to end with the specified string. |
void |
reset(int recsize)
Reset (clear) the record. |
void |
reset(java.lang.String str)
Reset (clear) record and initialize it with the specified string. |
void |
setAlignmentFlag(int alignmentFlag)
Set the default alignment flag. |
java.lang.String |
setField(int beg,
int end,
java.lang.String fld)
Set new value for field, returning the old value. |
java.lang.String |
setField(int beg,
int end,
java.lang.String fld,
int alignFld,
char padchar)
Set the value of a field and return the old value. |
void |
setPadChar(char padChar)
Set the default padding character. |
java.lang.String |
substring(int start,
int end)
Return substring of data record. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int ALIGN_LEFT
public static final int ALIGN_RIGHT
public static final int ALIGN_CENTER
private java.lang.StringBuffer sbuf
private int alignmentFlag
private char padChar
Constructor Detail |
---|
public WrpFixedCols(int recsize)
recsize
- the record sizepublic WrpFixedCols(java.lang.String str)
str
- the record datapublic WrpFixedCols(int recsize, int alignFlg, char padchar)
recsize
- the size of the recordalignFlg
- the alignment for new fieldspadchar
- the padding characterMethod Detail |
---|
private void init(int recsize)
recsize
- the record size of the objectpublic void reset(int recsize)
recsize
- the size of the recordpublic void reset(java.lang.String str)
str
- the data for the recordpublic java.lang.String substring(int start, int end)
start
- first column of field (zero based)end
- first column past end of field (zero based)
public java.lang.String replace(int start, int end, java.lang.String str)
start
- start of substring (zero based)end
- the first column past the end of the field (zero based)str
- the replacement string
public java.lang.String buildField(int fldSize, java.lang.String str, int alignFlg, char padchar)
fldSize
- size of fieldstr
- initial value of the fieldalignFlg
- alignment flagpadchar
- padding character, in case string is shorter than fldSize
public java.lang.String buildField(int fldSize, java.lang.String str)
fldSize
- str
-
public java.lang.String buildFieldLeft(int fldSize, java.lang.String str)
fldSize
- size of fieldstr
- string value of field
public java.lang.String buildFieldRight(int fldSize, java.lang.String str)
fldSize
- size of fieldstr
- string value of field
public java.lang.String setField(int beg, int end, java.lang.String fld, int alignFld, char padchar)
beg
- index of start of fieldend
- index of first character past the fieldfld
- new value for fieldalignFld
- alignment flagpadchar
- padding character
public java.lang.String setField(int beg, int end, java.lang.String fld)
beg
- index of start of fieldend
- index of first character past the fieldfld
- new value for field
public java.lang.String getField(int beg, int end)
beg
- first column of field (zero based)end
- first column past end of field (zero based)
public int length()
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String dump()
public java.lang.String dump(java.lang.String str)
str
- string to dump
public int getAlignmentFlag()
public void setAlignmentFlag(int alignmentFlag)
alignmentFlag
- the alignmentFlag to setpublic char getPadChar()
public void setPadChar(char padChar)
padChar
- the padChar to setpublic static void main(java.lang.String[] args)
args
- not used
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |