本文整理汇总了Java中org.red5.server.api.scope.IScope.getParent方法的典型用法代码示例。如果您正苦于以下问题:Java IScope.getParent方法的具体用法?Java IScope.getParent怎么用?Java IScope.getParent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.red5.server.api.scope.IScope
的用法示例。
在下文中一共展示了IScope.getParent方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resolveScope
import org.red5.server.api.scope.IScope; //导入方法依赖的package包/类
/**
* Resolves scope for specified scope and path.
*
* @param from
* Scope to use as context (to start from)
* @param path
* Path to resolve
* @return Resolved scope
*/
public static IScope resolveScope(IScope from, String path) {
log.debug("resolveScope from: {} path: {}", from.getName(), path);
IScope current = from;
if (path.startsWith(SLASH)) {
current = ScopeUtils.findRoot(current);
path = path.substring(1, path.length());
}
if (path.endsWith(SLASH)) {
path = path.substring(0, path.length() - 1);
}
log.trace("Current: {}", current);
String[] parts = path.split(SLASH);
if (log.isTraceEnabled()) {
log.trace("Parts: {}", Arrays.toString(parts));
}
for (String part : parts) {
log.trace("Part: {}", part);
if (part.equals(".")) {
continue;
}
if (part.equals("..")) {
if (!current.hasParent()) {
return null;
}
current = current.getParent();
continue;
}
if (!current.hasChildScope(part)) {
return null;
}
current = current.getScope(part);
log.trace("Current: {}", current);
}
return current;
}
示例2: findRoot
import org.red5.server.api.scope.IScope; //导入方法依赖的package包/类
/**
* Finds root scope for specified scope object. Root scope is the top level scope among scope's parents.
*
* @param from
* Scope to find root for
* @return Root scope object
*/
public static IScope findRoot(IScope from) {
IScope current = from;
while (current.hasParent()) {
current = current.getParent();
}
return current;
}
示例3: getStreamDirectory
import org.red5.server.api.scope.IScope; //导入方法依赖的package包/类
/**
* Generate stream directory based on relative scope path. The base directory is
*
* <pre>
* streams
* </pre>
*
* , e.g. a scope
*
* <pre>
* /application/one/two/
* </pre>
*
* will generate a directory
*
* <pre>
* /streams/one/two/
* </pre>
*
* inside the application.
*
* @param scope
* Scope
* @return Directory based on relative scope path
*/
private String getStreamDirectory(IScope scope) {
final StringBuilder result = new StringBuilder();
final IScope app = ScopeUtils.findApplication(scope);
final String prefix = "streams/";
while (scope != null && scope != app) {
result.insert(0, scope.getName() + "/");
scope = scope.getParent();
}
if (result.length() == 0) {
return prefix;
} else {
result.insert(0, prefix).append('/');
return result.toString();
}
}
示例4: findApplication
import org.red5.server.api.scope.IScope; //导入方法依赖的package包/类
/**
* Returns the application scope for specified scope. Application scope has depth of 1 and has no parent.
*
* See
*
* <pre>
* isApp
* </pre>
*
* method for details.
*
* @param from
* Scope to find application for
* @return Application scope.
*/
public static IScope findApplication(IScope from) {
IScope current = from;
while (current.hasParent() && !current.getType().equals(ScopeType.APPLICATION)) {
current = current.getParent();
}
return current;
}