View Javadoc
1   /*
2    * Copyright (c) 1997, 2012, 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   */
25  
26  package com.sun.xml.internal.ws.api.message;
27  
28  import com.sun.istack.internal.Nullable;
29  
30  /**
31   * A set of {@link Attachment} on a {@link Message}.
32   *
33   * <p>
34   * A particular attention is made to ensure that attachments
35   * can be read and parsed lazily as requested.
36   *
37   * @see Message#getAttachments()
38   */
39  public interface AttachmentSet extends Iterable<Attachment> {
40      /**
41       * Gets the attachment by the content ID.
42       *
43       * @param contentId
44       *      The content ID like "foo-bar-zot@abc.com", without
45       *      surrounding '&lt;' and '>' used as the transfer syntax.
46       *
47       * @return null
48       *      if no such attachment exist.
49       */
50      @Nullable
51      Attachment get(String contentId);
52  
53      /**
54       * Returns true if there's no attachment.
55       */
56      boolean isEmpty();
57  
58      /**
59       * Adds an attachment to this set.
60       *
61       * <p>
62       * Note that it's OK for an {@link Attachment} to belong to
63       * more than one {@link AttachmentSet} (which is in fact
64       * necessary when you wrap a {@link Message} into another.
65       *
66       * @param att
67       *      must not be null.
68       */
69      public void add(Attachment att);
70  
71  }