MCPcopy Create free account
hub / github.com/apache/tomcat / setLocale

Method setLocale

java/org/apache/catalina/connector/Response.java:744–786  ·  view source on GitHub ↗
(Locale locale)

Source from the content-addressed store, hash-verified

742
743
744 @Override
745 public void setLocale(Locale locale) {
746
747 if (isCommitted()) {
748 return;
749 }
750
751 // Ignore any call from an included servlet
752 if (included) {
753 return;
754 }
755
756 getCoyoteResponse().setLocale(locale);
757
758 // Ignore any call made after the getWriter has been invoked.
759 // The default should be used
760 if (usingWriter) {
761 return;
762 }
763
764 if (isCharacterEncodingSet) {
765 return;
766 }
767
768 if (locale == null) {
769 getCoyoteResponse().setCharsetHolder(CharsetHolder.EMPTY);
770 } else {
771 // In some error handling scenarios, the context is unknown
772 // (e.g. a 404 when a ROOT context is not present)
773 Context context = getContext();
774 if (context != null) {
775 String charset = context.getCharset(locale);
776 if (charset != null) {
777 getCoyoteResponse().setCharsetHolder(CharsetHolder.getInstance(charset));
778 try {
779 getCoyoteResponse().getCharsetHolder().validate();
780 } catch (UnsupportedEncodingException e) {
781 log.warn(sm.getString("coyoteResponse.encoding.invalid", charset), e);
782 }
783 }
784 }
785 }
786 }
787
788
789 // --------------------------------------------------- HttpResponse Methods

Callers

nothing calls this directly

Calls 11

isCommittedMethod · 0.95
getCoyoteResponseMethod · 0.95
getContextMethod · 0.95
getCharsetMethod · 0.95
getInstanceMethod · 0.95
setLocaleMethod · 0.65
validateMethod · 0.65
warnMethod · 0.65
getStringMethod · 0.65
setCharsetHolderMethod · 0.45
getCharsetHolderMethod · 0.45

Tested by

no test coverage detected