List of usage examples for java.util HashMap keySet
public Set<K> keySet()
From source file:com.github.ignition.support.http.HttpGet.java
HttpGet(IgnitedHttp ignitedHttp, String url, HashMap<String, String> defaultHeaders) { super(ignitedHttp); request = new org.apache.http.client.methods.HttpGet(url); for (String header : defaultHeaders.keySet()) { request.setHeader(header, defaultHeaders.get(header)); }/*from w w w. ja v a2s .c o m*/ }
From source file:com.aspire.mandou.framework.http.HttpGet.java
HttpGet(AbstractHttpClient httpClient, String url, HashMap<String, String> defaultHeaders) { super(httpClient); request = new org.apache.http.client.methods.HttpGet(url); for (String header : defaultHeaders.keySet()) { request.setHeader(header, defaultHeaders.get(header)); }// w ww . j a v a 2 s.c o m }
From source file:com.actionbarsherlock.ActionBarSherlock.java
/** * Wrap an activity with an action bar abstraction which will enable the * use of a custom implementation on platforms where a native version does * not exist.//w w w. j a v a 2 s. c om * * @param activity Owning activity. * @param flags Option flags to control behavior. * @return Instance to interact with the action bar. */ public static ActionBarSherlock wrap(Activity activity, int flags) { //Create a local implementation map we can modify HashMap<Implementation, Class<? extends ActionBarSherlock>> impls = new HashMap<Implementation, Class<? extends ActionBarSherlock>>( IMPLEMENTATIONS); boolean hasQualfier; /* DPI FILTERING */ hasQualfier = false; for (Implementation key : impls.keySet()) { //Only honor TVDPI as a specific qualifier if (key.dpi() == DisplayMetrics.DENSITY_TV) { hasQualfier = true; break; } } if (hasQualfier) { final boolean isTvDpi = activity.getResources() .getDisplayMetrics().densityDpi == DisplayMetrics.DENSITY_TV; for (Iterator<Implementation> keys = impls.keySet().iterator(); keys.hasNext();) { int keyDpi = keys.next().dpi(); if ((isTvDpi && keyDpi != DisplayMetrics.DENSITY_TV) || (!isTvDpi && keyDpi == DisplayMetrics.DENSITY_TV)) { keys.remove(); } } } /* API FILTERING */ hasQualfier = false; for (Implementation key : impls.keySet()) { if (key.api() != Implementation.DEFAULT_API) { hasQualfier = true; break; } } if (hasQualfier) { final int runtimeApi = Build.VERSION.SDK_INT; int bestApi = 0; for (Iterator<Implementation> keys = impls.keySet().iterator(); keys.hasNext();) { int keyApi = keys.next().api(); if (keyApi > runtimeApi) { keys.remove(); } else if (keyApi > bestApi) { bestApi = keyApi; } } for (Iterator<Implementation> keys = impls.keySet().iterator(); keys.hasNext();) { if (keys.next().api() != bestApi) { keys.remove(); } } } if (impls.size() > 1) { throw new IllegalStateException("More than one implementation matches configuration."); } if (impls.isEmpty()) { throw new IllegalStateException("No implementations match configuration."); } Class<? extends ActionBarSherlock> impl = impls.values().iterator().next(); if (DEBUG) Log.i(TAG, "Using implementation: " + impl.getSimpleName()); try { Constructor<? extends ActionBarSherlock> ctor = impl.getConstructor(CONSTRUCTOR_ARGS); return ctor.newInstance(activity, flags); } catch (NoSuchMethodException e) { throw new RuntimeException(e); } catch (IllegalArgumentException e) { throw new RuntimeException(e); } catch (InstantiationException e) { throw new RuntimeException(e); } catch (IllegalAccessException e) { throw new RuntimeException(e); } catch (InvocationTargetException e) { throw new RuntimeException(e); } }
From source file:gui.statistics.PieChartTest.java
/** * Creates new form PieChartTest//from w w w. j av a 2 s . co m */ public PieChartTest(java.awt.Frame parent, boolean modal) { super(parent, modal); initComponents(); Date a = new Date(2014 - 1900, 11, 1); Date b = new Date(2014 - 1900, 11, 31); DefaultPieDataset data = new DefaultPieDataset(); HashMap<String, BigDecimal> map = Database.getInstance().getTotalExpensesByCategory(a, b); for (String key : map.keySet()) { data.setValue(key, map.get(key).doubleValue()); } JFreeChart pieChart = ChartFactory.createPieChart("PIE CHART", data, true, false, Locale.GERMAN); PiePlot plot = (PiePlot) pieChart.getPlot(); plot.setLabelGenerator(null); BufferedImage pie = pieChart.createBufferedImage(500, 400); setSize(600, 500); jLabel1.setIcon(new ImageIcon(pie)); }
From source file:com.github.droidfu.http.HttpGet.java
HttpGet(AbstractHttpClient httpClient, String url, String host, HashMap<String, String> defaultHeaders) { super(httpClient); request = new org.apache.http.client.methods.HttpGet(url); for (String header : defaultHeaders.keySet()) { request.setHeader(header, defaultHeaders.get(header)); }//from w w w .j a v a 2 s.c om request.setHeader("Host", host); }
From source file:com.github.ignition.support.http.HttpDelete.java
HttpDelete(IgnitedHttp ignitedHttp, String url, HashMap<String, String> defaultHeaders) { super(ignitedHttp); request = new org.apache.http.client.methods.HttpDelete(url); for (String header : defaultHeaders.keySet()) { request.setHeader(header, defaultHeaders.get(header)); }/*from ww w . j a v a 2s . c om*/ }
From source file:com.github.ignition.support.http.IgnitedHttpDelete.java
IgnitedHttpDelete(IgnitedHttpClient ignitedHttp, String url, HashMap<String, String> defaultHeaders) { super(ignitedHttp); request = new org.apache.http.client.methods.HttpDelete(url); for (String header : defaultHeaders.keySet()) { request.setHeader(header, defaultHeaders.get(header)); }/* w w w . j av a 2 s.c om*/ }
From source file:cn.vlabs.duckling.vwb.FetchToSession.java
public void fetchToPortal(HttpSession session, SiteSessionImpl siteSession) { HashMap<String, String> params = getSavedParams(session); for (String param : params.keySet()) { siteSession.setAttribute(param, params.get(param)); }//from ww w .j a va 2 s . c o m }
From source file:com.fatminds.cmis.AlfrescoCmisHelper.java
public static JsonNode getJsonNodeFromHttpGetResponse(String proto, String host, int port, String user, String pass, String path, HashMap params) throws ClientProtocolException, IOException { DefaultHttpClient client = new DefaultHttpClient(); try {/*from w w w .j av a 2 s . co m*/ client.getCredentialsProvider().setCredentials(new AuthScope(host, port), new UsernamePasswordCredentials(user, pass)); String paramStr = ""; if (params != null && params.size() > 0) { Iterator<String> iter = params.keySet().iterator(); while (iter.hasNext()) { String key = iter.next(); //get.getParams().setParameter(key, params.get(key)); if (!paramStr.equals("")) { paramStr += "&"; } paramStr += key + "=" + params.get(key); } } if (!paramStr.equals("")) { path += "?" + URLEncoder.encode(paramStr, "UTF-8").replace("+", "%20"); } HttpGet get = new HttpGet(proto + host + ":" + port + path); log.info("Getting JsonNode for " + get.toString()); HttpResponse resp = client.execute(get); if (resp.getStatusLine().getStatusCode() != 200) { throw new RuntimeException( "Get failed, can't build JsonNode because: " + resp.getStatusLine().getReasonPhrase()); } org.apache.http.HttpEntity entity = resp.getEntity(); return mapper.readValue(entity.getContent(), JsonNode.class); } finally { client.getConnectionManager().shutdown(); } }
From source file:com.aspire.mandou.framework.http.HttpDelete.java
HttpDelete(AbstractHttpClient httpClient, String url, HashMap<String, String> defaultHeaders) { super(httpClient); request = new org.apache.http.client.methods.HttpDelete(url); for (String header : defaultHeaders.keySet()) { request.setHeader(header, defaultHeaders.get(header)); }/*from w w w.j a v a 2s. com*/ }