jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/messaging/saaj/soap/MultipartDataContentHandler.java
equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
41 /** |
41 /** |
42 * Return the DataFlavors for this <code>DataContentHandler</code>. |
42 * Return the DataFlavors for this <code>DataContentHandler</code>. |
43 * |
43 * |
44 * @return The DataFlavors |
44 * @return The DataFlavors |
45 */ |
45 */ |
|
46 @Override |
46 public DataFlavor[] getTransferDataFlavors() { // throws Exception; |
47 public DataFlavor[] getTransferDataFlavors() { // throws Exception; |
47 return new DataFlavor[] { myDF }; |
48 return new DataFlavor[] { myDF }; |
48 } |
49 } |
49 |
50 |
50 /** |
51 /** |
51 * Return the Transfer Data of type DataFlavor from InputStream. |
52 * Return the Transfer Data of type DataFlavor from InputStream. |
52 * |
53 * |
53 * @param df The DataFlavor |
54 * @param df The DataFlavor |
54 * @param ins The InputStream corresponding to the data |
55 * @param ds The DataSource |
55 * @return String object |
56 * @return String object |
56 */ |
57 */ |
|
58 @Override |
57 public Object getTransferData(DataFlavor df, DataSource ds) { |
59 public Object getTransferData(DataFlavor df, DataSource ds) { |
58 // use myDF.equals to be sure to get ActivationDataFlavor.equals, |
60 // use myDF.equals to be sure to get ActivationDataFlavor.equals, |
59 // which properly ignores Content-Type parameters in comparison |
61 // which properly ignores Content-Type parameters in comparison |
60 if (myDF.equals(df)) |
62 if (myDF.equals(df)) |
61 return getContent(ds); |
63 return getContent(ds); |
63 return null; |
65 return null; |
64 } |
66 } |
65 |
67 |
66 /** |
68 /** |
67 * Return the content. |
69 * Return the content. |
|
70 * |
|
71 * @param ds The DataSource |
|
72 * @return content |
68 */ |
73 */ |
|
74 @Override |
69 public Object getContent(DataSource ds) { |
75 public Object getContent(DataSource ds) { |
70 try { |
76 try { |
71 return new MimeMultipart( |
77 return new MimeMultipart( |
72 ds, new ContentType(ds.getContentType())); |
78 ds, new ContentType(ds.getContentType())); |
73 } catch (Exception e) { |
79 } catch (Exception e) { |
76 } |
82 } |
77 |
83 |
78 /** |
84 /** |
79 * Write the object to the output stream, using the specific MIME type. |
85 * Write the object to the output stream, using the specific MIME type. |
80 */ |
86 */ |
|
87 @Override |
81 public void writeTo(Object obj, String mimeType, OutputStream os) |
88 public void writeTo(Object obj, String mimeType, OutputStream os) |
82 throws IOException { |
89 throws IOException { |
83 if (obj instanceof MimeMultipart) { |
90 if (obj instanceof MimeMultipart) { |
84 try { |
91 try { |
85 //TODO: temporarily allow only ByteOutputStream |
92 //TODO: temporarily allow only ByteOutputStream |