Example usage for java.util Vector add

List of usage examples for java.util Vector add

Introduction

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

Prototype

public synchronized boolean add(E e) 

Source Link

Document

Appends the specified element to the end of this Vector.

Usage

From source file:edu.ku.brc.specify.dbsupport.AccessionAutoNumberAlphaNum.java

@Override
protected String getHighestObject(final UIFieldFormatterIFace formatter, final Session session,
        final String value, final Pair<Integer, Integer> yearPos, final Pair<Integer, Integer> pos)
        throws Exception {
    Division currDivision = AppContextMgr.getInstance().getClassObject(Division.class);

    String ansSQL = "SELECT ans.AutonumberingSchemeID, ans.FormatName, ans.IsNumericOnly, ans.SchemeName, dv.Name, dv.DivisionID "
            + "FROM autonumberingscheme ans "
            + "Inner Join autonumsch_div ad ON ans.AutoNumberingSchemeID = ad.AutoNumberingSchemeID "
            + "Inner Join division dv ON ad.DivisionID = dv.UserGroupScopeId WHERE dv.UserGroupScopeId = %d AND FormatName = '%s'";
    String sql = String.format(ansSQL, currDivision.getId(), formatter.getName());
    log.debug(sql);//from ww  w .j  av a 2s.co m

    Vector<Object[]> rows = BasicSQLUtils.query(sql);
    Integer ansID = null;
    if (rows.size() == 1) {
        ansID = (Integer) rows.get(0)[0];

    } else if (rows.size() == 0) {
        errorMsg = "There are NO formatters named [" + formatter.getName() + "]";
    } else {
        errorMsg = "Too many Formatters named [" + formatter.getName() + "]";
    }

    if (ansID == null) {
        log.debug(errorMsg);
        return null;
    }

    //String sql          = "SELECT autonumberingscheme.FormatName, autonumberingscheme.SchemeName, autonumberingscheme.IsNumericOnly, collection.CollectionName, discipline.Name, division.Name, accession.AccessionNumber FROM autonumberingscheme Inner Join autonumsch_coll ON autonumberingscheme.AutoNumberingSchemeID = autonumsch_coll.AutoNumberingSchemeID Inner Join collection ON autonumsch_coll.CollectionID = collection.UserGroupScopeId Inner Join discipline ON collection.DisciplineID = discipline.UserGroupScopeId Inner Join division ON discipline.DivisionID = division.UserGroupScopeId Inner Join accession ON division.UserGroupScopeId = accession.DivisionID ";
    //String ansToDivLong = "SELECT ans.FormatName, ans.SchemeName, ans.IsNumericOnly, c.CollectionName, ds.Name, dv.Name FROM autonumberingscheme ans Inner Join autonumsch_coll ac ON ans.AutoNumberingSchemeID = ac.AutoNumberingSchemeID Inner Join collection c ON ac.CollectionID = c.UserGroupScopeId Inner Join discipline ds ON c.DisciplineID = ds.UserGroupScopeId Inner Join division dv ON ds.DivisionID = dv.UserGroupScopeId ";
    String ansToDivSQL = "SELECT dv.UserGroupScopeId DivID FROM autonumberingscheme ans "
            + "Inner Join autonumsch_div ad ON ans.AutoNumberingSchemeID = ad.AutoNumberingSchemeID "
            + "Inner Join division dv ON ad.DivisionID = dv.UserGroupScopeId "
            + "WHERE ans.AutoNumberingSchemeID = %d";

    ansToDivSQL = String.format(ansToDivSQL, ansID);
    log.debug(ansToDivSQL);

    Vector<Integer> divIds = new Vector<Integer>();
    for (Object[] row : BasicSQLUtils.query(ansToDivSQL)) {
        divIds.add((Integer) row[0]);
    }

    Integer yearVal = null;
    if (yearPos != null && StringUtils.isNotEmpty(value) && value.length() >= yearPos.second) {
        yearVal = extractIntegerValue(yearPos, value).intValue();
    }

    StringBuilder sb = new StringBuilder(
            "SELECT a.accessionNumber FROM Accession a Join a.division dv Join dv.numberingSchemes ans WHERE ans.id = ");
    AutoNumberingScheme accessionAutoNumScheme = currDivision
            .getNumberingSchemesByType(Accession.getClassTableId());
    if (accessionAutoNumScheme != null && accessionAutoNumScheme.getAutoNumberingSchemeId() != null) {
        sb.append(accessionAutoNumScheme.getAutoNumberingSchemeId());
        sb.append(" AND dv.id in (");
        for (Integer dvId : divIds) {
            sb.append(dvId);
            sb.append(',');
        }
        sb.setLength(sb.length() - 1);
        sb.append(')');

    } else {
        UIRegistry.showError("There is no AutonumberingScheme for the Accession formatter!");
        return "";
    }

    if (yearVal != null) {
        sb.append(" AND ");
        sb.append(yearVal);
        sb.append(" = substring(" + fieldName + "," + (yearPos.first + 1) + ","
                + (yearPos.second - yearPos.first) + ")");
    }

    sb.append(" ORDER BY");

    try {
        if (yearPos != null) {
            sb.append(" substring(" + fieldName + "," + (yearPos.first + 1) + ","
                    + (yearPos.second - yearPos.first) + ") desc");
        }

        if (pos != null) {
            if (yearPos != null) {
                sb.append(", ");
            }
            sb.append(" substring(" + fieldName + "," + (pos.first + 1) + "," + (pos.second - pos.first)
                    + ") desc");
        }

        System.out.println("AccessionAutoNumberAlphaNum - " + sb.toString());

        List<?> list = session.createQuery(sb.toString()).setMaxResults(1).list();
        if (list.size() == 1) {
            return list.get(0).toString();
        }
    } catch (Exception ex) {
        edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
        edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(AccessionAutoNumberAlphaNum.class, ex);
        ex.printStackTrace();
    }
    return null;
}

