001: /*
002: * Copyright (c) 1998-2006 Caucho Technology -- all rights reserved
003: *
004: * This file is part of Resin(R) Open Source
005: *
006: * Each copy or derived work must preserve the copyright notice and this
007: * notice unmodified.
008: *
009: * Resin Open Source is free software; you can redistribute it and/or modify
010: * it under the terms of the GNU General Public License as published by
011: * the Free Software Foundation; either version 2 of the License, or
012: * (at your option) any later version.
013: *
014: * Resin Open Source is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017: * of NON-INFRINGEMENT. See the GNU General Public License for more
018: * details.
019: *
020: * You should have received a copy of the GNU General Public License
021: * along with Resin Open Source; if not, write to the
022: *
023: * Free Software Foundation, Inc.
024: * 59 Temple Place, Suite 330
025: * Boston, MA 02111-1307 USA
026: *
027: * @author Scott Ferguson
028: */
029:
030: package javax.xml.soap;
031:
032: import java.io.*;
033: import javax.activation.*;
034: import java.util.*;
035:
036: public abstract class AttachmentPart {
037: private static final String CONTENT_ID = "Content-ID";
038: private static final String CONTENT_LOCATION = "Content-Location";
039: private static final String CONTENT_TYPE = "Content-Type";
040:
041: public AttachmentPart() {
042: }
043:
044: public String getContentId() {
045: String[] contentIds = getMimeHeader(CONTENT_ID);
046:
047: if (contentIds != null && contentIds.length > 0)
048: return contentIds[0];
049:
050: return null;
051: }
052:
053: public String getContentLocation() {
054: String[] contentLocations = getMimeHeader(CONTENT_LOCATION);
055:
056: if (contentLocations != null && contentLocations.length > 0)
057: return contentLocations[0];
058:
059: return null;
060: }
061:
062: public String getContentType() {
063: String[] contentTypes = getMimeHeader(CONTENT_TYPE);
064:
065: if (contentTypes != null && contentTypes.length > 0)
066: return contentTypes[0];
067:
068: return null;
069: }
070:
071: public void setContentId(String contentId) {
072: setMimeHeader(CONTENT_ID, contentId);
073: }
074:
075: public void setContentLocation(String contentLocation) {
076: setMimeHeader(CONTENT_LOCATION, contentLocation);
077: }
078:
079: public void setContentType(String contentType) {
080: if (contentType == null)
081: throw new IllegalArgumentException(
082: "content type may not be null");
083:
084: setMimeHeader(CONTENT_TYPE, contentType);
085: }
086:
087: public abstract void addMimeHeader(String name, String value);
088:
089: public abstract void clearContent();
090:
091: public abstract Iterator getAllMimeHeaders();
092:
093: public abstract InputStream getBase64Content() throws SOAPException;
094:
095: public abstract Object getContent() throws SOAPException;
096:
097: public abstract DataHandler getDataHandler() throws SOAPException;
098:
099: public abstract Iterator getMatchingMimeHeaders(String[] names);
100:
101: public abstract String[] getMimeHeader(String name);
102:
103: public abstract Iterator getNonMatchingMimeHeaders(String[] names);
104:
105: public abstract InputStream getRawContent() throws SOAPException;
106:
107: public abstract byte[] getRawContentBytes() throws SOAPException;
108:
109: public abstract int getSize() throws SOAPException;
110:
111: public abstract void removeAllMimeHeaders();
112:
113: public abstract void removeMimeHeader(String header);
114:
115: public abstract void setBase64Content(InputStream content,
116: String contentType) throws SOAPException;
117:
118: public abstract void setContent(Object object, String contentType);
119:
120: public abstract void setDataHandler(DataHandler dataHandler);
121:
122: public abstract void setMimeHeader(String name, String value);
123:
124: public abstract void setRawContent(InputStream content,
125: String contentType) throws SOAPException;
126:
127: public abstract void setRawContentBytes(byte[] content, int offset,
128: int len, String contentType) throws SOAPException;
129: }
|