public Object get(String key) { if (this.myKey.equals(key)) { return this; } else if (this.children.containsKey(key)) { return this.children.get(key); } else if (key.startsWith(this.myKey)) { String smallKey = StringUtils.minus(key, this.myKey + "."); StringTokenizer tokenizer = new StringTokenizer(smallKey, "."); BundleContent bcont = this; while (tokenizer.hasMoreTokens()) { String token = tokenizer.nextToken(); if (bcont.children.containsKey(token)) { bcont = bcont.children.get(token); } else { return "!" + key + "!"; } } return bcont; } else { StringTokenizer tokenizer = new StringTokenizer(key, "."); if (tokenizer.hasMoreTokens()) { String token = tokenizer.nextToken(); if (this.children.containsKey(token)) { return this.children.get(token); } else { return "!" + key + "!"; } } else { return "!" + key + "!"; } } }
public BundleContent findOrCreateChildren(String key) { if (key.length() > this.myKey.length()) { String smallKey = StringUtils.minus(key, this.myKey + "."); StringTokenizer tokenizer = new StringTokenizer(smallKey, "."); Map<String, BundleContent> processingContent = this.children; BundleContent returingVal = this; while (tokenizer.hasMoreTokens()) { String tok = tokenizer.nextToken(); if (processingContent.containsKey(tok)) { returingVal = processingContent.get(tok); processingContent = returingVal.children; } else { returingVal = new BundleContent(tok); processingContent.put(tok, returingVal); processingContent = returingVal.children; } ; } return returingVal; } else if (key.equals(this.myKey)) { return this; } else return null; }