Java Code Examples for java.util.Vector.insertElementAt()

The following are Jave code examples for showing how to use insertElementAt() of the java.util.Vector class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: AgentWorkbench   File: TableModel.java   View Source Code Vote up 7 votes
/**
 * Converts the table data to a Vector of Object Vectors
 * @param addHeaders If true, an additional vector containing the column headers will be added
 * @param isTimeSeriesData If true, the first column is interpreted as timestamps and converted to a time format
 * @return The table data as a Vector of Object Vectors
 */
public Vector<Vector<Object>> getTableDataAsObjectVector(boolean addHeaders, boolean isTimeSeriesData){
	Vector<Vector<Object>> dataVector = new Vector<Vector<Object>>();
	
	DateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
	
	if(addHeaders == true){
		dataVector.addElement(new Vector<Object>(Arrays.asList(columnTitles.toArray())));
	}
	
	
	Collection<Vector<Number>> treeMapData = this.getTableModelDataVector().getKeyRowVectorTreeMap().values();
	for(Vector<Number> numberVector : treeMapData){
		Vector<Object> objectVector = new Vector<Object>(Arrays.asList(numberVector.toArray()));
		
		if(isTimeSeriesData == true){
			long timestamp = (long) objectVector.get(0);
			String dateTime = dateFormat.format(new Date(timestamp));
			objectVector.remove(0);
			objectVector.insertElementAt(dateTime, 0);
		}
		
		dataVector.addElement(objectVector);
	}
	return dataVector;
}
 
Example 2
Project: jmt   File: EngineConvex2D.java   View Source Code Vote up 7 votes
/**
 * This function return a vector that contains the same point of the parameter one but
 * the points are ordered from the point with the biggest X to the point with the smallest X
 * @param v The vector to order
 * @return The vector ordered
 */
private Vector<Point2D> orderByX(Vector<Point2D> v) {
	Vector<Point2D> r = (Vector<Point2D>) v.clone();
	boolean again = true;

	while (again) {
		again = false;
		for (int k = 0; k < r.size() - 1; k++) {
			//Take the points
			Point2D p1 = r.get(k);
			Point2D p2 = r.get(k + 1);

			if (p1.getX() < p2.getX()) {
				//swap
				r.remove(k);
				r.insertElementAt(p2, k);
				r.remove(k + 1);
				r.insertElementAt(p1, k + 1);
				again = true;
			}
		}
	}
	return r;
}
 
Example 3
Project: routerapp   File: AnimationUIState.java   View Source Code Vote up 7 votes
/**
 * @see ring.gui.context.UIState#loadState()
 */
public void loadState() {
	init();
	executed = new Vector();
	executed.insertElementAt(new Boolean(true),frame);
	executed.insertElementAt(new Boolean(false),frame+1);
	frame++;
	lastCommand = frame;
	algorithmFinished = false;

	this.execThread = new Thread(new AlgorithmExecutionThread(algName,graph,animationView.getWorkspace(),this));
	graph.addGraphObserver(this);
	
	animationView.refresh();
	execThread.start();
}
 
Example 4
Project: openjdk-jdk10   File: IIOPInputStream.java   View Source Code Vote up 7 votes
private Vector getOrderedDescriptions(String repositoryID,
                                      com.sun.org.omg.SendingContext.CodeBase sender) {
    Vector descs = new Vector();

    if (sender == null) {
        return descs;
    }

    FullValueDescription aFVD = sender.meta(repositoryID);
    while (aFVD != null) {
        descs.insertElementAt(aFVD, 0);
        if ((aFVD.base_value != null) && !kEmptyStr.equals(aFVD.base_value)) {
            aFVD = sender.meta(aFVD.base_value);
        }
        else return descs;
    }

    return descs;
}
 
Example 5
Project: SuperMarketManageSystem   File: XiaoShouPaiHang.java   View Source Code Vote up 7 votes
private void updateTable(Iterator iterator) {
	int rowCount = dftm.getRowCount();
	for (int i = 0; i < rowCount; i++) {
		dftm.removeRow(0);
	}
	while (iterator.hasNext()) {
		Vector vector = new Vector();
		List view = (List) iterator.next();
		Vector row=new Vector(view);
		int rowSize = row.size();
		for(int i=rowSize-2;i<rowSize;i++){
			Object colValue = row.get(i);
			row.remove(i);
			row.insertElementAt(colValue, 2);
		}
		vector.addAll(row);
		dftm.addRow(vector);
	}
}
 
