Example usage for java.util Vector contains

List of usage examples for java.util Vector contains

Introduction

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

Prototype

public boolean contains(Object o) 

Source Link

Document

Returns true if this vector contains the specified element.

Usage

From source file:de.lazyzero.kkMulticopterFlashTool.KKMulticopterFlashTool.java

private void loadTranslation() {
    // load the supported locales and the default locale
    Translatrix.loadSupportedLocales("de.lazyzero.kkMulticopterFlashTool.gui.resources.supportedLocales");
    Translatrix.setLocale(Translatrix.getDefaultLocale());
    // load resources for core package
    @SuppressWarnings("rawtypes")
    Vector<Locale> locales = new Vector<Locale>(Translatrix.getSupportedLocales());

    if (locales.contains(locale)) {
        Translatrix.setLocale(locale);//from   w  w w  .j  ava  2s .c  o  m
    } else {
        locale = Translatrix.getLocale();
    }
    Translatrix.addBundle("de.lazyzero.kkMulticopterFlashTool.gui.resources.translatrix");

}

From source file:es.emergya.ui.plugins.admin.AdminLayers.java

protected SummaryAction getSummaryAction(final CapaInformacion capaInformacion) {
    SummaryAction action = new SummaryAction(capaInformacion) {

        private static final long serialVersionUID = -3691171434904452485L;

        @Override//  w  ww  . j  av a2 s .  c  o m
        protected JFrame getSummaryDialog() {

            if (capaInformacion != null) {
                d = getDialog(capaInformacion, null, "", null, "image/png");
                return d;
            } else {
                JDialog primera = getJDialog();
                primera.setResizable(false);
                primera.setVisible(true);
                primera.setAlwaysOnTop(true);
            }
            return null;
        }

        private JDialog getJDialog() {
            final JDialog dialog = new JDialog();
            dialog.setTitle(i18n.getString("admin.capas.nueva.titleBar"));
            dialog.setIconImage(getBasicWindow().getIconImage());

            dialog.setLayout(new BorderLayout());

            JPanel centro = new JPanel(new FlowLayout());
            centro.setOpaque(false);
            JLabel label = new JLabel(i18n.getString("admin.capas.nueva.url"));
            final JTextField url = new JTextField(50);
            final JLabel icono = new JLabel(LogicConstants.getIcon("48x48_transparente"));
            label.setLabelFor(url);
            centro.add(label);
            centro.add(url);
            centro.add(icono);
            dialog.add(centro, BorderLayout.CENTER);

            JPanel pie = new JPanel(new FlowLayout(FlowLayout.TRAILING));
            pie.setOpaque(false);
            final JButton siguiente = new JButton(i18n.getString("admin.capas.nueva.boton.siguiente"),
                    LogicConstants.getIcon("button_next"));
            JButton cancelar = new JButton(i18n.getString("admin.capas.nueva.boton.cancelar"),
                    LogicConstants.getIcon("button_cancel"));
            final SiguienteActionListener siguienteActionListener = new SiguienteActionListener(url, dialog,
                    icono, siguiente);
            url.addActionListener(siguienteActionListener);

            siguiente.addActionListener(siguienteActionListener);

            cancelar.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent e) {
                    dialog.dispose();
                }
            });
            pie.add(siguiente);
            pie.add(cancelar);
            dialog.add(pie, BorderLayout.SOUTH);

            dialog.getContentPane().setBackground(Color.WHITE);

            dialog.pack();
            dialog.setLocationRelativeTo(null);
            return dialog;
        }

        private JFrame getDialog(final CapaInformacion c, final Capa[] left_items, final String service,
                final Map<String, Boolean> transparentes, final String png) {

            if (left_items != null && left_items.length == 0) {
                JOptionPane.showMessageDialog(AdminLayers.this,
                        i18n.getString("admin.capas.nueva.error.noCapasEnServicio"));
            } else {

                final String label_cabecera = i18n.getString("admin.capas.nueva.nombreCapa");
                final String label_pie = i18n.getString("admin.capas.nueva.infoAdicional");
                final String centered_label = i18n.getString("admin.capas.nueva.origenDatos");
                final String left_label = i18n.getString("admin.capas.nueva.subcapasDisponibles");
                final String right_label;
                if (left_items != null) {
                    right_label = i18n.getString("admin.capas.nueva.capasSeleccionadas");
                } else {
                    right_label = i18n.getString("admin.capas.ficha.capasSeleccionadas");
                }
                final String tituloVentana, cabecera;
                if (c.getNombre() == null) {
                    tituloVentana = i18n.getString("admin.capas.nueva.titulo.nuevaCapa");
                    cabecera = i18n.getString("admin.capas.nueva.cabecera.nuevaCapa");
                } else {
                    tituloVentana = i18n.getString("admin.capas.nueva.titulo.ficha");
                    cabecera = i18n.getString("admin.capas.nueva.cabecera.ficha");
                }

                final Capa[] right_items = c.getCapas().toArray(new Capa[0]);
                final AdminPanel.SaveOrUpdateAction<CapaInformacion> guardar = layers.new SaveOrUpdateAction<CapaInformacion>(
                        c) {

                    private static final long serialVersionUID = 7447770296943341404L;

                    @Override
                    public void actionPerformed(ActionEvent e) {

                        if (isNew && CapaConsultas.alreadyExists(textfieldCabecera.getText())) {
                            JOptionPane.showMessageDialog(super.frame,
                                    i18n.getString("admin.capas.nueva.error.nombreCapaYaExiste"));

                        } else if (textfieldCabecera.getText().isEmpty()) {
                            JOptionPane.showMessageDialog(super.frame,
                                    i18n.getString("admin.capas.nueva.error.nombreCapaEnBlanco"));

                        } else if (((DefaultListModel) right.getModel()).size() == 0) {
                            JOptionPane.showMessageDialog(super.frame,
                                    i18n.getString("admin.capas.nueva.error.noCapasSeleccionadas"));

                        } else if (cambios) {
                            int i = JOptionPane.showConfirmDialog(super.frame,
                                    i18n.getString("admin.capas.nueva.confirmar.guardar.titulo"),
                                    i18n.getString("admin.capas.nueva.confirmar.boton.guardar"),
                                    JOptionPane.YES_NO_CANCEL_OPTION);

                            if (i == JOptionPane.YES_OPTION) {

                                if (original == null) {
                                    original = new CapaInformacion();

                                }
                                original.setInfoAdicional(textfieldPie.getText());
                                original.setNombre(textfieldCabecera.getText());
                                original.setHabilitada(habilitado.isSelected());
                                original.setOpcional(comboTipoCapa.getSelectedIndex() != 0);

                                boolean transparente = true;

                                HashSet<Capa> capas = new HashSet<Capa>();
                                List<Capa> capasEnOrdenSeleccionado = new ArrayList<Capa>();
                                int indice = 0;
                                for (Object c : ((DefaultListModel) right.getModel()).toArray()) {
                                    if (c instanceof Capa) {
                                        transparente = transparente && (transparentes != null
                                                && transparentes.get(((Capa) c).getNombre()) != null
                                                && transparentes.get(((Capa) c).getNombre()));
                                        capas.add((Capa) c);
                                        capasEnOrdenSeleccionado.add((Capa) c);
                                        ((Capa) c).setCapaInformacion(original);
                                        ((Capa) c).setOrden(indice++);
                                        // ((Capa)
                                        // c).setNombre(c.toString());
                                    }

                                }
                                original.setCapas(capas);

                                if (original.getId() == null) {
                                    String url = nombre.getText();

                                    if (url.indexOf("?") > -1) {
                                        if (!url.endsWith("?")) {
                                            url += "&";

                                        }
                                    } else {
                                        url += "?";

                                    }
                                    url += "VERSION=" + version + "&REQUEST=GetMap&FORMAT=" + png + "&SERVICE="
                                            + service + "&WIDTH={2}&HEIGHT={3}&BBOX={1}&SRS={0}";
                                    // if (transparente)
                                    url += "&TRANSPARENT=TRUE";
                                    url += "&LAYERS=";

                                    String estilos = "";
                                    final String coma = "%2C";
                                    if (capasEnOrdenSeleccionado.size() > 0) {
                                        for (Capa c : capasEnOrdenSeleccionado) {
                                            url += c.getTitulo().replaceAll(" ", "+") + coma;
                                            estilos += c.getEstilo() + coma;
                                        }
                                        estilos = estilos.substring(0, estilos.length() - coma.length());

                                        estilos = estilos.replaceAll(" ", "+");

                                        url = url.substring(0, url.length() - coma.length());
                                    }
                                    url += "&STYLES=" + estilos;
                                    original.setUrl_visible(original.getUrl());
                                    original.setUrl(url);
                                }
                                CapaInformacionAdmin.saveOrUpdate(original);

                                cambios = false;

                                layers.setTableData(getAll(new CapaInformacion()));

                                closeFrame();
                            } else if (i == JOptionPane.NO_OPTION) {
                                closeFrame();

                            }
                        } else {
                            closeFrame();

                        }
                    }
                };
                JFrame segunda = generateUrlDialog(label_cabecera, label_pie, centered_label, tituloVentana,
                        left_items, right_items, left_label, right_label, guardar,
                        LogicConstants.getIcon("tittleficha_icon_capa"), cabecera, c.getHabilitada(),
                        c.getOpcional(), c.getUrl_visible());
                segunda.setResizable(false);

                if (c != null) {
                    textfieldCabecera.setText(c.getNombre());
                    textfieldPie.setText(c.getInfoAdicional());
                    nombre.setText(c.getUrl_visible());
                    nombre.setEditable(false);
                    if (c.getHabilitada() == null) {
                        c.setHabilitada(false);

                    }
                    habilitado.setSelected(c.getHabilitada());
                    if (c.isOpcional() != null && c.isOpcional()) {
                        comboTipoCapa.setSelectedIndex(1);
                    } else {
                        comboTipoCapa.setSelectedIndex(0);
                    }
                }

                if (c.getId() == null) {
                    habilitado.setSelected(true);
                    comboTipoCapa.setSelectedIndex(1);
                }

                habilitado.setEnabled(true);
                if (c == null || c.getId() == null) {
                    textfieldCabecera.setEditable(true);
                } else {
                    textfieldCabecera.setEditable(false);
                }

                cambios = false;

                segunda.pack();
                segunda.setLocationRelativeTo(null);
                segunda.setVisible(true);
                return segunda;
            }
            return null;
        }

        class SiguienteActionListener implements ActionListener {

            private final JTextField url;
            private final JDialog dialog;
            private final JLabel icono;
            private final JButton siguiente;

            public SiguienteActionListener(JTextField url, JDialog dialog, JLabel icono, JButton siguiente) {
                this.url = url;
                this.dialog = dialog;
                this.icono = icono;
                this.siguiente = siguiente;
            }

            @Override
            public void actionPerformed(ActionEvent e) {
                final CapaInformacion ci = new CapaInformacion();
                ci.setUrl(url.getText());
                ci.setCapas(new HashSet<Capa>());
                SwingWorker<Object, Object> sw = new SwingWorker<Object, Object>() {

                    private List<Capa> res = new LinkedList<Capa>();
                    private String service = "WMS";
                    private String png = null;
                    private Map<String, Boolean> transparentes = new HashMap<String, Boolean>();
                    private ArrayList<String> errorStack = new ArrayList<String>();
                    private Boolean goOn = true;

                    @SuppressWarnings(value = "unchecked")
                    @Override
                    protected Object doInBackground() throws Exception {
                        try {
                            final String url2 = ci.getUrl();
                            WMSClient client = new WMSClient(url2);
                            client.connect(new ICancellable() {

                                @Override
                                public boolean isCanceled() {
                                    return false;
                                }

                                @Override
                                public Object getID() {
                                    return System.currentTimeMillis();
                                }
                            });

                            version = client.getVersion();

                            for (final String s : client.getLayerNames()) {
                                WMSLayer layer = client.getLayer(s);
                                // this.service =
                                // client.getServiceName();
                                final Vector allSrs = layer.getAllSrs();
                                boolean epsg = (allSrs != null) ? allSrs.contains("EPSG:4326") : false;
                                final Vector formats = client.getFormats();
                                if (formats.contains("image/png")) {
                                    png = "image/png";
                                } else if (formats.contains("IMAGE/PNG")) {
                                    png = "IMAGE/PNG";
                                } else if (formats.contains("png")) {
                                    png = "png";
                                } else if (formats.contains("PNG")) {
                                    png = "PNG";
                                }
                                boolean image = png != null;
                                if (png == null) {
                                    png = "IMAGE/PNG";
                                }
                                if (epsg && image) {
                                    boolean hasTransparency = layer.hasTransparency();
                                    this.transparentes.put(s, hasTransparency);
                                    Capa capa = new Capa();
                                    capa.setCapaInformacion(ci);
                                    if (layer.getStyles().size() > 0) {
                                        capa.setEstilo(((WMSStyle) layer.getStyles().get(0)).getName());
                                    }
                                    capa.setNombre(layer.getTitle());
                                    capa.setTitulo(s);
                                    res.add(capa);
                                    if (!hasTransparency) {
                                        errorStack.add(i18n.getString(Locale.ROOT,
                                                "admin.capas.nueva.error.capaNoTransparente",
                                                layer.getTitle()));
                                    }
                                } else {
                                    String error = "";
                                    // if (opaque)
                                    // error += "<li>Es opaca</li>";
                                    if (!image) {
                                        error += i18n.getString("admin.capas.nueva.error.formatoPNG");
                                    }
                                    if (!epsg) {
                                        error += i18n.getString("admin.capas.nueva.error.projeccion");
                                    }
                                    final String cadena = i18n.getString(Locale.ROOT,
                                            "admin.capas.nueva.error.errorCapa", new Object[] { s, error });
                                    errorStack.add(cadena);
                                }
                            }
                        } catch (final Throwable t) {
                            log.error("Error al parsear el WMS", t);
                            goOn = false;
                            icono.setIcon(LogicConstants.getIcon("48x48_transparente"));

                            JOptionPane.showMessageDialog(dialog,
                                    i18n.getString("admin.capas.nueva.error.errorParseoWMS"));

                            siguiente.setEnabled(true);
                        }
                        return null;
                    }

                    @Override
                    protected void done() {
                        super.done();
                        if (goOn) {

                            dialog.dispose();
                            ci.setUrl_visible(ci.getUrl());
                            final JFrame frame = getDialog(ci, res.toArray(new Capa[0]), service, transparentes,
                                    png);
                            if (!errorStack.isEmpty()) {
                                String error = "<html>";
                                for (final String s : errorStack) {
                                    error += s + "<br/>";
                                }
                                error += "</html>";
                                final String errorString = error;
                                SwingUtilities.invokeLater(new Runnable() {

                                    @Override
                                    public void run() {
                                        JOptionPane.showMessageDialog(frame, errorString);
                                    }
                                });
                            }
                        }
                    }
                };
                sw.execute();
                icono.setIcon(LogicConstants.getIcon("anim_conectando"));
                icono.repaint();
                siguiente.setEnabled(false);
            }
        }
    };

    return action;
}

