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

The following are Jave code examples for showing how to use copyInto() 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: openjdk-jdk10   File: ImageTransferTest.java   View Source Code Vote up 6 votes
public TransferableObject(Object data) throws Exception {
    Vector v = new Vector();
    imageFlavor = new DataFlavor("image/x-java-Image;class=java.awt.Image");
    imageFlavor.setHumanPresentableName("Java Image Flavor Object");

    if( data instanceof java.awt.Image )
        v.addElement(imageFlavor);

    dfs = new DataFlavor[v.size()];
    v.copyInto(dfs);

    for (int j = 0; j < dfs.length; j++)
        System.out.println(" in constructor flavor : " + dfs[j]);

    this.data = data;
}
 
Example 2
Project: openjdk-jdk10   File: ZoneView.java   View Source Code Vote up 6 votes
/**
 * Break up the zone at the given index into pieces
 * of an acceptable size.
 */
void splitZone(int index, int offs0, int offs1) {
    // divide the old zone into a new set of bins
    Element elem = getElement();
    Document doc = elem.getDocument();
    Vector<View> zones = new Vector<View>();
    int offs = offs0;
    do {
        offs0 = offs;
        offs = Math.min(getDesiredZoneEnd(offs0), offs1);
        zones.addElement(createZone(offs0, offs));
    } while (offs < offs1);
    View oldZone = getView(index);
    View[] newZones = new View[zones.size()];
    zones.copyInto(newZones);
    replace(index, 1, newZones);
}
 
Example 3
Project: sstore-soft   File: ZaurusTableForm.java   View Source Code Vote up 5 votes
private void fetchPrimaryKeys() {

        Vector temp = new Vector(20);

        try {
            if (cConn == null) {
                return;
            }

            if (dbmeta == null) {
                dbmeta = cConn.getMetaData();
            }

            ResultSet colList = dbmeta.getPrimaryKeys(null, null, tableName);

            while (colList.next()) {
                temp.addElement(colList.getString("COLUMN_NAME"));
            }

            colList.close();
        } catch (SQLException e) {
            ZaurusEditor.printStatus("SQL Exception: " + e.getMessage());
        }

        primaryKeys = new String[temp.size()];

        temp.copyInto(primaryKeys);

        pkColIndex = new int[primaryKeys.length];

        for (int i = 0; i < primaryKeys.length; i++) {
            pkColIndex[i] = this.getColIndex(primaryKeys[i]);
        }    // end of for (int i=0; i<primaryKeys.length; i++)
    }
 
Example 4
Project: OpenJSharp   File: RemoteClass.java   View Source Code Vote up 5 votes
/**
 * Return a new Method object that is a legal combination of
 * this method object and another one.
 *
 * This requires determining the exceptions declared by the
 * combined method, which must be (only) all of the exceptions
 * declared in both old Methods that may thrown in either of
 * them.
 */
private Method mergeWith(Method other) {
    if (!getName().equals(other.getName()) ||
        !getType().equals(other.getType()))
        {
            throw new Error("attempt to merge method \"" +
                            other.getNameAndDescriptor() + "\" with \"" +
                            getNameAndDescriptor());
        }

    Vector<ClassDeclaration> legalExceptions
        = new Vector<ClassDeclaration>();
    try {
        collectCompatibleExceptions(
                                    other.exceptions, exceptions, legalExceptions);
        collectCompatibleExceptions(
                                    exceptions, other.exceptions, legalExceptions);
    } catch (ClassNotFound e) {
        env.error(0, "class.not.found", e.name,
                  getClassDefinition().getName());
        return null;
    }

    Method merged = (Method) clone();
    merged.exceptions = new ClassDeclaration[legalExceptions.size()];
    legalExceptions.copyInto(merged.exceptions);

    return merged;
}
 
Example 5
Project: jdk8u-jdk   File: RemoteClass.java   View Source Code Vote up 5 votes
/**
 * Return a new Method object that is a legal combination of
 * this method object and another one.
 *
 * This requires determining the exceptions declared by the
 * combined method, which must be (only) all of the exceptions
 * declared in both old Methods that may thrown in either of
 * them.
 */