Example 6
Project: QN-ACTR-Release   File: EngineConvex2D.java   View Source Code Vote up 7 votes
/**
 * This function return a vector that contains the same point of the parameter one but
 * the points are orderet from the point whith the biggest X to the point whith the smallest X
 * @param v The vector to order
 * @return The vector ordered
 */
private Vector<Point2D> orderByX(Vector<Point2D> v) {
	Vector<Point2D> r = (Vector<Point2D>) v.clone();
	boolean again = true;

	while (again) {
		again = false;
		for (int k = 0; k < r.size() - 1; k++) {
			//Take the points
			Point2D p1 = r.get(k);
			Point2D p2 = r.get(k + 1);

			if (p1.getX() < p2.getX()) {
				//swap
				r.remove(k);
				r.insertElementAt(p2, k);
				r.remove(k + 1);
				r.insertElementAt(p1, k + 1);
				again = true;
			}
		}
	}
	return r;
}
 
Example 7
Project: openjdk-jdk10   File: LdapName.java   View Source Code Vote up 7 votes
Vector<Rdn> getDn() throws InvalidNameException {
    cur = 0;
    Vector<Rdn> rdns = new Vector<>(len / 3 + 10);  // leave room for growth

    if (len == 0) {
        return rdns;
    }

    rdns.addElement(parseRdn());
    while (cur < len) {
        if (chars[cur] == ',' || chars[cur] == ';') {
            ++cur;
            rdns.insertElementAt(parseRdn(), 0);
        } else {
            throw new InvalidNameException("Invalid name: " + name);
        }
    }
    return rdns;
}
 
Example 8
Project: unitimes   File: ExamEditForm.java   View Source Code Vote up 7 votes
public Collection getCourseNbrs(int idx) { 
    Vector ret = new Vector();
    boolean contains = false;
    if (getSubjectArea(idx)>=0) {
        for (Iterator i= new CourseOfferingDAO().
                getSession().
                createQuery("select co.uniqueId, co.courseNbr, co.title from CourseOffering co "+
                        "where co.subjectArea.uniqueId = :subjectAreaId "+
                        "and co.instructionalOffering.notOffered = false "+
                        "order by co.courseNbr ").
                setFetchSize(200).
                setCacheable(true).
                setLong("subjectAreaId", getSubjectArea(idx)).iterate();i.hasNext();) {
            Object[] o = (Object[])i.next();
            ret.add(new IdValue((Long)o[0],((String)o[1] + " - " + (String)o[2])));
            if (o[0].equals(getCourseNbr(idx))) contains = true;
        }
    }
    if (!contains) setCourseNbr(idx, -1L);
    if (ret.size()==1) setCourseNbr(idx, ((IdValue)ret.firstElement()).getId());
    else ret.insertElementAt(new IdValue(-1L,"-"), 0);
    return ret;
}
 
Example 9
Project: openjdk-jdk10   File: IDLGenerator.java   View Source Code Vote up 7 votes
/**
 * Collect and sort data fields for a ValueType.
 * Sort in Java (not IDL) Unicode name string lexicographic increasing
 * order.
 * Non-static, non-transient fields are mapped.
 * If the type is a custom valuetype, only public fields are mapped.
 * @param t The current CompoundType
 * @return Vector containing the data fields
 */
protected Vector getData(
                         CompoundType t ) {
    Vector vec = new Vector();
    if ( t.getTypeCode() != TYPE_VALUE ) return vec;
    ValueType vt = (ValueType)t;
    CompoundType.Member[] mems = vt.getMembers();
    boolean notCust = !vt.isCustom();
    for ( int i1 = 0; i1 < mems.length; i1++ ) {               //forall members
        if ( !mems[i1].isStatic()    &&
             !mems[i1].isTransient() &&
             (  mems[i1].isPublic() || notCust ) ) {
            int i2;
            String memName = mems[i1].getName();
            for ( i2 = 0; i2 < vec.size(); i2++ ) {      //insert in java lex order
                CompoundType.Member aMem = (CompoundType.Member)vec.elementAt( i2 );
                if ( memName.compareTo( aMem.getName() ) < 0 ) break;
            }
            vec.insertElementAt( mems[i1],i2 );                   //insert this one
        }
    }
    return vec;
}
 
