/** * Set the message content given type and subtype. * * @param type is the message type (eg. application) * @param subType is the message sybtype (eg. sdp) * @param messageContent is the messge content as a string. */ public void setMessageContent(String type, String subType, String messageContent) { if (messageContent == null) throw new IllegalArgumentException("messgeContent is null"); ContentType ct = new ContentType(type, subType); this.setHeader(ct); this.messageContent = messageContent; this.messageContentBytes = null; this.messageContentObject = null; // Could be double byte so we need to compute length // after converting to byte[] computeContentLength(messageContent); }
/** * Creates a new ContentTypeHeader based on the newly supplied contentType and * contentSubType values. * * @param contentType - the new string content type value. * @param contentSubType - the new string content sub-type value. * @throws ParseException which signals that an error has been reached * unexpectedly while parsing the content type or content subtype value. * @return the newly created ContentTypeHeader object. */ public ContentTypeHeader createContentTypeHeader( 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; }
/** * Set the message content for a given type and subtype. * * @param type is the messge type. * @param subType is the message subType. * @param messageContent is the message content as a byte array. */ public void setMessageContent(String type, String subType, byte[] messageContent) { ContentType ct = new ContentType(type, subType); this.setHeader(ct); this.setMessageContent(messageContent); computeContentLength(messageContent); }
ContentTypeHeader cth = new ContentType("message", "sipfrag"); buf.append("\r\n" + cth.toString()); ContentLength clengthHeader = new ContentLength(clength);
public MultipartMimeContent createMultipartMimeContent(ContentTypeHeader multipartMimeCth, String[] contentType, String[] contentSubtype, String[] contentBody) { String boundary = multipartMimeCth.getParameter("boundary"); MultipartMimeContentImpl retval = new MultipartMimeContentImpl(multipartMimeCth); for (int i = 0 ; i < contentType.length; i++ ) { ContentTypeHeader cth = new ContentType(contentType[i],contentSubtype[i]); ContentImpl contentImpl = new ContentImpl(contentBody[i]); contentImpl.setContentTypeHeader(cth); retval.add(contentImpl); } return retval; }
public SIPHeader parse() throws ParseException { ContentType contentType = new ContentType(); if (debug) dbg_enter("ContentTypeParser.parse"); try { this.headerName(TokenTypes.CONTENT_TYPE); // The type: lexer.match(TokenTypes.ID); Token type = lexer.getNextToken(); this.lexer.SPorHT(); contentType.setContentType(type.getTokenValue()); // The sub-type: lexer.match('/'); lexer.match(TokenTypes.ID); Token subType = lexer.getNextToken(); this.lexer.SPorHT(); contentType.setContentSubType(subType.getTokenValue()); super.parse(contentType); this.lexer.match('\n'); } finally { if (debug) dbg_leave("ContentTypeParser.parse"); } return contentType; }
public SIPHeader parse() throws ParseException { ContentType contentType = new ContentType(); if (debug) dbg_enter("ContentTypeParser.parse"); try { this.headerName(TokenTypes.CONTENT_TYPE); // The type: lexer.match(TokenTypes.ID); Token type = lexer.getNextToken(); this.lexer.SPorHT(); contentType.setContentType(type.getTokenValue()); // The sub-type: lexer.match('/'); lexer.match(TokenTypes.ID); Token subType = lexer.getNextToken(); this.lexer.SPorHT(); contentType.setContentSubType(subType.getTokenValue()); super.parse(contentType); this.lexer.match('\n'); } finally { if (debug) dbg_leave("ContentTypeParser.parse"); } return contentType; }