From source file:de.fhg.fokus.odp.middleware.ckan.CKANGatewayUtil.java

/**
 * The function receives a vector with details for a set of revisions and
 * returns the details for the packages affected by these revisions.
 * /*  w ww . j  a  v a2  s  .c om*/
 * @param revisionsDetails
 *            a vector of strings containing the JSON details for the
 *            revisions.
 * @return a vector of maps with the details for each affected package.
 */
@SuppressWarnings("rawtypes")
public static Vector<Map> getUpdatedCategoriesDetails(Vector<String> revisionsDetails) {

    // pass the request to the function for the updated data sets
    Vector uDataSetResults = getUpdatedDataSetsDetails(revisionsDetails);
    if (uDataSetResults == null) {
        return null;
    }

    // the vector to contain the visited groups
    Vector<String> visitedGroups = new Vector<String>();

    // the variable which will be returned
    Vector<Map> toreturn = new Vector<Map>();

    // iterate over the data set results
    for (int i = 0; i < uDataSetResults.size(); i++) {

        // get the groups which where updated as a result of the data set
        // update
        Map m = (Map) uDataSetResults.get(i);
        JSONArray arr = (JSONArray) m.get("groups");

        for (int j = 0; j < arr.size(); j++) {

            // get the next group and check if its data was already obtained
            String grp = (String) arr.get(j);
            if (visitedGroups.contains(grp)) {
                continue;
            }

            visitedGroups.add(grp);

            // prepare the next rest call
            String RESTcall = "api/rest/group/" + grp;

            try {
                String restResponse = connectorInstance.restCallWithAuthorization(RESTcall, null);
                Map grMap = (Map) JSONValue.parse(restResponse);

                toreturn.add(grMap);

            } catch (MalformedURLException e) {
                log.log(Level.SEVERE, "Failed to realize api call \"" + url + RESTcall + "\" !!!");
                continue;
            } catch (IOException e) {
                continue;
            }
        }
    }

    return toreturn;
}

