test_class.declarator: generator = new PropertyHintNodeNameGenerator()
test_class.modifier: private
test_class.original_string: private PropertyHintNodeNameGenerator generator = new PropertyHintNodeNameGenerator();
test_class.type: PropertyHintNodeNameGenerator
test_class.var_name: generator
test_class.declarator: DEFAULT_CONFIG = new Config() {
  
          @Override
          public Class<? extends Annotation> annotationType() {
              return null;
          }
  
          @Override
          public String allowed_chars() {
              return "abcdefghijklmnopqrstuvwxyz_-";
          }
  
          @Override
          public String replacement_char() {
              return "-";
          }
  
      }
test_class.modifier: private
test_class.original_string: private Config DEFAULT_CONFIG = new Config() {
  
          @Override
          public Class<? extends Annotation> annotationType() {
              return null;
          }
  
          @Override
          public String allowed_chars() {
              return "abcdefghijklmnopqrstuvwxyz_-";
          }
  
          @Override
          public String replacement_char() {
              return "-";
          }
  
      };
test_class.type: Config
test_class.var_name: DEFAULT_CONFIG
test_class.file: core/src/test/java/org/apache/sling/cms/core/internal/operations/PropertyHintNodeNameGeneratorTest.java
test_class.identifier: PropertyHintNodeNameGeneratorTest
test_case.body: @Test
      public void testFilter() {
          generator.activate(DEFAULT_CONFIG);
  
          String filtered = generator.filter("A*dsf--dsfas__sdf_");
          assertNotNull(filtered);
          assertEquals("a-dsf--dsfas__sdf_", filtered);
  
          filtered = generator.filter("A*dsf--dsfas&&sdf*");
          assertNotNull(filtered);
          assertEquals("a-dsf--dsfas-sdf-", filtered);
  
          filtered = generator.filter("*A*dsf--dsfa  s&&sdf*");
          assertNotNull(filtered);
          assertEquals("-a-dsf--dsfa-s-sdf-", filtered);
  
          filtered = generator.filter("");
          assertNotNull(filtered);
          assertEquals("-", filtered);
  
          try {
              filtered = generator.filter(null);
              fail();
          } catch (NullPointerException e) {
              // expected
          }
      }
test_case.class_method_signature: PropertyHintNodeNameGeneratorTest.testFilter()
test_case.full_signature: @Test public void testFilter()
test_case.identifier: testFilter
test_case.invocations: activate filter assertNotNull assertEquals filter assertNotNull assertEquals filter assertNotNull assertEquals filter assertNotNull assertEquals filter fail
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testFilter()
focal_class.declarator: RP_NODE_NAME_PARAM = ":nameParam"
focal_class.modifier: public static final
focal_class.original_string: public static final String RP_NODE_NAME_PARAM = ":nameParam";
focal_class.type: String
focal_class.var_name: RP_NODE_NAME_PARAM
focal_class.declarator: allowedChars
focal_class.modifier: private
focal_class.original_string: private String allowedChars;
focal_class.type: String
focal_class.var_name: allowedChars
focal_class.declarator: replacementChar
focal_class.modifier: private
focal_class.original_string: private char replacementChar;
focal_class.type: char
focal_class.var_name: replacementChar
focal_class.file: core/src/main/java/org/apache/sling/cms/core/internal/operations/PropertyHintNodeNameGenerator.java
focal_class.identifier: PropertyHintNodeNameGenerator
focal_class.interfaces: implements NodeNameGenerator, NameFilter
focal_class.class_method_signature: PropertyHintNodeNameGenerator.activate(Config config)
focal_class.full_signature: @Activate @Modified public void activate(Config config)
focal_class.identifier: activate
focal_class.modifiers: @Activate @Modified public
focal_class.parameters: (Config config)
focal_class.return: void
focal_class.signature: void activate(Config config)
focal_class.class_method_signature: PropertyHintNodeNameGenerator.filter(String nodeName)
focal_class.full_signature: @Override public String filter(String nodeName)
focal_class.identifier: filter
focal_class.modifiers: @Override public
focal_class.parameters: (String nodeName)
focal_class.return: String
focal_class.signature: String filter(String nodeName)
focal_class.class_method_signature: PropertyHintNodeNameGenerator.getNodeName(SlingHttpServletRequest request, String parentPath, boolean requirePrefix,
              NodeNameGenerator defaultNodeNameGenerator)
focal_class.full_signature: @Override public String getNodeName(SlingHttpServletRequest request, String parentPath, boolean requirePrefix,
              NodeNameGenerator defaultNodeNameGenerator)
focal_class.identifier: getNodeName
focal_class.modifiers: @Override public
focal_class.parameters: (SlingHttpServletRequest request, String parentPath, boolean requirePrefix,
              NodeNameGenerator defaultNodeNameGenerator)
focal_class.return: String
focal_class.signature: String getNodeName(SlingHttpServletRequest request, String parentPath, boolean requirePrefix,
              NodeNameGenerator defaultNodeNameGenerator)
focal_method.body: @Override
      public String filter(String nodeName) {
          final StringBuilder sb = new StringBuilder();
          char lastAdded = 0;
  
          nodeName = nodeName.toLowerCase();
          for (int i = 0; i < nodeName.length(); i++) {
              final char c = nodeName.charAt(i);
              char toAdd = c;
  
              if (allowedChars.indexOf(c) < 0) {
                  if (lastAdded == replacementChar) {
                      // do not add several _ in a row
                      continue;
                  }
                  toAdd = replacementChar;
  
              } else if (i == 0 && Character.isDigit(c)) {
                  sb.append(replacementChar);
              }
  
              sb.append(toAdd);
              lastAdded = toAdd;
          }
  
          if (sb.length() == 0) {
              sb.append(replacementChar);
          }
  
          return sb.toString();
      }
focal_method.class_method_signature: PropertyHintNodeNameGenerator.filter(String nodeName)
focal_method.full_signature: @Override public String filter(String nodeName)
focal_method.identifier: filter
focal_method.invocations: toLowerCase length charAt indexOf isDigit append append length append toString
focal_method.modifiers: @Override public
focal_method.parameters: (String nodeName)
focal_method.return: String
focal_method.signature: String filter(String nodeName)