private Method mergeWith(Method other) {
    if (!getName().equals(other.getName()) ||
        !getType().equals(other.getType()))
        {
            throw new Error("attempt to merge method \"" +
                            other.getNameAndDescriptor() + "\" with \"" +
                            getNameAndDescriptor());
        }

    Vector<ClassDeclaration> legalExceptions
        = new Vector<ClassDeclaration>();
    try {
        collectCompatibleExceptions(
                                    other.exceptions, exceptions, legalExceptions);
        collectCompatibleExceptions(
                                    exceptions, other.exceptions, legalExceptions);
    } catch (ClassNotFound e) {
        env.error(0, "class.not.found", e.name,
                  getClassDefinition().getName());
        return null;
    }

    Method merged = (Method) clone();
    merged.exceptions = new ClassDeclaration[legalExceptions.size()];
    legalExceptions.copyInto(merged.exceptions);

    return merged;
}
 
Example 6
Project: OpenJSharp   File: KrbCredInfo.java   View Source Code Vote up 5 votes
/**
 * Encodes an KrbCredInfo object.
 * @return the byte array of encoded KrbCredInfo object.
 * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data.
 * @exception IOException if an I/O error occurs while reading encoded data.
 */
public byte[] asn1Encode() throws Asn1Exception, IOException {
    Vector<DerValue> v = new Vector<>();
    v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x00), key.asn1Encode()));
    if (pname != null) {
        v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x01), pname.getRealm().asn1Encode()));
        v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x02), pname.asn1Encode()));
    }
    if (flags != null)
        v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x03), flags.asn1Encode()));
    if (authtime != null)
        v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x04), authtime.asn1Encode()));
    if (starttime != null)
        v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x05), starttime.asn1Encode()));
    if (endtime != null)
        v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x06), endtime.asn1Encode()));
    if (renewTill != null)
        v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x07), renewTill.asn1Encode()));
    if (sname != null) {
        v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x08), sname.getRealm().asn1Encode()));
        v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x09), sname.asn1Encode()));
    }
    if (caddr != null)
        v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x0A), caddr.asn1Encode()));
    DerValue der[] = new DerValue[v.size()];
    v.copyInto(der);
    DerOutputStream out = new DerOutputStream();
    out.putSequence(der);
    return out.toByteArray();
}
 
Example 7
Project: Hubs   File: LuaTable.java   View Source Code Vote up 5 votes
/** This may be deprecated in a future release.  
 * It is recommended to use next() instead 
 * @return array of keys in the table 
 * */
public LuaValue[] keys() {
	Vector l = new Vector();
	LuaValue k = LuaValue.NIL;
	while ( true ) {
		Varargs n = next(k);
		if ( (k = n.arg1()).isnil() )
			break;
		l.addElement( k );
	}
	LuaValue[] a = new LuaValue[l.size()];
	l.copyInto(a);
	return a;
}
 
Example 8
Project: parabuild-ci   File: ZaurusTableForm.java   View Source Code Vote up 5 votes
private void fetchColumns() {

        Vector temp     = new Vector(20);
        Vector tempType = new Vector(20);

        try {
            if (cConn == null) {
                return;
            }

            if (dbmeta == null) {
                dbmeta = cConn.getMetaData();
            }

            ResultSet colList = dbmeta.getColumns(null, null, tableName, "%");

            while (colList.next()) {
                temp.addElement(colList.getString("COLUMN_NAME"));
                tempType.addElement(new Short(colList.getShort("DATA_TYPE")));
            }

            colList.close();
        } catch (SQLException e) {
            ZaurusEditor.printStatus("SQL Exception: " + e.getMessage());
        }

        columns = new String[temp.size()];

        temp.copyInto(columns);

        columnTypes = new short[temp.size()];

        for (int i = 0; i < columnTypes.length; i++) {
            columnTypes[i] = ((Short) tempType.elementAt(i)).shortValue();
        }
    }
 
