/** * Returns content type of {@link DataSource}. * * @return content type of {@link DataSource}. */ public String getContentType() { return dataSource.getContentType(); }
/** * Return the MIME type of this object as retrieved from * the source object. Note that this is the <i>full</i> * type with parameters. * * @return the MIME type */ public String getContentType() { if (dataSource != null) // data source case return dataSource.getContentType(); else return objectMimeType; // obj/type case }
/** * Return the DataFlavors for this <code>DataContentHandler</code>. * @return the DataFlavors */ public DataFlavor[] getTransferDataFlavors() { if (transferFlavors == null) { if (dch != null) { // is there a dch? transferFlavors = dch.getTransferDataFlavors(); } else { transferFlavors = new DataFlavor[1]; transferFlavors[0] = new ActivationDataFlavor(ds.getContentType(), ds.getContentType()); } } return transferFlavors; }
public DataSourceSource(DataSource source) throws MimeTypeParseException { this.source = source; String ct = source.getContentType(); if(ct==null) { charset = null; } else { MimeType mimeType = new MimeType(ct); this.charset = mimeType.getParameter("charset"); } }
/** * Write the object to the output stream. */ public void writeTo(Object obj, String mimeType, OutputStream os) throws IOException { if (dch != null) dch.writeTo(obj, mimeType, os); else throw new UnsupportedDataTypeException( "no DCH for content type " + ds.getContentType()); } }
attributes.put(CoreAttributes.FILENAME.key(), data.getName()); if (StringUtils.isNotBlank(data.getContentType())) { attributes.put(CoreAttributes.MIME_TYPE.key(), data.getContentType());
String dsct = ds.getContentType(); if(dsct!=null && (contentType==null || contentType.equals(dsct))) { bd.set(new DataHandler(ds));
/** * Creates {@link EmailAttachment}. * * @return {@link EmailAttachment}. * @throws MailException if issue with {@link DataSource}. */ public EmailAttachment<ByteArrayDataSource> buildByteArrayDataSource() throws MailException { try { final ByteArrayDataSource bads; if (dataSource instanceof ByteArrayDataSource) { bads = (ByteArrayDataSource) dataSource; } else { bads = new ByteArrayDataSource(dataSource.getInputStream(), dataSource.getContentType()); } checkDataSource(); return new EmailAttachment<>(name, contentId, isInline, bads).setEmbeddedMessage(targetMessage); } catch (final IOException ioexc) { throw new MailException(ioexc); } }
/** * Return the MIME type of this object as retrieved from * the source object. Note that this is the <i>full</i> * type with parameters. * * @return the MIME type */ public String getContentType() { if (dataSource != null) // data source case return dataSource.getContentType(); else return objectMimeType; // obj/type case }
/** * Return the DataFlavors for this <code>DataContentHandler</code>. * @return the DataFlavors */ public DataFlavor[] getTransferDataFlavors() { if (transferFlavors == null) { if (dch != null) { // is there a dch? transferFlavors = dch.getTransferDataFlavors(); } else { transferFlavors = new DataFlavor[1]; transferFlavors[0] = new ActivationDataFlavor(ds.getContentType(), ds.getContentType()); } } return transferFlavors; }
/** * Write the object to the output stream. */ public void writeTo(Object obj, String mimeType, OutputStream os) throws IOException { if (dch != null) dch.writeTo(obj, mimeType, os); else throw new UnsupportedDataTypeException( "no DCH for content type " + ds.getContentType()); } }
public DataSourceSource(DataSource source) throws MimeTypeParseException { this.source = source; String ct = source.getContentType(); if(ct==null) { charset = null; } else { MimeType mimeType = new MimeType(ct); this.charset = mimeType.getParameter("charset"); } }
enc = getCharset(ds.getContentType()); is = new InputStreamReader(ds.getInputStream(), enc); } catch (IllegalArgumentException iex) {
enc = getCharset(ds.getContentType()); is = new InputStreamReader(ds.getInputStream(), enc); } catch (IllegalArgumentException iex) {
bout.reset(); writer.append("--").append(boundary).append("\r\n"); writer.append("Content-Type: ").append(rootPart.getContentType()).append("\r\n"); writer.append("Content-ID: <").append(start).append(">\r\n\r\n"); writer.flush();
assertEquals(IMAGE_PNG, dataSource.getContentType()); assertArrayEquals(BYTES_1_7, read(dataSource)); assertEquals(APPLICATION_ZIP, dataSource.getContentType()); assertArrayEquals(BYTES_11_15, read(dataSource));
contentType = ds.getContentType();
contentType = ds.getContentType();
String dsct = ds.getContentType(); if(dsct!=null && (contentType==null || contentType.equals(dsct))) { bd.set(new DataHandler(ds));
/** * Parses the MimePart to create a DataSource. * * @param parent the parent multi-part * @param part the current part to be processed * @return the DataSource * @throws MessagingException creating the DataSource failed * @throws IOException creating the DataSource failed */ protected DataSource createDataSource(final Multipart parent, final MimePart part) throws MessagingException, IOException { final DataHandler dataHandler = part.getDataHandler(); final DataSource dataSource = dataHandler.getDataSource(); final String contentType = getBaseMimeType(dataSource.getContentType()); final byte[] content = this.getContent(dataSource.getInputStream()); final ByteArrayDataSource result = new ByteArrayDataSource(content, contentType); final String dataSourceName = getDataSourceName(part, dataSource); result.setName(dataSourceName); return result; }