csv issue

manipulates content field from db into csv file format
this is a case from enum and then showing the char in csv
example 1

List<Object[]> results = query.getResultList();

        for (Object[] item : results) {
           i=0;




            for (Object object : item) {

                //change a status to 'char'
                if(i==2){
                    if (object.equals(0)){
                        csvResult.append("Junior High Student").append(',');
                    } else if(object.equals(1)){
                        csvResult.append("Senior High Student").append(',');
                    } else if(object.equals(2)){
                        csvResult.append("Diplouma Student").append(',');
                    } else if(object.equals(3)){
                        csvResult.append("Bachelor Student").append(',');
                    } else if(object.equals(4)){
                        csvResult.append("MSc Student").append(',');
                    } else if(object.equals(5)){
                        csvResult.append("Doctor Student").append(',');
                    } else {
                        csvResult.append(object).append(',');
                    }

                }
                else {
                    csvResult.append(object).append(',');
                     }
                i++;

             }
            csvResult.deleteCharAt(csvResult.length() - 1);
            csvResult.append('\n');
        }

changes value ‘null’ to string
example 2

       if(i==4){
                    if(object== null){
                        csvResult.append("Zero").append(',');
                    } else if(object != null) {
                        csvResult.append(object).append(',');
                    } else {
                        csvResult.append(object).append(',');
                    }
                }
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s