/*
(non-Javadoc)

@see javax.servlet.sip.SipFactory#createAddress(javax.servlet.sip.URI,
java.lang.String)
964035
public Address createAddress(URI uri, String displayName) {
		try {
			if (logger.isDebugEnabled()) {
				logger.debug("Creating Address from URI[" + uri.toString()
						+ "] with display name[" + displayName + "]");
			}

			javax.sip.address.Address address = SipFactoryImpl.addressFactory
					.createAddress(((URIImpl) uri).getURI());
			address.setDisplayName(displayName);
			return new AddressImpl(address, null, ModifiableRule.Modifiable);

		} catch (ParseException e) {
			throw new IllegalArgumentException(e);
		}
	}
935849
public void setAddress(final String address) {
		// Do we have a subaddressing account?
		Preconditions.checkArgument(StringUtils.startsWith(this.address, accountId + "+"),
				"Mail address can only be changed when subaddressing is active");
		Preconditions.checkArgument(StringUtils.startsWith(address, accountId), "New mail address %s does not start with accountId=%s", address,
				accountId);
		log.info("Changing mail address from {} to {}", this.address, address);
		this.address = address;
	}
220270
public static InetSocketAddress toInetSocketAddress(URI uri) {
		final InetAddress adr = toInetAddress(uri);
		final int port = uri.getPort();
		if (port <= 0) {
			throw new IllegalArgumentException(uri.toString());
		}
		return new InetSocketAddress(adr, port);
	}
50601
public static IpAddress createIp6(String value, String admDom) {
		return createIp(IpAddressType.IPv6, value, admDom);
	}
102080
public void setURI(URI uri) {
		if(SipServletMessageImpl.isSystemHeader(isModifiable)) {
			throw new IllegalStateException("this Address is used in a context where it cannot be modified");
		}
		this.getAddress().setURI(((URIImpl) uri).uri);
	}
84282
public SipServletRequest createRequest(SipApplicationSession sipAppSession,
			String method, URI from, URI to, String handler) {
		if (logger.isDebugEnabled()) {
			logger
					.debug("Creating new SipServletRequest for SipApplicationSession["
							+ sipAppSession
							+ "] METHOD["
							+ method
							+ "] FROM_URI[" + from + "] TO_URI[" + to + "]");
		}

		validateCreation(method, sipAppSession);

		//javadoc specifies that a copy of the uri should be done hence the clone
		Address toA = this.createAddress(to.clone());
		Address fromA = this.createAddress(from.clone());

		try {
			return createSipServletRequest(sipAppSession, method, fromA, toA, handler, null, null);
		} catch (ServletParseException e) {
			logger.error("Error creating sipServletRequest", e);
			return null;
		}

	}
414473
@SuppressWarnings("unchecked")
	public Address getAddressHeader(String name) throws ServletParseException {
		if (name == null)
			throw new NullPointerException();

		String hName = getFullHeaderName(name);

		if (logger.isDebugEnabled())
			logger.debug("Fetching address header for name [" + hName + "]");

//		if (!isAddressTypeHeader(hName)) {
//			logger.error("Header of name [" + hName
//					+ "] is not address type header!!!");
//			throw new ServletParseException("Header of type [" + hName
//					+ "] cant be parsed to address, wrong content type!!!");
//		}
		String nameToSearch = getCorrectHeaderName(hName);
		ListIterator<Header> headers = (ListIterator<Header>) this.message
				.getHeaders(nameToSearch);
		ListIterator<Header> lit = headers;

		if (lit != null && lit.hasNext()) {
			Header first = lit.next();
			if (first instanceof HeaderAddress) {
				try {
					if(this.isCommitted()) {
						return new AddressImpl((HeaderAddress) first, ModifiableRule.NotModifiable);
					} else {
						return new AddressImpl((HeaderAddress) first, getModifiableRule(hName));
					}
				} catch (ParseException e) {
					throw new ServletParseException("Bad address " + first);
				}
			} else {
				Parameterable parametrable = createParameterable(first, first.getName(), message instanceof Request);
				try {
					logger.debug("parametrable Value " + parametrable.getValue());
					if(this.isCommitted()) {
						return new AddressImpl(SipFactoryImpl.addressFactory.createAddress(parametrable.getValue()), ((ParameterableHeaderImpl)parametrable).getInternalParameters(), ModifiableRule.NotModifiable);
					} else {
						return new AddressImpl(SipFactoryImpl.addressFactory.createAddress(parametrable.getValue()), ((ParameterableHeaderImpl)parametrable).getInternalParameters(), getModifiableRule(hName));
					}
				} catch (ParseException e) {
					throw new ServletParseException("Impossible to parse the following header " + name + " as an address.", e);
				}
			}
		}
		return null;

	}
1113300
@Action(
            publishing = Publishing.ENABLED // uses wrapper factory
    )
    public PublishedCustomer placeOrderToNewAddress(
            @ParameterLayout(named="Name of product to order")
            final String name,
            @ParameterLayout(named="New address Line 1")
            final String line1,
            @Parameter(optionality = Optionality.OPTIONAL)
            @ParameterLayout(named="New address Line 2")
            final String line2,
            @ParameterLayout(named="New address Town")
            final String town) {
        wrapperFactory.wrap(this).addOrder(name);
        wrapperFactory.wrap(this).updateAddress(line1, line2, town);
        return this;
    }
1285371
public ResourceAddress newResourceAddress(String location, ResourceOptions options) {
        return newResourceAddress(location, options, null /* qualifier */);
    }
1127810
public GeoLocationResponse addAddress(final String address) {
        if (StringUtils.isNotBlank(address)) {
            this.addresses.add(address);
        }
        return this;
    }
459396
public static URI createUri(String uriString) throws DataSourceException {
        if(uriString == null) {
            throw new DataSourceResourceException("URI string is null");
        }

        try {
            return new URI(uriString);
        } catch(URISyntaxException e) {
            throw new DataSourceResourceException("Not a valid URI: " +
                    uriString, e);
        }
    }
95163
private static URI createUriFromName(String name) {
        if (name == null) {
            throw new NullPointerException("name");
        }
        try {
            return new URI(name);
        } catch (final URISyntaxException e) {
            throw new IllegalArgumentException("Invalid name: " + name, e);
        }
    }
1296564
public void setValue(String value) {
		try {
			this.uri = SipFactoryImpl.addressFactory.createURI(value);
		} catch (ParseException ex) {
			logger.error("Bad input arg", ex);
			throw new IllegalArgumentException("Bad input arg", ex);
		}
	}
146303
public static SourceAddressAttribute createSourceAddressAttribute(
			TransportAddress address) {
		SourceAddressAttribute attribute = new SourceAddressAttribute();

		attribute.setAddress(address);

		return attribute;
	}
916361
public ADDRESST registerParticipant(ADDRESST address, EventListener entity) {
		synchronized (mutex()) {
			addListener(address, entity);
			this.participants.put(entity.getID(), address);
		}
		return address;
	}
1299928
@VisibleForTesting
  static String makeTargetStringForDirectAddress(SocketAddress address) {
    try {
      return new URI(DIRECT_ADDRESS_SCHEME, "", "/" + address, null).toString();
    } catch (URISyntaxException e) {
      // It should not happen.
      throw new RuntimeException(e);
    }
  }
1198026
@Override
	public Connector createConnector(InetAddress address, int port,
                                     String protocol) {
	return createConnector(address != null? address.toString() : null,
			       port, protocol);
    }