View Javadoc

1   package org.apache.maven.index.treeview;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0    
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
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 }