test_class.file: services/src/test/java/org/keycloak/theme/PropertiesUtilTest.java
test_class.identifier: PropertiesUtilTest
test_case.body: @Test
      public void testDetectEncoding() throws Exception {
          Charset encoding = PropertiesUtil.detectEncoding(new ByteArrayInputStream("# encoding: utf-8\nkey=value".getBytes()));
          assertEquals(Charset.forName("utf-8"), encoding);
  
          encoding = PropertiesUtil.detectEncoding(new ByteArrayInputStream("# encoding: Shift_JIS\nkey=value".getBytes()));
          assertEquals(Charset.forName("Shift_JIS"), encoding);
      }
test_case.class_method_signature: PropertiesUtilTest.testDetectEncoding()
test_case.full_signature: @Test public void testDetectEncoding()
test_case.identifier: testDetectEncoding
test_case.invocations: detectEncoding getBytes assertEquals forName detectEncoding getBytes assertEquals forName
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testDetectEncoding()
focal_class.declarator: logger = Logger.getLogger(PropertiesUtil.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger logger = Logger.getLogger(PropertiesUtil.class);
focal_class.type: Logger
focal_class.var_name: logger
focal_class.declarator: DETECT_ENCODING_PATTERN = Pattern.compile("^#\\s*encoding:\\s*([\\w.:-]+)",
              Pattern.CASE_INSENSITIVE)
focal_class.modifier: public static final
focal_class.original_string: public static final Pattern DETECT_ENCODING_PATTERN = Pattern.compile("^#\\s*encoding:\\s*([\\w.:-]+)",
              Pattern.CASE_INSENSITIVE);
focal_class.type: Pattern
focal_class.var_name: DETECT_ENCODING_PATTERN
focal_class.declarator: DEFAULT_ENCODING = Charset.forName("ISO-8859-1")
focal_class.modifier: public static final
focal_class.original_string: public static final Charset DEFAULT_ENCODING = Charset.forName("ISO-8859-1");
focal_class.type: Charset
focal_class.var_name: DEFAULT_ENCODING
focal_class.file: services/src/main/java/org/keycloak/theme/PropertiesUtil.java
focal_class.identifier: PropertiesUtil
focal_class.class_method_signature: PropertiesUtil.detectEncoding(InputStream in)
focal_class.full_signature: public static Charset detectEncoding(InputStream in)
focal_class.identifier: detectEncoding
focal_class.modifiers: public static
focal_class.parameters: (InputStream in)
focal_class.return: Charset
focal_class.signature: Charset detectEncoding(InputStream in)
focal_method.body: public static Charset detectEncoding(InputStream in) throws IOException {
          try (BufferedReader br = new BufferedReader(new InputStreamReader(in, DEFAULT_ENCODING))) {
              String firstLine = br.readLine();
              if (firstLine != null) {
                  Matcher matcher = DETECT_ENCODING_PATTERN.matcher(firstLine);
                  if (matcher.find()) {
                      String encoding = matcher.group(1);
                      if (Charset.isSupported(encoding)) {
                          return Charset.forName(encoding);
                      } else {
                          logger.warnv("Unsupported encoding: {0}", encoding);
                      }
                  }
              }
          }
          return DEFAULT_ENCODING;
      }
focal_method.class_method_signature: PropertiesUtil.detectEncoding(InputStream in)
focal_method.full_signature: public static Charset detectEncoding(InputStream in)
focal_method.identifier: detectEncoding
focal_method.invocations: readLine matcher find group isSupported forName warnv
focal_method.modifiers: public static
focal_method.parameters: (InputStream in)
focal_method.return: Charset
focal_method.signature: Charset detectEncoding(InputStream in)