From source file:org.ecoinformatics.seek.datasource.eml.eml2.Eml200DataSource.java

/**
 * Method to transform a string to token based on given type and
 * missingValue.// w  w w  . ja  va2  s . c  om
 */
static Token transformStringToToken(String eleStr, Type type, Vector missingValue, String columnName)
        throws IllegalActionException {
    Token val = null;
    if (missingValue != null && !missingValue.isEmpty()) {
        if (missingValue.contains(eleStr)) {
            eleStr = null;
        }
    }
    String elementError = "Element \"";
    String errorMessage1 = "\" couldn't be in the ";
    String errorMessage2 = " column " + columnName + ". It probably is a missing value code, however metadata "
            + "doesn't describe it. Please make a double check.";
    // find the data type for each att
    if (type == BaseType.INT) {

        if (eleStr != null && !eleStr.equals("")) {
            try {
                val = new IntToken(new Integer(eleStr).intValue());
            } catch (NumberFormatException e) {
                throw (new IllegalActionException(
                        elementError + eleStr + errorMessage1 + "integer" + errorMessage2));
            }
        } else {
            // eleStr = null;
            val = IntToken.NIL;
            // val.nil();
        }

    } else if (type == BaseType.DOUBLE) {
        if (eleStr != null && !eleStr.equals("")) {
            try {
                val = new DoubleToken(new Double(eleStr).doubleValue());
            } catch (NumberFormatException e) {
                throw (new IllegalActionException(
                        elementError + eleStr + errorMessage1 + "numerical" + errorMessage2));
            }
        } else {
            // eleStr = null;
            val = DoubleToken.NIL;
        }

    } else if (type == BaseType.LONG) {
        if (eleStr != null && !eleStr.equals("")) {
            try {
                val = new LongToken(new Long(eleStr).longValue());
            } catch (NumberFormatException e) {
                throw (new IllegalActionException(
                        elementError + eleStr + errorMessage1 + "numerical" + errorMessage2));
            }
        } else {
            // eleStr = null;
            val = LongToken.NIL;
            // val.nil();
        }

    } else if (type == BaseType.STRING) {
        if (eleStr != null) {
            val = new StringToken(eleStr);
        } else {
            // eleStr = "nil";
            val = StringToken.NIL;
            // val.nil();
        }

    } else {
        val = new IntToken(0);
    }
    return val;
}

