/** * Default constructor. Default MIME type, no Base64 encoding and no content. */ public CSSDataURL () { this (CSSDataURLHelper.DEFAULT_MIME_TYPE.getClone (), false, new byte [0], CSSDataURLHelper.DEFAULT_CHARSET, ""); }
public MimeTypeWithSource (@Nonnull final String sMimeType) { this (MimeTypeParser.parseMimeType (sMimeType), (String) null); }
@Nullable public static IMimeType safeParseMimeType (@Nullable final String sMimeType) { try { return MimeTypeParser.parseMimeType (sMimeType); } catch (final MimeTypeParserException ex) { if ("*".equals (sMimeType)) return new MimeType (EMimeContentType._STAR, "*"); } if (LOGGER.isWarnEnabled ()) LOGGER.warn ("Unparsable MIME type '" + sMimeType + "'"); return null; } }
@Nonnull @Nonempty public String getMimeTypeAsString () { return m_aMimeType.getAsString (); }
/** * Get the mime type of this SOAP version with the passed charset. * * @param aCharset * The charset to be used. May not be <code>null</code>. * @return Never <code>null</code>. */ @Nonnull @ReturnsMutableCopy public MimeType getMimeType (@Nonnull final Charset aCharset) { return new MimeType (m_aMimeType).addParameter (CMimeType.PARAMETER_NAME_CHARSET, aCharset.name ()); }
public void setContentType (@Nullable final String sContentType) { m_sContentType = sContentType; if (sContentType != null) { try { final IMimeType aContentType = MimeTypeParser.parseMimeType (sContentType); final String sEncoding = MimeTypeHelper.getCharsetNameFromMimeType (aContentType); if (sEncoding != null) setCharacterEncoding (sEncoding); } catch (final MimeTypeParserException ex) { LOGGER.warn ("Passed content type '" + sContentType + "' cannot be parsed as a MIME type"); } } }
@Nonnull public AS2ClientRequest setData (@Nonnull final byte [] aData) { m_aDataByteArray = ValueEnforcer.notNull (aData, "Data"); m_sDataText = null; m_aDataCharset = null; m_aDataHandler = null; m_sContentType = CMimeType.APPLICATION_OCTET_STREAM.getAsStringWithoutParameters (); return this; }
/** * Determine the charset from the passed MIME type. If no charset was found, * return the default charset. * * @param aMimeType * The MIME type to investigate. * @return Never <code>null</code>. */ @Nonnull public static Charset getCharsetFromMimeTypeOrDefault (@Nullable final IMimeType aMimeType) { final Charset ret = MimeTypeHelper.getCharsetFromMimeType (aMimeType); return ret != null ? ret : CSSDataURLHelper.DEFAULT_CHARSET; }
@Nonnull @Nonempty public String getMimeTypeAsString () { return m_aMimeType.getAsString (); }
@Nonnull public final UnifiedResponse setMimeTypeString (@Nonnull @Nonempty final String sMimeType) { ValueEnforcer.notEmpty (sMimeType, "MimeType"); final IMimeType aMimeType = MimeTypeParser.parseMimeType (sMimeType); if (aMimeType != null) setMimeType (aMimeType); else logError ("Failed to resolve mime type from '" + sMimeType + "'"); return this; }
@Nonnull public AS2ClientRequest setData (@Nonnull final String sText, @Nullable final Charset aCharset) { m_aDataByteArray = null; m_sDataText = ValueEnforcer.notNull (sText, "Text"); m_aDataCharset = aCharset; m_aDataHandler = null; m_sContentType = CMimeType.TEXT_PLAIN.getAsStringWithoutParameters (); return this; }
public Response toResponse (final SMPNotFoundException e) { return Response.status (Status.NOT_FOUND) .entity (e.getMessage ()) .type (CMimeType.TEXT_PLAIN.getAsString ()) .build (); } }
@Nonnull public MockHttpServletRequest setContentType (@Nullable final IMimeType aContentType) { return setContentType (aContentType == null ? null : aContentType.getAsString ()); }
public Response toResponse (final SMPUnknownUserException e) { return Response.status (Status.FORBIDDEN) .entity (e.getMessage ()) .type (CMimeType.TEXT_PLAIN.getAsString ()) .build (); } }
@Nonnull public final IMPLTYPE setAccept (@Nullable final IMimeType aAccept) { return setAccept (aAccept == null ? null : aAccept.getAsString ()); }
public Response toResponse (final RuntimeException ex) { final String sText = StackTraceHelper.getStackAsString (ex); return Response.status (Status.INTERNAL_SERVER_ERROR) .entity (sText) .type (CMimeType.TEXT_PLAIN.getAsString ()) .build (); } }
public Response toResponse (final SMPUnauthorizedException e) { return Response.status (Status.FORBIDDEN) .entity (e.getMessage ()) .type (CMimeType.TEXT_PLAIN.getAsString ()) .build (); } }
public AsicOutputStream (@Nonnull final OutputStream aOS) throws IOException { super (aOS); setComment ("mimetype=" + AsicUtils.MIMETYPE_ASICE.getAsString ()); _putMimeTypeAsFirstEntry (AsicUtils.MIMETYPE_ASICE); }
/** * Add a MIME type (for plugin-types) * * @param aMimeType * MIME type to add. May not be <code>null</code>. * @return this */ @Nonnull public CSP2SourceList addMimeType (@Nonnull final IMimeType aMimeType) { ValueEnforcer.notNull (aMimeType, "aMimeType"); m_aList.add (aMimeType.getAsString ()); return this; }
@Override protected void fillMicroElement (final IMicroElement aElement, final IHCConversionSettingsToNode aConversionSettings) { super.fillMicroElement (aElement, aConversionSettings); aElement.setAttribute (CHTMLAttributes.TYPE, m_aType.getAsString ()); if (StringHelper.hasText (m_sCharset)) aElement.setAttribute (CHTMLAttributes.CHARSET, m_sCharset); if (m_eCrossOrigin != null) aElement.setAttribute (CHTMLAttributes.CROSSORIGIN, m_eCrossOrigin); if (StringHelper.hasText (m_sIntegrity)) aElement.setAttribute (CHTMLAttributes.INTEGRITY, m_sIntegrity); }