Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   /*
   * Conditions Of Use
   *
   * This software was developed by employees of the National Institute of
   * Standards and Technology (NIST), an agency of the Federal Government.
   * Pursuant to title 15 Untied States Code Section 105, works of NIST
   * employees are not subject to copyright protection in the United States
   * and are considered to be in the public domain.  As a result, a formal
   * license is not needed to use the software.
  *
  * This software is provided by NIST as a service and is expressly
  * provided "AS IS."  NIST MAKES NO WARRANTY OF ANY KIND, EXPRESS, IMPLIED
  * OR STATUTORY, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTY OF
  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT
  * AND DATA ACCURACY.  NIST does not warrant or make any representations
  * regarding the use of the software or the results thereof, including but
  * not limited to the correctness, accuracy, reliability or usefulness of
  * the software.
  *
  * Permission to use this software is contingent upon your acceptance
  * of the terms of this agreement.
  *
  */
Product of NIST/ITL Advanced Networking Technologies Division (ANTD). * /
  
  package gov.nist.javax.sip.header;
  import gov.nist.javax.sip.header.ims.*/* IMS headers - issued by Miguel Freitas */
  import gov.nist.javax.sip.header.extensions.*// extension headers - pmusgrave
  
  
  import java.util.*;
  
  /*
  * This file contains enhancements contributed by Alexandre Silva Santos
  * (PT-Inovacao) and Miguel Freitas
  */

Implementation of the JAIN SIP HeaderFactory

Author(s):
M. Ranganathan
Olivier Deruelle
Version:
1.2 $Revision: 1.22 $ $Date: 2010/01/12 18:58:48 $
Since:
1.1
  
  public class HeaderFactoryImpl implements HeaderFactory , HeaderFactoryExt {

    
Determines whether or not we should tolerate and strip address scope zones from IPv6 addresses. Address scope zones are sometimes returned at the end of IPv6 addresses generated by InetAddress.getHostAddress(). They are however not part of the SIP semantics so basically this method determines whether or not the parser should be stripping them (as opposed simply being blunt and throwing an exception).
  
      private boolean stripAddressScopeZones = false;

    
Set pretty encoding on / off. This splits up via headers into multiple lines for readability ( better for debugging ).
  
      public void setPrettyEncoding(boolean flag) {
          SIPHeaderList.setPrettyEncode(flag);
      }

    
Creates a new AcceptEncodingHeader based on the newly supplied encoding value.

Parameters:
encoding - the new string containing the encoding value.
Returns:
the newly created AcceptEncodingHeader object.
Throws:
java.text.ParseException which signals that an error has been reached unexpectedly while parsing the encoding value.
  
          throws ParseException {
          if (encoding == null)
              throw new NullPointerException("the encoding parameter is null");
          AcceptEncoding acceptEncoding = new AcceptEncoding();
          acceptEncoding.setEncoding(encoding);
          return acceptEncoding;
      }

    
Creates a new AcceptHeader based on the newly supplied contentType and contentSubType values.

Parameters:
contentType The new string content type value.
contentSubType The new string content sub-type value.
Returns:
the newly created AcceptHeader object.
Throws:
java.text.ParseException which signals that an error has been reached unexpectedly while parsing the content type or content subtype value.
 
         String contentType,
         String contentSubType)
         throws ParseException {
         if (contentType == null || contentSubType == null)
             throw new NullPointerException("contentType or subtype is null ");
         Accept accept = new Accept();
         accept.setContentType(contentType);
         accept.setContentSubType(contentSubType);
 
         return accept;
     }

    
Creates a new AcceptLanguageHeader based on the newly supplied language value.

Parameters:
language - the new Locale value of the language
Returns:
the newly created AcceptLanguageHeader object.
 
         if (language == null)
             throw new NullPointerException("null arg");
         AcceptLanguage acceptLanguage = new AcceptLanguage();
         acceptLanguage.setAcceptLanguage(language);
 
         return acceptLanguage;
     }

    
Creates a new AlertInfoHeader based on the newly supplied alertInfo value.

Parameters:
alertInfo - the new URI value of the alertInfo
Returns:
the newly created AlertInfoHeader object.
Since:
v1.1
 
     public AlertInfoHeader createAlertInfoHeader(URI alertInfo) {
         if (alertInfo == null)
             throw new NullPointerException("null arg alertInfo");
         AlertInfo a = new AlertInfo();
         a.setAlertInfo(alertInfo);
         return a;
     }

    
Creates a new AllowEventsHeader based on the newly supplied event type value.

Parameters:
eventType - the new string containing the eventType value.
Returns:
the newly created AllowEventsHeader object.
Throws:
java.text.ParseException which signals that an error has been reached unexpectedly while parsing the eventType value.
Since:
v1.1
 
     public AllowEventsHeader createAllowEventsHeader(String eventType)
         throws ParseException {
         if (eventType == null)
             throw new NullPointerException("null arg eventType");
         AllowEvents allowEvents = new AllowEvents();
         allowEvents.setEventType(eventType);
         return allowEvents;
     }

    
Creates a new AllowHeader based on the newly supplied method value.

