Package de.xima.fc.common.mime
Class MimeNormalizers
- java.lang.Object
-
- de.xima.fc.common.mime.MimeNormalizers
-
public final class MimeNormalizers extends Object
Factory for creating various mime type normalizers.
-
-
Constructor Summary
Constructors Constructor Description MimeNormalizers()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static IMimeNormalizer
canonicalizing()
Gets aIMimeNormalizer
that normalizes the string representation of a mime type to its canonical format.static IMimeNormalizer
composing(IMimeNormalizer... normalizers)
Creates aIMimeNormalizer
that composes multiple normalizes by chaining them together.static IMimeNormalizer
composing(Iterable<? extends IMimeNormalizer> normalizers)
Creates aIMimeNormalizer
that composes multiple normalizes by chaining them together.static IMimeNormalizer
composing(Stream<? extends IMimeNormalizer> normalizers)
Creates aIMimeNormalizer
that composes multiple normalizes by chaining them together.static de.xima.fc.common.mime.MappingMimeNormalizer.Builder
mapping()
Creates a new mapping mime type normalizer that normalizes mime types by mapping certain types to other types.static IMimeNormalizer
noOp()
-
-
-
Method Detail
-
canonicalizing
public static IMimeNormalizer canonicalizing()
Gets aIMimeNormalizer
that normalizes the string representation of a mime type to its canonical format. E.g.text/plain; charset=utf-8
becomestext/plain; charset=utf-8
.
-
composing
public static IMimeNormalizer composing(IMimeNormalizer... normalizers)
Creates aIMimeNormalizer
that composes multiple normalizes by chaining them together. In other words, applies the first normalizer, then passed the output to the second normalizer etc.- Parameters:
normalizers
- Normalizers to compose.- Returns:
- A normalizer that applies each given normalizer in order.
-
composing
public static IMimeNormalizer composing(Iterable<? extends IMimeNormalizer> normalizers)
Creates aIMimeNormalizer
that composes multiple normalizes by chaining them together. In other words, applies the first normalizer, then passed the output to the second normalizer etc.- Parameters:
normalizers
- Normalizers to compose.- Returns:
- A normalizer that applies each given normalizer in order.
-
composing
public static IMimeNormalizer composing(Stream<? extends IMimeNormalizer> normalizers)
Creates aIMimeNormalizer
that composes multiple normalizes by chaining them together. In other words, applies the first normalizer, then passed the output to the second normalizer etc.- Parameters:
normalizers
- Normalizers to compose.- Returns:
- A normalizer that applies each given normalizer in order.
-
mapping
public static de.xima.fc.common.mime.MappingMimeNormalizer.Builder mapping()
Creates a new mapping mime type normalizer that normalizes mime types by mapping certain types to other types.MimeNormalizer normalizer = MimeNormalizers.mapping() .addMapping("application/xml", "text/plain") .addMapping("text/xml", "text/plain") .addMapping("application/xhtml+xml", "text/plain") .addMapping("text/plain", "text") .build();
- Returns:
- A builder for a mapping mime type normalizer.
-
noOp
public static IMimeNormalizer noOp()
- Returns:
- A MIME normalizer that does not normalize at all.
-
-