本文整理汇总了Java中org.apache.james.mime4j.stream.Field类的典型用法代码示例。如果您正苦于以下问题:Java Field类的具体用法?Java Field怎么用?Java Field使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Field类属于org.apache.james.mime4j.stream包,在下文中一共展示了Field类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getContentId
import org.apache.james.mime4j.stream.Field; //导入依赖的package包/类
@Override
public String getContentId (final Entity entity)
{
final Header header = entity.getHeader();
if (header == null)
{
return null;
}
final Field field = header.getField(FieldName.CONTENT_ID);
if (field == null)
{
return null;
}
// todo this is going to be a PITA to test because of ContentIdFieldImpl.
// todo Inject a FieldParser<ContentIdField> (then use ContentIdFieldImpl.PARSER in MimeUIFactory).
return getUnbracketedContentId(ContentIdFieldImpl.PARSER.parse(field, null).getId());
}
示例2: field
import org.apache.james.mime4j.stream.Field; //导入依赖的package包/类
@Override
public void field(Field parsedField) throws MimeException {
expect(Part.class);
// We need the original, unparsed header values for PGP/MIME signature calculation
byte[] rawByteValue = null;
byte[] rawBytes = parsedField.getRaw().toByteArray();
String raw = new String( rawBytes );
if( raw.length() > 0 ) {
int index = raw.indexOf( ":" );
if( index != -1 && raw.length() > index+2 ) {
rawByteValue = raw.substring( index+2 ).getBytes();
}
}
try {
((Part)stack.peek()).addHeader(parsedField.getName(), parsedField.getBody().trim(), rawByteValue);
} catch (MessagingException me) {
throw new Error(me);
}
}
示例3: field
import org.apache.james.mime4j.stream.Field; //导入依赖的package包/类
@Override
public void field(Field parsedField) throws MimeException {
String name = parsedField.getName();
String raw = parsedField.getRaw().toString();
Part part = (Part) stack.peek();
part.addRawHeader(name, raw);
}
示例4: field
import org.apache.james.mime4j.stream.Field; //导入依赖的package包/类
@Override
public void field(Field parsedField) throws MimeException {
expect(Part.class);
String name = parsedField.getName();
String raw = parsedField.getRaw().toString();
((Part) stack.peek()).addRawHeader(name, raw);
}
示例5: getEmailSubject
import org.apache.james.mime4j.stream.Field; //导入依赖的package包/类
public String getEmailSubject(){
Field subjectField = header.getField("Subject");
if (subjectField != null) {
Field decodedSubjectField = new CustomUnstructuredFieldImpl(subjectField,DecodeMonitor.SILENT);
return ((CustomUnstructuredFieldImpl)decodedSubjectField).getValue();
}
return null;
}
示例6: getToEmailHeaderValue
import org.apache.james.mime4j.stream.Field; //导入依赖的package包/类
public String getToEmailHeaderValue() {
Field to = header.getField("To");
if (to != null) {
return to.getBody();
}
return null;
}
示例7: getCCEmailHeaderValue
import org.apache.james.mime4j.stream.Field; //导入依赖的package包/类
public String getCCEmailHeaderValue(){
Field cc = header.getField("Cc");
if (cc != null) {
return cc.getBody();
}
return null;
}
示例8: getFromEmailHeaderValue
import org.apache.james.mime4j.stream.Field; //导入依赖的package包/类
public String getFromEmailHeaderValue(){
Field from = header.getField("From");
if (from != null) {
return from.getBody();
}
return null;
}
示例9: assertGettingHeader
import org.apache.james.mime4j.stream.Field; //导入依赖的package包/类
private void assertGettingHeader(String header)
throws MimeException, IOException {
Email email = getParsedSimpleGmail();
Header parsedHeader = email.getHeader();
Field from = parsedHeader.getField(header);
Assert.assertEquals(header, from.getName());
}
示例10: field
import org.apache.james.mime4j.stream.Field; //导入依赖的package包/类
@Override
public void field(Field parsedField) throws MimeException {
expect(Part.class);
try {
((Part)stack.peek()).addHeader(parsedField.getName(), parsedField.getBody().trim());
} catch (MessagingException me) {
throw new Error(me);
}
}
示例11: stripOutFieldPrefix
import org.apache.james.mime4j.stream.Field; //导入依赖的package包/类
private String stripOutFieldPrefix(Field field, String fieldname) {
String temp = field.getRaw().toString();
int loc = fieldname.length();
while (temp.charAt(loc) ==' ') {
loc++;
}
return temp.substring(loc);
}
示例12: getMessageHeaders
import org.apache.james.mime4j.stream.Field; //导入依赖的package包/类
/**
* Extract only those header fields that are listed in MessageHeader
* All keys are lower-cased.
*
* @param message
* @return
*/
public static Map<String, Field> getMessageHeaders(Message message) {
Map<String, Field> h = new HashMap<String, Field>();
for (Field f : message.getHeader().getFields()) {
if (MessageHeader.IGNORE.equals(MessageHeader.getValue(f.getName().toLowerCase()))) {
continue;
}
h.put(f.getName().toLowerCase(), f);
}
return h;
}
示例13: createNode
import org.apache.james.mime4j.stream.Field; //导入依赖的package包/类
/**
* Create a node given a Multipart body.
* Add the Preamble, all Body parts and the Epilogue to the node.
*
* @param multipart the Multipart.
* @return the root node of the tree.
*/
private DefaultMutableTreeNode createNode(Header header) {
DefaultMutableTreeNode node = new DefaultMutableTreeNode(
new ObjectWrapper("Header", header));
for (Field field : header.getFields()) {
String name = field.getName();
node.add(new DefaultMutableTreeNode(new ObjectWrapper(name, field)));
}
return node;
}
示例14: field
import org.apache.james.mime4j.stream.Field; //导入依赖的package包/类
@Override
public void field(Field rawField) throws MimeException {
String name = rawField.getName();
String raw = rawField.getRaw().toString();
part.addRawHeader(name, raw);
}
示例15: CustomUnstructuredFieldImpl
import org.apache.james.mime4j.stream.Field; //导入依赖的package包/类
public CustomUnstructuredFieldImpl(Field rawField, DecodeMonitor monitor) {
super(rawField, monitor);
}