From source file:es.pode.administracion.presentacion.adminusuarios.modificarUsuario.ModificarUsuarioControllerImpl.java

private GrupoTrabajoVOCheck[] obtenerGrupoTrabajoCheck(GrupoTrabajoVO[] grupoTrabajoVO, UsuarioVO usuarioVO) {

    GrupoTrabajoVOCheck[] resultado = null;
    resultado = new GrupoTrabajoVOCheck[grupoTrabajoVO.length];
    GrupoTrabajoVO[] gruposUsuario = usuarioVO.getGrupoTrabajo();
    Vector vRol = new Vector();

    for (int j = 0; j < gruposUsuario.length; j++) {
        vRol.add(gruposUsuario[j].getIdentificador());
    }//  ww w.ja v a2 s.c om

    for (int i = 0; i < grupoTrabajoVO.length; i++) {
        GrupoTrabajoVOCheck grupo = new GrupoTrabajoVOCheck();
        grupo.setId(grupoTrabajoVO[i].getIdentificador());
        grupo.setNombre(grupoTrabajoVO[i].getNombre());
        grupo.setDescripcion(grupoTrabajoVO[i].getDescripcion());
        grupo.setLoginUsuario(usuarioVO.getUsuario());
        if (vRol.contains(grupoTrabajoVO[i].getIdentificador())) {
            grupo.setChecked(Boolean.TRUE);
        } else {
            grupo.setChecked(Boolean.FALSE);
        }
        resultado[i] = grupo;
    }

    return resultado;
}

