Example usage for java.util Vector toArray

List of usage examples for java.util Vector toArray

Introduction

In this page you can find the example usage for java.util Vector toArray.

Prototype

public synchronized Object[] toArray() 

Source Link

Document

Returns an array containing all of the elements in this Vector in the correct order.

Usage

From source file:org.jboss.dashboard.commons.text.StringUtil.java

/**
 * Returns a String who replace Strings include into <I>str</I>,
 * which are into delimiters and known in <I>in</I>,
 * to corresponding String from <I>out</I>.
 * If in and out aren't of the same size, the string is returned
 * unchanged./*  w ww  .j a  v a2s .c  om*/
 *
 * @param str        String to manipulate
 * @param in         Vector which contains strings to find
 * @param out        Vector which contains strings to replace
 * @param beginDelim String who delimiters the begin of the substrings
 *                   into <I>str</I>
 * @param endDelim   String who delimiters the end of the substrings
 *                   into <I>str</I>
 * @return the new string
 */
public static String replaceAll(String str, Vector in, Vector out, String beginDelim, String endDelim) {
    return replaceAll(str, (String[]) in.toArray(), (String[]) out.toArray(), beginDelim, endDelim);
}

From source file:BugTrackerJFace.java

public BugTrackerJFace() {
    // Action./*from w w w . ja  v a2  s  .  c o m*/
    Action actionAddNew = new Action("New bug") {
        public void run() {
            // Append.
            Bug bug = new Bug("", "", "", false);
            bugs.add(bug);
            tableViewer.refresh(false);
        }
    };

    Action actionDelete = new Action("Delete selected") {
        public void run() {
            IStructuredSelection selection = (IStructuredSelection) tableViewer.getSelection();
            Bug bug = (Bug) selection.getFirstElement();
            if (bug == null) {
                System.out.println("Please select an item first. ");
                return;
            }
            MessageBox messageBox = new MessageBox(shell, SWT.YES | SWT.NO);
            messageBox.setText("Confirmation");
            messageBox.setMessage("Are you sure to remove the bug with id #" + bug.id);
            if (messageBox.open() == SWT.YES) {
                bugs.remove(bug);
                tableViewer.refresh(false);
            }
        }
    };

    Action actionSave = new Action("Save") {
        public void run() {
            saveBugs(bugs);
        }
    };

    final ViewerFilter filter = new ViewerFilter() {
        public boolean select(Viewer viewer, Object parentElement, Object element) {
            if (!((Bug) element).isSolved)
                return true;
            return false;
        }
    };

    Action actionShowUnsolvedOnly = new Action("Show unsolved only") {
        public void run() {
            if (!isChecked())
                tableViewer.removeFilter(filter);
            else
                tableViewer.addFilter(filter);
        }
    };
    actionShowUnsolvedOnly.setChecked(false);

    ToolBar toolBar = new ToolBar(shell, SWT.RIGHT | SWT.FLAT);

    ToolBarManager manager = new ToolBarManager(toolBar);
    manager.add(actionAddNew);
    manager.add(actionDelete);
    manager.add(new Separator());
    manager.add(actionSave);
    manager.add(new Separator());
    manager.add(actionShowUnsolvedOnly);

    manager.update(true);

    shell.setLayout(new GridLayout());

    table = new Table(shell, SWT.BORDER | SWT.FULL_SELECTION);

    TableColumn tcID = new TableColumn(table, SWT.LEFT);
    tcID.setText(colNames[0]);

    TableColumn tcSummary = new TableColumn(table, SWT.NULL);
    tcSummary.setText(colNames[1]);

    TableColumn tcAssignedTo = new TableColumn(table, SWT.NULL);
    tcAssignedTo.setText(colNames[2]);

    TableColumn tcSolved = new TableColumn(table, SWT.NULL);
    tcSolved.setText(colNames[3]);

    tcID.setWidth(60);
    tcSummary.setWidth(200);
    tcAssignedTo.setWidth(80);
    tcSolved.setWidth(50);

    tableViewer = new TableViewer(table);

    tableViewer.getTable().setLinesVisible(true);
    tableViewer.getTable().setHeaderVisible(true);
    tableViewer.getTable().setLayoutData(new GridData(GridData.FILL_BOTH));

    // Sets the content provider. 
    tableViewer.setContentProvider(new IStructuredContentProvider() {
        public Object[] getElements(Object inputElement) {
            Vector v = (Vector) inputElement;
            return v.toArray();
        }

        public void dispose() {
            System.out.println("Disposing ...");
        }

        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
            System.out.println("Input changed: old=" + oldInput + ", new=" + newInput);
        }
    });

    // Sets the label provider. 
    tableViewer.setLabelProvider(new ITableLabelProvider() {
        public Image getColumnImage(Object element, int columnIndex) {
            if (columnIndex == 0)
                return bugIcon;
            return null;
        }

        public String getColumnText(Object element, int columnIndex) {
            Bug bug = (Bug) element;
            switch (columnIndex) {
            case 0:
                return bug.id;
            case 1:
                return bug.summary;
            case 2:
                return bug.assignedTo;
            case 3:
                return bug.isSolved ? "YES" : "NO";
            }
            return null;
        }

        public void addListener(ILabelProviderListener listener) {
        }

        public void dispose() {
        }

        public boolean isLabelProperty(Object element, String property) {
            return false;
        }

        public void removeListener(ILabelProviderListener listener) {
        }
    });

    // Sets cell editors. 
    tableViewer.setColumnProperties(colNames);

    CellEditor[] cellEditors = new CellEditor[4];

    cellEditors[0] = new TextCellEditor(table);
    cellEditors[1] = cellEditors[0];
    cellEditors[2] = cellEditors[0];
    cellEditors[3] = new CheckboxCellEditor(table);

    tableViewer.setCellEditors(cellEditors);

    tableViewer.setCellModifier(new ICellModifier() {
        public boolean canModify(Object element, String property) {
            return true;
        }

        public Object getValue(Object element, String property) {
            // Get the index first. 
            int index = -1;
            for (int i = 0; i < colNames.length; i++) {
                if (colNames[i].equals(property)) {
                    index = i;
                    break;
                }
            }
            Bug bug = (Bug) element;

            switch (index) {
            case 0:
                return bug.id;
            case 1:
                return bug.summary;
            case 2:
                return bug.assignedTo;
            case 3:
                return new Boolean(bug.isSolved);
            }

            return null;
        }

        public void modify(Object element, String property, Object value) {
            System.out.println("Modify: " + element + ", " + property + ", " + value);
            // Get the index first. 
            int index = -1;
            for (int i = 0; i < colNames.length; i++) {
                if (colNames[i].equals(property)) {
                    index = i;
                    break;
                }
            }

            Bug bug = null;
            if (element instanceof Item) {
                TableItem item = (TableItem) element;
                bug = (Bug) item.getData();
            } else {
                bug = (Bug) element;
            }

            switch (index) {
            case 0:
                bug.id = (String) value;
                break;
            case 1:
                bug.summary = (String) value;
                break;
            case 2:
                bug.assignedTo = (String) value;
                break;
            case 3:
                bug.isSolved = ((Boolean) value).booleanValue();
                break;
            }

            tableViewer.update(bug, null);
        }
    });

    // Setting sorters. 
    tcID.addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event event) {
            tableViewer.setSorter(new BugSorter(colNames[0]));
        }
    });

    tcSummary.addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event event) {
            tableViewer.setSorter(new BugSorter(colNames[1]));
        }
    });

    tcAssignedTo.addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event event) {
            tableViewer.setSorter(new BugSorter(colNames[2]));
        }
    });

    tcSolved.addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event event) {
            tableViewer.setSorter(new BugSorter(colNames[3]));
        }
    });

    bugs = Bug.loadBugs(new File("bugs.dat"));

    tableViewer.setInput(bugs);

    shell.pack();
    shell.open();
    //textUser.forceFocus();

    // Set up the event loop.
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            // If no more entries in event queue
            display.sleep();
        }
    }

    display.dispose();
}

