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

The following are Jave code examples for showing how to use toArray() 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: Yass   File: YassLanguageFilter.java   View Source Code Vote up 8 votes
/**
 * Gets the genericRules attribute of the YassLanguageFilter object
 *
 * @param data Description of the Parameter
 * @return The genericRules value
 */
public String[] getGenericRules(Vector<YassSong> data) {
    Vector<String> langs = new Vector<>();
    for (Enumeration<?> e = data.elements(); e.hasMoreElements(); ) {
        YassSong s = (YassSong) e.nextElement();
        String lang = s.getLanguage();
        if (lang == null || lang.length() < 1) {
            continue;
        }
        if (!langs.contains(lang)) {
            langs.addElement(lang);

        }
    }
    Collections.sort(langs);

    return langs.toArray(new String[langs.size()]);
}
 
Example 2
Project: openjdk-jdk10   File: Harness.java   View Source Code Vote up 8 votes
String[] parseBenchArgs(StreamTokenizer tokens)
    throws IOException, ConfigFormatException
{
    Vector vec = new Vector();
    for (;;) {
        switch (tokens.ttype) {
            case StreamTokenizer.TT_EOF:
            case StreamTokenizer.TT_EOL:
                return (String[]) vec.toArray(new String[vec.size()]);

            case StreamTokenizer.TT_WORD:
            case '"':
                vec.add(tokens.sval);
                tokens.nextToken();
                break;

            default:
                throw new ConfigFormatException("unrecognized arg token " +
                        "on line " + tokens.lineno());
        }
    }
}
 
Example 3
Project: AgentWorkbench   File: EnvironmentController.java   View Source Code Vote up 7 votes
/**
 * Gets the description instances of the agents to start, identified by the agent name
 *
 * @param agentName the agent name
 * @return the array of AgentClassElement4SimStart depending on the agent name
 */
public AgentClassElement4SimStart[] getAgents2StartFromAgentName(String agentName) {
	
	AgentClassElement4SimStart[] ace4sArr = null;
	Vector<AgentClassElement4SimStart> ace4sVector = new Vector<AgentClassElement4SimStart>();
	
	for (int i = 0; i < this.agents2Start.size(); i++) {
		AgentClassElement4SimStart ace4s = (AgentClassElement4SimStart) this.agents2Start.get(i);
		if (ace4s.getStartAsName().equals(agentName)) {
			ace4sVector.add(ace4s);
		}
	}

	if (ace4sVector.size()!=0) {
		ace4sArr = ace4sVector.toArray(new AgentClassElement4SimStart[ace4sVector.size()]);	
	}
	return ace4sArr;
}
 
