dims 2002/06/23 10:39:19
Modified: java/src/org/apache/axis/attachments AttachmentPart.java
Log:
Fleshing AttachmentPart for SAAJ compliance.
Revision Changes Path
1.9 +16 -52
xml-axis/java/src/org/apache/axis/attachments/AttachmentPart.java
Index: AttachmentPart.java
===================================================================
RCS file:
/home/cvs/xml-axis/java/src/org/apache/axis/attachments/AttachmentPart.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- AttachmentPart.java 29 May 2002 13:05:54 -0000 1.8
+++ AttachmentPart.java 23 Jun 2002 17:39:19 -0000 1.9
@@ -73,7 +73,8 @@
javax.activation.DataHandler datahandler= null;
- private Hashtable headers = new Hashtable();
+ //private Hashtable headers = new Hashtable();
+ private javax.xml.soap.MimeHeaders mimeHeaders = new
javax.xml.soap.MimeHeaders();
private String contentId;
private String contentLocation;
@@ -96,26 +97,12 @@
/**
* TODO: everything!
- public int getContentLength() {
- return 0;
- }
- */
-
- /**
- * TODO: everything!
*/
public String getContentType() {
return getFirstMimeHeader(HTTPConstants.HEADER_CONTENT_TYPE);
}
/**
- * TODO: everything!
- public int getSize() {
- return 0;
- }
- */
-
- /**
* Add the specified MIME header, as per JAXM.
*/
public void addMimeHeader (String header, String value) {
@@ -135,14 +122,17 @@
throw new IllegalArgumentException(
JavaUtils.getMessage("headerValueNotNull"));
}
- headers.put(header.toLowerCase(), value);
+ mimeHeaders.setHeader(header.toLowerCase(), value);
}
/**
* Get the specified MIME header.
*/
public String getFirstMimeHeader (String header) {
- return (String) headers.get(header.toLowerCase());
+ String[] values = mimeHeaders.getHeader(header.toLowerCase());
+ if(values != null && values.length > 0)
+ return values[0];
+ return null;
}
/**
@@ -200,35 +190,14 @@
* Get all headers that match
*/
public java.util.Iterator getMatchingMimeHeaders( final String[] match){
- java.util.LinkedList retList= new java.util.LinkedList();
- if(null != match && 0 != match.length ){
- for(int i= match.length-1 ; i > -1 ; --i){
- if(match[i] != null){
- String key= match[i].toLowerCase();
- if(headers.containsKey(key))
- retList.add(match[i]);
- }
- }
- }
- return retList.iterator();
+ return mimeHeaders.getMatchingHeaders(match);
}
/**
* Get all headers that do not match
*/
public java.util.Iterator getNonMatchingMimeHeaders( final String[] match){
- java.util.LinkedList retList= new java.util.LinkedList(headers.keySet());
- if(null != match && 0 != match.length && !headers.isEmpty()){
- for(int i= match.length-1 ; i > -1 ; --i){
- if(match[i] != null){
- String remItem= match[i].toLowerCase();
- if(headers.containsKey(remItem)){
- retList.remove(remItem);
- }
- }
- }
- }
- return retList.iterator();
+ return mimeHeaders.getNonMatchingHeaders(match);
}
/**
@@ -239,8 +208,7 @@
* headers for this <CODE>AttachmentPart</CODE> object
*/
public Iterator getAllMimeHeaders() {
- //TODO: Implement this.
- return null;
+ return mimeHeaders.getAllHeaders();
}
/**
@@ -261,12 +229,12 @@
* or value
*/
public void setMimeHeader(String name, String value){
- //TODO: Implement this.
+ mimeHeaders.setHeader(name,value);
}
/** Removes all the MIME header entries. */
public void removeAllMimeHeaders() {
- //TODO: Implement this.
+ mimeHeaders.removeAllHeaders();
}
/**
@@ -275,7 +243,7 @@
* header/s to be removed
*/
public void removeMimeHeader(String header) {
- //TODO: Implement this.
+ mimeHeaders.removeHeader(header);
}
/**
@@ -287,8 +255,7 @@
* no data in this <CODE>AttachmentPart</CODE> object
*/
public DataHandler getDataHandler() throws SOAPException {
- //TODO: Implement this.
- return null;
+ return datahandler;
}
/**
@@ -306,7 +273,7 @@
* DataHandler</CODE> object
*/
public void setDataHandler(DataHandler datahandler) {
- //TODO: Implement this.
+ this.datahandler = datahandler;
}
/**
@@ -402,10 +369,7 @@
* @see #setMimeHeader(java.lang.String, java.lang.String)
setMimeHeader(java.lang.String, java.lang.String)
*/
public String[] getMimeHeader(String name) {
- //TODO: Flesh this out.
- String[] strings = new String[1];
- strings[0] = getFirstMimeHeader(name);
- return strings;
+ return mimeHeaders.getHeader(name);
}
}