/** * Adds a name value pair which represents a url connection request property. * For example, name could be "Content-Type" and the value could be * "application/x-www-form-urlencoded" */ public void addHeader(String name, String value) { Map<String, String> map = getHeaders(); if (map == null) { map = new HashMap<String, String>(); setHeaders(map); } map.put(name, value); }
@SuppressWarnings("unchecked") private Map<String, String> getParams() { return (Map)getValue(PARAMS); }
URL execURL = (URL)getValue(URL_CACHE); if (execURL == null && !"".equals(getURL())) { try { String url = getURL(); if (url.startsWith("http")) { execURL = new URL(url); } else { putValue(URL_CACHE, execURL); Set<String> headerNames = getHeaderNames(); if (headerNames != null && !headerNames.isEmpty()) { Iterator<String> iter = headerNames.iterator(); while (iter.hasNext()) { String name = (String)iter.next(); uc.setRequestProperty(name, getHeaderValue(name)); out.print(getPostData()); out.flush();
public static ServerAction createServerAction(String id, String name, String mnemonic) { ServerAction action = new ServerAction(name, id); if (mnemonic != null && !mnemonic.equals("")) { action.putValue(Action.MNEMONIC_KEY, new Integer(mnemonic.charAt(0))); } return action; }
/** * Retrieves a string which represents the parameter data for a server action. * @return a string of name value pairs prefixed by a '?' and delimited by an '&' */ private String getPostData() { // Write the data into local buffer StringBuffer postData = new StringBuffer(); // TODO: the action should be configured to retrieve the data. // Get all the param name/value pairs and build the data string Set<String> paramNames = getParamNames(); if (paramNames != null && !paramNames.isEmpty()) { Iterator<String> iter = paramNames.iterator(); try { while (iter.hasNext()) { String name = iter.next(); postData.append('&').append(name).append('='); postData.append(getParamValue(name)); } } catch (Exception ex) { // RG: append(char) throws IOException in J2SE 5.0 /** @todo Log it */ } // Replace the first & with a ? postData.setCharAt(0, '?'); } LOG.finer("ServerAction: POST data: " + postData.toString()); return postData.toString(); }
/** * Return a set of parameter names or null if there are no params */ public Set<String> getParamNames() { Map<String, String> params = getParams(); return params == null ? null : params.keySet(); }
/** * Return a set of parameter names or null if there are no params */ public Set<String> getHeaderNames() { Map<String, String> headers = getHeaders(); return headers == null ? null : headers.keySet(); }
URL execURL = (URL)getValue(URL_CACHE); if (execURL == null && !"".equals(getURL())) { try { String url = getURL(); if (url.startsWith("http")) { execURL = new URL(url); } else { putValue(URL_CACHE, execURL); Set<String> headerNames = getHeaderNames(); if (headerNames != null && !headerNames.isEmpty()) { Iterator<String> iter = headerNames.iterator(); while (iter.hasNext()) { String name = (String)iter.next(); uc.setRequestProperty(name, getHeaderValue(name)); out.print(getPostData()); out.flush();
public static ServerAction createServerAction(String id, String name, String mnemonic) { ServerAction action = new ServerAction(name, id); if (mnemonic != null && !mnemonic.equals("")) { action.putValue(Action.MNEMONIC_KEY, new Integer(mnemonic.charAt(0))); } return action; }
/** * Retrieves a string which represents the parameter data for a server action. * @return a string of name value pairs prefixed by a '?' and delimited by an '&' */ private String getPostData() { // Write the data into local buffer StringBuffer postData = new StringBuffer(); // TODO: the action should be configured to retrieve the data. // Get all the param name/value pairs and build the data string Set<String> paramNames = getParamNames(); if (paramNames != null && !paramNames.isEmpty()) { Iterator<String> iter = paramNames.iterator(); try { while (iter.hasNext()) { String name = iter.next(); postData.append('&').append(name).append('='); postData.append(getParamValue(name)); } } catch (Exception ex) { // RG: append(char) throws IOException in J2SE 5.0 /** @todo Log it */ } // Replace the first & with a ? postData.setCharAt(0, '?'); } LOG.finer("ServerAction: POST data: " + postData.toString()); return postData.toString(); }
/** * Return a parameter value corresponding to name or null if it doesn't exist. */ public String getParamValue(String name) { Map<String, String> params = getParams(); return params == null ? null : params.get(name); }
/** * Return a set of parameter names or null if there are no params */ public Set<String> getHeaderNames() { Map<String, String> headers = getHeaders(); return headers == null ? null : headers.keySet(); }
URL execURL = (URL)getValue(URL_CACHE); if (execURL == null && !"".equals(getURL())) { try { String url = getURL(); if (url.startsWith("http")) { execURL = new URL(url); } else { putValue(URL_CACHE, execURL); Set<String> headerNames = getHeaderNames(); if (headerNames != null && !headerNames.isEmpty()) { Iterator<String> iter = headerNames.iterator(); while (iter.hasNext()) { String name = (String)iter.next(); uc.setRequestProperty(name, getHeaderValue(name)); out.print(getPostData()); out.flush();
public static ServerAction createServerAction(String id, String name, String mnemonic) { ServerAction action = new ServerAction(name, id); if (mnemonic != null && !mnemonic.equals("")) { action.putValue(Action.MNEMONIC_KEY, new Integer(mnemonic.charAt(0))); } return action; }
@SuppressWarnings("unchecked") private Map<String, String> getHeaders() { return (Map)getValue(HEADERS); }
/** * Adds a name value pair which represents a url connection request property. * For example, name could be "Content-Type" and the value could be * "application/x-www-form-urlencoded" */ public void addHeader(String name, String value) { Map<String, String> map = getHeaders(); if (map == null) { map = new HashMap<String, String>(); setHeaders(map); } map.put(name, value); }
/** * Retrieves a string which represents the parameter data for a server action. * @return a string of name value pairs prefixed by a '?' and delimited by an '&' */ private String getPostData() { // Write the data into local buffer StringBuffer postData = new StringBuffer(); // TODO: the action should be configured to retrieve the data. // Get all the param name/value pairs and build the data string Set<String> paramNames = getParamNames(); if (paramNames != null && !paramNames.isEmpty()) { Iterator<String> iter = paramNames.iterator(); try { while (iter.hasNext()) { String name = iter.next(); postData.append('&').append(name).append('='); postData.append(getParamValue(name)); } } catch (Exception ex) { // RG: append(char) throws IOException in J2SE 5.0 /** @todo Log it */ } // Replace the first & with a ? postData.setCharAt(0, '?'); } LOG.finer("ServerAction: POST data: " + postData.toString()); return postData.toString(); }
/** * Return a parameter value corresponding to name or null if it doesn't exist. */ public String getParamValue(String name) { Map<String, String> params = getParams(); return params == null ? null : params.get(name); }