PageRenderTime 29ms CodeModel.GetById 17ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 0ms

/facebook-java-api/src/main/java/com/google/code/facebookapi/Metric.java

http://facebook-java-api.googlecode.com/
Java | 195 lines | 59 code | 10 blank | 126 comment | 1 complexity | 11dff3dbea3292797e74b5a5ef031066 MD5 | raw file
  1package com.google.code.facebookapi;
  2
  3import java.util.HashMap;
  4import java.util.Map;
  5
  6/**
  7 * This class enumerates the various metrics that are available through the admin.getMetrics API call. Typically, you will pass a set containing the metrics you are
  8 * interested in to the API call.
  9 * 
 10 * See http://wiki.developers.facebook.com/index.php/Admin.getMetrics for details.
 11 */
 12public enum Metric {
 13	/**
 14	 * Daily active users for your app. For use with Admin.getDailyMetrics only.
 15	 */
 16	@Deprecated
 17	DAILY_ACTIVE_USERS("daily_active_users"),
 18	/**
 19	 * Active users for your app. For use with Admin.getMetrics only.
 20	 */
 21	ACTIVE_USERS("active_users"),
 22	/**
 23	 * Number of unique users adding your app.
 24	 */
 25	UNIQUE_ADDS("unique_adds"),
 26	/**
 27	 * Number of unique users removing your app.
 28	 */
 29	UNIQUE_REMOVES("unique_removes"),
 30	/**
 31	 * Number of unique users blocking your app.
 32	 */
 33	UNIQUE_BLOCKS("unique_blocks"),
 34	/**
 35	 * Number of unique users unblocking your app.
 36	 */
 37	UNIQUE_UNBLOCKS("unique_unblocks"),
 38	/**
 39	 * Number of API calls made by your app.
 40	 */
 41	API_CALLS("api_calls"),
 42	/**
 43	 * Number of users making API calls through your app.
 44	 */
 45	UNIQUE_API_CALLS("unique_api_calls"),
 46	/**
 47	 * Number of canvas page views.
 48	 */
 49	CANVAS_PAGE_VIEWS("canvas_page_views"),
 50	/**
 51	 * Number of unique users viewing your canvas page.
 52	 */
 53	UNIQUE_CANVAS_PAGE_VIEWS("unique_canvas_page_views"),
 54	/**
 55	 * Average time required to load your app's canvas page.
 56	 */
 57	REQUEST_TIME_AVG("canvas_http_request_time_avg"),
 58	/**
 59	 * Average time required to render your app's FBML.
 60	 */
 61	FBML_RENDER_TIME_AVG("canvas_fbml_render_time_avg"),
 62	/**
 63	 * Number of requests that timed out.
 64	 */
 65	REQUEST_TIMEOUT("canvas_page_views_http_code_0"),
 66	/**
 67	 * Number of requests, that returned http code 100.
 68	 */
 69	REQUEST_CONTINUE("canvas_page_views_http_code_100"),
 70	/**
 71	 * Number of requests that completed successfully.
 72	 */
 73	REQUEST_OK("canvas_page_views_http_code_200"),
 74	/**
 75	 * Number of requests that returned status 200, but with no data.
 76	 */
 77	REQUEST_OK_NO_DATA("canvas_page_views_http_code_200ND"),
 78	/**
 79	 * Number of requests that produced a status 301 error.
 80	 */
 81	REQUEST_ERROR_301("canvas_page_views_http_code_301"),
 82	/**
 83	 * Number of requests that produced a status 302 error.
 84	 */
 85	REQUEST_ERROR_302("canvas_page_views_http_code_302"),
 86	/**
 87	 * Number of requests that produced a status 303 error.
 88	 */
 89	REQUEST_ERROR_303("canvas_page_views_http_code_303"),
 90	/**
 91	 * Number of requests that produced a status 400 error.
 92	 */
 93	REQUEST_ERROR_400("canvas_page_views_http_code_400"),
 94	/**
 95	 * Number of requests that produced a status 401 error.
 96	 */
 97	REQUEST_ERROR_401("canvas_page_views_http_code_401"),
 98	/**
 99	 * Number of requests that produced a status 403 error.
100	 */
101	REQUEST_ERROR_403("canvas_page_views_http_code_403"),
102	/**
103	 * Number of requests that produced a status 404 error.
104	 */
105	REQUEST_ERROR_404("canvas_page_views_http_code_404"),
106	/**
107	 * Number of requests that produced a status 405 error.
108	 */
109	REQUEST_ERROR_405("canvas_page_views_http_code_405"),
110	/**
111	 * Number of requests that produced a status 413 error.
112	 */
113	REQUEST_ERROR_413("canvas_page_views_http_code_413"),
114	/**
115	 * Number of requests that produced a status 422 error.
116	 */
117	REQUEST_ERROR_422("canvas_page_views_http_code_422"),
118	/**
119	 * Number of requests that produced a status 500 error.
120	 */
121	REQUEST_ERROR_500("canvas_page_views_http_code_500"),
122	/**
123	 * Number of requests that produced a status 502 error.
124	 */
125	REQUEST_ERROR_502("canvas_page_views_http_code_502"),
126	/**
127	 * Number of requests that produced a status 503 error.
128	 */
129	REQUEST_ERROR_503("canvas_page_views_http_code_503"),
130	/**
131	 * Number of requests that produced a status 505 error.
132	 */
133	REQUEST_ERROR_505("canvas_page_views_http_code_505");
134
135	/**
136	 * Use in Admin.getMetrics calls to specify a daily time-period.
137	 */
138	public static final Long PERIOD_DAY = 86400l;
139	/**
140	 * Use in Admin.getMetrics calls to specify a weekly time-period.
141	 */
142	public static final Long PERIOD_WEEK = 604800l;
143	/**
144	 * Use in Admin.getMetrics calls to specify a monthly time-period.
145	 */
146	public static final Long PERIOD_MONTH = 2592000l;
147
148	private String name;
149
150	private Metric( String name ) {
151		this.name = name;
152	}
153
154	protected static final Map<String,Metric> METRIC_TABLE;
155	static {
156		METRIC_TABLE = new HashMap<String,Metric>();
157		for ( Metric metric : Metric.values() ) {
158			METRIC_TABLE.put( metric.getName(), metric );
159		}
160	}
161
162	/**
163	 * Get the name by which Facebook refers to this metric.
164	 * 
165	 * @return the Facebook-supplied name of this metric.
166	 */
167	public String getName() {
168		return this.name;
169	}
170
171	/**
172	 * Lookup a metric by name.
173	 * 
174	 * @param name
175	 *            the Facebook-supplied name of the metric to lookup, such as "daily_active_users".
176	 * 
177	 * @return the metric the corresponds to the supplied name, or null if none exists.
178	 */
179	public static Metric getMetric( String name ) {
180		return METRIC_TABLE.get( name );
181	}
182
183	/**
184	 * Lookup a metric by HTTP error code.
185	 * 
186	 * @param errorCode
187	 *            the code to get the metric for, such as 500, 404, 401, 200, etc..
188	 * 
189	 * @return the metric the corresponds to the supplied HTTP error-code, or null if none exists.
190	 */
191	public static Metric getErrorMetric( int errorCode ) {
192		return METRIC_TABLE.get( "canvas_page_views_http_code_" + Integer.toString( errorCode ) );
193	}
194
195}