Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 7DCE7200B48 for ; Mon, 4 Jul 2016 01:33:43 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 795C8160A71; Sun, 3 Jul 2016 23:33:43 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 77C15160A6B for ; Mon, 4 Jul 2016 01:33:42 +0200 (CEST) Received: (qmail 75072 invoked by uid 500); 3 Jul 2016 23:33:41 -0000 Mailing-List: contact commits-help@poi.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@poi.apache.org Delivered-To: mailing list commits@poi.apache.org Received: (qmail 75063 invoked by uid 99); 3 Jul 2016 23:33:41 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 03 Jul 2016 23:33:41 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 2E941C0B71 for ; Sun, 3 Jul 2016 23:33:41 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.426 X-Spam-Level: X-Spam-Status: No, score=-0.426 tagged_above=-999 required=6.31 tests=[KAM_LAZY_DOMAIN_SECURITY=1, RP_MATCHES_RCVD=-1.426] autolearn=disabled Received: from mx2-lw-us.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id INM1w7t1O3v0 for ; Sun, 3 Jul 2016 23:33:38 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx2-lw-us.apache.org (ASF Mail Server at mx2-lw-us.apache.org) with ESMTP id 7860A5F1B8 for ; Sun, 3 Jul 2016 23:33:38 +0000 (UTC) Received: from svn01-us-west.apache.org (svn.apache.org [10.41.0.6]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id A0161E0016 for ; Sun, 3 Jul 2016 23:33:37 +0000 (UTC) Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id C9E193A019C for ; Sun, 3 Jul 2016 23:33:36 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1751183 - /poi/trunk/src/scratchpad/src/org/apache/poi/hmef/HMEFMessage.java Date: Sun, 03 Jul 2016 23:33:36 -0000 To: commits@poi.apache.org From: onealj@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20160703233336.C9E193A019C@svn01-us-west.apache.org> archived-at: Sun, 03 Jul 2016 23:33:43 -0000 Author: onealj Date: Sun Jul 3 23:33:36 2016 New Revision: 1751183 URL: http://svn.apache.org/viewvc?rev=1751183&view=rev Log: whitespace Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hmef/HMEFMessage.java Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hmef/HMEFMessage.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hmef/HMEFMessage.java?rev=1751183&r1=1751182&r2=1751183&view=diff ============================================================================== --- poi/trunk/src/scratchpad/src/org/apache/poi/hmef/HMEFMessage.java (original) +++ poi/trunk/src/scratchpad/src/org/apache/poi/hmef/HMEFMessage.java Sun Jul 3 23:33:36 2016 @@ -40,159 +40,159 @@ import org.apache.poi.util.LittleEndian; * http://search.cpan.org/dist/Convert-TNEF/ */ public final class HMEFMessage { - public static final int HEADER_SIGNATURE = 0x223e9f78; - - @SuppressWarnings("unused") - private int fileId; - private final List messageAttributes = new ArrayList(); - private final List mapiAttributes = new ArrayList(); - private final List attachments = new ArrayList(); - - public HMEFMessage(InputStream inp) throws IOException { - try { - // Check the signature matches - int sig = LittleEndian.readInt(inp); - if(sig != HEADER_SIGNATURE) { - throw new IllegalArgumentException( - "TNEF signature not detected in file, " + - "expected " + HEADER_SIGNATURE + " but got " + sig - ); - } - - // Read the File ID - fileId = LittleEndian.readUShort(inp); - - // Now begin processing the contents - process(inp); - } finally { - inp.close(); - } - } - - private void process(InputStream inp) throws IOException { - int level; - do { - // Fetch the level - level = inp.read(); - - // Decide what to attach it to, based on the levels and IDs - switch (level) { - case TNEFProperty.LEVEL_MESSAGE: - processMessage(inp); - break; - case TNEFProperty.LEVEL_ATTACHMENT: - processAttachment(inp); - break; - // ignore trailing newline - case '\r': - case '\n': - case TNEFProperty.LEVEL_END_OF_FILE: - break; - default: - throw new IllegalStateException("Unhandled level " + level); - } - } while (level != TNEFProperty.LEVEL_END_OF_FILE); - } - - void processMessage(InputStream inp) throws IOException { - // Build the attribute - TNEFAttribute attr = TNEFAttribute.create(inp); - - messageAttributes.add(attr); - - if (attr instanceof TNEFMAPIAttribute) { - TNEFMAPIAttribute tnefMAPI = (TNEFMAPIAttribute) attr; - mapiAttributes.addAll(tnefMAPI.getMAPIAttributes()); - } - } - - void processAttachment(InputStream inp) throws IOException { - // Build the attribute - TNEFAttribute attr = TNEFAttribute.create(inp); - - // Previous attachment or a new one? - if (attachments.isEmpty() - || attr.getProperty() == TNEFProperty.ID_ATTACHRENDERDATA) { - attachments.add(new Attachment()); - } - - // Save the attribute for it - Attachment attach = attachments.get(attachments.size() - 1); - attach.addAttribute(attr); - } - - /** - * Returns all HMEF/TNEF attributes of the message. - * Note - In a typical message, most of the interesting properties - * are stored as {@link MAPIAttribute}s - see {@link #getMessageMAPIAttributes()} - */ - public List getMessageAttributes() { - return Collections.unmodifiableList(messageAttributes); - } - - /** - * Returns all MAPI attributes of the message. - * Note - A small number of HMEF/TNEF specific attributes normally - * apply to most messages, see {@link #getMessageAttributes()} - */ - public List getMessageMAPIAttributes() { - return Collections.unmodifiableList(mapiAttributes); - } - - /** - * Returns all the Attachments of the message. - */ - public List getAttachments() { - return Collections.unmodifiableList(attachments); - } - - /** - * Return the message attribute with the given ID, - * or null if there isn't one. - */ - public TNEFAttribute getMessageAttribute(TNEFProperty id) { - for(TNEFAttribute attr : messageAttributes) { - if(attr.getProperty() == id) { - return attr; - } - } - return null; - } - - /** - * Return the message MAPI Attribute with the given ID, - * or null if there isn't one. - */ - public MAPIAttribute getMessageMAPIAttribute(MAPIProperty id) { - for(MAPIAttribute attr : mapiAttributes) { - if(attr.getProperty() == id) { - return attr; - } - } - return null; - } - - /** - * Return the string value of the mapi property, or null - * if it isn't set - */ - private String getString(MAPIProperty id) { - return MAPIStringAttribute.getAsString( getMessageMAPIAttribute(id) ); - } - - /** - * Returns the Message Subject, or null if the mapi property - * for this isn't set - */ - public String getSubject() { - return getString(MAPIProperty.CONVERSATION_TOPIC); - } - - /** - * Returns the Message Body, as RTF, or null if the mapi property - * for this isn't set - */ - public String getBody() { - return getString(MAPIProperty.RTF_COMPRESSED); - } + public static final int HEADER_SIGNATURE = 0x223e9f78; + + @SuppressWarnings("unused") + private int fileId; + private final List messageAttributes = new ArrayList(); + private final List mapiAttributes = new ArrayList(); + private final List attachments = new ArrayList(); + + public HMEFMessage(InputStream inp) throws IOException { + try { + // Check the signature matches + int sig = LittleEndian.readInt(inp); + if (sig != HEADER_SIGNATURE) { + throw new IllegalArgumentException( + "TNEF signature not detected in file, " + + "expected " + HEADER_SIGNATURE + " but got " + sig + ); + } + + // Read the File ID + fileId = LittleEndian.readUShort(inp); + + // Now begin processing the contents + process(inp); + } finally { + inp.close(); + } + } + + private void process(InputStream inp) throws IOException { + int level; + do { + // Fetch the level + level = inp.read(); + + // Decide what to attach it to, based on the levels and IDs + switch (level) { + case TNEFProperty.LEVEL_MESSAGE: + processMessage(inp); + break; + case TNEFProperty.LEVEL_ATTACHMENT: + processAttachment(inp); + break; + // ignore trailing newline + case '\r': + case '\n': + case TNEFProperty.LEVEL_END_OF_FILE: + break; + default: + throw new IllegalStateException("Unhandled level " + level); + } + } while (level != TNEFProperty.LEVEL_END_OF_FILE); + } + + void processMessage(InputStream inp) throws IOException { + // Build the attribute + TNEFAttribute attr = TNEFAttribute.create(inp); + + messageAttributes.add(attr); + + if (attr instanceof TNEFMAPIAttribute) { + TNEFMAPIAttribute tnefMAPI = (TNEFMAPIAttribute) attr; + mapiAttributes.addAll(tnefMAPI.getMAPIAttributes()); + } + } + + void processAttachment(InputStream inp) throws IOException { + // Build the attribute + TNEFAttribute attr = TNEFAttribute.create(inp); + + // Previous attachment or a new one? + if (attachments.isEmpty() + || attr.getProperty() == TNEFProperty.ID_ATTACHRENDERDATA) { + attachments.add(new Attachment()); + } + + // Save the attribute for it + Attachment attach = attachments.get(attachments.size() - 1); + attach.addAttribute(attr); + } + + /** + * Returns all HMEF/TNEF attributes of the message. + * Note - In a typical message, most of the interesting properties + * are stored as {@link MAPIAttribute}s - see {@link #getMessageMAPIAttributes()} + */ + public List getMessageAttributes() { + return Collections.unmodifiableList(messageAttributes); + } + + /** + * Returns all MAPI attributes of the message. + * Note - A small number of HMEF/TNEF specific attributes normally + * apply to most messages, see {@link #getMessageAttributes()} + */ + public List getMessageMAPIAttributes() { + return Collections.unmodifiableList(mapiAttributes); + } + + /** + * Returns all the Attachments of the message. + */ + public List getAttachments() { + return Collections.unmodifiableList(attachments); + } + + /** + * Return the message attribute with the given ID, + * or null if there isn't one. + */ + public TNEFAttribute getMessageAttribute(TNEFProperty id) { + for (TNEFAttribute attr : messageAttributes) { + if (attr.getProperty() == id) { + return attr; + } + } + return null; + } + + /** + * Return the message MAPI Attribute with the given ID, + * or null if there isn't one. + */ + public MAPIAttribute getMessageMAPIAttribute(MAPIProperty id) { + for (MAPIAttribute attr : mapiAttributes) { + if (attr.getProperty() == id) { + return attr; + } + } + return null; + } + + /** + * Return the string value of the mapi property, or null + * if it isn't set + */ + private String getString(MAPIProperty id) { + return MAPIStringAttribute.getAsString( getMessageMAPIAttribute(id) ); + } + + /** + * Returns the Message Subject, or null if the mapi property + * for this isn't set + */ + public String getSubject() { + return getString(MAPIProperty.CONVERSATION_TOPIC); + } + + /** + * Returns the Message Body, as RTF, or null if the mapi property + * for this isn't set + */ + public String getBody() { + return getString(MAPIProperty.RTF_COMPRESSED); + } } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org For additional commands, e-mail: commits-help@poi.apache.org