Example 9
Project: powertext   File: GenericTransformator.java   View Source Code Vote up 5 votes
private void buildRules(BufferedReader in) throws IOException {
  String read = null;
  Vector<TransformationRule> ruleList = new Vector<TransformationRule>();
  while ((read = in.readLine()) != null) {
    buildRule(realTrimmer(read), ruleList);
  }
  ruleArray = new TransformationRule[ruleList.size()];
  ruleList.copyInto(ruleArray);
}
 
Example 10
Project: parabuild-ci   File: ZaurusTableForm.java   View Source Code Vote up 5 votes
private void fetchColumns() {

        Vector temp     = new Vector(20);
        Vector tempType = new Vector(20);

        try {
            if (cConn == null) {
                return;
            }

            if (dbmeta == null) {
                dbmeta = cConn.getMetaData();
            }

            ResultSet colList = dbmeta.getColumns(null, null, tableName, "%");

            while (colList.next()) {
                temp.addElement(colList.getString("COLUMN_NAME"));
                tempType.addElement(new Short(colList.getShort("DATA_TYPE")));
            }

            colList.close();
        } catch (SQLException e) {
            ZaurusEditor.printStatus("SQL Exception: " + e.getMessage());
        }

        columns = new String[temp.size()];

        temp.copyInto(columns);

        columnTypes = new short[temp.size()];

        for (int i = 0; i < columnTypes.length; i++) {
            columnTypes[i] = ((Short) tempType.elementAt(i)).shortValue();
        }
    }
 
Example 11
Project: s-store   File: ZaurusTableForm.java   View Source Code Vote up 5 votes
private void fetchPrimaryKeys() {

        Vector temp = new Vector(20);

        try {
            if (cConn == null) {
                return;
            }

            if (dbmeta == null) {
                dbmeta = cConn.getMetaData();
            }

            ResultSet colList = dbmeta.getPrimaryKeys(null, null, tableName);

            while (colList.next()) {
                temp.addElement(colList.getString("COLUMN_NAME"));
            }

            colList.close();
        } catch (SQLException e) {
            ZaurusEditor.printStatus("SQL Exception: " + e.getMessage());
        }

        primaryKeys = new String[temp.size()];

        temp.copyInto(primaryKeys);

        pkColIndex = new int[primaryKeys.length];

        for (int i = 0; i < primaryKeys.length; i++) {
            pkColIndex[i] = this.getColIndex(primaryKeys[i]);
        }    // end of for (int i=0; i<primaryKeys.length; i++)
    }
 
Example 12
Project: jdk8u-jdk   File: LastReq.java   View Source Code Vote up 5 votes
/**
 * Constructs a LastReq object.
 * @param encoding a Der-encoded data.
 * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data.
 * @exception IOException if an I/O error occurs while reading encoded data.
 */

public LastReq(DerValue encoding) throws Asn1Exception, IOException {
    Vector<LastReqEntry> v= new Vector<>();
    if (encoding.getTag() != DerValue.tag_Sequence) {
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
    }
    while (encoding.getData().available() > 0) {
        v.addElement(new LastReqEntry(encoding.getData().getDerValue()));
    }
    if (v.size() > 0) {
        entry = new LastReqEntry[v.size()];
        v.copyInto(entry);
    }
}
 
Example 13
Project: jdk8u-jdk   File: AuthorizationData.java   View Source Code Vote up 5 votes
/**
 * Constructs a new <code>AuthorizationData,</code> instance.
 * @param der a single DER-encoded value.
 * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data.
 * @exception IOException if an I/O error occurs while reading encoded data.
 */
public AuthorizationData(DerValue der) throws Asn1Exception, IOException {
    Vector<AuthorizationDataEntry> v = new Vector<>();
    if (der.getTag() != DerValue.tag_Sequence) {
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
    }
    while (der.getData().available() > 0) {
        v.addElement(new AuthorizationDataEntry(der.getData().getDerValue()));
    }
    if (v.size() > 0) {
        entry = new AuthorizationDataEntry[v.size()];
        v.copyInto(entry);
    }
}
 