Example 4
Project: Android-SerialPort-API   File: SerialPortFinder.java   View Source Code Vote up 7 votes
public String[] getAllDevices() {
    Vector<String> devices = new Vector<String>();
    // Parse each driver
    Iterator<Driver> itdriv;
    try {
        itdriv = getDrivers().iterator();
        while (itdriv.hasNext()) {
            Driver driver = itdriv.next();
            Iterator<File> itdev = driver.getDevices().iterator();
            while (itdev.hasNext()) {
                String device = itdev.next().getName();
                String value = String.format("%s (%s)", device, driver.getName());
                devices.add(value);
            }
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
    return devices.toArray(new String[devices.size()]);
}
 
Example 5
Project: openjdk-jdk10   File: AreaOp.java   View Source Code Vote up 7 votes
public static void finalizeSubCurves(Vector<CurveLink> subcurves,
                                     Vector<ChainEnd> chains) {
    int numchains = chains.size();
    if (numchains == 0) {
        return;
    }
    if ((numchains & 1) != 0) {
        throw new InternalError("Odd number of chains!");
    }
    ChainEnd[] endlist = new ChainEnd[numchains];
    chains.toArray(endlist);
    for (int i = 1; i < numchains; i += 2) {
        ChainEnd open = endlist[i - 1];
        ChainEnd close = endlist[i];
        CurveLink subcurve = open.linkTo(close);
        if (subcurve != null) {
            subcurves.add(subcurve);
        }
    }
    chains.clear();
}
 
Example 6
Project: jdk8u-jdk   File: GetKeySpecException.java   View Source Code Vote up 7 votes
private static Provider[] removeProviders(String cipherAlg) {
    Vector providers = new Vector();
    boolean done = false;
    while (!done) {
        try {
            Cipher c = Cipher.getInstance(cipherAlg);
            Provider p = c.getProvider();
            providers.add(p);
            Security.removeProvider(p.getName());
        } catch (NoSuchAlgorithmException nsae) {
            done = true;
        } catch (NoSuchPaddingException nspe) {
            // should never happen
        }
    }
    return (Provider[]) (providers.toArray(new Provider[0]));
}
 
Example 7
Project: scheduling-connector-for-hadoop   File: HPCUtils.java   View Source Code Vote up 7 votes
public static String[] parseHostList(String hosts) {

		Matcher m = Pattern.compile("([^,\\[]+)(\\[(([^\\]])*)\\])?").matcher(
				hosts);
		Vector<String> list = new Vector<String>();

		while (m.find()) {
			String prefix = m.group(1);
			String range = m.group(3);
			if (range == null) {
				list.add(prefix);
				continue;
			}
			for (String x : range.split(",")) {
				String[] y = x.split("-");
				int start = Integer.parseInt(y[0]);
				int end = y.length == 1 ? start : Integer.parseInt(y[1]);
				for (int i = start; i <= end; i++)
					list.add(prefix + i);
			}
		}
		return list.toArray(new String[0]);
	}
 
Example 8
Project: keepass2android   File: OpenSSHConfig.java   View Source Code Vote up 7 votes
private String[] multiFind(String key) {
  Vector value = new Vector();
  for(int i = 0; i < _configs.size(); i++) {
    Vector v = (Vector)_configs.elementAt(i);
    for(int j = 0; j < v.size(); j++) {
      String[] kv = (String[])v.elementAt(j);
      if(kv[0].equals(key)) {
        String foo = kv[1];
        if(foo != null) {
          value.remove(foo);
          value.addElement(foo);
        }
      }
    }
  }
  String[] result = new String[value.size()]; 
  value.toArray(result);
  return result;
}
 
Example 9
Project: OpenJSharp   File: X11FontManager.java   View Source Code Vote up 7 votes
@Override
protected String[] getNativeNames(String fontFileName,
        String platformName) {
    Vector nativeNames;
    if ((nativeNames=(Vector)xlfdMap.get(fontFileName))==null) {
        if (platformName == null) {
            return null;
        } else {
            /* back-stop so that at least the name used in the
             * font configuration file is known as a native name
             */
            String []natNames = new String[1];
            natNames[0] = platformName;
            return natNames;
        }
    } else {
        int len = nativeNames.size();
        return (String[])nativeNames.toArray(new String[len]);
    }
}
 
Example 10
Project: aos-FileCoreLibrary   File: OpenSSHConfig.java   View Source Code Vote up 7 votes
private String[] multiFind(String key) {
  Vector value = new Vector();
  for(int i = 0; i < _configs.size(); i++) {
    Vector v = (Vector)_configs.elementAt(i);
    for(int j = 0; j < v.size(); j++) {
      String[] kv = (String[])v.elementAt(j);
      if(kv[0].equals(key)) {
        String foo = kv[1];
        if(foo != null) {
          value.remove(foo);
          value.addElement(foo);
        }
      }
    }
  }
  String[] result = new String[value.size()]; 
  value.toArray(result);
  return result;
}
 
Example 11
Project: https-github.com-apache-zookeeper   File: MergedLogSource.java   View Source Code Vote up 7 votes
public MergedLogSourceIterator(MergedLogSource src, long starttime, long endtime, FilterOp filter) throws IllegalArgumentException, FilterException {
    Vector<LogIterator> iters = new Vector<LogIterator>();
    for (LogSource s : src.sources) {
	if (s.overlapsRange(starttime, endtime)) {
	    iters.add(s.iterator(starttime, endtime, filter));
	}
    }
    
    sources = new LogIterator[iters.size()];
    sources = iters.toArray(sources);
    nexts = new LogEntry[iters.size()];
    for (int i = 0; i < sources.length; i++) {
	if (sources[i].hasNext()) 
	    nexts[i] = sources[i].next();
    }
    this.filter = filter;
}
 
Example 12
Project: OpenJSharp   File: UnionPathExpr.java   View Source Code Vote up 7 votes
public void setParser(Parser parser) {
    super.setParser(parser);
    // find all expressions in this Union
    final Vector components = new Vector();
    flatten(components);
    final int size = components.size();
    _components = (Expression[])components.toArray(new Expression[size]);
    for (int i = 0; i < size; i++) {
        _components[i].setParser(parser);
        _components[i].setParent(this);
        if (_components[i] instanceof Step) {
            final Step step = (Step)_components[i];
            final int axis = step.getAxis();
            final int type = step.getNodeType();
            // Put attribute iterators first
            if ((axis == Axis.ATTRIBUTE) || (type == DTM.ATTRIBUTE_NODE)) {
                _components[i] = _components[0];
                _components[0] = step;
            }
            // Check if the union contains a reverse iterator
    if (Axis.isReverse(axis)) _reverse = true;
        }
    }
    // No need to reverse anything if another expression lies on top of this
    if (getParent() instanceof Expression) _reverse = false;
}
 
Example 13
Project: Android-SerialPort-API   File: SerialPortFinder.java   View Source Code Vote up 7 votes
public String[] getAllDevicesPath() {
    Vector<String> devices = new Vector<String>();
    // Parse each driver
    Iterator<Driver> itdriv;
    try {
        itdriv = getDrivers().iterator();
        while (itdriv.hasNext()) {
            Driver driver = itdriv.next();
            Iterator<File> itdev = driver.getDevices().iterator();
            while (itdev.hasNext()) {
                String device = itdev.next().getAbsolutePath();
                devices.add(device);
            }
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
    return devices.toArray(new String[devices.size()]);
}
 
Example 14
Project: ramus   File: NDataPlugin.java   View Source Code Vote up 6 votes
public void sortByName(final Row row, final boolean element) {
    if (row == null) {
        final Vector v = getChilds(null, element);
        final Object o[] = v.toArray();
        Arrays.sort(o, new RowNameComparator<Object>());

    } else
        row.sortByName(element);
}
 
Example 15
Project: SER316-Ingolstadt   File: MimeType.java   View Source Code Vote up 6 votes
public String[] getExtensions() {
    Vector v = new Vector();
    String[] ss = {};
    Elements exts = _root.getChildElements("ext");
    for (int i = 0; i < exts.size(); i++)
        v.add(exts.get(i).getValue());
    return (String[]) v.toArray(ss);
}
 
Example 16
Project: ClassroomFlipkart   File: SerialStruct.java   View Source Code Vote up 5 votes
/**
  * Constructs a <code>SerialStruct</code> object from the
  * given <code>SQLData</code> object, using the given type
  * map to custom map it to a class in the Java programming
  * language.  The type map gives the SQL type and the class
  * to which it is mapped.  The <code>SQLData</code> object
  * defines the class to which the SQL type will be mapped.
  *
  * @param in an instance of the <code>SQLData</code> class
  *           that defines the mapping of the SQL structured
  *           type to one or more objects in the Java programming language
  * @param map a <code>java.util.Map</code> object in which
  *        each entry consists of 1) a <code>String</code> object
  *        giving the fully qualified name of a UDT and 2) the
  *        <code>Class</code> object for the <code>SQLData</code> implementation
  *        that defines how the UDT is to be mapped
  * @throws SerialException if an error occurs
  */
public SerialStruct(SQLData in, Map<String,Class<?>> map)
    throws SerialException
{

    try {

    //set the type name
    SQLTypeName = in.getSQLTypeName();

    Vector<Object> tmp = new Vector<>();
    in.writeSQL(new SQLOutputImpl(tmp, map));
    attribs = tmp.toArray();

    } catch (SQLException e) {
        throw new SerialException(e.getMessage());
    }
}
 
Example 17
Project: openjdk-jdk10   File: FontConfiguration.java   View Source Code Vote up 5 votes
protected String[] split(String sequence) {
    Vector<String> v = splitSequence(sequence);
    return v.toArray(new String[0]);
}
 
Example 18
Project: JDigitalSimulator   File: Application.java   View Source Code Vote up 5 votes
private SimulationFrame[] cast(JInternalFrame[] frames) {
	Vector<SimulationFrame> list = new Vector<SimulationFrame>(frames.length);
	for(JInternalFrame frame:frames)
		list.add((SimulationFrame)frame);
	return list.toArray(new SimulationFrame[0]);
}
 
Example 19
Project: OpenJSharp   File: SystemTray.java   View Source Code Vote up 4 votes
/**
 * Returns an array of all icons added to the tray by this
 * application.  You can't access the icons added by another
 * application.  Some browsers partition applets in different
 * code bases into separate contexts, and establish walls between
 * these contexts.  In such a scenario, only the tray icons added
 * from this context will be returned.
 *
 * <p> The returned array is a copy of the actual array and may be
 * modified in any way without affecting the system tray.  To
 * remove a <code>TrayIcon</code> from the
 * <code>SystemTray</code>, use the {@link
 * #remove(TrayIcon)} method.
 *
 * @return an array of all tray icons added to this tray, or an
 * empty array if none has been added
 * @see #add(TrayIcon)
 * @see TrayIcon
 */
public TrayIcon[] getTrayIcons() {
    Vector<TrayIcon> icons = (Vector<TrayIcon>)AppContext.getAppContext().get(TrayIcon.class);
    if (icons != null) {
        return (TrayIcon[])icons.toArray(new TrayIcon[icons.size()]);
    }
    return EMPTY_TRAY_ARRAY;
}
 
Example 20
Project: bluez-dbus   File: BluetoothDevice.java   View Source Code Vote up 4 votes
/**
 * <b>From bluez Documentation:</b>
 * <p>
 * List of 128-bit UUIDs that represents the available
 * remote services.
 * </p>
 * @return string array of UUIDs, maybe null
 */
public String[] getUuids() {
    Vector<?> typed = getTyped("UUIDs", Vector.class);
    if (typed != null) {
        return typed.toArray(new String[]{});
    }
    return null;
}