java.util.ArrayList#toArray ( )源码实例Demo

下面列出了java.util.ArrayList#toArray ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: OpenEphyra   文件: NuggetEvaluationFilter.java
/**	check if some result covers some nugger
 * @param	result	the result String
 * @param	nugget	the nugget string
 * @return the tokens of the specified nugget String not contained in the specified result String
 */
private String[] covers(String result, String nugget) {
	String[] rTokens = NETagger.tokenize(result);
	HashSet<String> rSet = new HashSet<String>();
	for (String r : rTokens)
		if (!FunctionWords.lookup(r) && (r.length() > 1))
			rSet.add(SnowballStemmer.stem(r).toLowerCase());
	
	String[] nTokens = NETagger.tokenize(nugget);
	HashSet<String> nSet = new HashSet<String>();
	for (String n : nTokens)
		if (!FunctionWords.lookup(n) && (n.length() > 1))
			nSet.add(SnowballStemmer.stem(n).toLowerCase());
	
	nSet.removeAll(rSet);
	ArrayList<String> remaining = new ArrayList<String>(nSet);
	
	return remaining.toArray(new String[remaining.size()]);
}
 
@Override
public IMarkerResolution[] getResolutions(IMarker marker) {
  
  ArrayList<IMarkerResolution> resolutions = new ArrayList<>();
  try {
    if ("com.google.cloud.tools.eclipse.appengine.validation.applicationMarker"
        .equals(marker.getType())) {
      resolutions.add(new ApplicationQuickFix());
    } else if ("com.google.cloud.tools.eclipse.appengine.validation.versionMarker"
        .equals(marker.getType())) {
      resolutions.add(new VersionQuickFix());
    } else if ("com.google.cloud.tools.eclipse.appengine.validation.runtimeMarker"
        .equals(marker.getType())) {
      resolutions.add(new UpgradeRuntimeQuickFix());
    }
  } catch (CoreException ex) {
    logger.log(Level.SEVERE, ex.getMessage());
  }
  return resolutions.toArray(new IMarkerResolution[0]);
}
 
源代码3 项目: openjdk-jdk8u   文件: ProcessTools.java
/**
 * Create ProcessBuilder using the java launcher from the jdk to be tested,
 * and with any platform specific arguments prepended.
 *
 * @param addTestVmAndJavaOptions If true, adds test.vm.opts and test.java.opts
 *        to the java arguments.
 * @param command Arguments to pass to the java command.
 * @return The ProcessBuilder instance representing the java command.
 */
public static ProcessBuilder createJavaProcessBuilder(boolean addTestVmAndJavaOptions, String... command) {
    String javapath = JDKToolFinder.getJDKTool("java");

    ArrayList<String> args = new ArrayList<>();
    args.add(javapath);

    args.add("-cp");
    args.add(System.getProperty("java.class.path"));

    if (addTestVmAndJavaOptions) {
        Collections.addAll(args, Utils.getTestJavaOpts());
    }

    Collections.addAll(args, command);

    // Reporting
    StringBuilder cmdLine = new StringBuilder();
    for (String cmd : args)
        cmdLine.append(cmd).append(' ');
    System.out.println("Command line: [" + cmdLine.toString() + "]");

    return new ProcessBuilder(args.toArray(new String[args.size()]));
}
 
源代码4 项目: APICloud-Studio   文件: SVNUIPlugin.java
public MergeFileAssociation[] getMergeFileAssociations() throws BackingStoreException {
	ArrayList associations = new ArrayList();
	String[] childrenNames = MergeFileAssociation.getParentPreferences().childrenNames();
	for (int i = 0; i < childrenNames.length; i++) {
		org.osgi.service.prefs.Preferences node = MergeFileAssociation.getParentPreferences().node(childrenNames[i]);
		MergeFileAssociation association = new MergeFileAssociation();
		association.setFileType(childrenNames[i]);
		association.setMergeProgram(node.get("mergeProgram", "")); //$NON-NLS-1$,  //$NON-NLS-1$
		association.setParameters(node.get("parameters", "")); //$NON-NLS-1$,  //$NON-NLS-1$
		association.setType(node.getInt("type",MergeFileAssociation.BUILT_IN));
		associations.add(association);
	}
	MergeFileAssociation[] associationArray = new MergeFileAssociation[associations.size()];
	associations.toArray(associationArray);	
	Arrays.sort(associationArray);
	return associationArray;
}
 