Example 14
Project: OpenJSharp   File: CryptoPermissions.java   View Source Code Vote up 4 votes
/**
 * Get the minimum of the two given PermissionCollection
 * <code>thisPc</code> and <code>thatPc</code>.
 *
 * @param thisPc the first given PermissionColloection
 * object.
 *
 * @param thatPc the second given PermissionCollection
 * object.
 */
private CryptoPermission[] getMinimum(PermissionCollection thisPc,
                                      PermissionCollection thatPc) {
    Vector<CryptoPermission> permVector = new Vector<>(2);

    Enumeration<Permission> thisPcPermissions = thisPc.elements();

    // For each CryptoPermission in
    // thisPc object, do the following:
    // 1) if this CryptoPermission is implied
    //     by thatPc, this CryptoPermission
    //     should be returned, and we can
    //     move on to check the next
    //     CryptoPermission in thisPc.
    // 2) otherwise, we should return
    //     all CryptoPermissions in thatPc
    //     which
    //     are implied by this CryptoPermission.
    //     Then we can move on to the
    //     next CryptoPermission in thisPc.
    while (thisPcPermissions.hasMoreElements()) {
        CryptoPermission thisCp =
            (CryptoPermission)thisPcPermissions.nextElement();

        Enumeration<Permission> thatPcPermissions = thatPc.elements();
        while (thatPcPermissions.hasMoreElements()) {
            CryptoPermission thatCp =
                (CryptoPermission)thatPcPermissions.nextElement();

            if (thatCp.implies(thisCp)) {
                permVector.addElement(thisCp);
                break;
            }
            if (thisCp.implies(thatCp)) {
                permVector.addElement(thatCp);
            }
        }
    }

    CryptoPermission[] ret = new CryptoPermission[permVector.size()];
    permVector.copyInto(ret);
    return ret;
}
 
Example 15
Project: OpenJSharp   File: Win32GraphicsDevice.java   View Source Code Vote up 4 votes
/**
 * Returns all of the graphics
 * configurations associated with this graphics device.
 */
public GraphicsConfiguration[] getConfigurations() {
    if (configs==null) {
        if (WindowsFlags.isOGLEnabled() && isDefaultDevice()) {
            defaultConfig = getDefaultConfiguration();
            if (defaultConfig != null) {
                configs = new GraphicsConfiguration[1];
                configs[0] = defaultConfig;
                return configs.clone();
            }
        }

        int max = getMaxConfigs(screen);
        int defaultPixID = getDefaultPixID(screen);
        Vector v = new Vector( max );
        if (defaultPixID == 0) {
            // Workaround for failing GDI calls
            defaultConfig = Win32GraphicsConfig.getConfig(this,
                                                          defaultPixID);
            v.addElement(defaultConfig);
        }
        else {
            for (int i = 1; i <= max; i++) {
                if (isPixFmtSupported(i, screen)) {
                    if (i == defaultPixID) {
                        defaultConfig = Win32GraphicsConfig.getConfig(
                         this, i);
                        v.addElement(defaultConfig);
                    }
                    else {
                        v.addElement(Win32GraphicsConfig.getConfig(
                         this, i));
                    }
                }
            }
        }
        configs = new GraphicsConfiguration[v.size()];
        v.copyInto(configs);
    }
    return configs.clone();
}
 
Example 16
Project: openjdk-jdk10   File: Parser.java   View Source Code Vote up 4 votes
/**
 * Parse the body of a class or interface declaration,
 * starting at the left brace.
 */