Example 10
Project: unitimes   File: ExamDistributionPrefsForm.java   View Source Code Vote up 7 votes
public Collection getCourseNbrs(int idx) {
    Vector ret = new Vector();
    boolean contains = false;
    if (getSubjectArea(idx)>=0) {
        for (Iterator i= new CourseOfferingDAO().
                getSession().
                createQuery("select co.uniqueId, co.courseNbr, co.title from CourseOffering co "+
                        "where co.subjectArea.uniqueId = :subjectAreaId "+
                        "and co.instructionalOffering.notOffered = false "+
                        "order by co.courseNbr ").
                setFetchSize(200).
                setCacheable(true).
                setLong("subjectAreaId", getSubjectArea(idx)).iterate();i.hasNext();) {
            Object[] o = (Object[])i.next();
            ret.add(new IdValue((Long)o[0],((String)o[1]) + " - " + (String) o[2]));
            if (o[0].equals(getCourseNbr(idx))) contains = true;
        }
    }
    if (!contains) setCourseNbr(idx, -1L);
    if (ret.size()==1) setCourseNbr(idx, ((IdValue)ret.firstElement()).getId());
    else ret.insertElementAt(new IdValue(-1L,"-"), 0);
    return ret;
}
 
Example 11
Project: unitimes   File: ExamDistributionPrefsForm.java   View Source Code Vote up 7 votes
public Collection getExams(int idx) { 
    Vector ret = new Vector();
    boolean contains = false;
    if (getCourseNbr(idx)>=0) {
        TreeSet exams = new TreeSet(Exam.findExamsOfCourseOffering(getCourseNbr(idx),getExamType())); 
        for (Iterator i=exams.iterator();i.hasNext();) {
            Exam exam = (Exam)i.next();
            ret.add(new IdValue(exam.getUniqueId(),exam.getLabel()));
            if (exam.getUniqueId().equals(getExam(idx))) contains = true;
        }
    }
    if (!contains) setExam(idx, -1L);
    if (ret.size()==1) setCourseNbr(idx, ((IdValue)ret.firstElement()).getId());
    else ret.insertElementAt(new IdValue(-1L,"-"), 0);
    return ret;
}
 
Example 12
Project: jdk8u-jdk   File: LdapName.java   View Source Code Vote up 7 votes
Vector<Rdn> getDn() throws InvalidNameException {
    cur = 0;
    Vector<Rdn> rdns = new Vector<>(len / 3 + 10);  // leave room for growth

    if (len == 0) {
        return rdns;
    }

    rdns.addElement(parseRdn());
    while (cur < len) {
        if (chars[cur] == ',' || chars[cur] == ';') {
            ++cur;
            rdns.insertElementAt(parseRdn(), 0);
        } else {
            throw new InvalidNameException("Invalid name: " + name);
        }
    }
    return rdns;
}
 
Example 13
Project: OpenJSharp   File: IIOPInputStream.java   View Source Code Vote up 7 votes
private Vector getOrderedDescriptions(String repositoryID,
                                      com.sun.org.omg.SendingContext.CodeBase sender) {
    Vector descs = new Vector();

    if (sender == null) {
        return descs;
    }

    FullValueDescription aFVD = sender.meta(repositoryID);
    while (aFVD != null) {
        descs.insertElementAt(aFVD, 0);
        if ((aFVD.base_value != null) && !kEmptyStr.equals(aFVD.base_value)) {
            aFVD = sender.meta(aFVD.base_value);
        }
        else return descs;
    }

    return descs;
}
 
Example 14
Project: OpenJSharp   File: LdapName.java   View Source Code Vote up 7 votes
Vector<Rdn> getDn() throws InvalidNameException {
    cur = 0;
    Vector<Rdn> rdns = new Vector<>(len / 3 + 10);  // leave room for growth

    if (len == 0) {
        return rdns;
    }

    rdns.addElement(parseRdn());
    while (cur < len) {
        if (chars[cur] == ',' || chars[cur] == ';') {
            ++cur;
            rdns.insertElementAt(parseRdn(), 0);
        } else {
            throw new InvalidNameException("Invalid name: " + name);
        }
    }
    return rdns;
}
 
Example 15
Project: jmt   File: Polygon.java   View Source Code Vote up 6 votes
/**
 * Reverse the order of the vertices that define a contour
 */
public void reverse() {
	/* Add vertices in reverse order */
	Vector<Vertex> vertices = getVertices();
	int size = vertices.size();
	for (int i = 1; i < size; i++) {
		vertices.insertElementAt(vertices.elementAt(i), 0);
		vertices.removeElementAt(i + 1);
	}
}
 
