public class DependencyGraphParser extends Object
[level]dependencyDefinition[;key=value;key=value;...]A
dependencyDefinition
is of the form:
(id|[(id)]gid:aid:ext:ver[:scope])It may also be
(null)
to indicate an "empty" node with no dependency.
If level
is empty, the line defines the root node. Only one root node may be defined. The level is
calculated by the distance from the beginning of the line. One level is three characters. A level definition has to
follow this format:
'[| ]*[+\\]- '
'[0-9a-zA-Z]+'To define a node with an ID, prefix the definition with an id in parens:
(id)gid:aid:ext:verTo insert a previously defined node into the graph, use a caret followed by the ID:
^id
A hash starts a comment. A comment ends with the end of the line. Empty lines are ignored.
gid:aid:ext:ver +- gid:aid2:ext:ver:scope | \- (id1)gid:aid3:ext:ver +- gid:aid4:ext:ver:scope \- ^id1
By using parseMultiple(String)
, definitions divided by a line beginning with "---" can be read from the same
resource. The rest of the line is ignored.
You may define substitutions (see setSubstitutions(String...)
,
DependencyGraphParser(String, Collection)
). Every '%s' in the definition will be substituted by the next
String in the defined substitutions.
parser.setSubstitutions( "foo", "bar" ); String def = "gid:%s:ext:ver\n" + "+- gid:%s:ext:ver";The first node will have "foo" as its artifact id, the second node (child to the first) will have "bar" as its artifact id.
Constructor and Description |
---|
DependencyGraphParser()
Create a parser with an empty prefix.
|
DependencyGraphParser(String prefix)
Create a parser with the given prefix.
|
DependencyGraphParser(String prefix,
Collection<String> substitutions)
Create a parser with the given prefix and the given substitution strings.
|
Modifier and Type | Method and Description |
---|---|
String |
dump(DependencyNode root) |
Collection<String> |
getSubstitutions() |
DependencyNode |
parse(String resource)
Parse the graph definition read from the given resource.
|
DependencyNode |
parse(URL resource)
Parse the graph definition read from the given URL.
|
DependencyNode |
parseLiteral(String dependencyGraph)
Parse the given graph definition.
|
List<DependencyNode> |
parseMultiple(String resource)
Parse multiple graphs in one resource, divided by "---".
|
void |
setSubstitutions(Collection<String> substitutions) |
void |
setSubstitutions(String... substitutions) |
public DependencyGraphParser(String prefix, Collection<String> substitutions)
parse(String)
public DependencyGraphParser(String prefix)
parse(String)
public DependencyGraphParser()
public DependencyNode parseLiteral(String dependencyGraph) throws IOException
IOException
public DependencyNode parse(String resource) throws IOException
IOException
public List<DependencyNode> parseMultiple(String resource) throws IOException
IOException
public DependencyNode parse(URL resource) throws IOException
IOException
public String dump(DependencyNode root)
public Collection<String> getSubstitutions()
public void setSubstitutions(Collection<String> substitutions)
public void setSubstitutions(String... substitutions)
Copyright © 2010-2012 Sonatype, Inc.. All Rights Reserved.