From source file:net.vanosten.dings.swing.SummaryView.java

private void initComponents() {
    chartP = new JPanel();
    chartP.setLayout(new BorderLayout());
    //to begin with we show an information
    JLabel infoL = new JLabel(
            "Choose the chart type belwo and press the \"Update View\" button to show statistics.");
    infoL.setEnabled(false); //only for display
    infoL.setHorizontalAlignment(SwingConstants.CENTER);
    chartP.add(infoL, BorderLayout.CENTER);

    Vector<String> items = new Vector<String>();
    items.add("Entries by " + Toolbox.getInstance().getInfoPointer().getUnitLabel());
    items.add("Entries by " + Toolbox.getInstance().getInfoPointer().getCategoryLabel());
    items.add("Entries by Entry Type");
    items.add("Entries by Score");
    items.add("Entry Scores over Time"); //do not change sequence of elements, as showGraph() and checkChosenStattype rely on it
    chartTypeCB = new JComboBox(items);
    chartTypeCB.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            if (4 == chartTypeCB.getSelectedIndex()) {
                chosenCB.setEnabled(false);
            } else {
                chosenCB.setEnabled(true);
            }//  w w  w .  j a  v a  2  s  .  co  m
        }
    });

    chosenCB = new JCheckBox("Only Selected Entries", false);
    chosenCB.setMnemonic("O".charAt(0));
}

From source file:at.lame.hellonzb.parser.DownloadFile.java

/**
 * Return a vector of all remaining file segments.
 * /*from  w w  w. j  a  v a  2 s .c  o m*/
 * @return The data vector
 */
public Vector<DownloadFileSegment> getAllSegments() {
    Vector<DownloadFileSegment> vec = new Vector<DownloadFileSegment>();

    for (int i = segments.firstKey(); i <= segCount; i++)
        vec.add(segments.get(i));

    return vec;
}

From source file:at.lame.hellonzb.parser.DownloadFile.java

/**
 * Return a vector of all original file segments.
 * /* w  w w  .  j  av a  2  s.com*/
 * @return The data vector
 */
public Vector<DownloadFileSegment> getAllOriginalSegments() {
    Vector<DownloadFileSegment> vec = new Vector<DownloadFileSegment>();

    for (int i = origSegments.firstKey(); i <= segCount; i++)
        vec.add(origSegments.get(i));

    return vec;
}

From source file:com.mtomczak.nausicaa.MainActivity.java

/**
 * Initializes the state notifiers, which are used when telemetry comes in
 * to determine if we need to send a notification to an output.
 *///  w  w w.  j av a  2  s.c o  m
private void initStateNotifiers() {
    Vector<OutputInterface> speak = new Vector<OutputInterface>();
    speak.add(tts);

    Vector<OutputInterface> speakAndKillTimeWarp = new Vector<OutputInterface>(speak);
    speakAndKillTimeWarp.add(timeWarpHalt);

    notifiers.add(new StateNotifier(new StateChecks.CircularOrbit(), speak, "Circular orbit achieved."));
    notifiers.add(new StateNotifier(new StateChecks.AtmosphereStrike(), speak,
            "Warning: orbit unstable; periapsis within atmosphere."));
    notifiers.add(new StateNotifier(new StateChecks.ElectricityCritical(), speakAndKillTimeWarp,
            "Warning: Electric charge has fallen to under fifty percent."));
}

From source file:gsn.http.A3DWebServiceImpl.java

public String[] getSensorLocation(String sensor) {

    VSensorConfig sensorConfig = Mappings.getVSensorConfig(sensor);
    Vector<String> sensorLocation = new Vector<String>();
    for (KeyValue df : sensorConfig.getAddressing())
        sensorLocation
                .add(StringEscapeUtils.escapeXml(df.getKey().toString()) + "=" + df.getValue().toString());

    String v_sensorLocation[] = new String[sensorLocation.size()];
    for (int i = 0; i < sensorLocation.size(); i++)
        v_sensorLocation[i] = sensorLocation.get(i);

    return v_sensorLocation;

}

From source file:it.intecs.pisa.toolbox.util.URLReader.java

protected static String[] getSSESchemaDirectoryListingFromPortal(String baseUrl) {
    String[] listing;//from  w w w. j  ava 2s.co  m
    String[] fileListing;
    String[] directoryListing;
    String[] subDirectoryListing;
    Vector<String> subFolderFullListing;
    Enumeration<String> en;
    int i = 0;
    String url;

    subFolderFullListing = new Vector<String>();

    ToolboxConfiguration toolboxConfiguration;
    toolboxConfiguration = ToolboxConfiguration.getInstance();

    url = "http://" + toolboxConfiguration.getConfigurationValue(ToolboxConfiguration.SSE_PORTAL) + "/schemas/"
            + baseUrl;

    fileListing = getFileToDW(url);
    directoryListing = getDirectoryToDW(url);
    for (String subDir : directoryListing) {
        subDirectoryListing = getSSESchemaDirectoryListingFromPortal(subDir);
        for (String sub : subDirectoryListing) {
            System.out.println("ADDING " + sub);
            subFolderFullListing.add(sub);
        }
    }

    listing = new String[fileListing.length + subFolderFullListing.size()];
    en = subFolderFullListing.elements();
    for (String file : fileListing) {
        listing[i] = file;
        i++;
    }

    while (en.hasMoreElements()) {
        listing[i] = en.nextElement();
        i++;
    }
    return listing;
}