Example 16
Project: marathonv5   File: RMenuItem.java   View Source Code Vote up 6 votes
private String buildMenuElementArray(JMenuItem leaf) {
    Vector<JMenuItem> elements = new Vector<JMenuItem>();

    elements.insertElementAt(leaf, 0);
    Component current = leaf.getParent();

    while (current != null) {
        if (current instanceof JPopupMenu) {
            JPopupMenu pop = (JPopupMenu) current;
            current = pop.getInvoker();
        } else if (current instanceof JMenu) {
            JMenu menu = (JMenu) current;
            elements.insertElementAt(menu, 0);
            current = menu.getParent();
        } else if (current instanceof JMenuBar) {
            break;
        } else {
            current = current.getParent();
        }
    }
    mainMenu = elements.get(0);
    JMenuItem parent = null;
    StringBuilder sb = new StringBuilder();
    RComponentFactory finder = new RComponentFactory(omapConfig);
    for (JMenuItem jMenuItem : elements) {
        RComponent rComponent = finder.findRComponent(jMenuItem, null, recorder);
        recorder.recordMenuItem(rComponent);
        String text = JMenuItemJavaElement.getText(JMenuItemJavaElement.getItemText(jMenuItem), jMenuItem,
                parent == null ? new Component[0] : ((JMenu) parent).getMenuComponents());
        parent = jMenuItem;
        sb.append(text).append(">>");
    }
    sb.setLength(sb.length() - 2);
    return sb.toString();
}
 
Example 17
Project: ramus   File: HTTPParser.java   View Source Code Vote up 6 votes
private Row[] getSelRows(Qualifier clasificator) {
    final Enumeration e = params.keys();
    Vector v = new Vector();
    final String base = params.get("base");
    if (base == null) {
        while (e.hasMoreElements()) {
            final Object key = e.nextElement();
            final GlobalId id = GlobalId.convert(key.toString());
            if (id != null) {
                if (!params.get(key).equals("")) {
                    final Row r = dataPlugin.findRowByGlobalId(id);
                    if (r != null)
                        v.add(r);
                }
            }
        }
        final Vector rec = dataPlugin.getRecChildren(clasificator);
        final Vector res = new Vector();
        Object tmp;
        for (int i = 0; i < rec.size(); i++)
            if (v.indexOf(tmp = rec.get(i)) >= 0)
                res.add(tmp);
        v = res;
    } else {
        try {
            final Row row = dataPlugin.findRowByGlobalId(GlobalId
                    .convert(base));
            v = dataPlugin.getRecChilds(row, true);
            v.insertElementAt(row, 0);
        } catch (final Exception ex) {

        }
    }
    final Row[] rows = new Row[v.size()];
    for (int i = 0; i < rows.length; i++)
        rows[i] = (Row) v.get(i);
    return rows;
}
 
Example 18
Project: ipack   File: X509Name.java   View Source Code Vote up 5 votes
/**
 * Takes an X509 dir name as a string of the format "C=AU, ST=Victoria", or
 * some such, converting it into an ordered set of name attributes. lookUp
 * should provide a table of lookups, indexed by lowercase only strings and
 * yielding a ASN1ObjectIdentifier, other than that OID. and numeric oids
 * will be processed automatically. The passed in converter is used to convert the
 * string values to the right of each equals sign to their ASN.1 counterparts.
 * <br>
 * @param reverse true if we should start scanning from the end, false otherwise.
 * @param lookUp table of names and oids.
 * @param dirName the string dirName
 * @param converter the converter to convert string values into their ASN.1 equivalents
 */
public X509Name(
    boolean                 reverse,
    Hashtable               lookUp,
    String                  dirName,
    X509NameEntryConverter  converter)
{
    this.converter = converter;
    X509NameTokenizer   nTok = new X509NameTokenizer(dirName);

    while (nTok.hasMoreTokens())
    {
        String  token = nTok.nextToken();

        if (token.indexOf('+') > 0)
        {
            X509NameTokenizer   pTok = new X509NameTokenizer(token, '+');

            addEntry(lookUp, pTok.nextToken(), FALSE);

            while (pTok.hasMoreTokens())
            {
                addEntry(lookUp, pTok.nextToken(), TRUE);
            }
        }
        else
        {
            addEntry(lookUp, token, FALSE);
        }
    }

    if (reverse)
    {
        Vector  o = new Vector();
        Vector  v = new Vector();
        Vector  a = new Vector();

        int count = 1;

        for (int i = 0; i < this.ordering.size(); i++)
        {
            if (((Boolean)this.added.elementAt(i)).booleanValue())
            {
                o.insertElementAt(this.ordering.elementAt(i), count);
                v.insertElementAt(this.values.elementAt(i), count);
                a.insertElementAt(this.added.elementAt(i), count);
                count++;
            }
            else
            {
                o.insertElementAt(this.ordering.elementAt(i), 0);
                v.insertElementAt(this.values.elementAt(i), 0);
                a.insertElementAt(this.added.elementAt(i), 0);
                count = 1;
            }
        }

        this.ordering = o;
        this.values = v;
        this.added = a;
    }
}
 
