本文整理了Java中org.ogema.core.model.Resource.isTopLevel
方法的一些代码示例,展示了Resource.isTopLevel
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Resource.isTopLevel
方法的具体详情如下:
包路径:org.ogema.core.model.Resource
类名称:Resource
方法名:isTopLevel
暂无
代码示例来源:origin: org.ogema.widgets/widget-extended
public void setResource(Resource resource, Class<?> targetType) {
if (resource != null && targetType == null)
targetType = resource.getResourceType();
if (resource != null && resource.isTopLevel())
throw new IllegalArgumentException("Cannot set a toplevel resource as a reference.");
if (targetType != null && !Resource.class.isAssignableFrom(targetType) && !ResourcePattern.class.isAssignableFrom(targetType))
throw new IllegalArgumentException("Class must be either a resource type or resource pattern type");
this.resource = resource;
this.type = targetType;
}
代码示例来源:origin: org.ogema.tools/resource-utils
/**
* Get top-level resource.
* @param resource
* not null
* @return top-level parent of resource, or resource itself if it is already top-level
* @throws SecurityException
* if the caller does not have the read permission for one of the parent resources
*/
public static Resource getToplevelResource(Resource resource) {
Objects.requireNonNull(resource);
while (!resource.isTopLevel()) {
resource = resource.getParent();
}
return resource;
}
代码示例来源:origin: org.ogema.drivers/homematic-xmlrpc-hl
public static Resource getToplevelResource(Resource r) {
Resource res = r.getLocationResource();
while(!res.isTopLevel()) {
res = res.getParent();
if(res == null) throw new IllegalStateException("This should never occur!");
}
return res;
}
代码示例来源:origin: org.ogema.ref-impl/resource-manager
public DeletionAction(Resource target, ResourceManagement rm) {
Objects.requireNonNull(target);
this.target = target;
this.rm = rm;
this.isTopLevel = target.isTopLevel();
if (isTopLevel) {
path = target.getPath();
type = target.getResourceType();
}
else {
path = null;
type = null;
}
}
代码示例来源:origin: org.ogema.widgets/widget-extended
private P getPattern(final String path, OgemaHttpRequest req) throws NoSuchMethodException, SecurityException,
InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
Resource res = AccessController.doPrivileged(new PrivilegedAction<Resource>() {
@Override
public Resource run() {
return am.getResourceAccess().getResource(path);
}
});
if (res == null)
throw new RuntimeException("Pattern resource is null... this should not happen;");
if (res.isTopLevel())
return am.getResourcePatternAccess().createResource(path, pattern);
else {
Resource parent = res.getParent();
return am.getResourcePatternAccess().addDecorator(parent, res.getName(), pattern);
}
}
代码示例来源:origin: org.ogema.tools/grafana-base
continue; // resource is not logged
if (parentClazz != null && (res.isTopLevel() || !res.getParent().getResourceType().equals(parentClazz)))
continue;
if (strictMode) {
代码示例来源:origin: org.ogema.tools/grafana-base
private String getDeviceLocation(String resLoc) {
Resource res = ra.getResource(resLoc);
if (res instanceof PhysicalElement) {
PhysicalElement device = (PhysicalElement) res;
// two possible ways to determine location of a device
if (device.location().exists() && device.location().room().exists()
&& device.location().room().name().exists()) {
return device.location().room().name().getValue();
}
Resource parent = device.getParent();
if (parent != null && parent.getSubResource("name") != null
&& (parent.getSubResource("name") instanceof StringResource)) {
return ((StringResource) parent.getSubResource("name")).getValue();
}
}
else if (res instanceof SingleValueResource) { // check whether parent has a location
if (!res.isTopLevel()) {
return getDeviceLocation(res.getParent().getLocation());
}
}
return null; // FIXME
}
内容来源于网络,如有侵权,请联系作者删除!