protected ClassDefinition parseClassBody(IdentifierToken nm, int mod,
                                         int ctx, String doc,
                                         Vector<IdentifierToken> ext, Vector<IdentifierToken> impl, long p
                                         ) throws SyntaxError, IOException {
    // Decide which is the super class
    IdentifierToken sup = null;
    if ((mod & M_INTERFACE) != 0) {
        if (impl.size() > 0) {
            env.error(impl.elementAt(0).getWhere(),
                      "intf.impl.intf");
        }
        impl = ext;
    } else {
        if (ext.size() > 0) {
            if (ext.size() > 1) {
                env.error(ext.elementAt(1).getWhere(),
                          "multiple.inherit");
            }
            sup = ext.elementAt(0);
        }
    }

    ClassDefinition oldClass = curClass;

    // Begin a new class
    IdentifierToken implids[] = new IdentifierToken[impl.size()];
    impl.copyInto(implids);
    ClassDefinition newClass =
        actions.beginClass(p, doc, mod, nm, sup, implids);

    // Parse fields
    expect(LBRACE);
    while ((token != EOF) && (token != RBRACE)) {
        try {
            curClass = newClass;
            parseField();
        } catch (SyntaxError e) {
            recoverField(newClass);
        } finally {
            curClass = oldClass;
        }
    }
    expect(RBRACE);

    // End the class
    actions.endClass(scanner.prevPos, newClass);
    return newClass;
}
 
Example 17
Project: OpenJSharp   File: IDLGenerator.java   View Source Code Vote up 4 votes
/**
 * Return the IDL module nesting of the given Type.
 * For IDLEntity CompoundTypes (or their arrays) apply any user specified
 * -idlModule translation or, if none applicable, strip any package
 * prefix.
 * Add boxedIDL or boxedRMI modules if required.
 * @param t Given Type
 * @return Array containing the original module nesting.
 */
protected String[] getIDLModuleNames(Type t) {
    String[] modNames = t.getIDLModuleNames();      //default module name array
    CompoundType ct;
    if ( t.isCompound() ) {
        ct = (CompoundType)t;
        if ( !ct.isIDLEntity ) return modNames;     //normal (non-IDLEntity) case
        if ( "org.omg.CORBA.portable.IDLEntity"
             .equals( t.getQualifiedName() ) )
            return modNames;
    }
    else if ( t.isArray() ) {
        Type et = t.getElementType();
        if ( et.isCompound() ) {
            ct = (CompoundType)et;
            if ( !ct.isIDLEntity ) return modNames;   //normal (non-IDLEntity) case
            if ( "org.omg.CORBA.portable.IDLEntity"
                 .equals( t.getQualifiedName() ) )
                return modNames;
        }
        else return modNames;
    }
    else return modNames;              //no preprocessing needed for primitives

    //it's an IDLEntity or an array of...
    Vector mVec = new Vector();
    if ( !translateJavaPackage( ct,mVec ) )      //apply -idlModule translation
        stripJavaPackage( ct,mVec );             //..or strip prefixes (not both)

    if ( ct.isBoxed() ) {                            //add boxedIDL if required
        mVec.insertElementAt( "org",0 );
        mVec.insertElementAt( "omg",1 );
        mVec.insertElementAt( "boxedIDL",2 );
    }
    if ( t.isArray() ) {                             //add boxedRMI if required
        mVec.insertElementAt( "org",0 );
        mVec.insertElementAt( "omg",1 );
        mVec.insertElementAt( "boxedRMI",2 );
    }
    String[] outArr = new String[mVec.size()];
    mVec.copyInto( outArr );
    return outArr;
}
 
Example 18
Project: openjdk-jdk10   File: CryptoPermissions.java   View Source Code Vote up 4 votes
/**
 * Get the minimum of the two given PermissionCollection
 * <code>thisPc</code> and <code>thatPc</code>.
 *
 * @param thisPc the first given PermissionColloection
 * object.
 *
 * @param thatPc the second given PermissionCollection
 * object.
 */
