test_class.declarator: INPUT_FILE = new File("src/test/resource/resfilter/json/input.json")
test_class.modifier: private static final
test_class.original_string: private static final File INPUT_FILE = new File("src/test/resource/resfilter/json/input.json");
test_class.type: File
test_class.var_name: INPUT_FILE
test_class.declarator: OUTPUT_FILE = new File("src/test/resource/resfilter/json/output.json")
test_class.modifier: private static final
test_class.original_string: private static final File OUTPUT_FILE = new File("src/test/resource/resfilter/json/output.json");
test_class.type: File
test_class.var_name: OUTPUT_FILE
test_class.declarator: INPUT_FILE2 = new File("src/test/resource/resfilter/json/other-input.json")
test_class.modifier: private static final
test_class.original_string: private static final File INPUT_FILE2 = new File("src/test/resource/resfilter/json/other-input.json");
test_class.type: File
test_class.var_name: INPUT_FILE2
test_class.declarator: SPLITKEYS = new File("src/test/resource/resfilter/json/testSplitKeys.json")
test_class.modifier: private static final
test_class.original_string: private static final File SPLITKEYS = new File("src/test/resource/resfilter/json/testSplitKeys.json");
test_class.type: File
test_class.var_name: SPLITKEYS
test_class.declarator: EXPECTED_WRITE_FILE = new File("src/test/resource/resfilter/json/write-output.json")
test_class.modifier: private static final
test_class.original_string: private static final File EXPECTED_WRITE_FILE = new File("src/test/resource/resfilter/json/write-output.json");
test_class.type: File
test_class.var_name: EXPECTED_WRITE_FILE
test_class.declarator: EXPECTED_INPUT_RES_LIST
test_class.modifier: private static final
test_class.original_string: private static final Collection<ResourceString> EXPECTED_INPUT_RES_LIST;
test_class.type: Collection<ResourceString>
test_class.var_name: EXPECTED_INPUT_RES_LIST
test_class.declarator: WRITE_BUNDLE
test_class.modifier: private static
test_class.original_string: private static LanguageBundle WRITE_BUNDLE;
test_class.type: LanguageBundle
test_class.var_name: WRITE_BUNDLE
test_class.declarator: res = new JsonResource()
test_class.modifier: private static final
test_class.original_string: private static final JsonResource res = new JsonResource();
test_class.type: JsonResource
test_class.var_name: res
test_class.file: gp-res-filter/src/test/java/com/ibm/g11n/pipeline/resfilter/impl/JsonResourceTest.java
test_class.identifier: JsonResourceTest
test_case.body: @Test
      public void testSplitKeyPieces() throws FileNotFoundException, IOException {
          /*
           * Initial data generated with: Gson g = new GsonBuilder().create();
           * TreeMap<String, List<KeyPiece>> tm = new TreeMap<String,
           * List<KeyPiece>>();
           * 
           * for (final ResourceString s : EXPECTED_INPUT_RES_LIST) {
           * tm.put(s.getKey(), JsonResource.splitKeyPieces(s.getKey())); }
           * System.out.println(g.toJson(tm));
           */
  
          JsonObject SPLITKEY_DATA = ResourceTestUtil.parseJson(SPLITKEYS).getAsJsonObject();
          for (final Entry<String, JsonElement> e : SPLITKEY_DATA.entrySet()) {
              final String key = e.getKey();
              final JsonArray expectList = e.getValue().getAsJsonArray();
  
              List<KeyPiece> actualList = JsonResource.splitKeyPieces(key);
  
              String prefix = "‘" + key + "’: ";
              assertEquals(prefix + "key count", expectList.size(), actualList.size());
              for (int n = 0; n < expectList.size(); n++) {
                  JsonObject expectObject = expectList.get(n).getAsJsonObject();
                  KeyPiece actualObject = actualList.get(n);
                  String subPrefix = prefix + " key " + n;
                  assertEquals(subPrefix + " value ", expectObject.get("keyValue").getAsString(), actualObject.keyValue);
                  assertEquals(subPrefix + " type ", expectObject.get("keyType").getAsString(),
                          actualObject.keyType.name());
              }
          }
      }
