@Test public void testGetProject() { Project foo = new Project("Project foo", "/foo"); Project bar = new Project("Project foo-bar", "/foo-bar"); HashMap<String, Project> projects = new HashMap<>(); projects.put("foo", foo); projects.put("bar", bar); RuntimeEnvironment env = RuntimeEnvironment.getInstance(); env.setProjectsEnabled(true); env.setProjects(projects); assertEquals(foo, Project.getProject("/foo")); assertEquals(bar, Project.getProject("/foo-bar")); assertEquals(foo, Project.getProject("/foo/blah.c")); assertEquals(bar, Project.getProject("/foo-bar/ha.c")); assertNull(Project.getProject("/foof")); assertNull(Project.getProject("/foof/ha.c")); }
public static Project getProject(String path) { final RuntimeEnvironment env = RuntimeEnvironment.getInstance(); if (env.hasProjects()) { final String lpath = Util.fixPathIfWindows(path); for (Project p : env.getProjectList()) { String projectPath = p.getPath(); if (projectPath == null) { LOGGER.log(Level.WARNING, "Path of project {0} is not set", p.getName()); return null; } if (lpath.startsWith(projectPath) && (projectPath.length() == lpath.length() || lpath.charAt(projectPath.length()) == '/')) { return p; } } } return null; }
Project implements Comparable<Project>, Nameable, Serializable { public static Project getProject(String path) { final RuntimeEnvironment env = RuntimeEnvironment.getInstance(); if (env.hasProjects()) { final String lpath = Util.fixPathIfWindows(path); for (Project p : env.getProjectList()) { String projectPath = p.getPath(); if (projectPath == null) { LOGGER.log(Level.WARNING, "Path of project {0} is not set", p.getName()); return null; } if (lpath.startsWith(projectPath) && (projectPath.length() == lpath.length() || lpath.charAt(projectPath.length()) == '/')) { return p; } } } return null; } }
Project implements Comparable<Project>, Nameable, Serializable { public static Project getProject(String path) { final RuntimeEnvironment env = RuntimeEnvironment.getInstance(); if (env.hasProjects()) { final String lpath = Util.fixPathIfWindows(path); for (Project p : env.getProjectList()) { String projectPath = p.getPath(); if (projectPath == null) { LOGGER.log(Level.WARNING, "Path of project {0} is not set", p.getName()); return null; } if (lpath.startsWith(projectPath) && (projectPath.length() == lpath.length() || lpath.charAt(projectPath.length()) == '/')) { return p; } } } return null; } Project();  Project(String name);  Project(String name, String path); }
Project implements Comparable<Project>, Nameable, Serializable { public static Project getProject(String path) { final RuntimeEnvironment env = RuntimeEnvironment.getInstance(); if (env.hasProjects()) { final String lpath = Util.fixPathIfWindows(path); for (Project p : env.getProjectList()) { String projectPath = p.getPath(); if (projectPath == null) { LOGGER.log(Level.WARNING, "Path of project {0} is not set", p.getName()); return null; } if (lpath.startsWith(projectPath) && (projectPath.length() == lpath.length() || lpath.charAt(projectPath.length()) == '/')) { return p; } } } return null; } Project();  Project(String name);  Project(String name, String path); @Override String getName(); String getPath(); boolean isIndexed(); String getId(); int getTabSize(); @Override void setName(String name); void setPath(String path); void setIndexed(boolean flag); void setTabSize(int tabSize); boolean hasTabSizeSetting(); boolean isNavigateWindowEnabled(); void setNavigateWindowEnabled(boolean navigateWindowEnabled); boolean isHandleRenamedFiles(); void setHandleRenamedFiles(boolean flag); boolean isHistoryEnabled(); void setHistoryEnabled(boolean flag); Set<Group> getGroups(); void setGroups(Set<Group> groups); void addGroup(Group group); final void completeWithDefaults(); static Project getProject(String path); static Project getProject(File file); static Project getByName(String name); @Override int compareTo(Project p2); @Override int hashCode(); @Override boolean equals(Object obj); }
Project implements Comparable<Project>, Nameable, Serializable { public static Project getProject(String path) { final RuntimeEnvironment env = RuntimeEnvironment.getInstance(); if (env.hasProjects()) { final String lpath = Util.fixPathIfWindows(path); for (Project p : env.getProjectList()) { String projectPath = p.getPath(); if (projectPath == null) { LOGGER.log(Level.WARNING, "Path of project {0} is not set", p.getName()); return null; } if (lpath.startsWith(projectPath) && (projectPath.length() == lpath.length() || lpath.charAt(projectPath.length()) == '/')) { return p; } } } return null; } Project();  Project(String name);  Project(String name, String path); @Override String getName(); String getPath(); boolean isIndexed(); String getId(); int getTabSize(); @Override void setName(String name); void setPath(String path); void setIndexed(boolean flag); void setTabSize(int tabSize); boolean hasTabSizeSetting(); boolean isNavigateWindowEnabled(); void setNavigateWindowEnabled(boolean navigateWindowEnabled); boolean isHandleRenamedFiles(); void setHandleRenamedFiles(boolean flag); boolean isHistoryEnabled(); void setHistoryEnabled(boolean flag); Set<Group> getGroups(); void setGroups(Set<Group> groups); void addGroup(Group group); final void completeWithDefaults(); static Project getProject(String path); static Project getProject(File file); static Project getByName(String name); @Override int compareTo(Project p2); @Override int hashCode(); @Override boolean equals(Object obj);  }