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 this( factory, path, null, null, ctx );
45 }
46
47 public TreeViewRequest( final TreeNodeFactory factory, final String path, final Map<Field, String> hints,
48 final ArtifactInfoFilter artifactInfoFilter, final IndexingContext ctx )
49 {
50 this.factory = factory;
51
52 this.path = path;
53
54 this.fieldHints = new HashMap<Field, String>();
55
56 if ( hints != null && hints.size() != 0 )
57 {
58 this.fieldHints.putAll( hints );
59 }
60
61 this.artifactInfoFilter = artifactInfoFilter;
62
63 this.indexingContext = ctx;
64 }
65
66 public TreeNodeFactory getFactory()
67 {
68 return factory;
69 }
70
71 public String getPath()
72 {
73 return path;
74 }
75
76 public ArtifactInfoFilter getArtifactInfoFilter()
77 {
78 return artifactInfoFilter;
79 }
80
81 public void addFieldHint( Field field, String hint )
82 {
83 fieldHints.put( field, hint );
84 }
85
86 public void removeFieldHint( Field field )
87 {
88 fieldHints.remove( field );
89 }
90
91 public boolean hasFieldHints()
92 {
93 return fieldHints.size() > 0 && ( hasFieldHint( MAVEN.GROUP_ID ) );
94 }
95
96 public boolean hasFieldHint( Field... fields )
97 {
98 for ( Field f : fields )
99 {
100 if ( !fieldHints.containsKey( f ) )
101 {
102 return false;
103 }
104 }
105
106 return true;
107 }
108
109 public String getFieldHint( Field field )
110 {
111 return fieldHints.get( field );
112 }
113
114 public Map<Field, String> getFieldHints()
115 {
116 return fieldHints;
117 }
118
119 public IndexingContext getIndexingContext()
120 {
121 return indexingContext;
122 }
123 }