本文整理了Java中org.apache.commons.collections.keyvalue.MultiKey.getKeys()
方法的一些代码示例,展示了MultiKey.getKeys()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MultiKey.getKeys()
方法的具体详情如下:
包路径:org.apache.commons.collections.keyvalue.MultiKey
类名称:MultiKey
方法名:getKeys
[英]Gets a clone of the array of keys.
The keys should be immutable If they are not then they must not be changed.
[中]获取密钥数组的克隆。
密钥应该是不可变的,如果不是,则不能更改。
代码示例来源:origin: commons-collections/commons-collections
public void testConstructors() throws Exception {
MultiKey mk = null;
mk = new MultiKey(ONE, TWO);
Assert.assertTrue(Arrays.equals(new Object[] {ONE, TWO}, mk.getKeys()));
mk = new MultiKey(ONE, TWO, THREE);
Assert.assertTrue(Arrays.equals(new Object[] {ONE, TWO, THREE}, mk.getKeys()));
mk = new MultiKey(ONE, TWO, THREE, FOUR);
Assert.assertTrue(Arrays.equals(new Object[] {ONE, TWO, THREE, FOUR}, mk.getKeys()));
mk = new MultiKey(ONE, TWO, THREE, FOUR, FIVE);
Assert.assertTrue(Arrays.equals(new Object[] {ONE, TWO, THREE, FOUR, FIVE}, mk.getKeys()));
mk = new MultiKey(new Object[] {THREE, FOUR, ONE, TWO}, false);
Assert.assertTrue(Arrays.equals(new Object[] {THREE, FOUR, ONE, TWO}, mk.getKeys()));
}
代码示例来源:origin: commons-collections/commons-collections
public void testConstructorsByArray() throws Exception {
MultiKey mk = null;
Object[] keys = new Object[] {THREE, FOUR, ONE, TWO};
mk = new MultiKey(keys);
Assert.assertTrue(Arrays.equals(new Object[] {THREE, FOUR, ONE, TWO}, mk.getKeys()));
keys[3] = FIVE; // no effect
Assert.assertTrue(Arrays.equals(new Object[] {THREE, FOUR, ONE, TWO}, mk.getKeys()));
keys = new Object[] {};
mk = new MultiKey(keys);
Assert.assertTrue(Arrays.equals(new Object[] {}, mk.getKeys()));
keys = new Object[] {THREE, FOUR, ONE, TWO};
mk = new MultiKey(keys, true);
Assert.assertTrue(Arrays.equals(new Object[] {THREE, FOUR, ONE, TWO}, mk.getKeys()));
keys[3] = FIVE; // no effect
Assert.assertTrue(Arrays.equals(new Object[] {THREE, FOUR, ONE, TWO}, mk.getKeys()));
keys = new Object[] {THREE, FOUR, ONE, TWO};
mk = new MultiKey(keys, false);
Assert.assertTrue(Arrays.equals(new Object[] {THREE, FOUR, ONE, TWO}, mk.getKeys()));
// change key - don't do this!
// the hashcode of the MultiKey is now broken
keys[3] = FIVE;
Assert.assertTrue(Arrays.equals(new Object[] {THREE, FOUR, ONE, FIVE}, mk.getKeys()));
}
代码示例来源:origin: commons-collections/commons-collections
public void testGetKeysArrayConstructorCloned() {
Object[] keys = new Object[] {ONE, TWO};
MultiKey mk = new MultiKey(keys, true);
Object[] array = mk.getKeys();
Assert.assertTrue(array != keys);
Assert.assertTrue(Arrays.equals(array, keys));
Assert.assertSame(ONE, array[0]);
Assert.assertSame(TWO, array[1]);
Assert.assertEquals(2, array.length);
}
代码示例来源:origin: commons-collections/commons-collections
public void testGetKeysArrayConstructorNonCloned() {
Object[] keys = new Object[] {ONE, TWO};
MultiKey mk = new MultiKey(keys, false);
Object[] array = mk.getKeys();
Assert.assertTrue(array != keys); // still not equal
Assert.assertTrue(Arrays.equals(array, keys));
Assert.assertSame(ONE, array[0]);
Assert.assertSame(TWO, array[1]);
Assert.assertEquals(2, array.length);
}
代码示例来源:origin: commons-collections/commons-collections
public void testGetKeysSimpleConstructor() {
MultiKey mk = new MultiKey(ONE, TWO);
Object[] array = mk.getKeys();
Assert.assertSame(ONE, array[0]);
Assert.assertSame(TWO, array[1]);
Assert.assertEquals(2, array.length);
}
代码示例来源:origin: SpoonLabs/astor
@SuppressWarnings("unchecked")
public void toJSON(String output) {
JSONObject space = new JSONObject();
JSONArray list = new JSONArray();
space.put("nrall", this.allElementsFromSpace.size());
space.put("space", list);
for (Object key : mkp.keySet()) {
JSONObject keyjson = new JSONObject();
MultiKey mk = (MultiKey) key;
keyjson.put("key", Arrays.toString(mk.getKeys()));
list.add(keyjson);
JSONArray ingredients = new JSONArray();
keyjson.put("ingredients", ingredients);
List ings = (List) mkp.get(key);
keyjson.put("nringredients", ings.size());
for (Object v : ings) {
ingredients.add(v.toString());
}
;
}
String fileName = output + "ingredients.json";
try (FileWriter file = new FileWriter(fileName)) {
file.write(space.toJSONString());
file.flush();
log.info("Storing ing JSON at " + fileName);
} catch (IOException e) {
e.printStackTrace();
log.error("Problem storing ing json file" + e.toString());
}
}
代码示例来源:origin: it.geosolutions.unredd/teststats
int newkeys = classes.getKeys().length-1;
Object subkeys[] = new Object[newkeys];
for (int i = 0; i < newkeys; i++) {
subkeys[i] = classes.getKeys()[i + (i>=index? 1:0)];
Double pivotKey = ((Number)classes.getKeys()[index]).doubleValue();
for (Object object : subKey.getKeys()) {
sb.append(object.toString()).append(cfg.getOutput().getSeparator());
代码示例来源:origin: it.geosolutions.unredd/teststats
for (Object o : classes.getKeys()) {
代码示例来源:origin: stackoverflow.com
MultiKeyMap multiKeyMap = new MultiKeyMap();
multiKeyMap.put("Key 1A","Key 1B","Value 1");
multiKeyMap.put("Key 2A","Key 2B","Value 2");
multiKeyMap.put("Key 3A","Key 3B","Value 3");
MapIterator it = multiKeyMap.mapIterator();
while (it.hasNext()) {
it.next();
MultiKey mk = (MultiKey) it.getKey();
// Option 1
System.out.println(mk.getKey(0));
System.out.println(mk.getKey(1));
// Option 2
for (Object subkey : mk.getKeys())
System.out.println(subkey);
System.out.println(it.getValue());
}
内容来源于网络,如有侵权,请联系作者删除!