From source file:fr.gouv.finances.cp.xemelios.importers.batch.BatchRealImporter.java

public BatchRealImporter(PropertiesExpansion applicationConfiguration, String[] args) throws Exception {
    super();/*from www .j a v a2  s.  c o m*/
    this.applicationConfiguration = applicationConfiguration;
    this.files = new ArrayList<File>();
    this.filesToDrop = new ArrayList<File>();
    this.opts = new Options();
    arguments = args;
    createLogger();
    setCommandLineOptions();
    posixparser = new PosixParser();
    CommandLine cm = posixparser.parse(opts, arguments);
    Option[] s = cm.getOptions();
    cmopts = new Vector<String>();
    for (int i = 0; i < s.length; i++) {
        cmopts.add(s[i].getOpt());
    }
    if (!cmopts.contains("h")) {
        // Chargement des fichiers de configuration
        if (cmopts.contains("g")) {
            for (int i = 0; i < args.length; i++) {
                if (args[i].matches("-g")) {
                    documentsDefDir = args[i + 1];
                    logger.debug("documents-def.dir =" + documentsDefDir);
                }
            }
        }
        loadConfig();
        // Type de document dans la ligne de commande?
        if (cmopts.contains("d")) {
            // Recupration du type de document
            for (int i = 0; i < args.length; i++) {
                if (args[i].matches("-d")) {
                    documentid = args[i + 1];
                    logger.debug("docId =" + documentid);
                } else if (args[i].matches("-r")) {
                    String rulesFileName = args[i + 1];
                    RulesParser rp = new RulesParser(FactoryProvider.getSaxParserFactory());
                    rp.parse(new File(rulesFileName));
                    RulesModel rules = (RulesModel) rp.getMarshallable();
                    setArchiveRules(rules);
                }
            }
            if (cmopts.contains("f")) {
                Vector<String> fil = new Vector<String>();
                for (int i = 0; i < args.length; i++) {
                    if (args[i].matches("-f")) {
                        for (int j = i + 1; j < args.length; j++) {
                            fil.add(args[j]);
                        }
                    }
                }
                setFilesToImport(fil.toArray());
            }
            // Option fichier(s) prsent(s) dans la ligne de commande?
            if (cmopts.contains("f") && cmopts.contains("i")) {
                Vector<String> fil = new Vector<String>();
                for (int i = 0; i < args.length; i++) {
                    if (args[i].matches("-i")) {
                        if (args[i + 1].matches("yes")) {
                            budgIsInterractif = true;
                        }
                        if (args[i + 2].matches("yes")) {
                            collIsInterractif = true;
                        }
                    }
                }
                setFilesToImport(fil.toArray());
            } else {
                System.err.println(
                        "L'option fichier(s) est obligatoire dans la ligne de commande lorsque le mode interractif est declar.");
                System.exit(SYNTAX_ERROR);
            }
            if (cmopts.contains("u")) {
                for (int i = 0; i < args.length; i++) {
                    if (args[i].matches("-u")) {
                        final String strUser = args[i + 1];
                        // c'est un peu violent, ok, mais on verra plus tard
                        user = new XemeliosUser() {
                            @Override
                            public String getId() {
                                return strUser;
                            }

                            @Override
                            public String getDisplayName() {
                                return getId();
                            }

                            @Override
                            public boolean hasRole(String role) {
                                return true;
                            }

                            @Override
                            public boolean hasDocument(String document) {
                                return true;
                            }

                            @Override
                            public boolean hasCollectivite(String collectivite, DocumentModel dm) {
                                return true;
                            }
                        };
                    }
                }
            } else {
                System.err.println("L'option -u est obligatoire");
                System.exit(SYNTAX_ERROR);
            }
            System.exit(importer(documentid));
        } else {
            System.err.println("L'option type de document est obligatoire dans la ligne de commande.");
            System.exit(SYNTAX_ERROR);
        }
    } else {
        System.out.println("\n\nAide de l'importeur batch.\n" + "_________________________\n\n"
                + "Syntaxe : importerBatch -config config-dir -d typeDoc [-c code libelle] [-b code libelle] [-i (y|n budget) (y|n collectivite)] [-r fichier.regles] -f fichier [fichier [...]]\n\n"
                + "-config : chaine contenant le ou les rpertoires o se trouvent les fichiers de dfinition des configurations de documents\n"
                + "          si cette option n'est pas fournie, utilise le contenu de la variable d'environnement "
                + Constants.SYS_PROP_DOC_DEF_DIR + "\n\n"
                + "-d : MODELE DU DOCUMENT  importer >> Option Obligatoire.\n\n"
                + "-b : BUDGET DU FICHIER  >> Option Facultative.\n\n"
                + "       - Si le budget est prsent dans le fichier cette option est inutile.\n"
                + "       - Sinon prcisez le libell puis le code du budget.\n"
                + "      - Si pas d'argument pour le budget :\n"
                + "         - Si prsence d'un budget par defaut dans fichier de conf, alors celui-ci sera pris.\n"
                + "         - Sinon, abandon de l'import car le budget n'est pas dfinit.\n"
                + "      - Si option particulire si y n alors mode interactif avec l'utilisateur dans la console."
                + "Pour chaque fichier sans budget, on pose la question  l'utilisateur.\n\n"
                + "-c : COLLECTIVITE DU FICHIER  >> Option Facultative.\n\n"
                + "      - Si la collectivit est prsente dans le fichier, on l'utilise.\n"
                + "      - Sinon on prend celui de l'argument.\n"
                + "      - Si pas d'argument pour la collectivit, alors mode interactif avec l'utilisateur dans la console.\n"
                + "Pour chaque fichier sans collectivit, on pose la question  l'utilisateur.\n\n"
                + "-i : MODE INTERACTIF  >> Option Facultative.\n"
                + "      - y ou n permet d'activer l'option interactive pour l'element en question.\n\n"
                + "-r : permet de spcifier le fichier de rgles  appliquer  l'import de l'archive ;\n\t\tuniquement si -d xemelios.archive.\n\n"
                + "-u : utilisateur (id ou login)  utiliser opur l'import\n\n"
                + "-f : NOM DU/DES FICHIER(S)  importer");
        System.exit(SYNTAX_ERROR);
    }
}

