/android/import-contacts

To get this branch, use:
bzr branch http://bzr.ed.am/android/import-contacts

« back to all changes in this revision

Viewing changes to src/am/ed/importcontacts/VcardImporter.java

  • Committer: Tim Marston
  • Date: 2013-06-22 17:29:31 UTC
  • Revision ID: tim@ed.am-20130622172931-ujydoni23t3a543b
minor style tweaks

Show diffs side-by-side

added added

removed removed

1
1
/*
2
2
 * VCFImporter.java
3
3
 *
4
 
 * Copyright (C) 2009 to 2013 Tim Marston <tim@ed.am>
 
4
 * Copyright (C) 2009 to 2011 Tim Marston <tim@ed.am>
5
5
 *
6
6
 * This file is part of the Import Contacts program (hereafter referred
7
7
 * to as "this program").  For more information, see
471
471
                private String extractCollonPartFromLine( ContentLine content_line,
472
472
                        boolean former )
473
473
                {
 
474
                        String ret = null;
 
475
 
474
476
                        // split line into name and value parts and check to make sure we
475
477
                        // only got 2 parts and that the first part is not zero in length
476
478
                        String[] parts = content_line.getUsAsciiLine().split( ":", 2 );
477
479
                        if( parts.length == 2 && parts[ 0 ].length() > 0 )
478
 
                                return parts[ former? 0 : 1 ].trim();
 
480
                                ret = parts[ former? 0 : 1 ];
479
481
 
480
 
                        return null;
 
482
                        return ret;
481
483
                }
482
484
 
483
485
                private String extractNameAndParamsFromLine( ContentLine content_line )
484
486
                {
485
 
                        return extractCollonPartFromLine( content_line, true );
 
487
                        return extractCollonPartFromLine( content_line, true ).trim();
486
488
                }
487
489
 
488
490
                private String extractValueFromLine( ContentLine content_line )
506
508
                                        name_and_params.equalsIgnoreCase( "VERSION" ) )
507
509
                                {
508
510
                                        // yes, get it!
509
 
                                        String value = extractValueFromLine( content_line );
510
 
                                        if( value == null || (
511
 
                                                !value.equals( "2.1" ) && !value.equals( "3.0" ) ) )
512
 
                                        {
 
511
                                        String value = extractValueFromLine( content_line ).trim();
 
512
                                        if( !value.equals( "2.1" ) && !value.equals( "3.0" ) )
513
513
                                                throw new ParseException( R.string.error_vcf_version );
514
 
                                        }
515
514
                                        _version = value;
516
515
 
517
516
                                        // parse any buffers we've been accumulating while we waited
724
723
                                        parseLABEL( name_param_parts, complete_value );
725
724
                                else if( name_param_parts[ 0 ].equalsIgnoreCase( "NOTE" ) )
726
725
                                        parseNOTE( name_param_parts, complete_value );
727
 
                                else if( name_param_parts[ 0 ].equalsIgnoreCase( "BDAY" ) )
728
 
                                        parseBDAY( name_param_parts, complete_value );
729
726
                        }
730
727
                }
731
728
 
1032
1029
                        addNote( unescapeValue( value ) );
1033
1030
                }
1034
1031
 
1035
 
                private void parseBDAY( String[] params, String value )
1036
 
                {
1037
 
                        setBirthday( value );
1038
 
                }
1039
 
 
1040
1032
                public void finaliseVcard()
1041
1033
                        throws ParseException, ContactNotIdentifiableException
1042
1034
                {