Parameters:
method - the new string containing the method value.
Returns:
the newly created AllowHeader object.
Throws:
java.text.ParseException which signals that an error has been reached unexpectedly while parsing the method value.
 
     public AllowHeader createAllowHeader(String methodthrows ParseException {
         if (method == null)
             throw new NullPointerException("null arg method");
         Allow allow = new Allow();
         allow.setMethod(method);
 
         return allow;
     }

    
Creates a new AuthenticationInfoHeader based on the newly supplied response value.

Parameters:
response - the new string value of the response.
Returns:
the newly created AuthenticationInfoHeader object.
Throws:
java.text.ParseException which signals that an error has been reached unexpectedly while parsing the response value.
Since:
v1.1
 
         throws ParseException {
         if (response == null)
             throw new NullPointerException("null arg response");
         AuthenticationInfo auth = new AuthenticationInfo();
         auth.setResponse(response);
 
         return auth;
     }

    
Creates a new AuthorizationHeader based on the newly supplied scheme value.

Parameters:
scheme - the new string value of the scheme.
Returns:
the newly created AuthorizationHeader object.
Throws:
java.text.ParseException which signals that an error has been reached unexpectedly while parsing the scheme value.
 
         throws ParseException {
         if (scheme == null)
             throw new NullPointerException("null arg scheme ");
         Authorization auth = new Authorization();
         auth.setScheme(scheme);
 
         return auth;
     }

    
Creates a new CSeqHeader based on the newly supplied sequence number and method values.

Parameters:
sequenceNumber - the new integer value of the sequence number.
method - the new string value of the method.
Returns:
the newly created CSeqHeader object.
Throws:
javax.sip.InvalidArgumentException if supplied sequence number is less than zero.
java.text.ParseException which signals that an error has been reached unexpectedly while parsing the method value.
 
     public CSeqHeader createCSeqHeaderlong sequenceNumberString method)
         throws ParseExceptionInvalidArgumentException {
         if (sequenceNumber < 0)
             throw new InvalidArgumentException("bad arg " + sequenceNumber);
         if (method == null)
             throw new NullPointerException("null arg method");
         CSeq cseq = new CSeq();
         cseq.setMethod(method);
         cseq.setSeqNumber(sequenceNumber);
 
         return cseq;
     }

    
For backwards compatibility, also accept int

Deprecated:
 
     public CSeqHeader createCSeqHeaderint sequenceNumberString method)
         throws ParseExceptionInvalidArgumentException {
         return this.createCSeqHeader( (longsequenceNumbermethod );
     }

    
Creates a new CallIdHeader based on the newly supplied callId value.

Parameters:
callId - the new string value of the call-id.
Returns:
the newly created CallIdHeader object.
Throws:
java.text.ParseException which signals that an error has been reached unexpectedly while parsing the callId value.
 
     public CallIdHeader createCallIdHeader(String callId)
         throws ParseException {
         if (callId == null)
             throw new NullPointerException("null arg callId");
         CallID c = new CallID();
         c.setCallId(callId);
         return c;
     }

    
Creates a new CallInfoHeader based on the newly supplied callInfo value.

Parameters:
callInfo The new string value of the callInfo.
Returns:
the newly created CallInfoHeader object.
 
     public CallInfoHeader createCallInfoHeader(URI callInfo) {
         if (callInfo == null)
             throw new NullPointerException("null arg callInfo");
 
         CallInfo c = new CallInfo();
         c.setInfo(callInfo);
         return c;
     }

    
Creates a new ContactHeader based on the newly supplied address value.

Parameters:
address - the new Address value of the address.
Returns:
the newly created ContactHeader object.
 
     public ContactHeader createContactHeader(Address address) {
         if (address == null)
             throw new NullPointerException("null arg address");
         Contact contact = new Contact();
         contact.setAddress(address);
 
         return contact;
     }

    
Creates a new wildcard ContactHeader. This is used in Register requests to indicate to the server that it should remove all locations the at which the user is currently available. This implies that the following conditions are met:
  • ContactHeader.getAddress.getAddress.getUserInfo() == *;
  • ContactHeader.getAddress.getAddress.isWildCard() == true;
  • ContactHeader.getExpires() == 0;

Returns:
the newly created wildcard ContactHeader.
 
     public ContactHeader createContactHeader() {
         Contact contact = new Contact();
         contact.setWildCardFlag(true);
         contact.setExpires(0);
 
         return contact;
     }

    
Creates a new ContentDispositionHeader based on the newly supplied contentDisposition value.

Parameters:
contentDisposition - the new string value of the contentDisposition.
Returns:
the newly created ContentDispositionHeader object.
Throws:
java.text.ParseException which signals that an error has been reached unexpectedly while parsing the contentDisposition value.
Since:
v1.1
 
     public ContentDispositionHeader createContentDispositionHeader(String contentDisposition)
         throws ParseException {
         if (contentDisposition == null)
             throw new NullPointerException("null arg contentDisposition");
         ContentDisposition c = new ContentDisposition();
         c.setDispositionType(contentDisposition);
 
         return c;
     }

    
Creates a new ContentEncodingHeader based on the newly supplied encoding value.

Parameters:
encoding - the new string containing the encoding value.
Returns:
the newly created ContentEncodingHeader object.
Throws:
java.text.ParseException which signals that an error has been reached unexpectedly while parsing the encoding value.
 
         throws ParseException {
         if (encoding == null)
             throw new NullPointerException("null encoding");
         ContentEncoding c = new ContentEncoding();
         c.setEncoding(encoding);
 
         return c;
     }

    
Creates a new ContentLanguageHeader based on the newly supplied contentLanguage value.

Parameters:
contentLanguage - the new Locale value of the contentLanguage.
Returns:
the newly created ContentLanguageHeader object.
Since:
v1.1
 
     public ContentLanguageHeader createContentLanguageHeader(Locale contentLanguage) {
         if (contentLanguage == null)
             throw new NullPointerException("null arg contentLanguage");
         ContentLanguage c = new ContentLanguage();
         c.setContentLanguage(contentLanguage);
 
         return c;
     }

    
Creates a new CSeqHeader based on the newly supplied contentLength value.

Parameters:
contentLength - the new integer value of the contentLength.
Returns:
the newly created ContentLengthHeader object.
Throws:
javax.sip.InvalidArgumentException if supplied contentLength is less than zero.
 
     public ContentLengthHeader createContentLengthHeader(int contentLength)
         throws InvalidArgumentException {
         if (contentLength < 0)
             throw new InvalidArgumentException("bad contentLength");
         ContentLength c = new ContentLength();
         c.setContentLength(contentLength);
 
         return c;
     }

    
Creates a new ContentTypeHeader based on the newly supplied contentType and contentSubType values.

Parameters:
contentType - the new string content type value.
contentSubType - the new string content sub-type value.
Returns:
the newly created ContentTypeHeader object.
Throws:
java.text.ParseException which signals that an error has been reached unexpectedly while parsing the content type or content subtype value.
 
         String contentType,
         String contentSubType)
         throws ParseException {
         if (contentType == null || contentSubType == null)
             throw new NullPointerException("null contentType or subType");
         ContentType c = new ContentType();
         c.setContentType(contentType);
         c.setContentSubType(contentSubType);
         return c;
     }

    