源代码5 项目: iBioSim   文件: StateGraph.java
public State[] getPrevStates() {
	ArrayList<State> prev = new ArrayList<State>();
	for (StateTransitionPair st : prevStates) {
		if (st.isEnabled()) {
			prev.add(st.getState());
		}
	}
	return prev.toArray(new State[0]);
}
 
源代码6 项目: lams   文件: LearnerProgress.java
/**
    * Extract the Id from activities and set them into an array.
    *
    * @param activities
    *            the activities that is being used to create the array.
    */
   private Long[] createIdArrayFrom(Set<Activity> activities) {
if (activities == null) {
    throw new IllegalArgumentException("Fail to create id array" + " from null activity set");
}

ArrayList<Long> activitiesIds = new ArrayList<Long>();
for (Iterator<Activity> i = activities.iterator(); i.hasNext();) {
    Activity activity = i.next();
    activitiesIds.add(activity.getActivityId());
}

return activitiesIds.toArray(new Long[activitiesIds.size()]);
   }
 
源代码7 项目: CloverETL-Engine   文件: DBOutputTable.java
public void setSqlQuery(String[] sqlQuery) {
	// filter empty queries
	ArrayList<String> queries = new ArrayList<>();
	for(int i = 0; i < sqlQuery.length; i++) {
		if (sqlQuery[i] != null && sqlQuery[i].trim().length() > 0) {
			queries.add(sqlQuery[i]);
		}
	}
	this.sqlQuery=queries.toArray(new String[queries.size()]);
}
 
源代码8 项目: phoebus   文件: TextEntryWidget.java
@Override
public Object[] getChildren() {
    ArrayList<Object> ret = new ArrayList<>();
    if (_adlObject != null) ret.add( _adlObject);
    if (_adlControl != null) ret.add( _adlControl);
    if (_adlLimits != null) ret.add( _adlLimits);
    if (!(color_mode.equals(""))) ret.add(new ADLResource(ADLResource.COLOR_MODE, color_mode));
    if (!(alignment.equals(""))) ret.add(new ADLResource(ADLResource.TEXT_ALIGNMENT, alignment));
    if (!(format.equals(""))) ret.add(new ADLResource(ADLResource.TEXT_FORMAT, format));
    return ret.toArray();
}
 
源代码9 项目: hadoop   文件: NLineInputFormat.java
/** 
 * Logically splits the set of input files for the job, splits N lines
 * of the input as one split.
 * 
 * @see org.apache.hadoop.mapred.FileInputFormat#getSplits(JobConf, int)
 */
public InputSplit[] getSplits(JobConf job, int numSplits)
throws IOException {
  ArrayList<FileSplit> splits = new ArrayList<FileSplit>();
  for (FileStatus status : listStatus(job)) {
    for (org.apache.hadoop.mapreduce.lib.input.FileSplit split : 
        org.apache.hadoop.mapreduce.lib.input.
        NLineInputFormat.getSplitsForFile(status, job, N)) {
      splits.add(new FileSplit(split));
    }
  }
  return splits.toArray(new FileSplit[splits.size()]);
}
 
源代码10 项目: happy-dns-android   文件: DnsManager.java
private static String[] records2Ip(Record[] records) {
    if (records == null || records.length == 0) {
        return null;
    }
    ArrayList<String> a = new ArrayList<>(records.length);
    for (Record r : records) {
        a.add(r.value);
    }
    if (a.size() == 0) {
        return null;
    }
    return a.toArray(new String[a.size()]);
}
 
源代码11 项目: chipster   文件: SADLReplacements.java
public String[] processStrings(Collection<String> options) throws IOException {
	ArrayList<String> newOptions = new ArrayList<>();
	for (String option : options) {
		return processReplacements(option).toArray(new String[0]);
	}
	return newOptions.toArray(new String[0]);
}
 
源代码12 项目: webrtc_android   文件: MediaCodecVideoEncoder.java
private static MediaCodecProperties[] vp8HwList() {
    final ArrayList<MediaCodecProperties> supported_codecs = new ArrayList<MediaCodecProperties>();
    supported_codecs.add(qcomVp8HwProperties);
    supported_codecs.add(exynosVp8HwProperties);
    if (PeerConnectionFactory.fieldTrialsFindFullName("WebRTC-IntelVP8").equals("Enabled")) {
        supported_codecs.add(intelVp8HwProperties);
    }
    return supported_codecs.toArray(new MediaCodecProperties[supported_codecs.size()]);
}
 
