Esempio n. 1
0
 private String getNameFor(final String key) {
   final String[] parts =
       (String[])
           Iterables.toArray(
               Splitter.on('.').split((CharSequence) this.createRelativeKey(key)),
               (Class) String.class);
   return parts[parts.length - 1];
 }
Esempio n. 2
0
 @Override
 public void removeKey(final String key) {
   final String[] parts =
       (String[])
           Iterables.toArray(
               Splitter.on('.').split((CharSequence) this.createRelativeKey(key)),
               (Class) String.class);
   final Map<String, Tag> parent = this.findLastParent(parts);
   parent.remove(parts[parts.length - 1]);
 }
Esempio n. 3
0
 private void putTag(final String key, final Tag tag) {
   final String[] parts =
       (String[])
           Iterables.toArray(
               Splitter.on('.').split((CharSequence) this.createRelativeKey(key)),
               (Class) String.class);
   Map<String, Tag> parent = NBTStorage.this.root;
   for (int i = 0; i < parts.length - 1; ++i) {
     if (!parent.containsKey(parts[i]) || !(parent.get(parts[i]) instanceof CompoundTag)) {
       parent.put(parts[i], new CompoundTag(parts[i]));
     }
     parent = parent.get(parts[i]).getValue();
   }
   parent.put(tag.getName(), tag);
 }
Esempio n. 4
0
 private Tag findLastTag(final String key, final boolean relative) {
   final String[] parts =
       (String[])
           Iterables.toArray(
               Splitter.on('.')
                   .omitEmptyStrings()
                   .split((CharSequence) (relative ? this.createRelativeKey(key) : key)),
               (Class) String.class);
   if (parts.length == 0) {
     return new CompoundTag(NBTStorage.this.name, NBTStorage.this.root);
   }
   final Map<String, Tag> map = this.findLastParent(parts);
   if (!map.containsKey(parts[parts.length - 1])) {
     return null;
   }
   return map.get(parts[parts.length - 1]);
 }
 @Override
 public Iterable<Object> getValues() {
   return Iterables.concat(Lists.transform(clauses, Constants.valuesGetter));
 }