• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package gov.nist.javax.sip.message;
2 
3 import java.text.ParseException;
4 
5 import javax.sip.header.ContentDispositionHeader;
6 import javax.sip.header.ContentTypeHeader;
7 
8 public class ContentImpl implements Content {
9 
10 
11     /*
12      * The content type header for this chunk of content.
13      */
14 
15     private Object content;
16 
17     private String boundary;
18 
19     private ContentTypeHeader contentTypeHeader;
20 
21     private ContentDispositionHeader contentDispositionHeader;
22 
23 
24 
ContentImpl( String content, String boundary )25     public ContentImpl( String content, String boundary ) {
26         this.content = content;
27 
28         this.boundary = boundary;
29     }
30 
31 
32 
33     /* (non-Javadoc)
34      * @see gov.nist.javax.sip.message.ContentExt#setContent(java.lang.String)
35      */
setContent(Object content)36     public void setContent(Object content) {
37         this.content = content;
38     }
39 
40     /* (non-Javadoc)
41      * @see gov.nist.javax.sip.message.ContentExt#getContentTypeHeader()
42      */
getContentTypeHeader()43     public ContentTypeHeader getContentTypeHeader() {
44         return contentTypeHeader;
45     }
46 
47     /*
48      * (non-Javadoc)
49      * @see gov.nist.javax.sip.message.Content#getContent()
50      */
getContent()51     public Object getContent() {
52         return this.content;
53     }
54 
55 
56     /* (non-Javadoc)
57      * @see gov.nist.javax.sip.message.ContentExt#toString()
58      */
toString()59     public String toString() {
60         // This is not part of a multipart message.
61         if (boundary == null) {
62             return content.toString();
63         } else {
64            if ( this.contentDispositionHeader != null ) {
65             return "--" + boundary + "\r\n" + getContentTypeHeader() +
66                     this.getContentDispositionHeader().toString() + "\r\n"
67                     + content.toString();
68            } else {
69                return "--" + boundary + "\r\n" + getContentTypeHeader() + "\r\n" +  content.toString();
70            }
71         }
72     }
73 
74 
75 
76     /**
77      * @param contentDispositionHeader the contentDispositionHeader to set
78      */
setContentDispositionHeader(ContentDispositionHeader contentDispositionHeader)79     public void setContentDispositionHeader(ContentDispositionHeader contentDispositionHeader) {
80         this.contentDispositionHeader = contentDispositionHeader;
81     }
82 
83 
84 
85     /**
86      * @return the contentDispositionHeader
87      */
getContentDispositionHeader()88     public ContentDispositionHeader getContentDispositionHeader() {
89         return contentDispositionHeader;
90     }
91 
92 
93 
94     /**
95      * @param contentTypeHeader the contentTypeHeader to set
96      */
setContentTypeHeader(ContentTypeHeader contentTypeHeader)97     public void setContentTypeHeader(ContentTypeHeader contentTypeHeader) {
98         this.contentTypeHeader = contentTypeHeader;
99     }
100 
101 
102 }
103