当前位置: 首页>>代码示例>>Java>>正文


Java MimeException类代码示例

本文整理汇总了Java中org.apache.james.mime4j.MimeException的典型用法代码示例。如果您正苦于以下问题:Java MimeException类的具体用法?Java MimeException怎么用?Java MimeException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MimeException类属于org.apache.james.mime4j包,在下文中一共展示了MimeException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parse

import org.apache.james.mime4j.MimeException; //导入依赖的package包/类
/**
 * Parse a comma separated list of addresses in RFC-822 format and return an
 * array of Address objects.
 *
 * @param addressList
 * @return An array of 0 or more Addresses.
 */
public static Address[] parse(String addressList) {
    if (TextUtils.isEmpty(addressList)) {
        return EMPTY_ADDRESS_ARRAY;
    }
    List<Address> addresses = new ArrayList<>();
    try {
        MailboxList parsedList =  DefaultAddressParser.DEFAULT.parseAddressList(addressList).flatten();

        for (int i = 0, count = parsedList.size(); i < count; i++) {
            Mailbox mailbox = parsedList.get(i);
            addresses.add(new Address(mailbox.getLocalPart() + "@" + mailbox.getDomain(), mailbox.getName(), false));
        }
    } catch (MimeException pe) {
        Timber.e(pe, "MimeException in Address.parse()");
        //but we do an silent failover : we just use the given string as name with empty address
        addresses.add(new Address(null, addressList, false));
    }
    return addresses.toArray(EMPTY_ADDRESS_ARRAY);
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:27,代码来源:Address.java

示例2: parse

import org.apache.james.mime4j.MimeException; //导入依赖的package包/类
public static MimeBodyPart parse(FileFactory fileFactory, InputStream inputStream)
        throws MessagingException, IOException {
    MimeBodyPart parsedRootPart = new MimeBodyPart();

    MimeConfig parserConfig  = new MimeConfig.Builder()
            .setMaxHeaderLen(-1)
            .setMaxLineLen(-1)
            .setMaxHeaderCount(-1)
            .build();

    MimeStreamParser parser = new MimeStreamParser(parserConfig);
    parser.setContentHandler(new PartBuilder(fileFactory, parsedRootPart));
    parser.setRecurse();

    try {
        parser.parse(new EOLConvertingInputStream(inputStream));
    } catch (MimeException e) {
        throw new MessagingException("Failed to parse decrypted content", e);
    }

    return parsedRootPart;
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:23,代码来源:MimePartStreamParser.java

示例3: decodeBytes

import org.apache.james.mime4j.MimeException; //导入依赖的package包/类
private static String decodeBytes(String value, String charset)
		throws MimeException {
	byte[] b = new byte[value.length()];

	int i = 0;
	int temp = 0;
	for (int bi = 0; i < value.length(); ++i) {
		char c = value.charAt(i);
		if (c == '%') {
			String hex = value.substring(i + 1, i + 3);
			c = (char) Integer.parseInt(hex, 16);
			i += 2;
		}
		b[(bi++)] = (byte) c;
		temp = bi;
	}
	
	String str;
	try {
		str = new String(b, 0, temp, charset);
	} catch (UnsupportedEncodingException e) {
		throw new MimeException(e);
	}
	return str;
}
 
开发者ID:ram-sharma-6453,项目名称:email-mime-parser,代码行数:26,代码来源:ContentDispositionDecoder.java

示例4: decodeDispositionFileName

import org.apache.james.mime4j.MimeException; //导入依赖的package包/类
public static String decodeDispositionFileName(Map<String, String> contentDispositionParameters) throws MimeException {
	// Refer RFC 2183 'The Content-Disposition Header Field' and
	// RFC 2184 'Parameter Value Character Set and Language Information'

	Set<String> contentDispositionKeySet = contentDispositionParameters.keySet();
	String fileName = null;
	if (contentDispositionKeySet != null) {
		String[] sortedDispositionFileNameKeys = getSortedStringArray(contentDispositionKeySet.toArray());
		StringBuilder valueStr = new StringBuilder();
		for (int i = 0; i < sortedDispositionFileNameKeys.length; i++) {
			valueStr.append(contentDispositionParameters.get(sortedDispositionFileNameKeys[i]));
		}
		String encodedStr = valueStr.toString();
		if (!encodedStr.isEmpty()) {
			fileName = decodeContentDisposition(encodedStr).getValue();
		}
	}
	return fileName;
}
 
开发者ID:ram-sharma-6453,项目名称:email-mime-parser,代码行数:20,代码来源:ContentDispositionDecoder.java

示例5: body

import org.apache.james.mime4j.MimeException; //导入依赖的package包/类
@Override
public void body(BodyDescriptor bd, InputStream is) throws MimeException,
        IOException {
    String r = "";
    byte[] buffer = new byte[200];
    String s;
    int len;
    try {
        while ((len = is.read(buffer)) != -1) {
            if (len != 200) {
                byte buffer2[] = new byte[len];
                System.arraycopy(buffer, 0, buffer2, 0, len);
                s = new String(buffer2);
            } else {
                s = new String(buffer);
            }
            if (s != null)
                r += s;
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    mailInfo.body = r;
    //System.out.println("body");
    //System.out.println(r);
}
 
开发者ID:linzeqipku,项目名称:SnowGraph,代码行数:27,代码来源:MboxHandler.java

示例6: parseMessageContent

import org.apache.james.mime4j.MimeException; //导入依赖的package包/类
/**
 * Parse the provided inputstream into the message domain
 * @param rawContentStream The inputstream to the message RAW content
 * @return A {@link MessageContent} object representing the parsed content, or
 *          a {@link HoldMailException} if parsing failed.
 */
public static MessageContent parseMessageContent(final InputStream rawContentStream) {

    try {
        MessageContentExtractor bodyPartExtractor = new MessageContentExtractor();

        MimeStreamParser parser = new MimeStreamParser();
        parser.setContentDecoding(true);
        parser.setContentHandler(bodyPartExtractor);
        parser.parse(rawContentStream);
        return bodyPartExtractor.getParts();
    } catch (MimeException | IOException e) {
        throw new HoldMailException("Failed to parse body", e);
    }

}
 
开发者ID:SpartaSystems,项目名称:holdmail,代码行数:22,代码来源:MimeUtils.java

示例7: parse

import org.apache.james.mime4j.MimeException; //导入依赖的package包/类
public static MimeBodyPart parse(FileFactory fileFactory, InputStream inputStream)
        throws MessagingException, IOException {
    MimeBodyPart parsedRootPart = new MimeBodyPart();

    MimeConfig parserConfig  = new MimeConfig();
    parserConfig.setMaxHeaderLen(-1);
    parserConfig.setMaxLineLen(-1);
    parserConfig.setMaxHeaderCount(-1);

    MimeStreamParser parser = new MimeStreamParser(parserConfig);
    parser.setContentHandler(new PartBuilder(fileFactory, parsedRootPart));
    parser.setRecurse();

    try {
        parser.parse(new EOLConvertingInputStream(inputStream));
    } catch (MimeException e) {
        throw new MessagingException("Failed to parse decrypted content", e);
    }

    return parsedRootPart;
}
 
开发者ID:scoute-dich,项目名称:K9-MailClient,代码行数:22,代码来源:MimePartStreamParser.java

示例8: startMessage

import org.apache.james.mime4j.MimeException; //导入依赖的package包/类
@Override
public void startMessage() throws MimeException {
    if (stack.isEmpty()) {
        stack.push(decryptedRootPart);
    } else {
        Part part = (Part) stack.peek();

        Message innerMessage = new MimeMessage();
        part.setBody(innerMessage);

        stack.push(innerMessage);
    }
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:14,代码来源:MimePartStreamParser.java

示例9: startBodyPart

import org.apache.james.mime4j.MimeException; //导入依赖的package包/类
@Override
public void startBodyPart() throws MimeException {
    try {
        Multipart multipart = (Multipart) stack.peek();

        BodyPart bodyPart = new MimeBodyPart();
        multipart.addBodyPart(bodyPart);

        stack.push(bodyPart);
    } catch (MessagingException e) {
        throw new MimeException(e);
    }
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:14,代码来源:MimePartStreamParser.java

示例10: field

import org.apache.james.mime4j.MimeException; //导入依赖的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);
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:9,代码来源:MimePartStreamParser.java

示例11: startMultipart

import org.apache.james.mime4j.MimeException; //导入依赖的package包/类
@Override
public void startMultipart(BodyDescriptor bd) throws MimeException {
    Part part = (Part) stack.peek();

    String mimeType = bd.getMimeType();
    String boundary = bd.getBoundary();

    MimeMultipart multipart = new MimeMultipart(mimeType, boundary);
    part.setBody(multipart);

    stack.push(multipart);
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:13,代码来源:MimePartStreamParser.java

示例12: parse

import org.apache.james.mime4j.MimeException; //导入依赖的package包/类
public static void parse(final Part part, InputStream headerInputStream) throws MessagingException {
    MimeStreamParser parser = getMimeStreamParser();
    parser.setContentHandler(new MessageHeaderParserContentHandler(part));

    try {
        parser.parse(headerInputStream);
    } catch (MimeException me) {
        throw new MessagingException("Error parsing headers", me);
    } catch (IOException e) {
        throw new MessagingException("I/O error parsing headers", e);
    }
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:13,代码来源:MessageHeaderParser.java

示例13: parse

import org.apache.james.mime4j.MimeException; //导入依赖的package包/类
private void parse(InputStream in, boolean recurse) throws IOException, MessagingException {
    mHeader.clear();
    mFrom = null;
    mTo = null;
    mCc = null;
    mBcc = null;
    mReplyTo = null;
    xOriginalTo = null;
    deliveredTo = null;
    xEnvelopeTo = null;

    mMessageId = null;
    mReferences = null;
    mInReplyTo = null;

    mSentDate = null;

    mBody = null;

    MimeConfig parserConfig = new MimeConfig.Builder()
            // The default is a mere 10k
            .setMaxHeaderLen(-1)
            // The default is 1000 characters. Some MUAs generate REALLY long References: headers
            .setMaxLineLen(-1)
            // Disable the check for header count.
            .setMaxHeaderCount(-1)
            .build();

    MimeStreamParser parser = new MimeStreamParser(parserConfig);
    parser.setContentHandler(new MimeMessageBuilder(new DefaultBodyFactory()));
    if (recurse) {
        parser.setRecurse();
    }
    try {
        parser.parse(new EOLConvertingInputStream(in));
    } catch (MimeException me) {
        throw new MessagingException(me.getMessage(), me);
    }
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:40,代码来源:MimeMessage.java

示例14: startMultipart

import org.apache.james.mime4j.MimeException; //导入依赖的package包/类
@Override
public void startMultipart(BodyDescriptor bd) throws MimeException {
    expect(Part.class);

    Part e = (Part)stack.peek();
    String mimeType = bd.getMimeType();
    String boundary = bd.getBoundary();
    MimeMultipart multiPart = new MimeMultipart(mimeType, boundary);
    e.setBody(multiPart);
    stack.addFirst(multiPart);
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:12,代码来源:MimeMessage.java

示例15: startBodyPart

import org.apache.james.mime4j.MimeException; //导入依赖的package包/类
@Override
public void startBodyPart() throws MimeException {
    expect(MimeMultipart.class);

    try {
        MimeBodyPart bodyPart = new MimeBodyPart();
        ((MimeMultipart)stack.peek()).addBodyPart(bodyPart);
        stack.addFirst(bodyPart);
    } catch (MessagingException me) {
        throw new MimeException(me);
    }
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:13,代码来源:MimeMessage.java


注:本文中的org.apache.james.mime4j.MimeException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。