Java Code Examples for java.util.Vector#setElementAt()

The following examples show how to use java.util.Vector#setElementAt() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultTableModel.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 *  Adds a column to the model.  The new column will have the
 *  identifier <code>columnName</code>, which may be null.
 *  <code>columnData</code> is the
 *  optional vector of data for the column.  If it is <code>null</code>
 *  the column is filled with <code>null</code> values.  Otherwise,
 *  the new data will be added to model starting with the first
 *  element going to row 0, etc.  This method will send a
 *  <code>tableChanged</code> notification message to all the listeners.
 *
 * @param   columnName the identifier of the column being added
 * @param   columnData       optional data of the column being added
 */
public void addColumn(Object columnName, Vector columnData) {
    columnIdentifiers.addElement(columnName);
    if (columnData != null) {
        int columnSize = columnData.size();
        if (columnSize > getRowCount()) {
            dataVector.setSize(columnSize);
        }
        justifyRows(0, getRowCount());
        int newColumn = getColumnCount() - 1;
        for(int i = 0; i < columnSize; i++) {
              Vector row = (Vector)dataVector.elementAt(i);
              row.setElementAt(columnData.elementAt(i), newColumn);
        }
    }
    else {
        justifyRows(0, getRowCount());
    }

    fireTableStructureChanged();
}
 
Example 2
Source File: DefaultTableModel.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 *  Adds a column to the model.  The new column will have the
 *  identifier <code>columnName</code>, which may be null.
 *  <code>columnData</code> is the
 *  optional vector of data for the column.  If it is <code>null</code>
 *  the column is filled with <code>null</code> values.  Otherwise,
 *  the new data will be added to model starting with the first
 *  element going to row 0, etc.  This method will send a
 *  <code>tableChanged</code> notification message to all the listeners.
 *
 * @param   columnName the identifier of the column being added
 * @param   columnData       optional data of the column being added
 */
public void addColumn(Object columnName, Vector columnData) {
    columnIdentifiers.addElement(columnName);
    if (columnData != null) {
        int columnSize = columnData.size();
        if (columnSize > getRowCount()) {
            dataVector.setSize(columnSize);
        }
        justifyRows(0, getRowCount());
        int newColumn = getColumnCount() - 1;
        for(int i = 0; i < columnSize; i++) {
              Vector row = (Vector)dataVector.elementAt(i);
              row.setElementAt(columnData.elementAt(i), newColumn);
        }
    }
    else {
        justifyRows(0, getRowCount());
    }

    fireTableStructureChanged();
}
 
Example 3
Source File: DefaultTableModel.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 *  Adds a column to the model.  The new column will have the
 *  identifier <code>columnName</code>, which may be null.
 *  <code>columnData</code> is the
 *  optional vector of data for the column.  If it is <code>null</code>
 *  the column is filled with <code>null</code> values.  Otherwise,
 *  the new data will be added to model starting with the first
 *  element going to row 0, etc.  This method will send a
 *  <code>tableChanged</code> notification message to all the listeners.
 *
 * @param   columnName the identifier of the column being added
 * @param   columnData       optional data of the column being added
 */
public void addColumn(Object columnName, Vector columnData) {
    columnIdentifiers.addElement(columnName);
    if (columnData != null) {
        int columnSize = columnData.size();
        if (columnSize > getRowCount()) {
            dataVector.setSize(columnSize);
        }
        justifyRows(0, getRowCount());
        int newColumn = getColumnCount() - 1;
        for(int i = 0; i < columnSize; i++) {
              Vector row = (Vector)dataVector.elementAt(i);
              row.setElementAt(columnData.elementAt(i), newColumn);
        }
    }
    else {
        justifyRows(0, getRowCount());
    }

    fireTableStructureChanged();
}
 
Example 4
Source File: Whitespace.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Used with quicksort method above
 */
private static int partition(Vector rules, int p, int r) {
    final WhitespaceRule x = (WhitespaceRule)rules.elementAt((p+r) >>> 1);
    int i = p - 1, j = r + 1;
    while (true) {
        while (x.compareTo((WhitespaceRule)rules.elementAt(--j)) < 0) {
        }
        while (x.compareTo((WhitespaceRule)rules.elementAt(++i)) > 0) {
        }
        if (i < j) {
            final WhitespaceRule tmp = (WhitespaceRule)rules.elementAt(i);
            rules.setElementAt(rules.elementAt(j), i);
            rules.setElementAt(tmp, j);
        }
        else {
            return j;
        }
    }
}
 