From source file:org.scratch.microwebserver.MicrowebserverActivity.java

@Override
public void recreate(boolean b, final Vector<String> addr) {

    if (b) {/*from   w ww .ja v a2  s . c  o m*/
        runOnUiThread(new Runnable() {
            public void run() {
                statusText.setText("Rebinding ...");
                socketInfo.setText("");
                statusImage.setClickable(false);
                statusImage.setImageResource(R.drawable.indicator_idle);
            }
        });
    } else {
        runOnUiThread(new Runnable() {
            public void run() {
                statusText.setText("Started");
                socketInfo.setText(Arrays.toString(addr.toArray()));
                statusImage.setImageResource(R.drawable.indicator_started);
                statusImage.setClickable(true);
            }
        });
    }
}

From source file:es.emergya.ui.plugins.AdminPanel.java

public void addRowSilent(Vector<Object> fila, int indice) {
    synchronized (sync) {
        Object newRowData[][] = new Object[rowData.length + 1][];
        int k = 0;
        for (int i = 0; i < newRowData.length; i++) {
            if (indice == i) {
                newRowData[i] = fila.toArray();
            } else {
                newRowData[i] = rowData[k++];
            }/*  w w w.  j av a 2  s . c  o  m*/
        }
        rowData = newRowData;
    }
}