Creates a new DateHeader based on the newly supplied date value.

Parameters:
date - the new Calender value of the date.
Returns:
the newly created DateHeader object.
 
     public DateHeader createDateHeader(Calendar date) {
         SIPDateHeader d = new SIPDateHeader();
         if (date == null)
             throw new NullPointerException("null date");
         d.setDate(date);
 
         return d;
     }

    
Creates a new EventHeader based on the newly supplied eventType value.

Parameters:
eventType - the new string value of the eventType.
Returns:
the newly created EventHeader object.
Throws:
java.text.ParseException which signals that an error has been reached unexpectedly while parsing the eventType value.
Since:
v1.1
 
     public EventHeader createEventHeader(String eventType)
         throws ParseException {
         if (eventType == null)
             throw new NullPointerException("null eventType");
         Event event = new Event();
         event.setEventType(eventType);
 
         return event;
     }

    
Creates a new ExpiresHeader based on the newly supplied expires value.

Parameters:
expires - the new integer value of the expires.
Returns:
the newly created ExpiresHeader object.
Throws:
javax.sip.InvalidArgumentException if supplied expires is less than zero.
 
     public ExpiresHeader createExpiresHeader(int expires)
         throws InvalidArgumentException {
         if (expires < 0)
             throw new InvalidArgumentException("bad value " + expires);
         Expires e = new Expires();
         e.setExpires(expires);
 
         return e;
     }

    
Creates a new ExtensionHeader based on the newly supplied name and value values.

Parameters:
name - the new string name of the ExtensionHeader value.
value - the new string value of the ExtensionHeader.
Returns:
the newly created ExtensionHeader object.
Throws:
java.text.ParseException which signals that an error has been reached unexpectedly while parsing the name or value values.
 
         String name,
         String value)
         throws ParseException {
         if (name == null)
             throw new NullPointerException("bad name");
 
         gov.nist.javax.sip.header.ExtensionHeaderImpl ext =
             new gov.nist.javax.sip.header.ExtensionHeaderImpl();
         ext.setName(name);
         ext.setValue(value);
 
         return ext;
     }

    
Creates a new FromHeader based on the newly supplied address and tag values.

Parameters:
address - the new Address object of the address.
tag - the new string value of the tag.
Returns:
the newly created FromHeader object.
Throws:
java.text.ParseException which signals that an error has been reached unexpectedly while parsing the tag value.
 
     public FromHeader createFromHeader(Address addressString tag)
         throws ParseException {
         if (address == null)
             throw new NullPointerException("null address arg");
         From from = new From();
         from.setAddress(address);
         if (tag != null)
             from.setTag(tag);
 
         return from;
     }

    
Creates a new InReplyToHeader based on the newly supplied callId value.

Parameters:
callId - the new string containing the callId value.
Returns:
the newly created InReplyToHeader object.
Throws:
java.text.ParseException which signals that an error has been reached unexpectedly while parsing the callId value.
Since:
v1.1
 
     public InReplyToHeader createInReplyToHeader(String callId)
         throws ParseException {
         if (callId == null)
             throw new NullPointerException("null callId arg");
         InReplyTo inReplyTo = new InReplyTo();
         inReplyTo.setCallId(callId);
 
         return inReplyTo;
     }
    
Creates a new MaxForwardsHeader based on the newly supplied maxForwards value.

Parameters:
maxForwards The new integer value of the maxForwards.
Returns:
the newly created MaxForwardsHeader object.
Throws:
javax.sip.InvalidArgumentException if supplied maxForwards is less than zero or greater than 255.
 
     public MaxForwardsHeader createMaxForwardsHeader(int maxForwards)
         throws InvalidArgumentException {
         if (maxForwards < 0 || maxForwards > 255)
             throw new InvalidArgumentException(
                 "bad maxForwards arg " + maxForwards);
         MaxForwards m = new MaxForwards();
         m.setMaxForwards(maxForwards);
 
         return m;
     }

    
Creates a new MimeVersionHeader based on the newly supplied mimeVersion value.