Example 5
Source File: DefaultTableModel.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 *  Adds a column to the model.  The new column will have the
 *  identifier <code>columnName</code>, which may be null.
 *  <code>columnData</code> is the
 *  optional vector of data for the column.  If it is <code>null</code>
 *  the column is filled with <code>null</code> values.  Otherwise,
 *  the new data will be added to model starting with the first
 *  element going to row 0, etc.  This method will send a
 *  <code>tableChanged</code> notification message to all the listeners.
 *
 * @param   columnName the identifier of the column being added
 * @param   columnData       optional data of the column being added
 */
public void addColumn(Object columnName, Vector columnData) {
    columnIdentifiers.addElement(columnName);
    if (columnData != null) {
        int columnSize = columnData.size();
        if (columnSize > getRowCount()) {
            dataVector.setSize(columnSize);
        }
        justifyRows(0, getRowCount());
        int newColumn = getColumnCount() - 1;
        for(int i = 0; i < columnSize; i++) {
              Vector row = (Vector)dataVector.elementAt(i);
              row.setElementAt(columnData.elementAt(i), newColumn);
        }
    }
    else {
        justifyRows(0, getRowCount());
    }

    fireTableStructureChanged();
}
 
Example 6
Source File: PolicyTool.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Add a Permission entry to an existing PolicyEntry at the specified index.
 * A Permission entry consists of a permission, name, and actions.
 *
 * If the permission already exists, it is not added again.
 */
boolean addPermEntry(PolicyEntry pe,
                    PolicyParser.PermissionEntry newPerm,
                    int index) {

    // first add the permission to the Policy Parser Vector
    PolicyParser.GrantEntry grantEntry = pe.getGrantEntry();
    if (grantEntry.contains(newPerm) == true)
        return false;

    Vector<PolicyParser.PermissionEntry> permList =
                                            grantEntry.permissionEntries;
    if (index != -1)
        permList.setElementAt(newPerm, index);
    else
        permList.addElement(newPerm);

    modified = true;
    return true;
}
 
Example 7
Source File: DefaultTableModel.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 *  Adds a column to the model.  The new column will have the
 *  identifier <code>columnName</code>, which may be null.
 *  <code>columnData</code> is the
 *  optional vector of data for the column.  If it is <code>null</code>
 *  the column is filled with <code>null</code> values.  Otherwise,
 *  the new data will be added to model starting with the first
 *  element going to row 0, etc.  This method will send a
 *  <code>tableChanged</code> notification message to all the listeners.
 *
 * @param   columnName the identifier of the column being added
 * @param   columnData       optional data of the column being added
 */
@SuppressWarnings("unchecked") // Adding element to raw columnIdentifiers
public void addColumn(Object columnName, Vector<?> columnData) {
    columnIdentifiers.addElement(columnName);
    if (columnData != null) {
        int columnSize = columnData.size();
        if (columnSize > getRowCount()) {
            dataVector.setSize(columnSize);
        }
        justifyRows(0, getRowCount());
        int newColumn = getColumnCount() - 1;
        for(int i = 0; i < columnSize; i++) {
              Vector<Object> row = dataVector.elementAt(i);
              row.setElementAt(columnData.elementAt(i), newColumn);
        }
    }
    else {
        justifyRows(0, getRowCount());
    }

    fireTableStructureChanged();
}
 
Example 8
Source File: Whitespace.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * Used with quicksort method above
 */
private static int partition(Vector rules, int p, int r) {
    final WhitespaceRule x = (WhitespaceRule)rules.elementAt((p+r) >>> 1);
    int i = p - 1, j = r + 1;
    while (true) {
        while (x.compareTo((WhitespaceRule)rules.elementAt(--j)) < 0) {
        }
        while (x.compareTo((WhitespaceRule)rules.elementAt(++i)) > 0) {
        }
        if (i < j) {
            final WhitespaceRule tmp = (WhitespaceRule)rules.elementAt(i);
            rules.setElementAt(rules.elementAt(j), i);
            rules.setElementAt(tmp, j);
        }
        else {
            return j;
        }
    }
}
 
