本文整理汇总了Java中org.eclipse.californium.core.server.resources.Resource.add方法的典型用法代码示例。如果您正苦于以下问题:Java Resource.add方法的具体用法?Java Resource.add怎么用?Java Resource.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.californium.core.server.resources.Resource
的用法示例。
在下文中一共展示了Resource.add方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setName
import org.eclipse.californium.core.server.resources.Resource; //导入方法依赖的package包/类
public synchronized void setName(String name) {
if (name == null)
throw new NullPointerException();
String old = this.name;
// adjust parent if in tree
Resource parent = getParent();
if (parent!=null) {
synchronized (parent) {
parent.delete(this);
this.name = name;
parent.add(this);
}
} else {
this.name = name;
}
adjustChildrenPath();
for (ResourceObserver obs:observers)
obs.changedName(old);
}
示例2: addRec
import org.eclipse.californium.core.server.resources.Resource; //导入方法依赖的package包/类
protected void addRec(String path, Resource resource, Resource parent) {
for (Resource r : parent.getChildren()) {
if (path.contains(path(r))) {
addRec(path, resource, r);
return;
}
}
parent.add(resource);
}
示例3: doStart
import org.eclipse.californium.core.server.resources.Resource; //导入方法依赖的package包/类
@Override
protected void doStart() throws Exception {
super.doStart();
String path = endpoint.getUri().getPath();
if (path.startsWith("/")) {
path = path.substring(1);
}
Resource cr = endpoint.getCoapServer().getRoot();
while (!path.isEmpty()) {
int idx = path.indexOf('/');
String part1 = path;
if (idx != -1) {
part1 = path.substring(0, idx);
path = path.substring(idx + 1);
} else {
path = "";
}
Resource child = cr.getChild(part1);
if (child == null) {
child = new CamelCoapResource(part1, this);
cr.add(child);
cr = child;
} else if (path.isEmpty()) {
((CamelCoapResource)child).addConsumer(this);
} else {
cr = child;
}
}
}
示例4: NodeServer
import org.eclipse.californium.core.server.resources.Resource; //导入方法依赖的package包/类
public NodeServer(int node_nr) {
//this(node_nr.to);
//Integer.par
super("node_" + Integer.toString(node_nr));
Resource seg2 = new NodeServer("led");
Resource seg2_1 = new NodeServer("on");
Resource seg2_2 = new NodeServer("off");
add(seg2);
seg2.add(seg2_1);
seg2.add(seg2_2);
}