MCPcopy Create free account
hub / github.com/antlr/codebuff / charset

Method charset

output/java_guava/1.4.16/MediaType.java:715–725  ·  view source on GitHub ↗

Returns an optional charset for the value of the charset parameter if it is specified. @throws IllegalStateException if multiple charset values have been set for this media type @throws IllegalCharsetNameException if a charset value is present, but illegal @throws UnsupportedCharsetException if a c

()

Source from the content-addressed store, hash-verified

713
714
715 public Optional<Charset> charset() {
716 ImmutableSet<String> charsetValues = ImmutableSet.copyOf(parameters.get(CHARSET_ATTRIBUTE));
717 switch (charsetValues.size()) {
718 case 0:
719 return Optional.absent();
720 case 1:
721 return Optional.of(Charset.forName(Iterables.getOnlyElement(charsetValues)));
722 default:
723 throw new IllegalStateException("Multiple charset values defined: " + charsetValues);
724 }
725 }
726
727 /**
728 * Returns a new instance with the same type and subtype as this instance, but without any

Callers

nothing calls this directly

Calls 6

copyOfMethod · 0.95
absentMethod · 0.95
ofMethod · 0.95
getOnlyElementMethod · 0.95
getMethod · 0.65
sizeMethod · 0.65

Tested by

no test coverage detected