@Test public void testCreateScopePaths() { final Collection<String> paths = new LinkedList<String>(); paths.add(File.separator + "test" + File.separator + "userName-hugo" + File.separator + "admin" + File.separator + "hf.pdf"); paths.add(File.separator + "test" + File.separator + "userName-peter" + File.separator + "blxcvcvx" + File.separator + "test" + File.separator + "ggg.txt"); paths.add(File.separator + "component" + File.separator + "userName-hugo" + File.separator + "test.xml"); final Map<String, String> map = new TreeMap<String, String>(); map.put("userName", "hugo"); final Collection<ScopePath> scopePaths = gen.createScopePaths(paths, "test", map); for (final ScopePath scopePath : scopePaths) { Assert.assertTrue((scopePath.findScopeByName(ClassScopeDescriptor.NAME) != null) && (scopePath.findScopeByName(CodeDefaultScopeDescriptor.NAME) != null) && (scopePath.findScopeByName("test") != null)); } }
@Override public Collection<ScopePath> createScopePaths( final Collection<String> paths, final String scopeName, final Map<String, String> properties) { final InternalScopePathBuilderFactory factory = new InternalScopePathBuilderFactory(); ScopePathBuilder builder = factory.createBuilder(); final String searchedPathPart = buildScopeWithProperty(scopeName, properties); final Collection<String> matches = new LinkedList<String>(); final Collection<ScopePath> results = new LinkedList<ScopePath>(); for (final Object path : paths) { if (((String) path).contains(searchedPathPart)) { matches.add((String) path); } } for (final String path : matches) { createClassAndCodeDefaultScope(builder, path); String[] pathsWithScopeOrProperty; if (scopeSeparator.equals("\\")) { pathsWithScopeOrProperty = path.split(scopeSeparator + scopeSeparator); } else if (scopeSeparator.equals("/")) { pathsWithScopeOrProperty = path.split("/"); } else { throw new RuntimeException("Unknown file separator for path '" + path + "'!"); } for (int i = 0; i < pathsWithScopeOrProperty.length - 1; i++) { final String tmp = pathsWithScopeOrProperty[i]; if (tmp.length() == 0) { continue; } else { if (!tmp.contains(PATH_PROPERTY_SEPARATOR)) { final String tmpScopeName = tmp.substring(0, tmp.length()); builder.append(tmpScopeName, getProperties(pathsWithScopeOrProperty, builder, i)); } } } results.add(builder.create()); builder = factory.createBuilder(); } return results; }
DefaultScopePathGenerator implements ScopePathGenerator { @Override public Collection<ScopePath> createScopePaths( final Collection<String> paths, final String scopeName, final Map<String, String> properties) { final InternalScopePathBuilderFactory factory = new InternalScopePathBuilderFactory(); ScopePathBuilder builder = factory.createBuilder(); final String searchedPathPart = buildScopeWithProperty(scopeName, properties); final Collection<String> matches = new LinkedList<String>(); final Collection<ScopePath> results = new LinkedList<ScopePath>(); for (final Object path : paths) { if (((String) path).contains(searchedPathPart)) { matches.add((String) path); } } for (final String path : matches) { createClassAndCodeDefaultScope(builder, path); String[] pathsWithScopeOrProperty; if (scopeSeparator.equals("\\")) { pathsWithScopeOrProperty = path.split(scopeSeparator + scopeSeparator); } else if (scopeSeparator.equals("/")) { pathsWithScopeOrProperty = path.split("/"); } else { throw new RuntimeException("Unknown file separator for path '" + path + "'!"); } for (int i = 0; i < pathsWithScopeOrProperty.length - 1; i++) { final String tmp = pathsWithScopeOrProperty[i]; if (tmp.length() == 0) { continue; } else { if (!tmp.contains(PATH_PROPERTY_SEPARATOR)) { final String tmpScopeName = tmp.substring(0, tmp.length()); builder.append(tmpScopeName, getProperties(pathsWithScopeOrProperty, builder, i)); } } } results.add(builder.create()); builder = factory.createBuilder(); } return results; } }
DefaultScopePathGenerator implements ScopePathGenerator { @Override public Collection<ScopePath> createScopePaths( final Collection<String> paths, final String scopeName, final Map<String, String> properties) { final InternalScopePathBuilderFactory factory = new InternalScopePathBuilderFactory(); ScopePathBuilder builder = factory.createBuilder(); final String searchedPathPart = buildScopeWithProperty(scopeName, properties); final Collection<String> matches = new LinkedList<String>(); final Collection<ScopePath> results = new LinkedList<ScopePath>(); for (final Object path : paths) { if (((String) path).contains(searchedPathPart)) { matches.add((String) path); } } for (final String path : matches) { createClassAndCodeDefaultScope(builder, path); String[] pathsWithScopeOrProperty; if (scopeSeparator.equals("\\")) { pathsWithScopeOrProperty = path.split(scopeSeparator + scopeSeparator); } else if (scopeSeparator.equals("/")) { pathsWithScopeOrProperty = path.split("/"); } else { throw new RuntimeException("Unknown file separator for path '" + path + "'!"); } for (int i = 0; i < pathsWithScopeOrProperty.length - 1; i++) { final String tmp = pathsWithScopeOrProperty[i]; if (tmp.length() == 0) { continue; } else { if (!tmp.contains(PATH_PROPERTY_SEPARATOR)) { final String tmpScopeName = tmp.substring(0, tmp.length()); builder.append(tmpScopeName, getProperties(pathsWithScopeOrProperty, builder, i)); } } } results.add(builder.create()); builder = factory.createBuilder(); } return results; } DefaultScopePathGenerator(final String scopeSeparator); }
DefaultScopePathGenerator implements ScopePathGenerator { @Override public Collection<ScopePath> createScopePaths( final Collection<String> paths, final String scopeName, final Map<String, String> properties) { final InternalScopePathBuilderFactory factory = new InternalScopePathBuilderFactory(); ScopePathBuilder builder = factory.createBuilder(); final String searchedPathPart = buildScopeWithProperty(scopeName, properties); final Collection<String> matches = new LinkedList<String>(); final Collection<ScopePath> results = new LinkedList<ScopePath>(); for (final Object path : paths) { if (((String) path).contains(searchedPathPart)) { matches.add((String) path); } } for (final String path : matches) { createClassAndCodeDefaultScope(builder, path); String[] pathsWithScopeOrProperty; if (scopeSeparator.equals("\\")) { pathsWithScopeOrProperty = path.split(scopeSeparator + scopeSeparator); } else if (scopeSeparator.equals("/")) { pathsWithScopeOrProperty = path.split("/"); } else { throw new RuntimeException("Unknown file separator for path '" + path + "'!"); } for (int i = 0; i < pathsWithScopeOrProperty.length - 1; i++) { final String tmp = pathsWithScopeOrProperty[i]; if (tmp.length() == 0) { continue; } else { if (!tmp.contains(PATH_PROPERTY_SEPARATOR)) { final String tmpScopeName = tmp.substring(0, tmp.length()); builder.append(tmpScopeName, getProperties(pathsWithScopeOrProperty, builder, i)); } } } results.add(builder.create()); builder = factory.createBuilder(); } return results; } DefaultScopePathGenerator(final String scopeSeparator); @Override String createName(final ScopePath scopePath); @Override String getPathFromScopePath(final ScopePath scopePath); @Override String buildScopeWithProperty(final String scopeName, final Map<String, String> properties); @Override Collection<ScopePath> createScopePaths(
		final Collection<String> paths,
		final String scopeName,
		final Map<String, String> properties); }
