1 /*
2  * Copyright 2008-2019 by Emeric Vernat
3  *
4  *     This file is part of Java Melody.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *     http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18 package net.bull.javamelody.internal.common;
19
20 import javax.servlet.http.HttpServletRequest;
21
22 /**
23  * Enumération des valeurs pour le paramètre "part" dans les requêtes http.
24  * @author Emeric Vernat
25  */

26 public enum HttpPart {
27     HEAP_HISTO("heaphisto"),
28     PROCESSES("processes"),
29     CURRENT_REQUESTS("currentRequests"),
30     DEFAULT_WITH_CURRENT_REQUESTS("defaultWithCurrentRequests"),
31     WEB_XML("web.xml"),
32     POM_XML("pom.xml"),
33     JNLP("jnlp"),
34     JVM("jvm"),
35     SESSIONS("sessions"),
36     HOTSPOTS("hotspots"),
37     DATABASE("database"),
38     CONNECTIONS("connections"),
39     GRAPH("graph"),
40     LAST_VALUE("lastValue"),
41     USAGES("usages"),
42     JNDI("jndi"),
43     MBEANS("mbeans"),
44     CRASHES("crashes"),
45     THREADS("threads"),
46     THREADS_DUMP("threadsDump"),
47     COUNTER_SUMMARY_PER_CLASS("counterSummaryPerClass"),
48     RUNTIME_DEPENDENCIES("runtimeDependencies"),
49     JROBINS("jrobins"),
50     OTHER_JROBINS("otherJRobins"),
51     EXPLAIN_PLAN("explainPlan"),
52     APPLICATIONS("applications"),
53     SOURCE("source"),
54     DEPENDENCIES("dependencies"),
55     SPRING_BEANS("springBeans"),
56     RUM("rum"),
57     WEBAPP_VERSIONS("webappVersions"),
58     CACHE_KEYS("cacheKeys"),
59     JCACHE_KEYS("jcacheKeys"),
60     HASH_PASSWORD("hashPassword");
61
62     private final String name;
63
64     HttpPart(String name) {
65         this.name = name;
66     }
67
68     public boolean isPart(HttpServletRequest request) {
69         return name.equals(HttpParameter.PART.getParameterFrom(request));
70     }
71
72     public String getName() {
73         return name;
74     }
75
76     @Override
77     public String toString() {
78         return name;
79     }
80
81     public static HttpPart getByName(String name) {
82         for (final HttpPart httpPart : values()) {
83             if (httpPart.name.equals(name)) {
84                 return httpPart;
85             }
86         }
87         throw new IllegalArgumentException("Unknown part: " + name);
88     }
89 }
90