/** * Factory constructor. * @param params property parameters * @param value string representation of a property value * @throws URISyntaxException where the specified URI value is not a valid URI * @throws DecoderException where the specified photo data value cannot be decoded */ public Photo(List<Parameter> params, String value) throws URISyntaxException, DecoderException { super(Id.PHOTO, params); final Parameter valueParameter = getParameter(Parameter.Id.VALUE); /* * in the relaxed parsing mode we allow the vcard 2.1-style VALUE=URL parameter */ if (valueParameter != null && Value.URI.equals(valueParameter) || valueParameter != null && CompatibilityHints.isHintEnabled(CompatibilityHints.KEY_RELAXED_PARSING) && "URL".equalsIgnoreCase(valueParameter.getValue())) { this.uri = new URI(value); } else { final BinaryDecoder decoder = new Base64(); this.binary = decoder.decode(value.getBytes()); } }
/** * Factory constructor. * * @param params property parameters * @param value string representation of a property value * @throws URISyntaxException where the specified URI value is not a valid URI * @throws DecoderException where the specified photo data value cannot be decoded */ public Photo(List<Parameter> params, String value) throws URISyntaxException, DecoderException { super(Id.PHOTO, params); final Parameter valueParameter = getParameter(Parameter.Id.VALUE); /* * in the relaxed parsing mode we allow the vcard 2.1-style VALUE=URL parameter */ if (Value.URI.equals(valueParameter) || valueParameter != null && CompatibilityHints.isHintEnabled(CompatibilityHints.KEY_RELAXED_PARSING) && "URL".equalsIgnoreCase(valueParameter.getValue())) { this.uri = new URI(value); } else { final BinaryDecoder decoder = new Base64(); this.binary = decoder.decode(value.getBytes()); } }