DefaultScopePathGenerator implements ScopePathGenerator { @Override public Collection<ScopePath> createScopePaths( final Collection<String> paths, final String scopeName, final Map<String, String> properties) { final InternalScopePathBuilderFactory factory = new InternalScopePathBuilderFactory(); ScopePathBuilder builder = factory.createBuilder(); final String searchedPathPart = buildScopeWithProperty(scopeName, properties); final Collection<String> matches = new LinkedList<String>(); final Collection<ScopePath> results = new LinkedList<ScopePath>(); for (final Object path : paths) { if (((String) path).contains(searchedPathPart)) { matches.add((String) path); } } for (final String path : matches) { createClassAndCodeDefaultScope(builder, path); String[] pathsWithScopeOrProperty; if (scopeSeparator.equals("\\")) { pathsWithScopeOrProperty = path.split(scopeSeparator + scopeSeparator); } else if (scopeSeparator.equals("/")) { pathsWithScopeOrProperty = path.split("/"); } else { throw new RuntimeException("Unknown file separator for path '" + path + "'!"); } for (int i = 0; i < pathsWithScopeOrProperty.length - 1; i++) { final String tmp = pathsWithScopeOrProperty[i]; if (tmp.length() == 0) { continue; } else { if (!tmp.contains(PATH_PROPERTY_SEPARATOR)) { final String tmpScopeName = tmp.substring(0, tmp.length()); builder.append(tmpScopeName, getProperties(pathsWithScopeOrProperty, builder, i)); } } } results.add(builder.create()); builder = factory.createBuilder(); } return results; } DefaultScopePathGenerator(final String scopeSeparator); @Override String createName(final ScopePath scopePath); @Override String getPathFromScopePath(final ScopePath scopePath); @Override String buildScopeWithProperty(final String scopeName, final Map<String, String> properties); @Override Collection<ScopePath> createScopePaths(
		final Collection<String> paths,
		final String scopeName,
		final Map<String, String> properties); static final String PATH_PROPERTY_SEPARATOR; }