protected int compareParameters(T mimeType1, T mimeType2) { int paramsSize1 = mimeType1.getParameters().size(); int paramsSize2 = mimeType2.getParameters().size(); return Integer.compare(paramsSize2, paramsSize1); // audio/basic;level=1 < audio/basic } }
protected int compareParameters(T mimeType1, T mimeType2) { int paramsSize1 = mimeType1.getParameters().size(); int paramsSize2 = mimeType2.getParameters().size(); return Integer.compare(paramsSize2, paramsSize1); // audio/basic;level=1 < audio/basic } }
return comp; comp = getParameters().size() - other.getParameters().size(); if (comp != 0) { return comp; thisAttributes.addAll(getParameters().keySet()); TreeSet<String> otherAttributes = new TreeSet<>(String.CASE_INSENSITIVE_ORDER); otherAttributes.addAll(other.getParameters().keySet()); Iterator<String> thisAttributesIterator = thisAttributes.iterator(); Iterator<String> otherAttributesIterator = otherAttributes.iterator(); String thisValue = getParameters().get(thisAttribute); String otherValue = other.getParameters().get(otherAttribute); if (otherValue == null) { otherValue = "";
/** * Re-create the given mime type as a media type. * @since 5.0 */ public static MediaType asMediaType(MimeType mimeType) { if (mimeType instanceof MediaType) { return (MediaType) mimeType; } return new MediaType(mimeType.getType(), mimeType.getSubtype(), mimeType.getParameters()); }
/** * Copy-constructor that copies the type, subtype, parameters of the given {@code MimeType}, * and allows to set the specified character set. * @param other the other MimeType * @param charset the character set * @throws IllegalArgumentException if any of the parameters contains illegal characters * @since 4.3 */ public MimeType(MimeType other, Charset charset) { this(other.getType(), other.getSubtype(), addCharsetParameter(charset, other.getParameters())); }
return comp; comp = getParameters().size() - other.getParameters().size(); if (comp != 0) { return comp; thisAttributes.addAll(getParameters().keySet()); TreeSet<String> otherAttributes = new TreeSet<>(String.CASE_INSENSITIVE_ORDER); otherAttributes.addAll(other.getParameters().keySet()); Iterator<String> thisAttributesIterator = thisAttributes.iterator(); Iterator<String> otherAttributesIterator = otherAttributes.iterator(); String thisValue = getParameters().get(thisAttribute); String otherValue = other.getParameters().get(otherAttribute); if (otherValue == null) { otherValue = "";
/** * Copy-constructor that copies the type, subtype, parameters of the given {@code MimeType}, * and allows to set the specified character set. * @param other the other MimeType * @param charset the character set * @throws IllegalArgumentException if any of the parameters contains illegal characters * @since 4.3 */ public MimeType(MimeType other, Charset charset) { this(other.getType(), other.getSubtype(), addCharsetParameter(charset, other.getParameters())); }
/** * Re-create the given mime type as a media type. * @since 5.0 */ public static MediaType asMediaType(MimeType mimeType) { if (mimeType instanceof MediaType) { return (MediaType) mimeType; } return new MediaType(mimeType.getType(), mimeType.getSubtype(), mimeType.getParameters()); }
/** * Parse the given String into a single {@code MediaType}. * @param mediaType the string to parse * @return the media type * @throws InvalidMediaTypeException if the media type value cannot be parsed */ public static MediaType parseMediaType(String mediaType) { MimeType type; try { type = MimeTypeUtils.parseMimeType(mediaType); } catch (InvalidMimeTypeException ex) { throw new InvalidMediaTypeException(ex); } try { return new MediaType(type.getType(), type.getSubtype(), type.getParameters()); } catch (IllegalArgumentException ex) { throw new InvalidMediaTypeException(mediaType, ex.getMessage()); } }
/** * Parse the given String into a single {@code MediaType}. * @param mediaType the string to parse * @return the media type * @throws InvalidMediaTypeException if the media type value cannot be parsed */ public static MediaType parseMediaType(String mediaType) { MimeType type; try { type = MimeTypeUtils.parseMimeType(mediaType); } catch (InvalidMimeTypeException ex) { throw new InvalidMediaTypeException(ex); } try { return new MediaType(type.getType(), type.getSubtype(), type.getParameters()); } catch (IllegalArgumentException ex) { throw new InvalidMediaTypeException(mediaType, ex.getMessage()); } }
protected int compareParameters(T mimeType1, T mimeType2) { int paramsSize1 = mimeType1.getParameters().size(); int paramsSize2 = mimeType2.getParameters().size(); return Integer.compare(paramsSize2, paramsSize1); // audio/basic;level=1 < audio/basic } }
return comp; comp = getParameters().size() - other.getParameters().size(); if (comp != 0) { return comp; thisAttributes.addAll(getParameters().keySet()); TreeSet<String> otherAttributes = new TreeSet<>(String.CASE_INSENSITIVE_ORDER); otherAttributes.addAll(other.getParameters().keySet()); Iterator<String> thisAttributesIterator = thisAttributes.iterator(); Iterator<String> otherAttributesIterator = otherAttributes.iterator(); String thisValue = getParameters().get(thisAttribute); String otherValue = other.getParameters().get(otherAttribute); if (otherValue == null) { otherValue = "";
/** * Copy-constructor that copies the type, subtype, parameters of the given {@code MimeType}, * and allows to set the specified character set. * @param other the other MimeType * @param charset the character set * @throws IllegalArgumentException if any of the parameters contains illegal characters * @since 4.3 */ public MimeType(MimeType other, Charset charset) { this(other.getType(), other.getSubtype(), addCharsetParameter(charset, other.getParameters())); }
/** * Re-create the given mime type as a media type. * @since 5.0 */ public static MediaType asMediaType(MimeType mimeType) { if (mimeType instanceof MediaType) { return (MediaType) mimeType; } return new MediaType(mimeType.getType(), mimeType.getSubtype(), mimeType.getParameters()); }
/** * Copy-constructor that copies the type, subtype, parameters of the given {@code MimeType}, * and allows to set the specified character set. * @param other the other MimeType * @param charset the character set * @throws IllegalArgumentException if any of the parameters contains illegal characters * @since 4.3 */ public MimeType(MimeType other, Charset charset) { this(other.getType(), other.getSubtype(), addCharsetParameter(charset, other.getParameters())); }
/** * Re-create the given mime type as a media type. * @since 5.0 */ public static MediaType asMediaType(MimeType mimeType) { if (mimeType instanceof MediaType) { return (MediaType) mimeType; } return new MediaType(mimeType.getType(), mimeType.getSubtype(), mimeType.getParameters()); }
/** * Parse the given String into a single {@code MediaType}. * @param mediaType the string to parse * @return the media type * @throws IllegalArgumentException if the string cannot be parsed */ public static MediaType parseMediaType(String mediaType) { MimeType type; try { type = MimeTypeUtils.parseMimeType(mediaType); } catch (InvalidMimeTypeException ex) { throw new IllegalArgumentException(ex); } try { return new MediaType(type.getType(), type.getSubtype(), type.getParameters()); } catch (IllegalArgumentException ex) { throw new IllegalArgumentException(mediaType + "," +ex.getMessage()); } }
thisAttributes.addAll(getParameters().keySet()); TreeSet<String> otherAttributes = new TreeSet<>(String.CASE_INSENSITIVE_ORDER); otherAttributes.addAll(other.getParameters().keySet()); Iterator<String> thisAttributesIterator = thisAttributes.iterator(); Iterator<String> otherAttributesIterator = otherAttributes.iterator();
/** * Parse the given String into a single {@code MediaType}. * @param mediaType the string to parse * @return the media type * @throws InvalidMediaTypeException if the media type value cannot be parsed */ public static MediaType parseMediaType(String mediaType) { MimeType type; try { type = MimeTypeUtils.parseMimeType(mediaType); } catch (InvalidMimeTypeException ex) { throw new InvalidMediaTypeException(ex); } try { return new MediaType(type.getType(), type.getSubtype(), type.getParameters()); } catch (IllegalArgumentException ex) { throw new InvalidMediaTypeException(mediaType, ex.getMessage()); } }
/** * Parse the given String into a single {@code MediaType}. * @param mediaType the string to parse * @return the media type * @throws InvalidMediaTypeException if the media type value cannot be parsed */ public static MediaType parseMediaType(String mediaType) { MimeType type; try { type = MimeTypeUtils.parseMimeType(mediaType); } catch (InvalidMimeTypeException ex) { throw new InvalidMediaTypeException(ex); } try { return new MediaType(type.getType(), type.getSubtype(), type.getParameters()); } catch (IllegalArgumentException ex) { throw new InvalidMediaTypeException(mediaType, ex.getMessage()); } }