960
* Amongst the params, find the value of the first, only, of any with
964
* @return a value, or null
959
966
private String checkParam( String[] params, String name )
968
String[] res = checkParams( params, name );
969
return res.length > 0? res[ 0 ] : null;
973
* Amongst the params, find the values of any with the specified name
976
* @return an array of values, or null
978
private String[] checkParams( String[] params, String name )
980
HashSet< String > ret = new HashSet< String >();
961
982
Pattern p = Pattern.compile(
962
983
"^" + name + "[ \\t]*=[ \\t]*(\"?)(.*)\\1$" );
963
984
for( int i = 0; i < params.length; i++ ) {
964
985
Matcher m = p.matcher( params[ i ] );
965
986
if( m.matches() )
987
ret.add( m.group( 2 ) );
990
return (String[]) ret.toArray( new String[ ret.size() ] );
994
* Amongst the params, return any type values present. For v2.1 vCards,
995
* those types are just parameters. For v3.0, they are prefixed with
996
* "TYPE=". There may also be multiple type parameters.
998
* @param a list of type values to look for
999
* @return a set of present type values
971
1001
private Set< String > extractTypes( String[] params,
972
1002
List< String > valid_types )
974
1004
HashSet< String > types = new HashSet< String >();
976
1006
// get 3.0-style TYPE= param
978
if( ( type_param = checkParam( params, "TYPE" ) ) != null ) {
979
String[] parts = type_param.split( "," );
1007
String type_params[] = checkParams( params, "TYPE" );
1008
for( int a = 0; a < type_params.length; a++ )
1010
// check for a comma-separated list of types (why? this isn't in
1012
String[] parts = type_params[ a ].split( "," );
980
1013
for( int i = 0; i < parts.length; i++ )
981
1014
if( valid_types.contains( parts[ i ] ) )
982
1015
types.add( parts[ i ] );