entanglement 25 de jul. de 2013
1) Use as tags [code]
2) Ponha a declaração de ConstroiTaxTable também.
Cuidado: casts não são coisas mágicas.
Por exemplo, eles não servem para converter alguma coisa que você tem em alguma coisa que você quer "magicamente".
eldomin 25 de jul. de 2013
Segue a classe ConstroiTaxTable
[ import java.io.BufferedReader ;
import java.io.FileReader ;
import java.io.IOException ;
import java.math.BigDecimal ;
import java.util.ArrayList ;
import java.util.List ;
import com.saft.classes.TaxTable;
import com.saft.classes.TaxTableEntr;
public class ConstroiTaxTable {
private String taxType ;
private String taxCountryRegion ;
private String taxAmount ;
List < TaxTableEntr > taxTables = new ArrayList < TaxTableEntr > ();
public List < TaxTableEntr > getTaxTableEntr () {
return taxTables ;
}
public ConstroiTaxTable ( String filePath ) {
identificaOsCamposDoTxt ( filePath );
}
private void mapeiaOobjecto () {
TaxTableEntry taxTableEntr = new TaxTableEntr ();
taxTableEntry . setTaxType ( taxType );
taxTableEntry . setTaxCountryRegion ( taxCountryRegion );
BigDecimal vlor2 = new BigDecimal ( taxAmount );
taxTableEntry . setTaxAmount ( vlor2 . divide ( new BigDecimal ( "100" )));
TaxTable taxTable = new TaxTable ();
taxTable . getTaxTableEntr ();
taxTables . add ( taxTableEntr );
}
private void verCampos () {
System . out . println ( "taxType: " + taxType );
System . out . println ( "taxCountryRegion: " + taxCountryRegion );
System . out . println ( "taxAmount: " + taxAmount );
}
private void identificaOsCamposDoTxt ( String filePath ) {
try {
BufferedReader br = new BufferedReader ( new FileReader ( filePath ));
String line ;
while (( line = br . readLine ()) != null ){
taxType = line . substring ( 0 , 3 );
taxCountryRegion = line . substring ( 3 , 8 );
taxAmount = line . substring ( 8 , 18 );
//verCampos();
mapeiaOobjecto ();
}
} catch ( IOException e ) {
e . printStackTrace ();
}
}
}
]