public ContentType getResponseContentType() { if (!executed) { throw new IllegalStateException( "Must call execute() before attempting to read response"); } String value = httpConn.getHeaderField("Content-Type"); if (value == null) { return null; } return new ContentType(value); }
public ContentType getResponseContentType() { if (!executed) { throw new IllegalStateException( "Must call execute() before attempting to read response"); } String value = httpConn.getHeaderField("Content-Type"); if (value == null) { return null; } return new ContentType(value); }
public ContentType getResponseContentType() { if (!executed) { throw new IllegalStateException( "Must call execute() before attempting to read response"); } String value = httpConn.getHeaderField("Content-Type"); if (value == null) { return null; } return new ContentType(value); }
/** @return the MIME content type, or {@code null} if none exists */ public ContentType getMimeType() { String type = getAttributeValue(TYPE); if (type == null) { return null; } return new ContentType(type); }
/** @return the MIME content type, or {@code null} if none exists */ public ContentType getMimeType() { String type = getAttributeValue(TYPE); if (type == null) { return null; } return new ContentType(type); }
/** @return the MIME content type, or {@code null} if none exists */ public ContentType getMimeType() { String type = getAttributeValue(TYPE); if (type == null) { return null; } return new ContentType(type); }
/** * Processes attributes. * * @throws ParseException */ @Override public void processAttribute(String namespace, String localName, String value) throws ParseException { if (namespace.equals("")) { if (localName.equals("type")) { try { mimeType = new ContentType(value); } catch (IllegalArgumentException e) { throw new ParseException( CoreErrorDomain.ERR.invalidMimeType, e); } } } }
/** * Sets the MIME type for the content of the error message contained in this * element. * * @param contentType MIME type for the content of the error message contained * in this element or <code>null</code> to reset */ public BatchStatus setContentType(ContentType contentType) { setAttributeValue(CONTENT_TYPE, (contentType == null) ? null : new ContentType(contentType.getMediaType())); return this; }
/** * Sets the MIME type of the content of this element. * * @param contentType MIME type of the content of this element or * <code>null</code> to reset */ public BatchInterrupted setContentType(ContentType contentType) { setAttributeValue(CONTENT_TYPE, (contentType == null) ? null : new ContentType(contentType.getMediaType())); return this; }
/** * Sets the MIME type of the content of this element. * * @param contentType MIME type of the content of this element or * <code>null</code> to reset */ public BatchInterrupted setContentType(ContentType contentType) { setAttributeValue(CONTENT_TYPE, (contentType == null) ? null : new ContentType(contentType.getMediaType())); return this; }
/** * Sets the MIME type for the content of the error message contained in this * element. * * @param contentType MIME type for the content of the error message contained * in this element or <code>null</code> to reset */ public BatchStatus setContentType(ContentType contentType) { setAttributeValue(CONTENT_TYPE, (contentType == null) ? null : new ContentType(contentType.getMediaType())); return this; }
/** * Sets the MIME type for the content of the error message contained in this * element. * * @param contentType MIME type for the content of the error message contained * in this element or <code>null</code> to reset */ public BatchStatus setContentType(ContentType contentType) { setAttributeValue(CONTENT_TYPE, (contentType == null) ? null : new ContentType(contentType.getMediaType())); return this; }
/** * Sets the MIME type of the content of this element. * * @param contentType MIME type of the content of this element or * <code>null</code> to reset */ public BatchInterrupted setContentType(ContentType contentType) { setAttributeValue(CONTENT_TYPE, (contentType == null) ? null : new ContentType(contentType.getMediaType())); return this; }
public BatchInterruptedElementHandler(ExtensionProfile extProfile, Attributes attrs) throws ParseException { super(extProfile, BatchInterrupted.class); totalCount = getIntegerAttribute(attrs, "parsed", 0); successCount = getIntegerAttribute(attrs, "success", 0); errorCount = getIntegerAttribute(attrs, "error", 0); reason = attrs.getValue("reason"); String contentTypeString = attrs.getValue("content-type"); if (contentTypeString != null) { try { contentType = new ContentType(contentTypeString); } catch (IllegalArgumentException e) { ParseException pe = new ParseException( CoreErrorDomain.ERR.invalidContentType, e); pe.setInternalReason("Invalid content type: '" + contentTypeString + "'"); throw pe; } } }
public void setMediaSource(MediaSource mediaSource) { MediaContent content; if (state.content == null) { content = new MediaContent(); state.content = content; } else if (state.content instanceof MediaContent) { content = (MediaContent) state.content; } else { throw new IllegalArgumentException("Cannot set media source on entry " + "with existing non-MediaContent: " + state.content); } content.setMediaSource(mediaSource); content.setMimeType(new ContentType(mediaSource.getContentType())); }
public void setMediaSource(MediaSource mediaSource) { MediaContent content; if (state.content == null) { content = new MediaContent(); state.content = content; } else if (state.content instanceof MediaContent) { content = (MediaContent) state.content; } else { throw new IllegalArgumentException("Cannot set media source on entry " + "with existing non-MediaContent: " + state.content); } content.setMediaSource(mediaSource); content.setMimeType(new ContentType(mediaSource.getContentType())); }
@SuppressWarnings("unchecked") public Object getContent(DataSource ds) throws IOException { // Get the input properties to use when parsing content InputProperties inputProperties = getThreadInputProperties(); // Find the parser to handle the input content type ContentType contentType = new ContentType(ds.getContentType()); AltRegistry altRegistry = inputProperties.getAltRegistry(); AltFormat altFormat = altRegistry.lookupType(contentType); InputParser<?> parser = altRegistry.getParser(altFormat); if (parser == null) { throw new IOException("Invalid multipart content: " + contentType); } try { return parseAtom(parser, ds.getInputStream(), contentType, inputProperties, inputProperties.getRootType()); } catch (ServiceException se) { IOException ioe = new IOException("Error parsing content"); ioe.initCause(se); throw ioe; } }
/** * Associate a File with this entry with the specified mime type */ public void setFile(File file, String mimeType) { MediaFileSource fileSource = new MediaFileSource(file, mimeType); MediaContent content = new MediaContent(); content.setMediaSource(fileSource); content.setMimeType(new ContentType(mimeType)); setContent(content); }
/** * Associate a File with this entry with the specified mime type */ public void setFile(File file, String mimeType) { MediaFileSource fileSource = new MediaFileSource(file, mimeType); MediaContent content = new MediaContent(); content.setMediaSource(fileSource); content.setMimeType(new ContentType(mimeType)); setContent(content); }
/** * Associate a File with this entry with the specified mime type */ public void setFile(File file, String mimeType) { MediaFileSource fileSource = new MediaFileSource(file, mimeType); MediaContent content = new MediaContent(); content.setMediaSource(fileSource); content.setMimeType(new ContentType(mimeType)); setContent(content); }