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

The following examples show how to use java.util.Vector#toArray() . 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: X11FontManager.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
@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
Source File: UnionPathExpr.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
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
Source File: GetKeySpecException.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
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
Source File: SerialPortFinder.java    From Android-SerialPort with Apache License 2.0 6 votes vote down vote up
/**
 * 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 File: Harness.java    From jdk8u_jdk with 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 6
Source File: AudioSystem.java    From Bytecoder with 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 7
Source File: UnionPathExpr.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
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 8
Source File: Resample.java    From tsml with 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 9
Source File: RevDatabase.java    From Rel with 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 10
Source File: DisplayableClass.java    From pdfxtk with 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 11
Source File: FormulaContentProvider.java    From tlaplus with 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 12
Source File: GSSAPIConfiguration.java    From Spark with 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 13
Source File: ChromeBrowserProvider.java    From 365browser with 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(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 14
Source File: CheckSource.java    From tsml with 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
Source File: CreateHDFSStoreDUnit.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
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 16
Source File: ChromeBrowserProvider.java    From delion with 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 17
Source File: RegisteredServiceRegexAttributeFilter.java    From cas4.0.x-server-wechat with Apache License 2.0 5 votes vote down vote up
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 18
Source File: AbstractRow.java    From ramus with 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 19
Source File: SystemTray.java    From JDKSourceCode1.8 with 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;
}
 
Example 20
Source File: SystemTray.java    From hottub with 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;
}