@Test public void testSubject() throws Exception { Assert.assertEquals("Subject: ", decode(Fields.subject(""))); Assert.assertEquals("Subject: test", decode(Fields.subject("test"))); Assert.assertEquals("Subject: =?ISO-8859-1?Q?Sm=F8rebr=F8d?=", decode(Fields .subject("Sm\370rebr\370d"))); String seventyEight = "12345678901234567890123456789012345678901234567890123456789012345678"; Assert.assertEquals("Subject:\r\n " + seventyEight, decode(Fields.subject( seventyEight))); String seventyNine = seventyEight + "9"; String expected = "Subject: =?US-ASCII?Q?123456789012345678901234567890123?=" + "\r\n =?US-ASCII?Q?456789012345678901234567890123456789?="; Assert.assertEquals(expected, decode(Fields.subject(seventyNine))); }
public static UnstructuredField subject(String subject) { int usedCharacters = FieldName.SUBJECT.length() + 2; String fieldValue = EncoderUtil.encodeIfNecessary(subject, EncoderUtil.Usage.TEXT_TOKEN, usedCharacters); return parse(UnstructuredFieldImpl.PARSER, FieldName.SUBJECT, fieldValue); }
Fields { public static UnstructuredField subject(String subject) { int usedCharacters = FieldName.SUBJECT.length() + 2; String fieldValue = EncoderUtil.encodeIfNecessary(subject, EncoderUtil.Usage.TEXT_TOKEN, usedCharacters); return parse(UnstructuredFieldImpl.PARSER, FieldName.SUBJECT, fieldValue); } }
Fields { public static UnstructuredField subject(String subject) { int usedCharacters = FieldName.SUBJECT.length() + 2; String fieldValue = EncoderUtil.encodeIfNecessary(subject, EncoderUtil.Usage.TEXT_TOKEN, usedCharacters); return parse(UnstructuredFieldImpl.PARSER, FieldName.SUBJECT, fieldValue); } private  Fields(); }
Fields { public static UnstructuredField subject(String subject) { int usedCharacters = FieldName.SUBJECT.length() + 2; String fieldValue = EncoderUtil.encodeIfNecessary(subject, EncoderUtil.Usage.TEXT_TOKEN, usedCharacters); return parse(UnstructuredFieldImpl.PARSER, FieldName.SUBJECT, fieldValue); } private  Fields(); static MimeVersionField version(String ver); static ContentTypeField contentType(String contentType); static ContentTypeField contentType(String mimeType,
            Map<String, String> parameters); static ContentTypeField contentType(String mimeType,
                                               Iterable<NameValuePair> parameters); static ContentTypeField contentType(String mimeType, NameValuePair... parameters); static ContentTransferEncodingField contentTransferEncoding(
            String contentTransferEncoding); static ContentDispositionField contentDisposition(
            String contentDisposition); static ContentDispositionField contentDisposition(
            String dispositionType, Map<String, String> parameters); static ContentDispositionField contentDisposition(
            String dispositionType, Iterable<NameValuePair> parameters); static ContentDispositionField contentDisposition(
            String dispositionType, String filename); static ContentDispositionField contentDisposition(
            String dispositionType, String filename, long size); static ContentDispositionField contentDisposition(
            String dispositionType, String filename, long size,
            Date creationDate, Date modificationDate, Date readDate); static DateTimeField date(Date date); static DateTimeField date(String fieldName, Date date); static DateTimeField date(String fieldName, Date date, TimeZone zone); static UnstructuredField generateMessageId(String hostname); static UnstructuredField messageId(String messageId); static UnstructuredField subject(String subject); static MailboxField sender(Mailbox mailbox); static MailboxListField from(Mailbox mailbox); static MailboxListField from(Mailbox... mailboxes); static MailboxListField from(Iterable<Mailbox> mailboxes); static AddressListField to(Address address); static AddressListField to(Address... addresses); static AddressListField to(Iterable<Address> addresses); static AddressListField cc(Address address); static AddressListField cc(Address... addresses); static AddressListField cc(Iterable<Address> addresses); static AddressListField bcc(Address address); static AddressListField bcc(Address... addresses); static AddressListField bcc(Iterable<Address> addresses); static AddressListField replyTo(Address address); static AddressListField replyTo(Address... addresses); static AddressListField replyTo(Iterable<Address> addresses); static MailboxField mailbox(String fieldName, Mailbox mailbox); static MailboxListField mailboxList(String fieldName,
            Iterable<Mailbox> mailboxes); static AddressListField addressList(String fieldName,
            Iterable<? extends Address> addresses); }
Fields { public static UnstructuredField subject(String subject) { int usedCharacters = FieldName.SUBJECT.length() + 2; String fieldValue = EncoderUtil.encodeIfNecessary(subject, EncoderUtil.Usage.TEXT_TOKEN, usedCharacters); return parse(UnstructuredFieldImpl.PARSER, FieldName.SUBJECT, fieldValue); } private  Fields(); static MimeVersionField version(String ver); static ContentTypeField contentType(String contentType); static ContentTypeField contentType(String mimeType,
            Map<String, String> parameters); static ContentTypeField contentType(String mimeType,
                                               Iterable<NameValuePair> parameters); static ContentTypeField contentType(String mimeType, NameValuePair... parameters); static ContentTransferEncodingField contentTransferEncoding(
            String contentTransferEncoding); static ContentDispositionField contentDisposition(
            String contentDisposition); static ContentDispositionField contentDisposition(
            String dispositionType, Map<String, String> parameters); static ContentDispositionField contentDisposition(
            String dispositionType, Iterable<NameValuePair> parameters); static ContentDispositionField contentDisposition(
            String dispositionType, String filename); static ContentDispositionField contentDisposition(
            String dispositionType, String filename, long size); static ContentDispositionField contentDisposition(
            String dispositionType, String filename, long size,
            Date creationDate, Date modificationDate, Date readDate); static DateTimeField date(Date date); static DateTimeField date(String fieldName, Date date); static DateTimeField date(String fieldName, Date date, TimeZone zone); static UnstructuredField generateMessageId(String hostname); static UnstructuredField messageId(String messageId); static UnstructuredField subject(String subject); static MailboxField sender(Mailbox mailbox); static MailboxListField from(Mailbox mailbox); static MailboxListField from(Mailbox... mailboxes); static MailboxListField from(Iterable<Mailbox> mailboxes); static AddressListField to(Address address); static AddressListField to(Address... addresses); static AddressListField to(Iterable<Address> addresses); static AddressListField cc(Address address); static AddressListField cc(Address... addresses); static AddressListField cc(Iterable<Address> addresses); static AddressListField bcc(Address address); static AddressListField bcc(Address... addresses); static AddressListField bcc(Iterable<Address> addresses); static AddressListField replyTo(Address address); static AddressListField replyTo(Address... addresses); static AddressListField replyTo(Iterable<Address> addresses); static MailboxField mailbox(String fieldName, Mailbox mailbox); static MailboxListField mailboxList(String fieldName,
            Iterable<Mailbox> mailboxes); static AddressListField addressList(String fieldName,
            Iterable<? extends Address> addresses);  }