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

The following examples show how to use java.util.Vector#toArray() . These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
@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 2
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 3
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 4
/**
 * get serialPort devices path
 *
 * @return serialPort path
 */
public String[] getAllDeicesPath() {
    Vector<String> paths = new Vector<>();
    Iterator<Driver> drivers;
    try {
        drivers = getDrivers().iterator();
        while (drivers.hasNext()) {
            Driver driver = drivers.next();
            Iterator<File> files = driver.getDevices().iterator();
            while (files.hasNext()) {
                String devicesPaths = files.next().getAbsolutePath();
                paths.add(devicesPaths);
            }
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
    return paths.toArray(new String[paths.size()]);
}
 
Example 5
Source Project: Bytecoder   File: AudioSystem.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Obtains the encodings that the system can obtain from an audio input
 * stream with the specified encoding using the set of installed format
 * converters.
 *
 * @param  sourceEncoding the encoding for which conversion support is
 *         queried
 * @return array of encodings. If {@code sourceEncoding} is not supported,
 *         an array of length 0 is returned. Otherwise, the array will have
 *         a length of at least 1, representing {@code sourceEncoding}
 *         (no conversion).
 * @throws NullPointerException if {@code sourceEncoding} is {@code null}
 */
public static AudioFormat.Encoding[] getTargetEncodings(AudioFormat.Encoding sourceEncoding) {
    Objects.requireNonNull(sourceEncoding);

    List<FormatConversionProvider> codecs = getFormatConversionProviders();
    Vector<AudioFormat.Encoding> encodings = new Vector<>();

    AudioFormat.Encoding[] encs = null;

    // gather from all the codecs
    for(int i=0; i<codecs.size(); i++ ) {
        FormatConversionProvider codec = codecs.get(i);
        if( codec.isSourceEncodingSupported( sourceEncoding ) ) {
            encs = codec.getTargetEncodings();
            for (int j = 0; j < encs.length; j++) {
                encodings.addElement( encs[j] );
            }
        }
    }
    if (!encodings.contains(sourceEncoding)) {
        encodings.addElement(sourceEncoding);
    }

    return encodings.toArray(new AudioFormat.Encoding[encodings.size()]);
}
 
Example 6
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 7
Source Project: tsml   File: Resample.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
  * Gets the current settings of the filter.
  *
  * @return an array of strings suitable for passing to setOptions
  */
 public String [] getOptions() {
   Vector<String>	result;

   result = new Vector<String>();

   result.add("-S");
   result.add("" + getRandomSeed());

   result.add("-Z");
   result.add("" + getSampleSizePercent());

   if (getNoReplacement()) {
     result.add("-no-replacement");
     if (getInvertSelection())
result.add("-V");
   }
   
   return result.toArray(new String[result.size()]);
 }
 
Example 8
Source Project: jdk8u_jdk   File: Harness.java    License: GNU General Public License v2.0 6 votes vote down vote up
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 9
Source Project: pdfxtk   File: DisplayableClass.java    License: Apache License 2.0 5 votes vote down vote up
/**
  * Creates the hierarchy of childs for a given element. This is used
  * when working with nested objects.
  *
  * @param element Pointer to the element whose children should be
  * instantiated.
  * @param context Current browser context.
  * @return List of Displayables.
  */
 public Displayable[] getChilds(Element element, BrowserContext context) {
   NodeList nl     = DOMUtils.getChildElements(element);
   Vector   childs = new Vector();
   for (int i = 0; i < nl.getLength(); i++) {
     Displayable child = context.displayableFactory.getDisplayable((Element) nl.item(i));
     if (child != null) {
childs.add(child);
     }
   }
   return (Displayable[]) childs.toArray(new Displayable[0]);
 }
 
Example 10
Source Project: ramus   File: AbstractRow.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Deprecated
 public void sortByName(final boolean element) {
     final Vector<Row> v = dataPlugin.getChilds(this, element);
     final Object o[] = v.toArray();
     Arrays.sort(o, new RowNameComparator<Object>());
     /*
      * for (int i = 0; i < o.length; i++) { childs.remove(o[i]); }
* 
* for (int i = 0; i < o.length; i++) { ((Row)
* o[i]).sortByName(element); ((Row) o[i]).setParent(this, i); //
* childs.add((Row) o[i]); }
*/
 }
 
Example 11
private String[] filterArrayAttributes(final String[] valuesToFilter, final String attributeName) {
    final Vector<String> vector = new Vector<String>(valuesToFilter.length);
    for (final String attributeValue : valuesToFilter) {
        if (patternMatchesAttributeValue(attributeValue)) {
            logReleasedAttributeEntry(attributeName, attributeValue);
            vector.add(attributeValue);
        }
    }
    return vector.toArray(new String[] {});
}
 
Example 12
Source Project: delion   File: ChromeBrowserProvider.java    License: Apache License 2.0 5 votes vote down vote up
private Cursor getBookmarkHistorySuggestions(String selection, String[] selectionArgs,
        String sortOrder, boolean excludeHistory) {
    boolean matchTitles = false;
    Vector<String> args = new Vector<String>();
    String like = selectionArgs[0] + "%";
    if (selectionArgs[0].startsWith("http") || selectionArgs[0].startsWith("file")) {
        args.add(like);
    } else {
        // Match against common URL prefixes.
        args.add("http://" + like);
        args.add("https://" + like);
        args.add("http://www." + like);
        args.add("https://www." + like);
        args.add("file://" + like);
        matchTitles = true;
    }

    StringBuilder urlWhere = new StringBuilder("(");
    urlWhere.append(buildSuggestWhere(selection, args.size()));
    if (matchTitles) {
        args.add(like);
        urlWhere.append(" OR title LIKE ?");
    }
    urlWhere.append(")");

    if (excludeHistory) {
        urlWhere.append(" AND bookmark=?");
        args.add("1");
    }

    selectionArgs = args.toArray(selectionArgs);
    Cursor cursor = queryBookmarkFromAPI(SUGGEST_PROJECTION, urlWhere.toString(),
            selectionArgs, sortOrder);
    return new ChromeBrowserProviderSuggestionsCursor(cursor);
}
 
Example 13
private void checkHDFSIteratorResultSet(ResultSet rs, int expectedSize)
    throws Exception {
  Vector<Object> v = new Vector<Object>();
  while (rs.next()) {
    v.add(rs.getObject(1));
  }
  Object[] arr = v.toArray();
  Arrays.sort(arr);
  assertEquals(expectedSize, arr.length);
  for (int i = 0; i < expectedSize; i++) {
    assertEquals(i, ((Integer) arr[i]).intValue());
  }
}
 
Example 14
Source Project: tsml   File: CheckSource.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
  * Gets the current settings of the filter.
  *
  * @return an array of strings suitable for passing to setOptions
  */
 public String[] getOptions() {
   Vector<String>      result;
   
   result  = new Vector<String>();

   if (getFilter() != null) {
     result.add("-W");
     result.add(getFilter().getClass().getName() + " " 
         + Utils.joinOptions(((OptionHandler) getFilter()).getOptions()));
   }

   if (getSourceCode() != null) {
     result.add("-S");
     result.add(getSourceCode().getClass().getName());
   }

   if (getDataset() != null) {
     result.add("-t");
     result.add(m_Dataset.getAbsolutePath());
   }

   if (getClassIndex() != -1) {
     result.add("-c");
     if (getClassIndex() == -2)
result.add("last");
     else if (getClassIndex() == 0)
result.add("first");
     else 
result.add("" + (getClassIndex() + 1));
   }
   
   return result.toArray(new String[result.size()]);
 }
 
Example 15
private Cursor getBookmarkHistorySuggestions(String selection, String[] selectionArgs,
        String sortOrder, boolean excludeHistory) {
    boolean matchTitles = false;
    Vector<String> args = new Vector<String>();
    String like = selectionArgs[0] + "%";
    if (selectionArgs[0].startsWith(UrlConstants.HTTP_SCHEME)
            || selectionArgs[0].startsWith(UrlConstants.FILE_SCHEME)) {
        args.add(like);
    } else {
        // Match against common URL prefixes.
        args.add(UrlConstants.HTTP_URL_PREFIX + like);
        args.add(UrlConstants.HTTPS_URL_PREFIX + like);
        args.add(UrlConstants.HTTP_URL_PREFIX + "www." + like);
        args.add(UrlConstants.HTTPS_URL_PREFIX + "www." + like);
        args.add(UrlConstants.FILE_URL_PREFIX + like);
        matchTitles = true;
    }

    StringBuilder urlWhere = new StringBuilder("(");
    urlWhere.append(buildSuggestWhere(selection, args.size()));
    if (matchTitles) {
        args.add(like);
        urlWhere.append(" OR title LIKE ?");
    }
    urlWhere.append(")");

    if (excludeHistory) {
        urlWhere.append(" AND bookmark=?");
        args.add("1");
    }

    selectionArgs = args.toArray(selectionArgs);
    Cursor cursor = queryBookmarkFromAPI(SUGGEST_PROJECTION, urlWhere.toString(),
            selectionArgs, sortOrder);
    return new ChromeBrowserProviderSuggestionsCursor(cursor);
}
 
Example 16
Source Project: Spark   File: GSSAPIConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public AppConfigurationEntry[] getAppConfigurationEntry( String name )
   {
       AppConfigurationEntry[] a = new AppConfigurationEntry[ 1 ];
       if ( configs.containsKey( name ) )
       {
           Vector<AppConfigurationEntry> v = configs.get( name );
           a = v.toArray( a );
           return a;
       }
       else
       {
           return null;
       }
   }
 
Example 17
Source Project: tlaplus   File: FormulaContentProvider.java    License: MIT License 5 votes vote down vote up
public Object[] getElements(Object inputElement)
 {
     if (inputElement != null && inputElement instanceof Vector)
     {
         @SuppressWarnings("unchecked")
Vector<Formula> formulaList = (Vector<Formula>) inputElement;
         return formulaList.toArray(new Formula[formulaList.size()]);
     }
     return EMPTY;
 }
 
Example 18
Source Project: Rel   File: RevDatabase.java    License: Apache License 2.0 5 votes vote down vote up
public String[] getRelvarTypes() {
	String query = "UNION {sys.ExternalRelvarTypes {Identifier, Description}, REL {TUP {Identifier \"REAL\", Description \"REAL relation-valued variable.\"}}}  ORDER (ASC Identifier)";
	Tuples tuples = (Tuples)evaluate(query);
	Vector<String> types = new Vector<String>(); 
	try {
		for (Tuple tuple: tuples) {
			String identifier = tuple.get("Identifier").toString();
			String description = tuple.get("Description").toString();
			types.add(identifier + ": " + description);
		}
	} catch (Exception e) {}
	return types.toArray(new String[0]);
}
 
Example 19
Source Project: hottub   File: SystemTray.java    License: GNU General Public License v2.0 3 votes vote down vote up
/**
 * 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
Source Project: JDKSourceCode1.8   File: SystemTray.java    License: MIT License 3 votes vote down vote up
/**
 * 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;
}