@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;

	}
@ 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 + "]" ) ; 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 ; }
/*
(non-Javadoc)
@see javax.servlet.sip.SipServletMessage#getAddressHeader(java.lang.String)