/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: edam
  • Date: 2012-12-20 17:32:37 UTC
  • Revision ID: tim@ed.am-20121220173237-gmimhhsosiahq9po
be less sensitive to case when parsing vCard params

Show diffs side-by-side

added added

removed removed

Lines of Context:
1013
1013
                        HashSet< String > ret = new HashSet< String >();
1014
1014
 
1015
1015
                        Pattern p = Pattern.compile(
1016
 
                                "^" + name + "[ \\t]*=[ \\t]*(\"?)(.*)\\1$" );
 
1016
                                "^" + name + "[ \\t]*=[ \\t]*(\"?)(.*)\\1$",
 
1017
                                Pattern.CASE_INSENSITIVE );
1017
1018
                        for( int i = 0; i < params.length; i++ ) {
1018
1019
                                Matcher m = p.matcher( params[ i ] );
1019
1020
                                if( m.matches() )
1027
1028
                 * Amongst the params, return any type values present. For v2.1 vCards,
1028
1029
                 * those types are just parameters. For v3.0, they are prefixed with
1029
1030
                 * "TYPE=". There may also be multiple type parameters.
1030
 
                 * @param params
1031
 
                 * @param a list of type values to look for
 
1031
                 * @param params an array of params to look for types in
 
1032
                 * @param valid_types an list of upper-case type values to look for
1032
1033
                 * @return a set of present type values
1033
1034
                 */
1034
1035
                private Set< String > extractTypes( String[] params,
1044
1045
                                // the specs!)
1045
1046
                                String[] parts = type_params[ a ].split( "," );
1046
1047
                                for( int i = 0; i < parts.length; i++ )
 
1048
                                        parts[ i ] = parts[ i ].toUpperCase( Locale.US );
 
1049
                                for( int i = 0; i < parts.length; i++ )
1047
1050
                                        if( valid_types.contains( parts[ i ] ) )
1048
1051
                                                types.add( parts[ i ] );
1049
1052
                        }