Package org.ribax.utils.types

Examples of org.ribax.utils.types.NameValuePair


 
  public Object getElementAt(int index) {
    Object o = table.get(index);
   
    if (o instanceof NameValuePair) {
      NameValuePair p = (NameValuePair)o;
      return p.getName();
    } else
      return o;
  }
View Full Code Here


        // check the data has changed
        if (value != null && value.equals(newValue))
            return;
       
        ArrayList<NameValuePair> params = new ArrayList<NameValuePair>();
        params.add(new NameValuePair("fieldname",fieldname)); //$NON-NLS-1$
        try {
            model.setElement(modelPath,newValue,params);
        } catch (Exception ex) {
            errorMessage(Messages.getString("TextDataItem.2")+ex.getMessage()); //$NON-NLS-1$
        }
View Full Code Here

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

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

      list.add(pair);
View Full Code Here

    protected void loadItemData(ArrayList params,String action) {
   
      stopped = false;
        if (action != null)
          params.add(new NameValuePair("Action",action)); //$NON-NLS-1$
     
        try {
            // get an inputstream from the streaming data source
            InputStream fin = getInputStream(streamSource,params);
             BufferedReader bin
View Full Code Here

  }

  public InputStream getInputStream(ArrayList<Object> params)
  throws IOException
  {
    NameValuePair pair = null;
    Iterator<Object> iter = null;
    InputStream stream = null;
    OutputStream out;
   
    if (url.startsWith("telnet:")) //$NON-NLS-1$
      url = url.replaceFirst("telnet:","http:"); //$NON-NLS-1$ //$NON-NLS-2$
   
    try {
      URI u = new URI(url);
     
      host = u.getHost();
      port = u.getPort();
    } catch (URISyntaxException ex) {
      LOG.warn(Messages.getString("SocketDataSource.6")+url); //$NON-NLS-1$
      return null;
    }
   
    Socket sock = new Socket(host,port);
    stream = sock.getInputStream();
    out = sock.getOutputStream();
   
    // send the form data
    if (LOG.isDebugEnabled())
      LOG.debug(Messages.getString("SocketDataSource.7")+url); //$NON-NLS-1$
   
    int paramcount = 0;
   
    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 p = new StringPart(pair.getName(),pair.getValue());
       
        out.write(p.toString().getBytes());
       
      } 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) {
            LOG.warn(Messages.getString("SocketDataSource.8")+pair.getValue()); //$NON-NLS-1$
            continue;
          }
         
          byte[] b = new byte[1024];
         
          //send the file
          FileInputStream fin = new FileInputStream(f);
         
          while(fin.available() > 0) {
            fin.read(b);
            out.write(b);
          }
      } 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){
            LOG.warn(Messages.getString("SocketDataSource.9")+pair.getValue()); //$NON-NLS-1$
            continue;
          }

          //send the file
          byte[] b = new byte[1024];
         
          //send the file
          FileInputStream fin = new FileInputStream(f);
         
          while(fin.available() > 0) {
            fin.read(b);
            out.write(b);
          }

      } 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 p = new StringPart(pair.getName(),pair.getValue());
       
        out.write(p.toString().getBytes());

      } 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 p = new StringPart(pair.getName(),pair.getValue());
       
        out.write(p.toString().getBytes());
      }
      paramcount++;
      if (LOG.isDebugEnabled())
        LOG.debug(url+Messages.getString("SocketDataSource.10")+pair.getName()+"="+pair.getValue()); //$NON-NLS-1$ //$NON-NLS-2$
    }

    return stream;
  }
View Full Code Here

            // get the parameter from the environment
            pvalue = getParameter(pname,null);

            // if it has a value then add it to the set of base params
            if (pvalue != null) {
                baseParams.add(new NameValuePair(pname,pvalue));
                if (LOG.isDebugEnabled())
                    LOG.debug(Messages.getString("RIBAXApplet.17")+pname+ "="+pvalue); //$NON-NLS-1$ //$NON-NLS-2$
            }
        }
View Full Code Here

     * @return the collection of NameValuePairs.
     */
    private ArrayList<NameValuePair> getRowDataElements(TableRow row,int paramnum) {
       
      ArrayList<NameValuePair> list = new ArrayList<NameValuePair>();
    NameValuePair pair = null;
    String name;

    // add a parameter for he row key if it is not null
      String key = row.getKey();
     
      if (key != null) {
        pair = new NameValuePair("key_"+paramnum,key); //$NON-NLS-1$
        list.add(pair);
      }
   
        // for each column in the row
        for(int j = 0; j < columnAttributes.size() ; j++) {
          TableRowColumnAttributes attr = columnAttributes.elementAt(j);

            // get the column name
          name = attr.name;

            // get the cell data
          Object o = row.elementAt(j);
           
            // add parameters for certain types, other types are ignored
            if (o instanceof String) {
                // make a name of columName_paramnum
              pair = new NameValuePair(name+"_"+paramnum,(String)o); //$NON-NLS-1$
              list.add(pair);
            } else if (o instanceof Boolean) {            
              pair = new NameValuePair(name+"_"+paramnum,((Boolean)o).toString()); //$NON-NLS-1$
              list.add(pair);
            } else if (o instanceof Integer) {            
              pair = new NameValuePair(name+"_"+paramnum,((Integer)o).toString()); //$NON-NLS-1$
              list.add(pair);
            } else if (o instanceof Float) {
              pair = new NameValuePair(name+"_"+paramnum,((Float)o).toString()); //$NON-NLS-1$
              list.add(pair);
            } else if (o instanceof Memo) {
                pair = new NameValuePair(name+"_"+paramnum,((Memo)o).toString()); //$NON-NLS-1$
                list.add(pair);
            }
        }
      return list;
    }
View Full Code Here

   
    // sync the data with the back end
    // create a new list of parameters and add the model name and path
        // so the back end web service knows which value has been updated
    ArrayList<NameValuePair> list = new ArrayList<NameValuePair>();
    list.add(new NameValuePair("modelName",name)); //$NON-NLS-1$
    list.add(new NameValuePair("modelPath",path)); //$NON-NLS-1$
       
        // if the value is a string object then add a NameValuePair with the value
        if (value instanceof String)
            list.add(new NameValuePair("value",value.toString())); //$NON-NLS-1$
        else if (value instanceof ArrayList) {
            // otherwise we assume it is an arraylist of NameValuePairs
            list.addAll((ArrayList)value);
        }
        // add the passed in parameters
View Full Code Here

    public NameValuePair getNameValuePair() {
      if (editable == false || fieldname == null || fieldname.length() == 0)
        return null;
      else
        return new NameValuePair(fieldname,field.getText());
    }
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.