Values.java
1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* javax.jcr.Node
* javax.jcr.Property
* javax.jcr.RepositoryException
* javax.jcr.Value
* javax.jcr.nodetype.NodeType
*/
package com.day.crx.explorer.impl.util;
import javax.jcr.Node;
import javax.jcr.Property;
import javax.jcr.RepositoryException;
import javax.jcr.Value;
import javax.jcr.nodetype.NodeType;
public class Values {
public static final Value[] EMPTY_VALUES = new Value[0];
public static String[] getNames(NodeType[] nodeTypes) {
String[] ret = new String[nodeTypes.length];
for (int i = 0; i < nodeTypes.length; ++i) {
ret[i] = nodeTypes[i].getName();
}
return ret;
}
public static String getProperty(Node node, String name, String def) throws RepositoryException {
return node != null && node.hasProperty(name) ? node.getProperty(name).getString() : def;
}
public static String[] getProperty(Node node, String name, String[] def) throws RepositoryException {
if (node == null || !node.hasProperty(name)) {
return def;
}
Value[] values = node.getProperty(name).getValues();
String[] ret = new String[values.length];
for (int i = 0; i < ret.length; ++i) {
ret[i] = values[i].getString();
}
return ret;
}
public static boolean getProperty(Node node, String name, boolean def) throws RepositoryException {
return node != null && node.hasProperty(name) ? node.getProperty(name).getBoolean() : def;
}
}