From source file:com.alfaariss.oa.sso.web.profile.logout.LogoutProfile.java

private void processConfirmation(HttpServletRequest servletRequest, HttpServletResponse servletResponse,
        ITGT tgt, ISession session) throws OAException {
    //create requestor list with latest added requestor first
    Vector<IRequestor> vRequestors = new Vector<IRequestor>();
    List<String> listRequestorIDs = tgt.getRequestorIDs();
    for (int i = (listRequestorIDs.size() - 1); i >= 0; i--) {
        String sRequestorID = listRequestorIDs.get(i);
        IRequestor oRequestor = _requestorPoolFactory.getRequestor(sRequestorID);
        if (oRequestor != null && !vRequestors.contains(oRequestor))
            vRequestors.add(oRequestor);
    }/*ww w .  j  a  v  a2 s  .  c  o m*/

    session.persist();

    IRequestor requestor = _requestorPoolFactory.getRequestor(session.getRequestorId());

    showConfirmJSP(servletRequest, servletResponse, session, vRequestors, requestor);
}

From source file:org.ecoinformatics.seek.sms.AnnotationEngine.java

/**
 *@param classname// w  ww .  j a v  a  2 s.c  o m
 *            the classname (as a term/keyword) to search for
 *@param approx
 *            if true, find approximate term matches, and if false, do exact
 *            matches Searches the ontology matching the term and for
 *            matches, finds annotated items. For example,
 *            search("RichnessIndex") finds all actors that instantiate
 *            either the class named "RichnessIndex" or one of its
 *            subclasses.
 *@return Description of the Return Value
 */
