Package org.ribax.utils.types

Examples of org.ribax.utils.types.NameValuePair


     */
    public NameValuePair getNameValuePair() {
      if (editable == false || fieldname == null || fieldname.length() == 0)
        return null;
      else
        return new NameValuePair(fieldname,field.getText());
    }
View Full Code Here


    }
    /* (non-Javadoc)
     * @see org.ribax.ui.DataItem#getParameters()
     */
    public ArrayList getParameters() {
      NameValuePair pair;
     
      if ((pair = getNameValuePair()) == null)
        return null;
     
      ArrayList<NameValuePair> list = new ArrayList<NameValuePair>();
View Full Code Here

      stopped = false;
     
       
        if (action != null)
          params.add(new NameValuePair("Action",action)); //$NON-NLS-1$
     
        try {
            // post the parameters to the web service url and
            // get an input stream
            InputStream fin = getInputStream(streamSource,params);
View Full Code Here

      Element opt = optit.next();
           
            // if the element has a name attribute then add a NameValuePair object
            // this allows us to associate values with displayed names
      if (opt.getChild("name") != null) { //$NON-NLS-1$
        options.addElement(new NameValuePair(opt.getChild("name").getText(), //$NON-NLS-1$
            opt.getChild("value").getText())); //$NON-NLS-1$
      } else
                // otherwise add the text as a String object
        options.addElement(opt.getText());
    }
View Full Code Here

    public NameValuePair getNameValuePair() {
        if (menu.getSelectedIndex() < 0)
            return null;
        // return the field name and the selected element
        return new NameValuePair(fieldname,menu.getSelectedItem().toString());
    }
View Full Code Here

     */
    public NameValuePair getNameValuePair() {
        if (value == null || value.length() == 0)
            return null;
       
        return new NameValuePair(name,value);
    }
View Full Code Here

      Iterator iter = data.iterator();
      while(iter.hasNext()) {
        DataElement de = (DataElement)iter.next();
       
            // add a new NameValuePair for each data element
        list.add(new NameValuePair(de.name,de.value));
      }
        // add a NameValuePair for the image URL
        if (imageURL != null) {
            list.add(new NameValuePair("image",imageURL)); //$NON-NLS-1$
        }
      return list;
    }
View Full Code Here

    }

    public InputStream getInputStream(ArrayList<Object> params)
    throws IOException {

        NameValuePair pair = null;
        Iterator<Object> iter = null;
        InputStream stream = null;
        URLConnection conn = null;

        // send the form data
        if (requestLog.isDebugEnabled(name))
            requestLog.debug(name,Messages.getString("WebDataSource.14")+url); //$NON-NLS-1$

        URL hp=new URL(url);

        conn = hp.openConnection()

        // we don't want the connection to stay alive
        conn.setRequestProperty("Connection", "close"); //$NON-NLS-1$ 

        conn.setDoOutput(true);
        conn.setDoInput(true);
        conn.setUseCaches(false);

        // add  headers
        for (Enumeration<String> e = headers.keys() ; e.hasMoreElements() ;) {
            String name = e.nextElement();
            conn.setRequestProperty(name,headers.get(name));        
        }

        HTTPmultipart mp = null;

        if (params != null && params.size() > 0) {
            mp = new HTTPmultipart();
            String boundary = new String(mp.getBoundary());
            conn.setRequestProperty("Boundary",boundary); //$NON-NLS-1$
            conn.setRequestProperty("Content-Type","multipart/form-data; boundary=\""+boundary+"\""); //$NON-NLS-1$ //$NON-NLS-2$
        }

        ArrayList<Part> content = new ArrayList<Part>();

        int length = 0;

        // determine the content length and save the parts to the content list

        if (params != null && params.size() > 0) {

            try{
                iter = params.iterator();

                while (iter.hasNext()) {
                    Object o = iter.next();

                    if (o == null)
                        continue;

                    if (o instanceof NameValuePair) {
                        pair = (NameValuePair)o;

                        if (pair == null || pair.getName() == null || pair.getValue() == null) {
                            nullParameterWarning(pair);
                            continue;
                        }
                        StringPart part = new StringPart(pair.getName(),pair.getValue());
                        content.add(part);
                        length += mp.getContentLength(part);
                    } else if (o instanceof FileParameter) {
                        FileParameter fp = (FileParameter)o;
                        pair = fp.getNameValuePair();

                        if (pair == null || pair.getName() == null || pair.getValue() == null) {
                            nullParameterWarning(pair);
                            continue;
                        }

                        File f = new File(pair.getValue());

                        if (f == null) {
                            requestLog.warn(Messages.getString("WebDataSource.19")+pair.getValue()); //$NON-NLS-1$
                            continue;
                        }
                        FilePart part = new FilePart(pair.getName(),f);
                        content.add(part);
                        length += mp.getContentLength(part);
                    } else if (o instanceof FileDataItem) {
                        FileDataItem fp = (FileDataItem)o;
                        pair = fp.getNameValuePair();

                        if (pair == null || pair.getName() == null || pair.getValue() == null) {
                            nullParameterWarning(pair);
                            continue;
                        }

                        File f = new File(pair.getValue());

                        if (f == null){
                            requestLog.warn(Messages.getString("WebDataSource.20")+pair.getValue()); //$NON-NLS-1$
                            continue;
                        }

                        FilePart part = new FilePart(pair.getName(),f);
                        content.add(part);
                        length += mp.getContentLength(part);
                    } else if (o instanceof DataItem) {
                        DataItem fp = (DataItem)o;
                        pair = fp.getNameValuePair();

                        if (pair == null || pair.getName() == null || pair.getValue() == null) {
                            nullParameterWarning(pair);
                            continue;
                        }

                        StringPart part = new StringPart(pair.getName(),pair.getValue());
                        content.add(part);
                        length += mp.getContentLength(part);
                    } else if (o instanceof Parameter) {
                        Parameter param = (Parameter)o;
                        pair = param.getNameValuePair();

                        if (pair == null || pair.getName() == null || pair.getValue() == null) {
                            nullParameterWarning(pair);
                            continue;
                        }

                        StringPart part = new StringPart(pair.getName(),pair.getValue());
                        content.add(part);
                        length += mp.getContentLength(part);
                    }

                    if (requestLog.isDebugEnabled(name))
                        requestLog.debug(name,url+Messages.getString("WebDataSource.21")+pair.getName()+"="+pair.getValue()); //$NON-NLS-1$ //$NON-NLS-2$
                }

            }catch(Exception e){
                throw new IOException(Messages.getString("WebDataSource.23")); //$NON-NLS-1$
            }
View Full Code Here

    public NameValuePair getNameValuePair() {
        if (editorPane.getText().length() == 0)
            return null;
       
        // return the fieldname and text value
        return new NameValuePair(fieldname,editorPane.getText());
    }
View Full Code Here

     */
    public NameValuePair getNameValuePair() {
        if (value == null || value.length() == 0)
            return null;
       
        return new NameValuePair(fieldname,value);
    }
View Full Code Here

TOP

Related Classes of org.ribax.utils.types.NameValuePair

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.