test_case.class_method_signature: JsonResourceTest.testSplitKeyPieces()
test_case.full_signature: @Test public void testSplitKeyPieces()
test_case.identifier: testSplitKeyPieces
test_case.invocations: getAsJsonObject parseJson entrySet getKey getAsJsonArray getValue splitKeyPieces assertEquals size size size getAsJsonObject get get assertEquals getAsString get assertEquals getAsString get name
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testSplitKeyPieces()
focal_class.declarator: JSONPATH_ROOT = "$"
focal_class.modifier: private static final
focal_class.original_string: private static final String JSONPATH_ROOT = "$";
focal_class.type: String
focal_class.var_name: JSONPATH_ROOT
focal_class.declarator: USE_JSONPATH_PATTERN = Pattern.compile("^\\$[.\\[].*")
focal_class.modifier: private static final
focal_class.original_string: private static final Pattern USE_JSONPATH_PATTERN = Pattern.compile("^\\$[.\\[].*");
focal_class.type: Pattern
focal_class.var_name: USE_JSONPATH_PATTERN
focal_class.declarator: USE_BRACKET_PATTERN = Pattern.compile("[.'\\[\\]]")
focal_class.modifier: private static final
focal_class.original_string: private static final Pattern USE_BRACKET_PATTERN = Pattern.compile("[.'\\[\\]]");
focal_class.type: Pattern
focal_class.var_name: USE_BRACKET_PATTERN
focal_class.file: gp-res-filter/src/main/java/com/ibm/g11n/pipeline/resfilter/impl/JsonResource.java
focal_class.identifier: JsonResource
focal_class.class_method_signature: JsonResource.parse(InputStream inStream, FilterOptions options)
focal_class.full_signature: @Override public LanguageBundle parse(InputStream inStream, FilterOptions options)
focal_class.identifier: parse
focal_class.modifiers: @Override public
focal_class.parameters: (InputStream inStream, FilterOptions options)
focal_class.return: LanguageBundle
focal_class.signature: LanguageBundle parse(InputStream inStream, FilterOptions options)
focal_class.class_method_signature: JsonResource.addBundleStrings(JsonObject obj, String keyPrefix, LanguageBundleBuilder bb, int sequenceNum)
focal_class.full_signature: protected int addBundleStrings(JsonObject obj, String keyPrefix, LanguageBundleBuilder bb, int sequenceNum)
focal_class.identifier: addBundleStrings
focal_class.modifiers: protected
focal_class.parameters: (JsonObject obj, String keyPrefix, LanguageBundleBuilder bb, int sequenceNum)
focal_class.return: int
focal_class.signature: int addBundleStrings(JsonObject obj, String keyPrefix, LanguageBundleBuilder bb, int sequenceNum)
focal_class.class_method_signature: JsonResource.encodeResourceKey(String parent, String key, boolean isLeaf)
focal_class.full_signature: protected String encodeResourceKey(String parent, String key, boolean isLeaf)
focal_class.identifier: encodeResourceKey
focal_class.modifiers: protected
focal_class.parameters: (String parent, String key, boolean isLeaf)
focal_class.return: String
focal_class.signature: String encodeResourceKey(String parent, String key, boolean isLeaf)
focal_class.class_method_signature: JsonResource.write(OutputStream outStream, LanguageBundle languageBundle,
              FilterOptions options)
focal_class.full_signature: @Override public void write(OutputStream outStream, LanguageBundle languageBundle,
              FilterOptions options)
focal_class.identifier: write
focal_class.modifiers: @Override public
focal_class.parameters: (OutputStream outStream, LanguageBundle languageBundle,
              FilterOptions options)
focal_class.return: void
focal_class.signature: void write(OutputStream outStream, LanguageBundle languageBundle,
              FilterOptions options)
focal_class.class_method_signature: JsonResource.splitKeyPieces(String key)
focal_class.full_signature: static List<KeyPiece> splitKeyPieces(String key)
focal_class.identifier: splitKeyPieces
focal_class.modifiers: static
focal_class.parameters: (String key)
focal_class.return: List<KeyPiece>
focal_class.signature: List<KeyPiece> splitKeyPieces(String key)
focal_class.class_method_signature: JsonResource.addToken(List<KeyPiece> result, String s, boolean inSubscript)
focal_class.full_signature: static void addToken(List<KeyPiece> result, String s, boolean inSubscript)
focal_class.identifier: addToken
focal_class.modifiers: static
focal_class.parameters: (List<KeyPiece> result, String s, boolean inSubscript)
focal_class.return: void
focal_class.signature: void addToken(List<KeyPiece> result, String s, boolean inSubscript)
focal_class.superclass: extends ResourceFilter
focal_method.body: static List<KeyPiece> splitKeyPieces(String key) {
          if (USE_JSONPATH_PATTERN.matcher(key).matches()) {
              List<KeyPiece> result = new ArrayList<KeyPiece>();
              boolean inQuotes = false;
              StringBuilder currentToken = new StringBuilder();
              // Disregard $ at the beginning - it's not really part of the key...
              StringCharacterIterator i = new StringCharacterIterator(key.substring(JSONPATH_ROOT.length()));
              boolean inSubscript = false;
              while (i.current() != StringCharacterIterator.DONE) {
                  char c = i.current();
                  if (c == '\'') {
                      inQuotes = !inQuotes;
                  }
                  if (!inQuotes && (c == '.' || c == '[' || c == ']')) {
                      if (currentToken.length() > 0) {
                          addToken(result, currentToken.toString(), inSubscript);
                          currentToken.setLength(0);
                          if (inSubscript) {
                              inSubscript = false;
                          }
                      }
                      if (c == '[') {
                          inSubscript = true; // Record that the next token had an
                                          // array subscript on it.
                      }
                  } else {
                      currentToken.append(c);
                  }
                  i.next();
              }
              addToken(result, currentToken.toString(), inSubscript);
  
              return Collections.unmodifiableList(result);
          }
          // Otherwise, this is a plain JSON object label
          return Collections.singletonList(new KeyPiece(key, JsonToken.BEGIN_OBJECT));
      }
focal_method.class_method_signature: JsonResource.splitKeyPieces(String key)
focal_method.full_signature: static List<KeyPiece> splitKeyPieces(String key)
focal_method.identifier: splitKeyPieces
focal_method.invocations: matches matcher substring length current current length addToken toString setLength append next addToken toString unmodifiableList singletonList
focal_method.modifiers: static
focal_method.parameters: (String key)
focal_method.return: List<KeyPiece>
focal_method.signature: List<KeyPiece> splitKeyPieces(String key)