public Vector<NamedObj> search(String classname, boolean approx) {
    if (isDebugging)
        log.debug("search(" + classname + ", " + approx + ")");
    // check if valid concept name
    if (!isValidClass(classname, approx)) {
        debug("didn't find classname", true);
        return new Vector<NamedObj>();
    }

    Vector<NamedObj> result = new Vector<NamedObj>();
    // find all the matching class names and their subclasses
    Vector<OntClass> classes = getMatchingClassNames(classname, approx);
    Iterator<OntClass> iter = classes.iterator();
    while (iter.hasNext()) {
        // find the matching lsids for the class name
        OntClass cls = iter.next();
        Vector<Object> ids = getMatchingAnnotatedItemIds(cls);
        Iterator<Object> idIter = ids.iterator();
        while (idIter.hasNext()) {
            // get the associated objects
            NamedObj obj = _libService.getData(idIter.next().toString());
            if (obj != null && !result.contains(obj)) {
                result.add(obj);
            }
            // add the results
        }
    }
    return result;
}

From source file:org.mahasen.util.PutUtil.java

/**
 * @return/*  w w w  .  j  a  v  a  2 s. c o  m*/
 */
private Vector<String> getNodeIpsToPut() throws InterruptedException {

    Vector<NodeHandle> nodeHandles = getNodeHandlesToPut();
    Vector<String> nodeIps = new Vector<String>();
    MahasenMsg msg = new MahasenMsg();

    msg.setSendersNodeHandle(mahasenManager.getNode().getLocalHandle());

    for (NodeHandle nodeHandle : nodeHandles) {
        BlockFlag blockFlag = new BlockFlag(true, 100);

        mahasenPastryApp.sendRequestForIp(nodeHandle, msg);
        while (!mahasenPastryApp.isResultAvailable()) {
            if (blockFlag.isBlocked()) {
                mahasenManager.getNode().getEnvironment().getTimeSource().sleep(10);
            } else {
                break;
            }
        }
        if (mahasenPastryApp.isResultAvailable()) {
            String ip = mahasenPastryApp.getResultIpVector().remove(0).toString();
            if (!nodeIps.contains(ip))
                nodeIps.add(ip);
        }

    }

    return nodeIps;
}

