src/share/jaxws_classes/com/sun/xml/internal/org/jvnet/mimepull/MIMEEvent.java

Tue, 06 Mar 2012 16:09:35 -0800

author
ohair
date
Tue, 06 Mar 2012 16:09:35 -0800
changeset 286
f50545b5e2f1
child 368
0989ad8c0860
permissions
-rw-r--r--

7150322: Stop using drop source bundles in jaxws
Reviewed-by: darcy, ohrstrom

     1 /*
     2  * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     8  * particular file as subject to the "Classpath" exception as provided
     9  * by Oracle in the LICENSE file that accompanied this code.
    10  *
    11  * This code is distributed in the hope that it will be useful, but WITHOUT
    12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    14  * version 2 for more details (a copy is included in the LICENSE file that
    15  * accompanied this code).
    16  *
    17  * You should have received a copy of the GNU General Public License version
    18  * 2 along with this work; if not, write to the Free Software Foundation,
    19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    20  *
    21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    22  * or visit www.oracle.com if you need additional information or have any
    23  * questions.
    24  */
    26 package com.sun.xml.internal.org.jvnet.mimepull;
    28 import java.nio.ByteBuffer;
    30 /**
    31  * @author Jitendra Kotamraju
    32  */
    33 abstract class MIMEEvent {
    35     enum EVENT_TYPE {START_MESSAGE, START_PART, HEADERS, CONTENT, END_PART, END_MESSAGE}
    37     /**
    38      * Returns a event for parser's current cursor location in the MIME message.
    39      *
    40      * <p>
    41      * {@link EVENT_TYPE#START_MESSAGE} and {@link EVENT_TYPE#START_MESSAGE} events
    42      * are generated only once.
    43      *
    44      * <p>
    45      * {@link EVENT_TYPE#START_PART}, {@link EVENT_TYPE#END_PART}, {@link EVENT_TYPE#HEADERS}
    46      * events are generated only once for each attachment part.
    47      *
    48      * <p>
    49      * {@link EVENT_TYPE#CONTENT} event may be generated more than once for an attachment
    50      * part.
    51      *
    52      * @return event type
    53      */
    54     abstract EVENT_TYPE getEventType();
    56     static final StartMessage START_MESSAGE = new StartMessage();
    57     static final StartPart START_PART = new StartPart();
    58     static final EndPart END_PART = new EndPart();
    59     static final EndMessage END_MESSAGE = new EndMessage();
    61     static final class StartMessage extends MIMEEvent {
    62         EVENT_TYPE getEventType() {
    63             return EVENT_TYPE.START_MESSAGE;
    64         }
    65     }
    67     static final class StartPart extends MIMEEvent {
    68         EVENT_TYPE getEventType() {
    69             return EVENT_TYPE.START_PART;
    70         }
    71     }
    73     static final class EndPart extends MIMEEvent {
    74         EVENT_TYPE getEventType () {
    75             return EVENT_TYPE.END_PART;
    76         }
    77     }
    79     static final class Headers extends MIMEEvent {
    80         InternetHeaders ih;
    82         Headers(InternetHeaders ih) {
    83             this.ih = ih;
    84         }
    86         EVENT_TYPE getEventType() {
    87             return EVENT_TYPE.HEADERS;
    88         }
    90         InternetHeaders getHeaders() {
    91             return ih;
    92         }
    93     }
    95     static final class Content extends MIMEEvent {
    96         private final ByteBuffer buf;
    98         Content(ByteBuffer buf) {
    99             this.buf = buf;
   100         }
   102         EVENT_TYPE getEventType() {
   103             return EVENT_TYPE.CONTENT;
   104         }
   106         ByteBuffer getData() {
   107             return buf;
   108         }
   109     }
   111     static final class EndMessage extends MIMEEvent {
   112         EVENT_TYPE getEventType() {
   113             return EVENT_TYPE.END_MESSAGE;
   114         }
   115     }
   117 }

mercurial