源代码13 项目: springreplugin   文件: PluginManagerServer.java
private String[] getRunningProcessesByPluginLocked(String pluginName) {
    ArrayList<String> l = new ArrayList<>();
    for (PluginRunningList prl : mProcess2PluginsMap.values()) {
        if (prl.isRunning(pluginName)) {
            l.add(prl.mProcessName);
        }
    }
    return l.toArray(new String[0]);
}
 
源代码14 项目: medialibrary   文件: BucketHelper.java
private static BucketEntry[] loadBucketEntriesFromFilesTable(
        ThreadPool.JobContext jc, ContentResolver resolver, int type) {
    Uri uri = getFilesContentUri();
    Cursor cursor = resolver.query(uri,
            PROJECTION_BUCKET, BUCKET_GROUP_BY,
            null, BUCKET_ORDER_BY);
    if (cursor == null) {
        Log.w(TAG, "cannot open local database: " + uri);
        return new BucketEntry[0];
    }
    ArrayList<BucketEntry> buffer = new ArrayList<BucketEntry>();
    int typeBits = 0;
    if ((type & MediaObject.MEDIA_TYPE_IMAGE) != 0) {
        typeBits |= (1 << FileColumns.MEDIA_TYPE_IMAGE);
    }
    if ((type & MediaObject.MEDIA_TYPE_VIDEO) != 0) {
        typeBits |= (1 << FileColumns.MEDIA_TYPE_VIDEO);
    }
    try {
        while (cursor.moveToNext()) {
            if ((typeBits & (1 << cursor.getInt(INDEX_MEDIA_TYPE))) != 0) {
                BucketEntry entry = new BucketEntry(
                        cursor.getInt(INDEX_BUCKET_ID),
                        cursor.getString(INDEX_BUCKET_NAME));
                if (!buffer.contains(entry)) {
                    buffer.add(entry);
                }
            }
            if (jc.isCancelled()) return null;
        }
    } finally {
        Utils.closeSilently(cursor);
    }
    return buffer.toArray(new BucketEntry[buffer.size()]);
}
 
源代码15 项目: hadoop-gpu   文件: FSImage.java
/**
 * Return the name of the image file that is uploaded by periodic
 * checkpointing.
 */
File[] getFsImageNameCheckpoint() {
  ArrayList<File> list = new ArrayList<File>();
  for (Iterator<StorageDirectory> it = 
               dirIterator(NameNodeDirType.IMAGE); it.hasNext();) {
    list.add(getImageFile(it.next(), NameNodeFile.IMAGE_NEW));
  }
  return list.toArray(new File[list.size()]);
}
 
源代码16 项目: hadoop   文件: BlockManagerTestUtil.java
public static StorageReport[] getStorageReportsForDatanode(
    DatanodeDescriptor dnd) {
  ArrayList<StorageReport> reports = new ArrayList<StorageReport>();
  for (DatanodeStorageInfo storage : dnd.getStorageInfos()) {
    DatanodeStorage dns = new DatanodeStorage(
        storage.getStorageID(), storage.getState(), storage.getStorageType());
    StorageReport report = new StorageReport(
        dns ,false, storage.getCapacity(),
        storage.getDfsUsed(), storage.getRemaining(),
        storage.getBlockPoolUsed());
    reports.add(report);
  }
  return reports.toArray(StorageReport.EMPTY_ARRAY);
}
 
源代码17 项目: eclipse.jdt.ls   文件: TextMatchUpdater.java
private IProject[] getProjectsInScope() {
	IPath[] enclosingProjects= fScope.enclosingProjectsAndJars();
	Set<IPath> enclosingProjectSet= new HashSet<>();
	enclosingProjectSet.addAll(Arrays.asList(enclosingProjects));

	ArrayList<IProject> projectsInScope= new ArrayList<>();
	IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
	for (int i =0 ; i < projects.length; i++){
		if (enclosingProjectSet.contains(projects[i].getFullPath())) {
			projectsInScope.add(projects[i]);
		}
	}

	return projectsInScope.toArray(new IProject[projectsInScope.size()]);
}
 
源代码18 项目: ForgeHax   文件: CommandHelper.java
/**
 * [code borrowed from ant.jar] Crack a command line.
 *
 * @param toProcess the command line to process.
 * @return the command line broken into strings. An empty or null toProcess parameter results in a
 * zero sized array.
 */
