本文整理汇总了Java中org.jgroups.util.Util.components方法的典型用法代码示例。如果您正苦于以下问题:Java Util.components方法的具体用法?Java Util.components怎么用?Java Util.components使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jgroups.util.Util
的用法示例。
在下文中一共展示了Util.components方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isChildOf
import org.jgroups.util.Util; //导入方法依赖的package包/类
/**
* Verifies whether child is a child (dir or file) of parent
* @param parent
* @param child
* @return True if child is a child, false otherwise
*/
protected static boolean isChildOf(String parent, String child) {
if(parent == null || child == null)
return false;
if(!child.startsWith(parent))
return false;
if(child.length() <= parent.length())
return false;
int from=parent.equals(File.separator)? parent.length() : parent.length() +1;
// if(from-1 > child.length())
// return false;
String[] comps=Util.components(child.substring(from), File.separator);
return comps != null && comps.length <= 1;
}
示例2: checkParentDirs
import org.jgroups.util.Util; //导入方法依赖的package包/类
/**
* Checks whether the parent directories are present (and are directories). If create_if_absent is true,
* creates missing dirs
* @param path
* @param create_if_absent
* @return
*/
protected boolean checkParentDirs(String path, boolean create_if_absent) throws IOException {
String[] components=Util.components(path, File.separator);
if(components == null)
return false;
if(components.length == 1) // no parent directories to create, e.g. "data.txt"
return true;
StringBuilder sb=new StringBuilder();
boolean first=true;
for(int i=0; i < components.length-1; i++) {
String tmp=components[i];
if(!tmp.equals(File.separator)) {
if(first)
first=false;
else
sb.append(File.separator);
}
sb.append(tmp);
String comp=sb.toString();
if(exists(comp)) {
if(isFile(comp))
throw new IOException("cannot create " + path + " as component " + comp + " is a file");
}
else {
if(create_if_absent)
cache.put(comp, new Metadata(0, System.currentTimeMillis(), chunk_size, Metadata.DIR), (short)-1, 0);
else
return false;
}
}
return true;
}
示例3: trim
import org.jgroups.util.Util; //导入方法依赖的package包/类
protected static String trim(String str) {
if(str == null) return null;
str=str.trim();
if(str.equals(File.separator))
return str;
String[] comps=Util.components(str, File.separator);
return comps != null && comps.length > 0? comps[comps.length-1] : null;
}
示例4: filename
import org.jgroups.util.Util; //导入方法依赖的package包/类
protected static String filename(String full_path) {
String[] comps=Util.components(full_path, File.separator);
return comps != null? comps[comps.length -1] : null;
}