From source file:edu.ku.brc.specify.plugins.ipadexporter.ManageDataSetsDlg.java

/**
 * //from   w ww . ja va2s.  c o m
 */
private void addUserToDS() {
    final Vector<String> wsList = new Vector<String>();
    final Vector<String> instItems = new Vector<String>();

    String addStr = getResourceString("ADD");
    instItems.add(addStr);
    wsList.add(addStr);
    for (String fullName : cloudHelper.getInstList()) {
        String[] toks = StringUtils.split(fullName, '\t');
        instItems.add(toks[0]);
        wsList.add(toks[1]);
    }

    final JTextField userNameTF = createTextField(20);
    final JTextField passwordTF = createTextField(20);
    final JLabel pwdLbl = createI18NFormLabel("Password");
    final JLabel statusLbl = createLabel("");
    final JCheckBox isNewUser = UIHelper.createCheckBox("Is New User");
    final JLabel instLbl = createI18NFormLabel("Insitution");
    final JComboBox instCmbx = UIHelper.createComboBox(instItems.toArray());

    if (instItems.size() == 2) {
        instCmbx.setSelectedIndex(1);
    }

    CellConstraints cc = new CellConstraints();
    PanelBuilder pb = new PanelBuilder(new FormLayout("p,2px,f:p:g", "p,4px,p,4px,p,4px,p,4px,p,8px,p"));

    pb.add(createI18NLabel("Add New or Existing User to DataSet"), cc.xyw(1, 1, 3));
    pb.add(createI18NFormLabel("Username"), cc.xy(1, 3));
    pb.add(userNameTF, cc.xy(3, 3));
    pb.add(pwdLbl, cc.xy(1, 5));
    pb.add(passwordTF, cc.xy(3, 5));
    pb.add(instLbl, cc.xy(1, 7));
    pb.add(instCmbx, cc.xy(3, 7));

    pb.add(isNewUser, cc.xy(3, 9));

    pb.add(statusLbl, cc.xyw(1, 11, 3));
    pb.setDefaultDialogBorder();

    pwdLbl.setVisible(false);
    passwordTF.setVisible(false);
    instLbl.setVisible(false);
    instCmbx.setVisible(false);

    final CustomDialog dlg = new CustomDialog(this, "Add User", true, OKCANCEL, pb.getPanel()) {
        @Override
        protected void okButtonPressed() {
            String usrName = userNameTF.getText();
            if (cloudHelper.isUserNameOK(usrName)) {
                String collGuid = datasetGUIDList.get(dataSetList.getSelectedIndex());
                if (cloudHelper.addUserAccessToDataSet(usrName, collGuid)) {
                    super.okButtonPressed();
                } else {
                    iPadDBExporterPlugin.setErrorMsg(statusLbl,
                            String.format("Unable to add usr: %s to the DataSet guid: %s", usrName, collGuid));
                }
            } else if (isNewUser.isSelected()) {
                String pwdStr = passwordTF.getText();
                String guid = null;
                if (instCmbx.getSelectedIndex() == 0) {
                    //                        InstDlg instDlg = new InstDlg(cloudHelper);
                    //                        if (!instDlg.isInstOK())
                    //                        {
                    //                            instDlg.createUI();
                    //                            instDlg.pack();
                    //                            centerAndShow(instDlg, 600, null);
                    //                            if (instDlg.isCancelled())
                    //                            {
                    //                                return;
                    //                            }
                    //                            //guid = instDlg.getGuid()();
                    //                        }
                } else {
                    //webSite = wsList.get(instCmbx.getSelectedIndex());

                }

                if (guid != null) {
                    String collGuid = datasetGUIDList.get(dataSetList.getSelectedIndex());
                    if (cloudHelper.addNewUser(usrName, pwdStr, guid)) {
                        if (cloudHelper.addUserAccessToDataSet(usrName, collGuid)) {
                            ManageDataSetsDlg.this.loadUsersForDataSetsIntoJList();
                            super.okButtonPressed();
                        } else {
                            iPadDBExporterPlugin.setErrorMsg(statusLbl,
                                    String.format("Unable to add%s to the DataSet %s", usrName, collGuid));
                        }
                    } else {
                        iPadDBExporterPlugin.setErrorMsg(statusLbl,
                                String.format("Unable to add%s to the DataSet %s", usrName, collGuid));
                    }
                } else {
                    // error
                }
            } else {
                iPadDBExporterPlugin.setErrorMsg(statusLbl, String.format("'%s' doesn't exist.", usrName));
            }
        }
    };

    KeyAdapter ka = new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent e) {
            statusLbl.setText("");
            String usrNmStr = userNameTF.getText();
            boolean hasData = StringUtils.isNotEmpty(usrNmStr)
                    && (!isNewUser.isSelected() || StringUtils.isNotEmpty(passwordTF.getText()))
                    && UIHelper.isValidEmailAddress(usrNmStr);
            dlg.getOkBtn().setEnabled(hasData);
        }

    };
    userNameTF.addKeyListener(ka);
    passwordTF.addKeyListener(ka);

    final Color textColor = userNameTF.getForeground();

    FocusAdapter fa = new FocusAdapter() {
        @Override
        public void focusGained(FocusEvent e) {
            JTextField tf = (JTextField) e.getSource();
            if (!tf.getForeground().equals(textColor)) {
                tf.setText("");
                tf.setForeground(textColor);
            }
        }

        @Override
        public void focusLost(FocusEvent e) {
            JTextField tf = (JTextField) e.getSource();
            if (tf.getText().length() == 0) {
                tf.setText("Enter email address");
                tf.setForeground(Color.LIGHT_GRAY);
            }
        }
    };
    userNameTF.addFocusListener(fa);

    userNameTF.setText("Enter email address");
    userNameTF.setForeground(Color.LIGHT_GRAY);

    isNewUser.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            boolean isSel = isNewUser.isSelected();
            pwdLbl.setVisible(isSel);
            passwordTF.setVisible(isSel);
            instLbl.setVisible(isSel);
            instCmbx.setVisible(isSel);

            Dimension s = dlg.getSize();
            int hgt = isNewUser.getSize().height + 4 + instCmbx.getSize().height;
            s.height += isSel ? hgt : -hgt;
            dlg.setSize(s);
        }
    });

    dlg.createUI();
    dlg.getOkBtn().setEnabled(false);

    centerAndShow(dlg);
    if (!dlg.isCancelled()) {
        loadUsersForDataSetsIntoJList();
    }
}