Example 19
Project: OpenJSharp   File: Mode.java   View Source Code Vote up 5 votes
/**
 * Adds a pattern to a pattern group
 */
private void addPattern(int kernelType, LocationPathPattern pattern) {
    // Make sure the array of pattern groups is long enough
    final int oldLength = _patternGroups.length;
    if (kernelType >= oldLength) {
        Vector[] newGroups = new Vector[kernelType * 2];
        System.arraycopy(_patternGroups, 0, newGroups, 0, oldLength);
        _patternGroups = newGroups;
    }

    // Find the vector to put this pattern into
    Vector patterns;

    if (kernelType == DOM.NO_TYPE) {
        if (pattern.getAxis() == Axis.ATTRIBUTE) {
            patterns = (_attribNodeGroup == null) ?
                (_attribNodeGroup = new Vector(2)) : _attribNodeGroup;
        }
        else {
            patterns = (_childNodeGroup == null) ?
                (_childNodeGroup = new Vector(2)) : _childNodeGroup;
        }
    }
    else {
        patterns = (_patternGroups[kernelType] == null) ?
            (_patternGroups[kernelType] = new Vector(2)) :
            _patternGroups[kernelType];
    }

    if (patterns.size() == 0) {
        patterns.addElement(pattern);
    }
    else {
        boolean inserted = false;
        for (int i = 0; i < patterns.size(); i++) {
            final LocationPathPattern lppToCompare =
                (LocationPathPattern)patterns.elementAt(i);

            if (pattern.noSmallerThan(lppToCompare)) {
                inserted = true;
                patterns.insertElementAt(pattern, i);
                break;
            }
        }
        if (inserted == false) {
            patterns.addElement(pattern);
        }
    }
}
 
Example 20
Project: openjdk-jdk10   File: IDLGenerator.java   View Source Code Vote up 5 votes
/**
 * Apply user specified -idlModule translation to package names of given
 * IDLEntity ct. Example:
 *   -idlModule foo.bar real::mod::nesting
 * @param ct CompoundType containing given IDLEntity.
 * @param vec Returned Vector of translated IDL module names.
 * @return boolean true if any translation was done.
 */
protected boolean translateJavaPackage(
                                       CompoundType ct,
                                       Vector vec ) {
    vec.removeAllElements();
    boolean ret = false;
    String fc = null;
    if ( ! ct.isIDLEntity() ) return ret;

    String pName = ct.getPackageName();         //start from Java package names
    if ( pName == null ) return ret;
    StringTokenizer pt = new StringTokenizer( pName,"." );
    while ( pt.hasMoreTokens() ) vec.addElement( pt.nextToken() );

    if ( imHash.size() > 0 ) {           //any -idlModule translation to apply?
        Enumeration k = imHash.keys();

    nextModule:
        while ( k.hasMoreElements() ) {      //loop thro user-defined -idlModules
            String from = (String)k.nextElement();                  //from String..
            StringTokenizer ft = new StringTokenizer( from,"." );
            int vecLen = vec.size();
            int ifr;
            for ( ifr = 0; ifr < vecLen && ft.hasMoreTokens(); ifr++ )
                if ( ! vec.elementAt(ifr).equals( ft.nextToken() ) )
                    continue nextModule;                                  //..no match

            if ( ft.hasMoreTokens() ) {                          //matched so far..
                fc = ft.nextToken();                         //a 'from' token remains
                if ( ! ct.getName().equals( fc ) ||             //matches class name?
                     ft.hasMoreTokens() )
                    continue nextModule;                                   //..no match
            }

            ret = true;                                             //found a match
            for ( int i4 = 0; i4 < ifr; i4++ )
                vec.removeElementAt( 0 );                     //remove 'from' package

            String to = (String)imHash.get( from );                   //..to String
            StringTokenizer tt = new StringTokenizer( to,IDL_NAME_SEPARATOR );

            int itoco = tt.countTokens();
            int ito = 0;
            if ( fc != null ) itoco--;               //user may have given IDL type
            for ( ito = 0; ito < itoco; ito++ )
                vec.insertElementAt( tt.nextToken(),ito );      //insert 'to' modules
            if ( fc != null ) {
                String tc = tt.nextToken();
                if ( ! ct.getName().equals( tc ) )           //not the IDL type, so..
                    vec.insertElementAt( tc,ito );           //insert final 'to' module
            }
        }
    }
    return ret;
}