Parameters:
majorVersion - the new integer value of the majorVersion.
minorVersion - the new integer value of the minorVersion.
Returns:
the newly created MimeVersionHeader object.
Throws:
javax.sip.InvalidArgumentException if supplied mimeVersion is less than zero.
Since:
v1.1
 
         int majorVersion,
         int minorVersion)
         throws InvalidArgumentException {
         if (majorVersion < 0 || minorVersion < 0)
             throw new javax.sip.InvalidArgumentException(
                 "bad major/minor version");
         MimeVersion m = new MimeVersion();
         m.setMajorVersion(majorVersion);
         m.setMinorVersion(minorVersion);
 
         return m;
     }

    
Creates a new MinExpiresHeader based on the newly supplied minExpires value.

Parameters:
minExpires - the new integer value of the minExpires.
Returns:
the newly created MinExpiresHeader object.
Throws:
javax.sip.InvalidArgumentException if supplied minExpires is less than zero.
Since:
v1.1
 
     public MinExpiresHeader createMinExpiresHeader(int minExpires)
         throws InvalidArgumentException {
         if (minExpires < 0)
             throw new InvalidArgumentException("bad minExpires " + minExpires);
         MinExpires min = new MinExpires();
         min.setExpires(minExpires);
 
         return min;
     }

    
Creates a new MinSEHeader based on the newly supplied expires value.

Parameters:
expires - the new integer value of the expires.
Returns:
the newly created ExpiresHeader object. TODO: Once interfaces are in javax, change the type to MinSEHeader and add to HeaderFactory. - pmusgrave pmusgrave
Throws:
javax.sip.InvalidArgumentException if supplied expires is less than zero.
 
     public ExtensionHeader createMinSEHeader(int expires)
         throws InvalidArgumentException {
         if (expires < 0)
             throw new InvalidArgumentException("bad value " + expires);
         MinSE e = new MinSE();
         e.setExpires(expires);
 
         return e;
     }

    
Creates a new OrganizationHeader based on the newly supplied organization value.

Parameters:
organization - the new string value of the organization.
Returns:
the newly created OrganizationHeader object.
Throws:
java.text.ParseException which signals that an error has been reached unexpectedly while parsing the organization value.
 
     public OrganizationHeader createOrganizationHeader(String organization)
         throws ParseException {
         if (organization == null)
             throw new NullPointerException("bad organization arg");
         Organization o = new Organization();
         o.setOrganization(organization);
 
         return o;
     }

    
Creates a new PriorityHeader based on the newly supplied priority value.

Parameters:
priority - the new string value of the priority.
Returns:
the newly created PriorityHeader object.
Throws:
java.text.ParseException which signals that an error has been reached unexpectedly while parsing the priority value.
 
     public PriorityHeader createPriorityHeader(String priority)
         throws ParseException {
         if (priority == null)
             throw new NullPointerException("bad priority arg");
         Priority p = new Priority();
         p.setPriority(priority);
 
         return p;
     }

    
Creates a new ProxyAuthenticateHeader based on the newly supplied scheme value.

Parameters:
scheme - the new string value of the scheme.
Returns:
the newly created ProxyAuthenticateHeader object.
Throws:
java.text.ParseException which signals that an error has been reached unexpectedly while parsing the scheme value.
 
         throws ParseException {
         if (scheme == null)
             throw new NullPointerException("bad scheme arg");
         ProxyAuthenticate p = new ProxyAuthenticate();
         p.setScheme(scheme);
 
         return p;
     }

    
Creates a new ProxyAuthorizationHeader based on the newly supplied scheme value.

Parameters:
scheme - the new string value of the scheme.
Returns:
the newly created ProxyAuthorizationHeader object.
Throws:
java.text.ParseException which signals that an error has been reached unexpectedly while parsing the scheme value.
 
         throws ParseException {
         if (scheme == null)
             throw new NullPointerException("bad scheme arg");
         ProxyAuthorization p = new ProxyAuthorization();
         p.setScheme(scheme);
 
         return p;
     }

    
Creates a new ProxyRequireHeader based on the newly supplied optionTag value.

Parameters:
optionTag - the new string OptionTag value.
Returns:
the newly created ProxyRequireHeader object.
Throws:
java.text.ParseException which signals that an error has been reached unexpectedly while parsing the optionTag value.
 
         throws ParseException {
         if (optionTag == null)
             throw new NullPointerException("bad optionTag arg");
         ProxyRequire p = new ProxyRequire();
         p.setOptionTag(optionTag);
 
         return p;
     }

    
Creates a new RAckHeader based on the newly supplied rSeqNumber, cSeqNumber and method values.