private CryptoPermission[] getMinimum(PermissionCollection thisPc,
                                      PermissionCollection thatPc) {
    Vector<CryptoPermission> permVector = new Vector<>(2);

    Enumeration<Permission> thisPcPermissions = thisPc.elements();

    // For each CryptoPermission in
    // thisPc object, do the following:
    // 1) if this CryptoPermission is implied
    //     by thatPc, this CryptoPermission
    //     should be returned, and we can
    //     move on to check the next
    //     CryptoPermission in thisPc.
    // 2) otherwise, we should return
    //     all CryptoPermissions in thatPc
    //     which
    //     are implied by this CryptoPermission.
    //     Then we can move on to the
    //     next CryptoPermission in thisPc.
    while (thisPcPermissions.hasMoreElements()) {
        CryptoPermission thisCp =
            (CryptoPermission)thisPcPermissions.nextElement();

        Enumeration<Permission> thatPcPermissions = thatPc.elements();
        while (thatPcPermissions.hasMoreElements()) {
            CryptoPermission thatCp =
                (CryptoPermission)thatPcPermissions.nextElement();

            if (thatCp.implies(thisCp)) {
                permVector.addElement(thisCp);
                break;
            }
            if (thisCp.implies(thatCp)) {
                permVector.addElement(thatCp);
            }
        }
    }

    CryptoPermission[] ret = new CryptoPermission[permVector.size()];
    permVector.copyInto(ret);
    return ret;
}
 
Example 19
Project: OpenJSharp   File: PrincipalName.java   View Source Code Vote up 4 votes
private static String[] parseName(String name) {

        Vector<String> tempStrings = new Vector<>();
        String temp = name;
        int i = 0;
        int componentStart = 0;
        String component;

        while (i < temp.length()) {
            if (temp.charAt(i) == NAME_COMPONENT_SEPARATOR) {
                /*
                 * If this separator is escaped then don't treat it
                 * as a separator
                 */
                if (i > 0 && temp.charAt(i - 1) == '\\') {
                    temp = temp.substring(0, i - 1) +
                        temp.substring(i, temp.length());
                    continue;
                }
                else {
                    if (componentStart <= i) {
                        component = temp.substring(componentStart, i);
                        tempStrings.addElement(component);
                    }
                    componentStart = i + 1;
                }
            } else {
                if (temp.charAt(i) == NAME_REALM_SEPARATOR) {
                    /*
                     * If this separator is escaped then don't treat it
                     * as a separator
                     */
                    if (i > 0 && temp.charAt(i - 1) == '\\') {
                        temp = temp.substring(0, i - 1) +
                            temp.substring(i, temp.length());
                        continue;
                    } else {
                        if (componentStart < i) {
                            component = temp.substring(componentStart, i);
                            tempStrings.addElement(component);
                        }
                        componentStart = i + 1;
                        break;
                    }
                }
            }
            i++;
        }

        if (i == temp.length()) {
            component = temp.substring(componentStart, i);
            tempStrings.addElement(component);
        }

        String[] result = new String[tempStrings.size()];
        tempStrings.copyInto(result);
        return result;
    }
 
Example 20
Project: BiglyBT   File: SimpleXMLParserDocumentImpl.java   View Source Code Vote up 3 votes
protected SimpleXMLParserDocumentNodeImpl[]
parseNode(
	Node		node,
	boolean		skip_this_node )
{
       int type = node.getNodeType();

	if ( (	type == Node.ELEMENT_NODE ||
			type == Node.PROCESSING_INSTRUCTION_NODE )&& !skip_this_node ){

		return( new SimpleXMLParserDocumentNodeImpl[]{ new SimpleXMLParserDocumentNodeImpl( this, node )});
	}

	Vector	v = new Vector();

       for (Node child = node.getFirstChild(); child != null; child = child.getNextSibling()){

		SimpleXMLParserDocumentNodeImpl[] kids = parseNode( child, false );

		for (int i=0;i<kids.length;i++){

			v.addElement(kids[i]);
		}
       }

	SimpleXMLParserDocumentNodeImpl[]	res = new SimpleXMLParserDocumentNodeImpl[v.size()];

	v.copyInto( res );

	return( res );
}