1 | |
package org.apache.maven.index.treeview; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
import java.util.HashMap; |
23 | |
import java.util.Map; |
24 | |
|
25 | |
import org.apache.maven.index.ArtifactInfoFilter; |
26 | |
import org.apache.maven.index.Field; |
27 | |
import org.apache.maven.index.MAVEN; |
28 | |
import org.apache.maven.index.context.IndexingContext; |
29 | |
|
30 | |
public class TreeViewRequest |
31 | |
{ |
32 | |
private final TreeNodeFactory factory; |
33 | |
|
34 | |
private final String path; |
35 | |
|
36 | |
private final ArtifactInfoFilter artifactInfoFilter; |
37 | |
|
38 | |
private final Map<Field, String> fieldHints; |
39 | |
|
40 | |
private final IndexingContext indexingContext; |
41 | |
|
42 | |
public TreeViewRequest( final TreeNodeFactory factory, final String path, final IndexingContext ctx ) |
43 | |
{ |
44 | 5 | this( factory, path, null, null, ctx ); |
45 | 5 | } |
46 | |
|
47 | |
public TreeViewRequest( final TreeNodeFactory factory, final String path, final Map<Field, String> hints, |
48 | |
final ArtifactInfoFilter artifactInfoFilter, final IndexingContext ctx ) |
49 | 47 | { |
50 | 47 | this.factory = factory; |
51 | |
|
52 | 47 | this.path = path; |
53 | |
|
54 | 47 | this.fieldHints = new HashMap<Field, String>(); |
55 | |
|
56 | 47 | if ( hints != null && hints.size() != 0 ) |
57 | |
{ |
58 | 0 | this.fieldHints.putAll( hints ); |
59 | |
} |
60 | |
|
61 | 47 | this.artifactInfoFilter = artifactInfoFilter; |
62 | |
|
63 | 47 | this.indexingContext = ctx; |
64 | 47 | } |
65 | |
|
66 | |
public TreeNodeFactory getFactory() |
67 | |
{ |
68 | 301 | return factory; |
69 | |
} |
70 | |
|
71 | |
public String getPath() |
72 | |
{ |
73 | 291 | return path; |
74 | |
} |
75 | |
|
76 | |
public ArtifactInfoFilter getArtifactInfoFilter() |
77 | |
{ |
78 | 113 | return artifactInfoFilter; |
79 | |
} |
80 | |
|
81 | |
public void addFieldHint( Field field, String hint ) |
82 | |
{ |
83 | 0 | fieldHints.put( field, hint ); |
84 | 0 | } |
85 | |
|
86 | |
public void removeFieldHint( Field field ) |
87 | |
{ |
88 | 0 | fieldHints.remove( field ); |
89 | 0 | } |
90 | |
|
91 | |
public boolean hasFieldHints() |
92 | |
{ |
93 | 139 | return fieldHints.size() > 0 && ( hasFieldHint( MAVEN.GROUP_ID ) ); |
94 | |
} |
95 | |
|
96 | |
public boolean hasFieldHint( Field... fields ) |
97 | |
{ |
98 | 0 | for ( Field f : fields ) |
99 | |
{ |
100 | 0 | if ( !fieldHints.containsKey( f ) ) |
101 | |
{ |
102 | 0 | return false; |
103 | |
} |
104 | |
} |
105 | |
|
106 | 0 | return true; |
107 | |
} |
108 | |
|
109 | |
public String getFieldHint( Field field ) |
110 | |
{ |
111 | 0 | return fieldHints.get( field ); |
112 | |
} |
113 | |
|
114 | |
public Map<Field, String> getFieldHints() |
115 | |
{ |
116 | 42 | return fieldHints; |
117 | |
} |
118 | |
|
119 | |
public IndexingContext getIndexingContext() |
120 | |
{ |
121 | 160 | return indexingContext; |
122 | |
} |
123 | |
} |