this.configs.add(0, new ImmutableConfigMap() {
Map<ImmutableBytesWritable, ImmutableBytesWritable> m = map;
@Override
public String get(String key) {
ImmutableBytesWritable ibw = new ImmutableBytesWritable(Bytes
.toBytes(key));
if (!m.containsKey(ibw))
return null;
ImmutableBytesWritable value = m.get(ibw);
if (value == null || value.get() == null)
return null;
return Bytes.toString(value.get());
}
@Override
public String getRaw(String key) {
return get(key);
}
@Override
public Class<?> getClassByName(String name)
throws ClassNotFoundException {
return null;
}
@Override
public int size() {
// TODO Auto-generated method stub
return m.size();
}
@Override
public String toString() {
return m.toString();
}
@Override
public Iterator<Entry<String, String>> iterator() {
final Iterator<Entry<ImmutableBytesWritable, ImmutableBytesWritable>> entries = m
.entrySet().iterator();
return new Iterator<Entry<String, String>>() {
@Override
public boolean hasNext() {
return entries.hasNext();
}
@Override
public Entry<String, String> next() {
final Entry<ImmutableBytesWritable, ImmutableBytesWritable> e = entries.next();
return new Entry<String, String>() {
@Override
public String setValue(String value) {
throw new UnsupportedOperationException(
"Cannot set value on entry from a CompoundConfiguration!");
}
@Override
public String getValue() {
ImmutableBytesWritable bytes = e.getValue();
// unlike regular configuration, ImmutableBytesWritableMaps can take a null value
if (bytes != null) {
return Bytes.toString(bytes.get(), bytes.getOffset(), bytes.getLength());
}
return null;
}
@Override
public String getKey() {
ImmutableBytesWritable bytes = e.getKey();
return Bytes.toString(bytes.get(), bytes.getOffset(), bytes.getLength());
}
};
}
@Override