提交 f897cb53 编写于 作者: K Kohsuke Kawaguchi

consistent naming

上级 e05659d6
...@@ -2116,28 +2116,28 @@ public class Jenkins extends AbstractCIBase implements ModifiableItemGroup<TopLe ...@@ -2116,28 +2116,28 @@ public class Jenkins extends AbstractCIBase implements ModifiableItemGroup<TopLe
} }
/** /**
* Gets the item by its relative name from the given context * Gets the item by its path name from the given context
* *
* <h2>Relative Names</h2> * <h2>Path Names</h2>
* <p> * <p>
* If the name starts from '/', like "/foo/bar/zot", then it's interpreted as absolute. * If the name starts from '/', like "/foo/bar/zot", then it's interpreted as absolute.
* Otherwise, the name should be something like "../foo/bar" and it's interpreted like * Otherwise, the name should be something like "foo/bar" and it's interpreted like
* relative path name is, against the given context. * relative path name in the file system is, against the given context.
* *
* @param context * @param context
* null is interpreted as {@link Jenkins}. Base 'directory' of the interpretation. * null is interpreted as {@link Jenkins}. Base 'directory' of the interpretation.
* @since 1.406 * @since 1.406
*/ */
public Item getItem(String relativeName, ItemGroup context) { public Item getItem(String pathName, ItemGroup context) {
if (context==null) context = this; if (context==null) context = this;
if (relativeName==null) return null; if (pathName==null) return null;
if (relativeName.startsWith("/")) // absolute if (pathName.startsWith("/")) // absolute
return getItemByFullName(relativeName); return getItemByFullName(pathName);
Object/*Item|ItemGroup*/ ctx = context; Object/*Item|ItemGroup*/ ctx = context;
StringTokenizer tokens = new StringTokenizer(relativeName,"/"); StringTokenizer tokens = new StringTokenizer(pathName,"/");
while (tokens.hasMoreTokens()) { while (tokens.hasMoreTokens()) {
String s = tokens.nextToken(); String s = tokens.nextToken();
if (s.equals("..")) { if (s.equals("..")) {
...@@ -2168,22 +2168,22 @@ public class Jenkins extends AbstractCIBase implements ModifiableItemGroup<TopLe ...@@ -2168,22 +2168,22 @@ public class Jenkins extends AbstractCIBase implements ModifiableItemGroup<TopLe
return (Item)ctx; return (Item)ctx;
// fall back to the classic interpretation // fall back to the classic interpretation
return getItemByFullName(relativeName); return getItemByFullName(pathName);
} }
public final Item getItem(String relativeName, Item context) { public final Item getItem(String pathName, Item context) {
return getItem(relativeName,context!=null?context.getParent():null); return getItem(pathName,context!=null?context.getParent():null);
} }
public final <T extends Item> T getItem(String relativeName, ItemGroup context, Class<T> type) { public final <T extends Item> T getItem(String pathName, ItemGroup context, Class<T> type) {
Item r = getItem(relativeName, context); Item r = getItem(pathName, context);
if (type.isInstance(r)) if (type.isInstance(r))
return type.cast(r); return type.cast(r);
return null; return null;
} }
public final <T extends Item> T getItem(String relativeName, Item context, Class<T> type) { public final <T extends Item> T getItem(String pathName, Item context, Class<T> type) {
return getItem(relativeName,context!=null?context.getParent():null,type); return getItem(pathName,context!=null?context.getParent():null,type);
} }
public File getRootDirFor(TopLevelItem child) { public File getRootDirFor(TopLevelItem child) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册