From source file:org.freedesktop.dbus.Message.java

/**
 * Demarshall values from a buffer./*ww w  . j  a  va  2s  .c  o m*/
 * 
 * @param sig
 *            The D-Bus signature(s) of the value(s).
 * @param buf
 *            The buffer to demarshall from.
 * @param ofs
 *            An array of two ints, the offset into the signature
 *            and the offset into the data buffer. These values will be
 *            updated to the start of the next value ofter demarshalling.
 * @return The demarshalled value(s).
 */
public Object[] extract(String sig, byte[] buf, int[] ofs) throws DBusException {
    if (log.isTraceEnabled()) {
        log.trace("extract(" + sig + ",#" + buf.length + ", {" + ofs[0] + "," + ofs[1] + "}");
    }
    Vector<Object> rv = new Vector<>();
    byte[] sigb = sig.getBytes();
    for (int[] i = ofs; i[0] < sigb.length; i[0]++) {
        rv.add(extractone(sigb, buf, i, false));
    }
    return rv.toArray();
}

From source file:com.evolveum.openicf.lotus.DominoConnector.java

private void removeUserFromGroup(String usernameCanonical, String groupName) throws NotesException {
    LOG.ok("removeUserFromGroup: usernameCanonical {0}, groupName {1}", usernameCanonical, groupName);

    Document group = getGroup(groupName);
    if (group == null) {
        LOG.error("Invalid group name {0}.", groupName);
        throw new ConnectorException("Invalid group name '" + groupName + "'.");
    }/*  w  w w. ja  v  a2 s  . c om*/

    Vector members = group.getItemValue(MEMBERS.getName());
    if (members != null && members.remove(usernameCanonical)) {
        Map<String, Attribute> attrs = new HashMap<String, Attribute>();
        attrs.put(MEMBERS.getName(), build(MEMBERS, members.toArray()));

        updateGroup(createGroupUid(group), attrs, null, Update.REPLACE);
    }
}