From source file:de.fhg.fokus.odp.middleware.ckan.CKANGatewayUtil.java

/**
 * The function receives a vector with details for a set of revisions and
 * returns the details for the packages affected by these revisions.
 * //from  w  w w.j a  v a  2s  . c o  m
 * @param revisionsDetails
 *            a vector of strings containing the JSON details for the
 *            revisions.
 * @return a vector of maps with the details for each affected package.
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
public static Vector getUpdatedDataSetsDetails(Vector<String> revisionsDetails) {

    // check the input packages
    if (revisionsDetails == null) {
        return null;
    }

    // the vector to store return results
    Vector toreturn = new Vector();

    // a variable to hold the already visited packages
    Vector<String> visitedPackages = new Vector<String>();

    // iterate over each single package
    for (int i = 0; i < revisionsDetails.size(); i++) {

        // parse the JSON string and obtain an array of JSON objects
        Object obj = JSONValue.parse(revisionsDetails.get(i));
        Map array = (Map) obj;

        // get the packages
        JSONArray arr = (JSONArray) (array.get("packages"));

        // iterate over all the packages
        for (int j = 0; j < arr.size(); j++) {

            // get the name of the next package
            String pkg = (String) arr.get(j);

            // check whether the package was already visited
            if (visitedPackages.contains(pkg)) {
                continue;
            }

            // add the package to the list of visited packages
            visitedPackages.add(pkg);

            // get the package details
            Object pkgObject = CKANGatewayCore.getDataSetDetails(pkg);

            // add the package details to the toreturn object
            if (pkgObject != null) {
                toreturn.add(pkgObject);
            }
        }
    }

    return toreturn;
}

From source file:org.ecoinformatics.seek.ecogrid.EcoGridServicesController.java

/**
 * Finds a list of services with serviceTypes in the given type list
 * /* ww  w  .  jav a 2  s  . c o m*/
 * @param serviceTypeList
 *            list of serviceTypes to match on
 * @return list of EcoGridService objects for the given serviceTypes
 */
public Vector getServicesList(Vector serviceTypeList) {
    Vector retList = new Vector();
    for (int i = 0; i < currentServicesList.size(); i++) {
        EcoGridService service = (EcoGridService) currentServicesList.get(i);
        if (serviceTypeList.contains(service.getServiceType())) {
            retList.add(service);
        }
    }
    return retList;
}