当前位置: 首页>>代码示例>>Java>>正文


Java List.toArray方法代码示例

本文整理汇总了Java中java.util.List.toArray方法的典型用法代码示例。如果您正苦于以下问题:Java List.toArray方法的具体用法?Java List.toArray怎么用?Java List.toArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.List的用法示例。


在下文中一共展示了List.toArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getDirectlyAndIndirectlyPresent

import java.util.List; //导入方法依赖的package包/类
/**
 * Finds and returns all annotations in {@code annotations} matching
 * the given {@code annoClass}.
 *
 * Apart from annotations directly present in {@code annotations} this
 * method searches for annotations inside containers i.e. indirectly
 * present annotations.
 *
 * The order of the elements in the array returned depends on the iteration
 * order of the provided map. Specifically, the directly present annotations
 * come before the indirectly present annotations if and only if the
 * directly present annotations come before the indirectly present
 * annotations in the map.
 *
 * @param annotations the {@code Map} in which to search for annotations
 * @param annoClass the type of annotation to search for
 *
 * @return an array of instances of {@code annoClass} or an empty
 *         array if none were found
 */
public static <A extends Annotation> A[] getDirectlyAndIndirectlyPresent(
        Map<Class<? extends Annotation>, Annotation> annotations,
        Class<A> annoClass) {
    List<A> result = new ArrayList<A>();

    @SuppressWarnings("unchecked")
    A direct = (A) annotations.get(annoClass);
    if (direct != null)
        result.add(direct);

    A[] indirect = getIndirectlyPresent(annotations, annoClass);
    if (indirect != null && indirect.length != 0) {
        boolean indirectFirst = direct == null ||
                                containerBeforeContainee(annotations, annoClass);

        result.addAll((indirectFirst ? 0 : 1), Arrays.asList(indirect));
    }

    @SuppressWarnings("unchecked")
    A[] arr = (A[]) Array.newInstance(annoClass, result.size());
    return result.toArray(arr);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:43,代码来源:AnnotationSupport.java

示例2: concreteAliases

import java.util.List; //导入方法依赖的package包/类
public String[] concreteAliases(MetaData metaData, String concreteIndex) {
    if (expandAliasesWildcards()) {
        //for DELETE we expand the aliases
        String[] indexAsArray = {concreteIndex};
        ImmutableOpenMap<String, List<AliasMetaData>> aliasMetaData = metaData.findAliases(aliases, indexAsArray);
        List<String> finalAliases = new ArrayList<>();
        for (ObjectCursor<List<AliasMetaData>> curAliases : aliasMetaData.values()) {
            for (AliasMetaData aliasMeta: curAliases.value) {
                finalAliases.add(aliasMeta.alias());
            }
        }
        return finalAliases.toArray(new String[finalAliases.size()]);
    } else {
        //for add we just return the current aliases
        return aliases;
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:18,代码来源:IndicesAliasesRequest.java

示例3: dealInclude

import java.util.List; //导入方法依赖的package包/类
protected  Word[] dealInclude(Word[] wordObjects) throws Exception{
    boolean isInclude = false;
    StringBuffer includeFileName = new StringBuffer();
    int point = 0;
    List<Word> result = new ArrayList<Word>();
    while(point <wordObjects.length ){
      if(wordObjects[point].word.equals("include") ==true){
    	  isInclude = true;
    	  includeFileName.setLength(0);
      }else if(isInclude == true && wordObjects[point].word.equals(";") ==true) {
    	  isInclude = false;
    	  Word[] childExpressWord = this.getExpressByName(includeFileName.toString());
    	  childExpressWord = this.dealInclude(childExpressWord);
    	  for(int i=0;i< childExpressWord.length;i++){
    		  result.add(childExpressWord[i]);
    	  }
      }else if(isInclude == true){
    	  includeFileName.append(wordObjects[point].word);
      }else{
    	  result.add(wordObjects[point]);
      }
      point = point + 1;
    }
    return result.toArray(new Word[0]);
}
 
开发者ID:alibaba,项目名称:QLExpress,代码行数:26,代码来源:ExpressParse.java

示例4: getVideoQualityOptions

import java.util.List; //导入方法依赖的package包/类
@Override
protected CharSequence[] getVideoQualityOptions() {
    List<CharSequence> videoQualities = new ArrayList<>();

    if (getMinimumVideoDuration() > 0)
        videoQualities.add(new VideoQualityOption(CameraConfiguration.MEDIA_QUALITY_AUTO, CameraHelper.getCamcorderProfile(CameraConfiguration.MEDIA_QUALITY_AUTO, getCameraController().getCurrentCameraId()), getMinimumVideoDuration()));

    CamcorderProfile camcorderProfile = CameraHelper.getCamcorderProfile(CameraConfiguration.MEDIA_QUALITY_HIGH, getCameraController().getCurrentCameraId());
    double videoDuration = CameraHelper.calculateApproximateVideoDuration(camcorderProfile, getVideoFileSize());
    videoQualities.add(new VideoQualityOption(CameraConfiguration.MEDIA_QUALITY_HIGH, camcorderProfile, videoDuration));

    camcorderProfile = CameraHelper.getCamcorderProfile(CameraConfiguration.MEDIA_QUALITY_MEDIUM, getCameraController().getCurrentCameraId());
    videoDuration = CameraHelper.calculateApproximateVideoDuration(camcorderProfile, getVideoFileSize());
    videoQualities.add(new VideoQualityOption(CameraConfiguration.MEDIA_QUALITY_MEDIUM, camcorderProfile, videoDuration));

    camcorderProfile = CameraHelper.getCamcorderProfile(CameraConfiguration.MEDIA_QUALITY_LOW, getCameraController().getCurrentCameraId());
    videoDuration = CameraHelper.calculateApproximateVideoDuration(camcorderProfile, getVideoFileSize());
    videoQualities.add(new VideoQualityOption(CameraConfiguration.MEDIA_QUALITY_LOW, camcorderProfile, videoDuration));

    CharSequence[] array = new CharSequence[videoQualities.size()];
    videoQualities.toArray(array);

    return array;
}
 
开发者ID:MartinRGB,项目名称:android_camera_experiment,代码行数:25,代码来源:Camera1Activity.java

示例5: getInputs

import java.util.List; //导入方法依赖的package包/类
@Override
public RecipeElement[] getInputs()
{
	List<RecipeElement> buf = new ArrayList<>();
	for (RecipeElement ore : recipeItems)
	{
		if (ore != null)
		{
			buf.add(ore);
		}
	}

	return buf.toArray(new RecipeElement[0]);
}
 
开发者ID:einsteinsci,项目名称:BetterBeginningsReborn,代码行数:15,代码来源:BrickOvenShapedRecipe.java

示例6: toArray

import java.util.List; //导入方法依赖的package包/类
private static <T> T[] toArray(Class <? super T > clazz, Iterable <? extends T > it)
{
    List<T> list = Lists.<T>newArrayList();

    for (T t : it)
    {
        list.add(t);
    }

    return (T[])((Object[])list.toArray(createArray(clazz, list.size())));
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:12,代码来源:Cartesian.java

示例7: TabularDataSupport

import java.util.List; //导入方法依赖的package包/类
/**
 * Creates an empty <tt>TabularDataSupport</tt> instance whose open-type is <var>tabularType</var>,
 * and whose underlying <tt>HashMap</tt> has the specified initial capacity and load factor.
 *
 * @param  tabularType               the <i>tabular type</i> describing this <tt>TabularData</tt> instance;
 *                           cannot be null.
 *
 * @param  initialCapacity   the initial capacity of the HashMap.
 *
 * @param  loadFactor        the load factor of the HashMap
 *
 * @throws IllegalArgumentException  if the initial capacity is less than zero,
 *                                   or the load factor is nonpositive,
 *                                   or the tabular type is null.
 */
public TabularDataSupport(TabularType tabularType, int initialCapacity, float loadFactor) {

    // Check tabularType is not null
    //
    if (tabularType == null) {
        throw new IllegalArgumentException("Argument tabularType cannot be null.");
    }

    // Initialize this.tabularType (and indexNamesArray for convenience)
    //
    this.tabularType = tabularType;
    List<String> tmpNames = tabularType.getIndexNames();
    this.indexNamesArray = tmpNames.toArray(new String[tmpNames.size()]);

    // Since LinkedHashMap was introduced in SE 1.4, it's conceivable even
    // if very unlikely that we might be the server of a 1.3 client.  In
    // that case you'll need to set this property.  See CR 6334663.
    String useHashMapProp = AccessController.doPrivileged(
            new GetPropertyAction("jmx.tabular.data.hash.map"));
    boolean useHashMap = "true".equalsIgnoreCase(useHashMapProp);

    // Construct the empty contents HashMap
    //
    this.dataMap = useHashMap ?
        new HashMap<Object,CompositeData>(initialCapacity, loadFactor) :
        new LinkedHashMap<Object, CompositeData>(initialCapacity, loadFactor);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:43,代码来源:TabularDataSupport.java

示例8: getRolesForComponent

import java.util.List; //导入方法依赖的package包/类
/** Get the list of Role names that have access to the specified component
 * @param componentName The component name to get the roles for
 * @return Returns an array of Strings, each entry is a role name.
 *         If no roles have access to the component an empty array (new String[] {}) will be returned,
 *         If all roles have access to the component 'null' will be returned
 * @throws SecurityException if the component is invalid
 */
public static String[] getRolesForComponent(String componentName) {
    Map<String, List<String>> index = getComponentRoleIndex();
    if (index == null)
        return null;

    // Throw an exception if there is no entry for the component. This would mean an invalid component.
    if (!index.containsKey(componentName))
        throw new SecurityException("PolicyManager could not find component '" + componentName + "'");

    // Convert the extracted list to an array
    List<String> l = index.get(componentName);
    return l != null ? l.toArray(new String[l.size()]) : null;
}
 
开发者ID:jaffa-projects,项目名称:jaffa-framework,代码行数:21,代码来源:PolicyManager.java

示例9: fromList

import java.util.List; //导入方法依赖的package包/类
public void fromList(List<Float> lb) {
    if(lb==null || lb.size()==0)
        return;
    Float ab[] = lb.toArray(new Float[0]);
    float a[] = new float[ab.length];
    for(int i=0; i<ab.length; i++)
        a[i] = ab[i];
    fromArray(a);
}
 
开发者ID:johnhany,项目名称:MOAAP,代码行数:10,代码来源:MatOfFloat6.java

示例10: collectRefCursorParameters

import java.util.List; //导入方法依赖的package包/类
/**
 * Collects any parameter registrations which indicate a REF_CURSOR parameter type/mode.
 *
 * @return The collected REF_CURSOR type parameters.
 */
public ParameterRegistrationImplementor[] collectRefCursorParameters() {
	final List<ParameterRegistrationImplementor> refCursorParams = new ArrayList<ParameterRegistrationImplementor>();
	for ( ParameterRegistrationImplementor param : registeredParameters ) {
		if ( param.getMode() == ParameterMode.REF_CURSOR ) {
			refCursorParams.add( param );
		}
	}
	return refCursorParams.toArray( new ParameterRegistrationImplementor[refCursorParams.size()] );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:ProcedureCallImpl.java

示例11: getMethodValuesWithSubQueries

import java.util.List; //导入方法依赖的package包/类
private Object[] getMethodValuesWithSubQueries(SQLMethodInvokeExpr method) throws SqlParseException {
    List<Object> values = new ArrayList<>();
    for (SQLExpr innerExpr : method.getParameters()) {
        if (innerExpr instanceof SQLQueryExpr) {
            Select select = sqlParser.parseSelect((MySqlSelectQueryBlock) ((SQLQueryExpr) innerExpr).getSubQuery().getQuery());
            values.add(new SubQueryExpression(select));
        } else if (innerExpr instanceof SQLTextLiteralExpr) {
            values.add(((SQLTextLiteralExpr) innerExpr).getText());
        } else {
            values.add(innerExpr);
        }

    }
    return values.toArray();
}
 
开发者ID:mazhou,项目名称:es-sql,代码行数:16,代码来源:WhereParser.java

示例12: concatenating

import java.util.List; //导入方法依赖的package包/类
/**
 * Returns a hash function which computes its hash code by concatenating the hash codes of the
 * underlying hash functions together. This can be useful if you need to generate hash codes of a
 * specific length.
 *
 * <p>For example, if you need 1024-bit hash codes, you could join two {@link Hashing#sha512} hash
 * functions together: {@code Hashing.concatenating(Hashing.sha512(), Hashing.sha512())}.
 *
 * @since 19.0
 */
public static HashFunction concatenating(Iterable<HashFunction> hashFunctions) {
  checkNotNull(hashFunctions);
  // We can't use Iterables.toArray() here because there's no hash->collect dependency
  List<HashFunction> list = new ArrayList<HashFunction>();
  for (HashFunction hashFunction : hashFunctions) {
    list.add(hashFunction);
  }
  checkArgument(list.size() > 0, "number of hash functions (%s) must be > 0", list.size());
  return new ConcatenatedHashFunction(list.toArray(new HashFunction[0]));
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:21,代码来源:Hashing.java

示例13: getCacheList

import java.util.List; //导入方法依赖的package包/类
@Override
public String[] getCacheList(String ssid, String lastUpdate)
{
	try
	{
		authenticate(ssid);
		final List<String> l = remoteCachingService.getCacheList(lastUpdate);
		return l.toArray(new String[l.size()]);
	}
	catch( final Exception ex )
	{
		throw new RuntimeException(ex);
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:15,代码来源:ToolsServiceImpl.java

示例14: getActions

import java.util.List; //导入方法依赖的package包/类
@Override
public Action[] getActions(boolean context) {
    List<? extends Action> actionsForPath = Utilities.actionsForPath("Android/ADB/EmulatorDevice");
    return actionsForPath.toArray(new Action[actionsForPath.size()]);
}
 
开发者ID:NBANDROIDTEAM,项目名称:NBANDROID-V2,代码行数:6,代码来源:EmulatorDeviceNode.java

示例15: getFiles

import java.util.List; //导入方法依赖的package包/类
/**
 * Returns an array of FTPFile objects containing the whole list of
 * files returned by the server as read by this object's parser.
 * The files are filtered before being added to the array.
 *
 * @param filter FTPFileFilter, must not be <code>null</code>.
 *
 * @return an array of FTPFile objects containing the whole list of
 *         files returned by the server as read by this object's parser.
 * <p><b>
 * NOTE:</b> This array may contain null members if any of the
 * individual file listings failed to parse.  The caller should
 * check each entry for null before referencing it, or use the
 * a filter such as {@link org.apache.commons.net.ftp.FTPFileFilters#NON_NULL} which does not
 * allow null entries.
 * @since 2.2
 * @exception java.io.IOException - not ever thrown, may be removed in a later release
 */
public FTPFile[] getFiles(FTPFileFilter filter)
throws IOException // TODO remove; not actually thrown
{
    List<FTPFile> tmpResults = new ArrayList<FTPFile>();
    Iterator<String> iter = this.entries.iterator();
    while (iter.hasNext()) {
        String entry = iter.next();
        FTPFile temp = this.parser.parseFTPEntry(entry);
        if (filter.accept(temp)){
            tmpResults.add(temp);
        }
    }
    return tmpResults.toArray(new FTPFile[tmpResults.size()]);

}
 
开发者ID:archos-sa,项目名称:aos-FileCoreLibrary,代码行数:34,代码来源:FTPListParseEngine.java


注:本文中的java.util.List.toArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。