From source file:net.sf.sail.webapp.dao.user.impl.HibernateUserDao.java

/**
 * Get all the Users that have fields with the given matching values
 * @param fields an array of field names
 * e.g./* w  ww. ja  va 2 s . c  om*/
 * 'firstname'
 * 'lastname'
 * 'birthmonth'
 * 'birthday'
 * 
 * @param values an array of values, the index of a value must line up with
 * the index in the field array
 * e.g.
 * fields[0] = "firstname"
 * fields[1] = "lastname"
 * 
 * values[0] = "Spongebob"
 * values[1] = "Squarepants"
 * 
 * @param classVar 'studentUserDetails' or 'teacherUserDetails'
 * @return a list of Users that have matching values for the given fields
 */
@SuppressWarnings("unchecked")
public List<User> retrieveByFields(String[] fields, String[] values, String classVar) {
    Vector<Object> objectValues = new Vector<Object>();

    StringBuffer query = new StringBuffer();

    //make the beginning of the query
    query.append("select user from UserImpl user, " + capitalizeFirst(classVar) + " " + classVar + " where ");
    query.append("user.userDetails.id=" + classVar + ".id");

    //loop through all the fields so we can add more constraints to the 'where' clause
    for (int x = 0; x < fields.length; x++) {
        query.append(" and ");

        if (fields[x] != null && (fields[x].equals("birthmonth") || fields[x].equals("birthday"))) {
            //field is a birth month or birth day so we need to use a special function call
            if (fields[x].equals("birthmonth")) {
                query.append("month(" + classVar + ".birthday)=?");
            } else if (fields[x].equals("birthday")) {
                query.append("day(" + classVar + ".birthday)=?");
            }

            //number values must be Integer objects in the array we pass to the find() below
            objectValues.add(Integer.parseInt(values[x]));
        } else {
            //add the constraint
            query.append(classVar + "." + fields[x] + "=?");
            objectValues.add(values[x]);
        }
    }

    //run the query and return the results
    return this.getHibernateTemplate().find(query.toString(), objectValues.toArray());
}