public static String[] translate(String toProcess) {
  if (toProcess == null || toProcess.length() == 0) {
    // no command? no string
    return new String[0];
  }
  // parse with a simple finite state machine
  
  final int normal = 0;
  final int inQuote = 1;
  final int inDoubleQuote = 2;
  int state = normal;
  final StringTokenizer tok = new StringTokenizer(toProcess, "\"\' ", true);
  final ArrayList<String> result = new ArrayList<String>();
  final StringBuilder current = new StringBuilder();
  boolean lastTokenHasBeenQuoted = false;
  
  while (tok.hasMoreTokens()) {
    String nextTok = tok.nextToken();
    switch (state) {
      case inQuote:
        if ("\'".equals(nextTok)) {
          lastTokenHasBeenQuoted = true;
          state = normal;
        } else {
          current.append(nextTok);
        }
        break;
      case inDoubleQuote:
        if ("\"".equals(nextTok)) {
          lastTokenHasBeenQuoted = true;
          state = normal;
        } else {
          current.append(nextTok);
        }
        break;
      default:
        if ("\'".equals(nextTok)) {
          state = inQuote;
        } else if ("\"".equals(nextTok)) {
          state = inDoubleQuote;
        } else if (" ".equals(nextTok)) {
          if (lastTokenHasBeenQuoted || current.length() != 0) {
            result.add(current.toString());
            current.setLength(0);
          }
        } else {
          current.append(nextTok);
        }
        lastTokenHasBeenQuoted = false;
        break;
    }
  }
  if (lastTokenHasBeenQuoted || current.length() != 0) {
    result.add(current.toString());
  }
  if (state == inQuote || state == inDoubleQuote) {
    throw new RuntimeException("unbalanced quotes in " + toProcess);
  }
  return result.toArray(new String[result.size()]);
}
 
源代码19 项目: netbeans   文件: ProfilingPointsManager.java
private ProfilingPoint[] getInvalidProfilingPoints(ProfilingPoint[] profilingPointsArr) {
    ArrayList<ProfilingPoint> invalidProfilingPoints = new ArrayList<ProfilingPoint>();
    for (ProfilingPoint profilingPoint : profilingPointsArr) if(!profilingPoint.isValid()) invalidProfilingPoints.add(profilingPoint);
    return invalidProfilingPoints.toArray(new ProfilingPoint[0]);
}
 
源代码20 项目: MediaSDK   文件: Id3Decoder.java
private static ChapterTocFrame decodeChapterTOCFrame(
    ParsableByteArray id3Data,
    int frameSize,
    int majorVersion,
    boolean unsignedIntFrameSizeHack,
    int frameHeaderSize,
    @Nullable FramePredicate framePredicate)
    throws UnsupportedEncodingException {
  int framePosition = id3Data.getPosition();
  int elementIdEndIndex = indexOfZeroByte(id3Data.data, framePosition);
  String elementId = new String(id3Data.data, framePosition, elementIdEndIndex - framePosition,
      "ISO-8859-1");
  id3Data.setPosition(elementIdEndIndex + 1);

  int ctocFlags = id3Data.readUnsignedByte();
  boolean isRoot = (ctocFlags & 0x0002) != 0;
  boolean isOrdered = (ctocFlags & 0x0001) != 0;

  int childCount = id3Data.readUnsignedByte();
  String[] children = new String[childCount];
  for (int i = 0; i < childCount; i++) {
    int startIndex = id3Data.getPosition();
    int endIndex = indexOfZeroByte(id3Data.data, startIndex);
    children[i] = new String(id3Data.data, startIndex, endIndex - startIndex, "ISO-8859-1");
    id3Data.setPosition(endIndex + 1);
  }

  ArrayList<Id3Frame> subFrames = new ArrayList<>();
  int limit = framePosition + frameSize;
  while (id3Data.getPosition() < limit) {
    Id3Frame frame = decodeFrame(majorVersion, id3Data, unsignedIntFrameSizeHack,
        frameHeaderSize, framePredicate);
    if (frame != null) {
      subFrames.add(frame);
    }
  }

  Id3Frame[] subFrameArray = new Id3Frame[subFrames.size()];
  subFrames.toArray(subFrameArray);
  return new ChapterTocFrame(elementId, isRoot, isOrdered, children, subFrameArray);
}