Example 9
Source File: AttributeValueTemplate.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
    final Vector contents = getContents();
    final int n = contents.size();
    for (int i = 0; i < n; i++) {
        final Expression exp = (Expression)contents.elementAt(i);
        if (!exp.typeCheck(stable).identicalTo(Type.String)) {
            contents.setElementAt(new CastExpr(exp, Type.String), i);
        }
    }
    return _type = Type.String;
}
 
Example 10
Source File: DefaultTableModel.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static void rotate(Vector v, int a, int b, int shift) {
    int size = b - a;
    int r = size - shift;
    int g = gcd(size, r);
    for(int i = 0; i < g; i++) {
        int to = i;
        Object tmp = v.elementAt(a + to);
        for(int from = (to + r) % size; from != i; from = (to + r) % size) {
            v.setElementAt(v.elementAt(a + from), a + to);
            to = from;
        }
        v.setElementAt(tmp, a + to);
    }
}
 
Example 11
Source File: DefaultTableModel.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private static void rotate(Vector v, int a, int b, int shift) {
    int size = b - a;
    int r = size - shift;
    int g = gcd(size, r);
    for(int i = 0; i < g; i++) {
        int to = i;
        Object tmp = v.elementAt(a + to);
        for(int from = (to + r) % size; from != i; from = (to + r) % size) {
            v.setElementAt(v.elementAt(a + from), a + to);
            to = from;
        }
        v.setElementAt(tmp, a + to);
    }
}
 
Example 12
Source File: DefaultTableModel.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private static void rotate(Vector v, int a, int b, int shift) {
    int size = b - a;
    int r = size - shift;
    int g = gcd(size, r);
    for(int i = 0; i < g; i++) {
        int to = i;
        Object tmp = v.elementAt(a + to);
        for(int from = (to + r) % size; from != i; from = (to + r) % size) {
            v.setElementAt(v.elementAt(a + from), a + to);
            to = from;
        }
        v.setElementAt(tmp, a + to);
    }
}
 
Example 13
Source File: IvmContext.java    From tomee with Apache License 2.0 5 votes vote down vote up
protected void buildEnumeration(final Vector vect) {
    for (int i = 0; i < vect.size(); i++) {
        final NameNode node = (NameNode) vect.elementAt(i);
        final String className = node.getBinding().getClass().getName();
        vect.setElementAt(new Binding(node.getAtomicName(), className, node.getBinding()), i);
    }
    myEnum = vect.elements();
}
 
Example 14
Source File: VectorSorter.java    From systemsgenetics with GNU General Public License v3.0 4 votes vote down vote up
private static void swap(Vector a, int i, int j) {
Object T = a.elementAt(i);
a.setElementAt(a.elementAt(j), i);
a.setElementAt(T, j);
   }
 
Example 15
Source File: SetOfIntegerSyntax.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Accumulate the given range (lb .. ub) into the canonical array form
 * into the given vector of int[] objects.
 */
private static void accumulate(Vector ranges, int lb,int ub) {
    // Make sure range is non-null.
    if (lb <= ub) {
        // Stick range at the back of the vector.
        ranges.add(new int[] {lb, ub});

        // Work towards the front of the vector to integrate the new range
        // with the existing ranges.
        for (int j = ranges.size()-2; j >= 0; -- j) {
        // Get lower and upper bounds of the two ranges being compared.
            int[] rangea = (int[]) ranges.elementAt (j);
            int lba = rangea[0];
            int uba = rangea[1];
            int[] rangeb = (int[]) ranges.elementAt (j+1);
            int lbb = rangeb[0];
            int ubb = rangeb[1];

            /* If the two ranges overlap or are adjacent, coalesce them.
             * The two ranges overlap if the larger lower bound is less
             * than or equal to the smaller upper bound. The two ranges
             * are adjacent if the larger lower bound is one greater
             * than the smaller upper bound.
             */
            if (Math.max(lba, lbb) - Math.min(uba, ubb) <= 1) {
                // The coalesced range is from the smaller lower bound to
                // the larger upper bound.
                ranges.setElementAt(new int[]
                                       {Math.min(lba, lbb),
                                            Math.max(uba, ubb)}, j);
                ranges.remove (j+1);
            } else if (lba > lbb) {

                /* If the two ranges don't overlap and aren't adjacent but
                 * are out of order, swap them.
                 */
                ranges.setElementAt (rangeb, j);
                ranges.setElementAt (rangea, j+1);
            } else {
            /* If the two ranges don't overlap and aren't adjacent and
             * aren't out of order, we're done early.
             */
                break;
            }
        }
    }
}
 