From source file:org.freedesktop.dbus.MethodCall.java

public MethodCall(String source, String dest, String path, String iface, String member, byte flags, String sig,
        Object... args) throws DBusException {
    super(Message.Endian.BIG, Message.MessageType.METHOD_CALL, flags);

    if (null == member || null == path)
        throw new MessageFormatException("Must specify destination, path and function name to MethodCalls.");
    this.headers.put(Message.HeaderField.PATH, path);
    this.headers.put(Message.HeaderField.MEMBER, member);

    Vector<Object> hargs = new Vector<>();

    hargs.add(/*from ww  w .j  a v a2  s . co m*/
            new Object[] { Message.HeaderField.PATH, new Object[] { ArgumentType.OBJECT_PATH_STRING, path } });

    if (null != source) {
        this.headers.put(Message.HeaderField.SENDER, source);
        hargs.add(new Object[] { Message.HeaderField.SENDER,
                new Object[] { ArgumentType.STRING_STRING, source } });
    }

    if (null != dest) {
        this.headers.put(Message.HeaderField.DESTINATION, dest);
        hargs.add(new Object[] { Message.HeaderField.DESTINATION,
                new Object[] { ArgumentType.STRING_STRING, dest } });
    }

    if (null != iface) {
        hargs.add(new Object[] { Message.HeaderField.INTERFACE,
                new Object[] { ArgumentType.STRING_STRING, iface } });
        this.headers.put(Message.HeaderField.INTERFACE, iface);
    }

    hargs.add(new Object[] { Message.HeaderField.MEMBER, new Object[] { ArgumentType.STRING_STRING, member } });

    if (null != sig) {
        if (log.isDebugEnabled()) {
            log.debug("Appending arguments with signature: " + sig);
        }
        hargs.add(new Object[] { Message.HeaderField.SIGNATURE,
                new Object[] { ArgumentType.SIGNATURE_STRING, sig } });
        this.headers.put(Message.HeaderField.SIGNATURE, sig);
        setArgs(args);
    }

    byte[] blen = new byte[4];
    appendBytes(blen);
    append("ua(yv)", this.serial, hargs.toArray());
    pad((byte) 8);

    long c = this.bytecounter;
    if (null != sig)
        append(sig, args);

    if (log.isDebugEnabled()) {
        log.debug("Appended body, type: " + sig + " start: " + c + " end: " + this.bytecounter + " size: "
                + (this.bytecounter - c));
    }
    marshallint(this.bytecounter - c, blen, 0, 4);
    if (log.isDebugEnabled()) {
        Hex h = new Hex();
        log.debug("marshalled size (" + blen + "): " + h.encode(blen));
    }
}