/** * Attempts to create a URI instance and will optionally swallow any resulting URISyntaxException depending on * configured {@link CompatibilityHints}. Will also automatically attempt encoding of the string representation for * greater compatibility. * @param s a string representation of a URI. * @return a URI instance, or null if a valid URI string is not specified and relaxed parsing is enabled. * @throws URISyntaxException if a valid URI string is not specified and relaxed parsing is disabled */ public static URI create(final String s) throws URISyntaxException { try { return new URI(encode(s)); } catch (URISyntaxException use) { if (CompatibilityHints .isHintEnabled(CompatibilityHints.KEY_RELAXED_PARSING)) { return null; } throw use; } } }
/** * Parses the specified string representation to create a list of addresses. * @param aValue a string representation of a list of addresses * @throws URISyntaxException where the specified string is not a valid representation */ public AddressList(final String aValue) throws URISyntaxException { addresses = new CopyOnWriteArrayList<>(); final StringTokenizer t = new StringTokenizer(aValue, ","); while (t.hasMoreTokens()) { try { addresses.add(new URI(Uris.encode(Strings .unquote(t.nextToken())))); } catch (URISyntaxException use) { // ignore invalid addresses if relaxed parsing is enabled.. if (!CompatibilityHints.isHintEnabled( CompatibilityHints.KEY_RELAXED_PARSING)) { throw use; } } } }
/** * Parses the specified string representation to create a list of addresses. * @param aValue a string representation of a list of addresses * @throws URISyntaxException where the specified string is not a valid representation */ public AddressList(final String aValue) throws URISyntaxException { addresses = new CopyOnWriteArrayList<>(); final StringTokenizer t = new StringTokenizer(aValue, ","); while (t.hasMoreTokens()) { try { addresses.add(new URI(Uris.encode(Strings .unquote(t.nextToken())))); } catch (URISyntaxException use) { // ignore invalid addresses if relaxed parsing is enabled.. if (!CompatibilityHints.isHintEnabled( CompatibilityHints.KEY_RELAXED_PARSING)) { throw use; } } } }
/** * Parses the specified string representation to create a list of addresses. * @param aValue a string representation of a list of addresses * @throws URISyntaxException where the specified string is not a valid representation */ public AddressList(final String aValue) throws URISyntaxException { addresses = new CopyOnWriteArrayList<URI>(); final StringTokenizer t = new StringTokenizer(aValue, ","); while (t.hasMoreTokens()) { try { addresses.add(new URI(Uris.encode(Strings .unquote(t.nextToken())))); } catch (URISyntaxException use) { // ignore invalid addresses if relaxed parsing is enabled.. if (!CompatibilityHints.isHintEnabled( CompatibilityHints.KEY_RELAXED_PARSING)) { throw use; } } } }
/** * Parses the specified string representation to create a list of addresses. * @param aValue a string representation of a list of addresses * @throws URISyntaxException where the specified string is not a valid representation */ public AddressList(final String aValue) throws URISyntaxException { addresses = new CopyOnWriteArrayList(); final StringTokenizer t = new StringTokenizer(aValue, ","); while (t.hasMoreTokens()) { try { addresses.add(new URI(Uris.encode(Strings .unquote(t.nextToken())))); } catch (URISyntaxException use) { // ignore invalid addresses if relaxed parsing is enabled.. if (!CompatibilityHints.isHintEnabled( CompatibilityHints.KEY_RELAXED_PARSING)) { throw use; } } } }
/** * Parses the specified string representation to create a list of addresses. * @param aValue a string representation of a list of addresses * @throws URISyntaxException where the specified string is not a valid representation */ public AddressList(final String aValue) throws URISyntaxException { addresses = new CopyOnWriteArrayList<URI>(); final StringTokenizer t = new StringTokenizer(aValue, ","); while (t.hasMoreTokens()) { try { addresses.add(new URI(Uris.encode(Strings .unquote(t.nextToken())))); } catch (URISyntaxException use) { // ignore invalid addresses if relaxed parsing is enabled.. if (!CompatibilityHints.isHintEnabled( CompatibilityHints.KEY_RELAXED_PARSING)) { throw use; } } } }