Example 16
Source File: JDBCTableModel.java    From cropplanning with GNU General Public License v3.0 4 votes vote down vote up
public void setValueAt(Object aValue, int aRow, int aCol) {
   Vector dataRow = (Vector) allRows.elementAt(aRow);
   dataRow.setElementAt(aValue, aCol);
   fireTableCellUpdated(aRow, aCol);
}
 
Example 17
Source File: SetOfIntegerSyntax.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Accumulate the given range (lb .. ub) into the canonical array form
 * into the given vector of int[] objects.
 */
private static void accumulate(Vector ranges, int lb,int ub) {
    // Make sure range is non-null.
    if (lb <= ub) {
        // Stick range at the back of the vector.
        ranges.add(new int[] {lb, ub});

        // Work towards the front of the vector to integrate the new range
        // with the existing ranges.
        for (int j = ranges.size()-2; j >= 0; -- j) {
        // Get lower and upper bounds of the two ranges being compared.
            int[] rangea = (int[]) ranges.elementAt (j);
            int lba = rangea[0];
            int uba = rangea[1];
            int[] rangeb = (int[]) ranges.elementAt (j+1);
            int lbb = rangeb[0];
            int ubb = rangeb[1];

            /* If the two ranges overlap or are adjacent, coalesce them.
             * The two ranges overlap if the larger lower bound is less
             * than or equal to the smaller upper bound. The two ranges
             * are adjacent if the larger lower bound is one greater
             * than the smaller upper bound.
             */
            if (Math.max(lba, lbb) - Math.min(uba, ubb) <= 1) {
                // The coalesced range is from the smaller lower bound to
                // the larger upper bound.
                ranges.setElementAt(new int[]
                                       {Math.min(lba, lbb),
                                            Math.max(uba, ubb)}, j);
                ranges.remove (j+1);
            } else if (lba > lbb) {

                /* If the two ranges don't overlap and aren't adjacent but
                 * are out of order, swap them.
                 */
                ranges.setElementAt (rangeb, j);
                ranges.setElementAt (rangea, j+1);
            } else {
            /* If the two ranges don't overlap and aren't adjacent and
             * aren't out of order, we're done early.
             */
                break;
            }
        }
    }
}
 
Example 18
Source File: DefaultTableModel.java    From jdk8u_jdk with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Sets the object value for the cell at <code>column</code> and
 * <code>row</code>.  <code>aValue</code> is the new value.  This method
 * will generate a <code>tableChanged</code> notification.
 *
 * @param   aValue          the new value; this can be null
 * @param   row             the row whose value is to be changed
 * @param   column          the column whose value is to be changed
 * @exception  ArrayIndexOutOfBoundsException  if an invalid row or
 *               column was given
 */
public void setValueAt(Object aValue, int row, int column) {
    Vector rowVector = (Vector)dataVector.elementAt(row);
    rowVector.setElementAt(aValue, column);
    fireTableCellUpdated(row, column);
}
 
Example 19
Source File: DefaultTableModel.java    From jdk8u60 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Sets the object value for the cell at <code>column</code> and
 * <code>row</code>.  <code>aValue</code> is the new value.  This method
 * will generate a <code>tableChanged</code> notification.
 *
 * @param   aValue          the new value; this can be null
 * @param   row             the row whose value is to be changed
 * @param   column          the column whose value is to be changed
 * @exception  ArrayIndexOutOfBoundsException  if an invalid row or
 *               column was given
 */
public void setValueAt(Object aValue, int row, int column) {
    Vector rowVector = (Vector)dataVector.elementAt(row);
    rowVector.setElementAt(aValue, column);
    fireTableCellUpdated(row, column);
}
 
Example 20
Source File: DefaultTableModel.java    From jdk8u-dev-jdk with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Sets the object value for the cell at <code>column</code> and
 * <code>row</code>.  <code>aValue</code> is the new value.  This method
 * will generate a <code>tableChanged</code> notification.
 *
 * @param   aValue          the new value; this can be null
 * @param   row             the row whose value is to be changed
 * @param   column          the column whose value is to be changed
 * @exception  ArrayIndexOutOfBoundsException  if an invalid row or
 *               column was given
 */
public void setValueAt(Object aValue, int row, int column) {
    Vector rowVector = (Vector)dataVector.elementAt(row);
    rowVector.setElementAt(aValue, column);
    fireTableCellUpdated(row, column);
}