Parameters:
rSeqNumber - the new integer value of the rSeqNumber.
cSeqNumber - the new integer value of the cSeqNumber.
method - the new string value of the method.
Returns:
the newly created RAckHeader object.
Throws:
javax.sip.InvalidArgumentException if supplied rSeqNumber or cSeqNumber is less than zero or greater than than 2**31-1.
java.text.ParseException which signals that an error has been reached unexpectedly while parsing the method value.
Since:
v1.1
 
     public RAckHeader createRAckHeader(
         long rSeqNumber,
         long cSeqNumber,
         String method)
         throws InvalidArgumentExceptionParseException {
         if (method == null)
             throw new NullPointerException("Bad method");
         if (cSeqNumber < 0 || rSeqNumber < 0)
             throw new InvalidArgumentException("bad cseq/rseq arg");
         RAck rack = new RAck();
         rack.setMethod(method);
         rack.setCSequenceNumber(cSeqNumber);
         rack.setRSequenceNumber(rSeqNumber);
 
         return rack;
     }

    
 
     public RAckHeader createRAckHeader(int rSeqNumberint cSeqNumberString methodthrows InvalidArgumentExceptionParseException {
 
         return createRAckHeader((long)rSeqNumber, (long)cSeqNumbermethod);
     }


    
 
     public RSeqHeader createRSeqHeader(int sequenceNumberthrows InvalidArgumentException {
 
         return createRSeqHeader((longsequenceNumber) ;
     }

    
Creates a new RSeqHeader based on the newly supplied sequenceNumber value.

Parameters:
sequenceNumber - the new integer value of the sequenceNumber.
Returns:
the newly created RSeqHeader object.
Throws:
javax.sip.InvalidArgumentException if supplied sequenceNumber is less than zero or greater than than 2**31-1.
Since:
v1.1
 
     public RSeqHeader createRSeqHeader(long sequenceNumber)
         throws InvalidArgumentException {
         if (sequenceNumber < 0)
             throw new InvalidArgumentException(
                 "invalid sequenceNumber arg " + sequenceNumber);
         RSeq rseq = new RSeq();
         rseq.setSeqNumber(sequenceNumber);
 
         return rseq;
     }

    
Creates a new ReasonHeader based on the newly supplied reason value.

Parameters:
protocol - the new string value of the protocol.
cause - the new integer value of the cause.
text - the new string value of the text.
Returns:
the newly created ReasonHeader object.
Throws:
java.text.ParseException which signals that an error has been reached unexpectedly while parsing the protocol, cause or text value.
Since:
v1.1
 
         String protocol,
         int cause,
         String text)
         throws InvalidArgumentExceptionParseException {
         if (protocol == null)
             throw new NullPointerException("bad protocol arg");
         if (cause < 0)
             throw new InvalidArgumentException("bad cause");
         Reason reason = new Reason();
         reason.setProtocol(protocol);
         reason.setCause(cause);
         reason.setText(text);
 
         return reason;
     }

    
Creates a new RecordRouteHeader based on the newly supplied address value.

Parameters:
address - the new Address object of the address.
Returns:
the newly created RecordRouteHeader object.
 
     public RecordRouteHeader createRecordRouteHeader(Address address) {
         if ( address == nullthrow new NullPointerException("Null argument!");
         RecordRoute recordRoute = new RecordRoute();
         recordRoute.setAddress(address);
 
         return recordRoute;
     }

    
Creates a new ReplyToHeader based on the newly supplied address value.

Parameters:
address - the new Address object of the address.
Returns:
the newly created ReplyToHeader object.
Since:
v1.1
 
     public ReplyToHeader createReplyToHeader(Address address) {
         if (address == null)
             throw new NullPointerException("null address");
         ReplyTo replyTo = new ReplyTo();
         replyTo.setAddress(address);
 
         return replyTo;
     }

    
Creates a new RequireHeader based on the newly supplied optionTag value.

Parameters:
optionTag - the new string value containing the optionTag value.
Returns:
the newly created RequireHeader object.
Throws:
java.text.ParseException which signals that an error has been reached unexpectedly while parsing the List of optionTag value.
 
     public RequireHeader createRequireHeader(String optionTag)
         throws ParseException {
         if (optionTag == null)
             throw new NullPointerException("null optionTag");
         Require require = new Require();
         require.setOptionTag(optionTag);
 
         return require;
     }

    
Creates a new RetryAfterHeader based on the newly supplied retryAfter value.

Parameters:
retryAfter - the new integer value of the retryAfter.
Returns:
the newly created RetryAfterHeader object.
Throws:
javax.sip.InvalidArgumentException if supplied retryAfter is less than zero.
 
     public RetryAfterHeader createRetryAfterHeader(int retryAfter)
         throws InvalidArgumentException {
         if (retryAfter < 0)
             throw new InvalidArgumentException("bad retryAfter arg");
         RetryAfter r = new RetryAfter();
         r.setRetryAfter(retryAfter);
 
         return r;
     }

    
Creates a new RouteHeader based on the newly supplied address value.

Parameters:
address - the new Address object of the address.
Returns:
the newly created RouteHeader object.
 
     public RouteHeader createRouteHeader(Address address) {
         if (address == null)
             throw new NullPointerException("null address arg");
         Route route = new Route();
         route.setAddress(address);
 
         return route;
     }

    
Creates a new ServerHeader based on the newly supplied product value.

Parameters:
product - the new list value of the product.
Returns:
the newly created ServerHeader object.
Throws:
java.text.ParseException which signals that an error has been reached unexpectedly while parsing the product value.
 
     public ServerHeader createServerHeader(List product)
         throws ParseException {
         if (product == null)
             throw new NullPointerException("null productList arg");
         Server server = new Server();
         server.setProduct(product);
 
         return server;
     }

    
Creates a new SubjectHeader based on the newly supplied subject value.

Parameters:
subject - the new string value of the subject.
Returns:
the newly created SubjectHeader object.
Throws:
java.text.ParseException which signals that an error has been reached unexpectedly while parsing the subject value.
 
     public SubjectHeader createSubjectHeader(String subject)
         throws ParseException {
         if (subject == null)
             throw new NullPointerException("null subject arg");
         Subject s = new Subject();
         s.setSubject(subject);
 
         return s;
     }

    
Creates a new SubscriptionStateHeader based on the newly supplied subscriptionState value.

Parameters:
subscriptionState - the new string value of the subscriptionState.
Returns:
the newly created SubscriptionStateHeader object.
Throws:
java.text.ParseException which signals that an error has been reached unexpectedly while parsing the subscriptionState value.
Since:
v1.1
 
     public SubscriptionStateHeader createSubscriptionStateHeader(String subscriptionState)
         throws ParseException {
         if (subscriptionState == null)
             throw new NullPointerException("null subscriptionState arg");
         SubscriptionState s = new SubscriptionState();
         s.setState(subscriptionState);
 
         return s;
     }

    
Creates a new SupportedHeader based on the newly supplied optionTag value.

Parameters:
optionTag - the new string containing the optionTag value.
Returns:
the newly created SupportedHeader object.
Throws:
java.text.ParseException which signals that an error has been reached unexpectedly while parsing the optionTag value.
 
     public SupportedHeader createSupportedHeader(String optionTag)
         throws ParseException {
         if (optionTag == null)
             throw new NullPointerException("null optionTag arg");
         Supported supported = new Supported();
         supported.setOptionTag(optionTag);
 
         return supported;
     }

    
Creates a new TimeStampHeader based on the newly supplied timeStamp value.

Parameters:
timeStamp - the new float value of the timeStamp.
Returns:
the newly created TimeStampHeader object.
Throws:
javax.sip.InvalidArgumentException if supplied timeStamp is less than zero.
 
     public TimeStampHeader createTimeStampHeader(float timeStamp)
         throws InvalidArgumentException {
         if (timeStamp < 0)
             throw new IllegalArgumentException("illegal timeStamp");
         TimeStamp t = new TimeStamp();
         t.setTimeStamp(timeStamp);
 
         return t;
     }

    
Creates a new ToHeader based on the newly supplied address and tag values.

Parameters:
address - the new Address object of the address.
tag - the new string value of the tag.
Returns:
the newly created ToHeader object.
Throws:
java.text.ParseException which signals that an error has been reached unexpectedly while parsing the tag value.
    public ToHeader createToHeader(Address addressString tag)
        throws ParseException {
        if (address == null)
            throw new NullPointerException("null address");
        To to = new To();
        to.setAddress(address);
        if (tag != null)
            to.setTag(tag);
        return to;
    }

    
Creates a new UnsupportedHeader based on the newly supplied optionTag value.

Parameters:
optionTag - the new string containing the optionTag value.
Returns:
the newly created UnsupportedHeader object.
Throws:
java.text.ParseException which signals that an error has been reached unexpectedly while parsing the List of optionTag value.
        throws ParseException {
        if (optionTag == null)
            throw new NullPointerException(optionTag);
        Unsupported unsupported = new Unsupported();
        unsupported.setOptionTag(optionTag);
        return unsupported;
    }

    
Creates a new UserAgentHeader based on the newly supplied product value.

Parameters:
product - the new list value of the product.
Returns:
the newly created UserAgentHeader object.
Throws:
java.text.ParseException which signals that an error has been reached unexpectedly while parsing the product value.
        throws ParseException {
        if (product == null)
            throw new NullPointerException("null user agent");
        UserAgent userAgent = new UserAgent();
        userAgent.setProduct(product);
        return userAgent;
    }

    
Creates a new ViaHeader based on the newly supplied uri and branch values.

Parameters:
host the new host value of uri.
port the new port value of uri.
transport the new transport value of uri.
branch the new string value of the branch.
Returns:
the newly created ViaHeader object.
Throws:
java.text.ParseException which signals that an error has been reached unexpectedly while parsing the branch value.
    public ViaHeader createViaHeader(
        String host,
        int port,
        String transport,
        String branch)
        throws ParseExceptionInvalidArgumentException {
        // This should be changed.
        if (host == null || transport == null)
            throw new NullPointerException("null arg");
        Via via = new Via();
        if (branch != null)
            via.setBranch(branch);
        // for supporting IPv6 addresses
        if(host.indexOf(':') >= 0
            && host.indexOf('[') < 0)
        {
            //strip address scope zones if any
            if()
            {
                int zoneStart = host.indexOf('%');
                if(zoneStart != -1)
                    host = host.substring(0, zoneStart);
            }
            host = '[' + host + ']';
        }
        via.setHost(host);
        via.setPort(port);
        via.setTransport(transport);
        return via;
    }

    
Creates a new WWWAuthenticateHeader based on the newly supplied scheme value.

Parameters:
scheme - the new string value of the scheme.
Returns:
the newly created WWWAuthenticateHeader object.
Throws:
java.text.ParseException which signals that an error has been reached unexpectedly while parsing the scheme values.
        throws ParseException {
        if (scheme == null)
            throw new NullPointerException("null scheme");
        WWWAuthenticate www = new WWWAuthenticate();
        www.setScheme(scheme);
        return www;
    }

    
Creates a new WarningHeader based on the newly supplied agent, code and comment values.

Parameters:
agent - the new string value of the agent.
code - the new boolean integer of the code.
comment - the new string value of the comment.
Returns:
the newly created WarningHeader object.
Throws:
java.text.ParseException which signals that an error has been reached unexpectedly while parsing the agent or comment values.
javax.sip.InvalidArgumentException if an invalid integer code is given for the WarningHeader.
        String agent,
        int code,
        String comment)
        throws ParseExceptionInvalidArgumentException {
        if (agent == null)
            throw new NullPointerException("null arg");
        Warning warning = new Warning();
        warning.setAgent(agent);
        warning.setCode(code);
        warning.setText(comment);
        return warning;
    }

    
Creates a new ErrorInfoHeader based on the newly supplied errorInfo value.

Parameters:
errorInfo - the new URI value of the errorInfo.
Returns:
the newly created ErrorInfoHeader object.
    public ErrorInfoHeader createErrorInfoHeader(URI errorInfo) {
        if (errorInfo == null)
            throw new NullPointerException("null arg");
        return new ErrorInfo((GenericURIerrorInfo);
    }
    
    
Create a header from the given header text. Header should not have the trailng crlf.

    public javax.sip.header.Header createHeader(String headerTextthrows ParseException {
        StringMsgParser smp = new StringMsgParser();
        SIPHeader sipHeader = smp.parseSIPHeader(headerText.trim());
        if (sipHeader instanceof SIPHeaderList) {
            if (((SIPHeaderListsipHeader).size() > 1) {
                throw new ParseException(
                    "Only singleton allowed " + headerText,
                    0);
            } else if (((SIPHeaderListsipHeader).size() == 0) {
                try {
                    return (Header) ((SIPHeaderListsipHeader)
                        .getMyClass()
                        .newInstance();
                } catch (InstantiationException ex) {
                    ex.printStackTrace();
                    return null;
                } catch (IllegalAccessException ex) {
                    ex.printStackTrace();
                    return null;
                }
            } else {
                return (Header) ((SIPHeaderListsipHeader).getFirst();
            }
        } else {
            return (HeadersipHeader;
        }
        
    }

    
Create and parse a header.

Parameters:
headerName -- header name for the header to parse.
headerValue -- header value for the header to parse.
Returns:
the parsed sip header
Throws:
java.text.ParseException
        String headerName,
        String headerValue)
        throws java.text.ParseException {
        if (headerName == null)
            throw new NullPointerException("header name is null");
        String hdrText =
            new StringBuffer()
                .append(headerName)
                .append(":")
                .append(headerValue)
                .toString();
        return createHeader(hdrText);
        
    }

    
Create and return a list of headers.

Parameters:
headers -- list of headers.
Returns:
a List containing the headers.
Throws:
java.text.ParseException -- if a parse exception occurs or a List of that type of header is not alowed.
    public java.util.List createHeaders(String headers)
        throws java.text.ParseException {
        if (headers == null)
            throw new NullPointerException("null arg!");
        StringMsgParser smp = new StringMsgParser();
        SIPHeader shdr = smp.parseSIPHeader(headers);
        if (shdr instanceof SIPHeaderList)
            return (SIPHeaderListshdr;
        else
            throw new ParseException(
                "List of headers of this type is not allowed in a message",
                0);
    }

    
Create a ReferTo Header.

Parameters:
address -- address for the header.
    public ReferToHeader createReferToHeader(Address address) {
        if (address == null)
            throw new NullPointerException("null address!");
        ReferTo referTo = new ReferTo();
        referTo.setAddress(address);
        return referTo;
    }

    
Create a ReferredBy Header. pmusgrave

Parameters:
address -- address for the header. TODO: Once interfaces are in javax, change the type to MinSEHeader and add to HeaderFactory. - pmusgrave
        if (address == null)
            throw new NullPointerException("null address!");
        ReferredBy referredBy = new ReferredBy();
        referredBy.setAddress(address);
        return referredBy;
    }

    
Create a Replaces header with a call Id, to and from tag. TODO: Once interfaces are in javax, change the type to MinSEHeader and add to HeaderFactory. - pmusgrave pmusgrave
    public ReplacesHeader createReplacesHeader(String callIdString toTag,
                String fromTagthrows ParseException
    {
        Replaces replaces = new Replaces();
        replaces.setCallId(callId);
        replaces.setFromTag(fromTag);
        replaces.setToTag(toTag);
        return replaces;
    }

    
Create a Join header with a call Id, to and from tag.
    public JoinHeader createJoinHeader(String callIdString toTag,
                String fromTagthrows ParseException
    {
        Join join = new Join();
        join.setCallId(callId);
        join.setFromTag(fromTag);
        join.setToTag(toTag);
        return join;
    }
    /*
     * (non-Javadoc)
     * @see javax.sip.header.HeaderFactory#createSIPETagHeader(java.lang.String)
     */
    public SIPETagHeader createSIPETagHeader(String etagthrows ParseException {
        return new SIPETag(etag);
    }
    /*
     * (non-Javadoc)
     * @see javax.sip.header.HeaderFactory#createSIPIfMatchHeader(java.lang.String)
     */
        return new SIPIfMatch(etag);
    }
    //////////////////////////////////////////////////////////////////////////
    // The following headers are not part of the JSIP spec.
    // They are IMS headers
    // (contributed by Miguel Freitas - PT Inovacao and Telecommunications Institute)
    ///////////////////////////////////////////////////////////////////////////

    
creates a P-Access-Network-Info header

Returns:
newly created P-Access-Network-Info header
    {
        PAccessNetworkInfo accessNetworkInfo = new PAccessNetworkInfo();
        return accessNetworkInfo;
    }


    
P-Asserted-Identity header

Parameters:
address - Address
Returns:
newly created P-Asserted-Identity header
Throws:
java.text.ParseException
java.lang.NullPointerException
        throws NullPointerExceptionParseException
    {
        if (address == null)
            throw new NullPointerException("null address!");
        PAssertedIdentity assertedIdentity = new PAssertedIdentity();
        assertedIdentity.setAddress(address);
        return assertedIdentity;
    }


    
Creates a new P-Associated-URI header based on the supplied address

Parameters:
assocURI - Address
Returns:
newly created P-Associated-URI header
Throws:
java.lang.NullPointerException if the supplied address is null
java.text.ParseException
    {
        if (assocURI == null)
        throw new NullPointerException("null associatedURI!");
        PAssociatedURI associatedURI = new PAssociatedURI();
        associatedURI.setAddress(assocURI);
        return associatedURI;
    }




    
P-Called-Party-ID header

Parameters:
address - Address
Returns:
newly created P-Called-Party-ID header
Throws:
java.lang.NullPointerException
java.text.ParseException
    {
        if (address == null)
            throw new NullPointerException("null address!");
        PCalledPartyID calledPartyID = new PCalledPartyID();
        calledPartyID.setAddress(address);
        return calledPartyID;
    }



    
P-Charging-Function-Addresses header

Returns:
newly created P-Charging-Function-Addresses header
    {
        return cfa;
    }


    
P-Charging-Vector header

Parameters:
icid - icid string
Returns:
newly created P-Charging-Vector header
Throws:
java.lang.NullPointerException
java.text.ParseException
        throws ParseException
    {
        if (icid == null)
        throw new NullPointerException("null icid arg!");
        PChargingVector chargingVector = new PChargingVector();
        chargingVector.setICID(icid);
        return chargingVector;
    }


    
P-Media-Authorization header

Parameters:
token - token string
Returns:
newly created P-Media-Authorizarion header
Throws:
javax.sip.InvalidArgumentException
java.text.ParseException
    {
        if (token == null || token == "")
            throw new InvalidArgumentException("The Media-Authorization-Token parameter is null or empty");
        PMediaAuthorization mediaAuthorization = new PMediaAuthorization();
        mediaAuthorization.setMediaAuthorizationToken(token);
        return mediaAuthorization;
    }


    
P-Preferred-Identity header

Parameters:
address - Address
Returns:
newly created P-Preferred-Identity header
Throws:
java.lang.NullPointerException
    {
        if (address == null)
            throw new NullPointerException("null address!");
        PPreferredIdentity preferredIdentity = new PPreferredIdentity();
        preferredIdentity.setAddress(address);
        return preferredIdentity;
    }

    
P-Visited-Network-ID header

Returns:
newly created P-Visited-Network-ID header
    {
        PVisitedNetworkID visitedNetworkID = new PVisitedNetworkID();
        return visitedNetworkID;
    }



    
PATH header

Parameters:
address - Address
Returns:
newly created Path header
Throws:
java.lang.NullPointerException
java.text.ParseException
    public PathHeader createPathHeader(Address address)
    {
        if (address == null)
            throw new NullPointerException("null address!");
        Path path = new Path();
        path.setAddress(address);
        return path;
    }


    
Privacy header

Parameters:
privacyType - privacy type string
Returns:
newly created Privacy header
Throws:
java.lang.NullPointerException
    public PrivacyHeader createPrivacyHeader(String privacyType)
    {
        if (privacyType == null)
            throw new NullPointerException("null privacyType arg");
        Privacy privacy = new Privacy(privacyType);
        return privacy;
    }


    
Service-Route header

Parameters:
address - Address
Returns:
newly created Service-Route header
Throws:
java.lang.NullPointerException
    {
        if (address == null)
            throw new NullPointerException("null address!");
        ServiceRoute serviceRoute = new ServiceRoute();
        serviceRoute.setAddress(address);
        return serviceRoute;
    }

    
Security-Server header

Returns:
newly created Security-Server header
    {
        SecurityServer secServer = new SecurityServer();
        return secServer;
    }

    
Security-Client header

Returns:
newly created Security-Client header
    {
        SecurityClient secClient = new SecurityClient();
        return secClient;
    }

    
Security-Verify header

Returns:
newly created Security-Verify header
    {
        SecurityVerify secVerify = new SecurityVerify();
        return secVerify;
    }

    

Returns:
the newly create P-User-Database header. Please note that this is not a SIP/TEL uri. It is a DIAMETER AAA URI.
    {
        if((databaseName ==null)||(databaseName.equals(" ")))
            throw new NullPointerException("Database name is null");
        PUserDatabase pUserDatabase = new PUserDatabase();
        pUserDatabase.setDatabaseName(databaseName);
        return pUserDatabase;
    }


    

Returns:
The newly created P-Profile-Key header.
    {
        if (address ==null)
            throw new NullPointerException("Address is null");
        PProfileKey pProfileKey = new PProfileKey();
        pProfileKey.setAddress(address);
        return pProfileKey;
    }

    

Returns:
The newly created P-Served-User header.
    {
        if(address==null)
            throw new NullPointerException("Address is null");
        PServedUser psu = new PServedUser();
        psu.setAddress(address);
        return psu;
    }
    

Returns:
The newly created P-Preferred-Service header.
    {
        PPreferredService pps = new PPreferredService();
        return pps;
    }

    

Returns:
The newly created P-Asserted-Service header.
    {
        PAssertedService pas = new PAssertedService();
        return pas;
    }

    
Creates a new SessionExpiresHeader based on the newly supplied expires value.

Parameters:
expires - the new integer value of the expires.
Returns:
the newly created SessionExpiresHeader object.
Throws:
javax.sip.InvalidArgumentException if supplied expires is less than zero.