本文整理汇总了Java中java.util.SortedSet.toArray方法的典型用法代码示例。如果您正苦于以下问题:Java SortedSet.toArray方法的具体用法?Java SortedSet.toArray怎么用?Java SortedSet.toArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.SortedSet
的用法示例。
在下文中一共展示了SortedSet.toArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAvailableFriends
import java.util.SortedSet; //导入方法依赖的package包/类
/**
* Returns sorted arrays of CNBs of available friends for this module.
*/
String[] getAvailableFriends() {
SortedSet<String> set = new TreeSet<String>();
if (isSuiteComponent()) {
for (Iterator it = SuiteUtils.getSubProjects(getSuite()).iterator(); it.hasNext();) {
Project prj = (Project) it.next();
String cnb = ProjectUtils.getInformation(prj).getName();
if (!getCodeNameBase().equals(cnb)) {
set.add(cnb);
}
}
} else if (isNetBeansOrg()) {
Set<ModuleDependency> deps = getUniverseDependencies(false);
for (Iterator it = deps.iterator(); it.hasNext();) {
ModuleDependency dep = (ModuleDependency) it.next();
set.add(dep.getModuleEntry().getCodeNameBase());
}
} // else standalone module - leave empty (see the UI spec)
return set.toArray(new String[set.size()]);
}
示例2: getAllTokens
import java.util.SortedSet; //导入方法依赖的package包/类
String[] getAllTokens() {
if (allTokens == null) {
try {
SortedSet<String> provTokens = new TreeSet<String>();
provTokens.addAll(Arrays.asList(IDE_TOKENS));
for (ModuleEntry me : getModuleList().getAllEntries()) {
provTokens.addAll(Arrays.asList(me.getProvidedTokens()));
}
String[] result = new String[provTokens.size()];
return provTokens.toArray(result);
} catch (IOException e) {
allTokens = new String[0];
ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e);
}
}
return allTokens;
}
示例3: getCreatedPaths
import java.util.SortedSet; //导入方法依赖的package包/类
@Override
public String[] getCreatedPaths() {
LayerHandle handle = cmf.getLayerHandle();
FileObject layer = handle.getLayerFile();
String layerPath = layer != null
? FileUtil.getRelativePath(project.getProjectDirectory(), layer)
: project.getLookup().lookup(NbModuleProvider.class).getResourceDirectoryPath(false) + '/' + handle.newLayerPath();
int slash = layerPath.lastIndexOf('/');
String prefix = layerPath.substring(0, slash + 1);
SortedSet<String> s = new TreeSet<String>();
if (layer == null) {
s.add(layerPath);
}
for (String file : externalFiles) {
s.add(prefix + file);
}
return s.toArray(new String[s.size()]);
}
示例4: EncodingNode
import java.util.SortedSet; //导入方法依赖的package包/类
public EncodingNode(String[] ids, CodeSequence[] seqs) {
SortedSet<String> idSet = new TreeSet<String>();
SortedSet<String> nidSet = new TreeSet<String>();
for (int i = 0; i < ids.length; i++) {
String nid = ids[i].toLowerCase().replaceAll("[^a-z0-9]+", "");
if (ids[i].length() > 0 && nid.length() > 0) {
if (idSet.contains(ids[i])) throw new IllegalArgumentException("Duplicate id: " + ids[i]);
if (nidSet.contains(nid)) throw new IllegalArgumentException("Duplicate id:" + nid);
idSet.add(ids[i]);
nidSet.add(nid);
}
}
if (idSet.isEmpty() || nidSet.isEmpty()) throw new IllegalArgumentException("No ids");
this.ids = idSet.toArray(new String[idSet.size()]);
this.nids = nidSet.toArray(new String[nidSet.size()]);
SortedSet<CodeSequence> seqSet = new TreeSet<CodeSequence>();
for (int i = 0; i < seqs.length; i++) {
if (seqs[i].length() > 0) {
if (seqSet.contains(seqs[i])) throw new IllegalArgumentException("Duplicate code sequence: " + seqs[i]);
seqSet.add(seqs[i]);
}
}
if (seqSet.isEmpty()) throw new IllegalArgumentException("No code sequences");
this.seqs = seqSet.toArray(new CodeSequence[seqSet.size()]);
}
示例5: listAllRegionPaths
import java.util.SortedSet; //导入方法依赖的package包/类
/**
*
* @return a list of region names hosted on the system
*/
public String[] listAllRegionPaths() {
if (distrRegionMap.values().size() == 0) {
return ManagementConstants.NO_DATA_STRING;
}
// Sort region paths
SortedSet<String> regionPathsSet = new TreeSet<String>();
for (DistributedRegionBridge bridge : distrRegionMap.values()) {
regionPathsSet.add(bridge.getFullPath());
}
String[] regionPaths = new String[regionPathsSet.size()];
regionPaths = regionPathsSet.toArray(regionPaths);
regionPathsSet.clear();
return regionPaths;
}
示例6: printMock
import java.util.SortedSet; //导入方法依赖的package包/类
protected String printMock(List<ServerAndLoad> balancedCluster) {
SortedSet<ServerAndLoad> sorted = new TreeSet<ServerAndLoad>(balancedCluster);
ServerAndLoad[] arr = sorted.toArray(new ServerAndLoad[sorted.size()]);
StringBuilder sb = new StringBuilder(sorted.size() * 4 + 4);
sb.append("{ ");
for (int i = 0; i < arr.length; i++) {
if (i != 0) {
sb.append(" , ");
}
sb.append(arr[i].getServerName().getHostname());
sb.append(":");
sb.append(arr[i].getLoad());
}
sb.append(" }");
return sb.toString();
}
示例7: actionPerformed
import java.util.SortedSet; //导入方法依赖的package包/类
@Messages({
"ProjectAssociationAction.open_some_projects=Open some projects to choose from.",
"ProjectAssociationAction.title_select_project=Select Project",
"ProjectAssociationAction.could_not_associate=Failed to record a Hudson job association.",
"ProjectAssociationAction.could_not_dissociate=Failed to find the Hudson job association to be removed."
})
@Override public void actionPerformed(ActionEvent e) {
if (alreadyAssociatedProject == null) {
SortedSet<Project> projects = new TreeSet<Project>(ProjectRenderer.comparator());
projects.addAll(Arrays.asList(OpenProjects.getDefault().getOpenProjects()));
if (projects.isEmpty()) {
DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(Bundle.ProjectAssociationAction_open_some_projects(), NotifyDescriptor.INFORMATION_MESSAGE));
return;
}
JComboBox box = new JComboBox(new DefaultComboBoxModel(projects.toArray(new Project[projects.size()])));
box.setRenderer(new ProjectRenderer());
if (DialogDisplayer.getDefault().notify(new NotifyDescriptor(box, Bundle.ProjectAssociationAction_title_select_project(), NotifyDescriptor.OK_CANCEL_OPTION, NotifyDescriptor.PLAIN_MESSAGE, null, null)) != NotifyDescriptor.OK_OPTION) {
return;
}
if (!ProjectHudsonProvider.getDefault().recordAssociation((Project) box.getSelectedItem(), assoc)) {
DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(Bundle.ProjectAssociationAction_could_not_associate(), NotifyDescriptor.WARNING_MESSAGE));
}
} else {
if (!ProjectHudsonProvider.getDefault().recordAssociation(alreadyAssociatedProject, null)) {
DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(Bundle.ProjectAssociationAction_could_not_dissociate(), NotifyDescriptor.WARNING_MESSAGE));
}
}
}
示例8: getAllConclusionItems
import java.util.SortedSet; //导入方法依赖的package包/类
public Item[] getAllConclusionItems() {
SortedSet<Item> conclusions = new TreeSet<Item>();
for (AssociationRule rule : this) {
Iterator<Item> i = rule.getConclusionItems();
while (i.hasNext()) {
conclusions.add(i.next());
}
}
Item[] itemArray = new Item[conclusions.size()];
conclusions.toArray(itemArray);
return itemArray;
}
示例9: ContentAdapter
import java.util.SortedSet; //导入方法依赖的package包/类
public ContentAdapter(Context context) {
mChangasReference = FirebaseDatabase.getInstance().getReference("changas");
ValueEventListener changaListener = new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
SortedSet<Integer> ids = new TreeSet<>();
for (DataSnapshot changaSnapshot: dataSnapshot.getChildren()) {
Changa changa = changaSnapshot.getValue(Changa.class);
ids.add(changa.category);
}
LENGTH = ids.size();
mIDS = new Integer[LENGTH];
ids.toArray(mIDS);
notifyDataSetChanged();
}
@Override
public void onCancelled(DatabaseError databaseError) {
Log.w(TAG, "loadPost:onCancelled", databaseError.toException());
}
};
mChangasReference.addValueEventListener(changaListener);
Resources resources = context.getResources();
mChangasTitle = resources.getStringArray(R.array.array_categories);
TypedArray a = resources.obtainTypedArray(R.array.changas_imgs);
mChangasPictures = new Drawable[a.length()];
for (int i = 0; i < a.length(); i++) {
mChangasPictures[i] = a.getDrawable(i);
}
a.recycle();
}
示例10: getXMLDisplay
import java.util.SortedSet; //导入方法依赖的package包/类
public Document getXMLDisplay()
{
Document doc = createNewDocument() ;
FieldComparator comp = new FieldComparator() ;
SortedSet<Element> setFields = new TreeSet<Element>(comp) ;
// if (m_SendMapOrder != null)
// {
// Form form = m_SendMapOrder.m_varFrom ;
// }
Element eRoot = createNewFormBody(doc, "CESM", "CESM") ;
Element eBody = createVBox(doc, eRoot);
int nb = setFields.size() ;
Element[] arr = new Element[nb] ;
setFields.toArray(arr);
int curline = 0 ;
int curCol = 0 ;
Element curLineElem = null ;
for (int i=0; i<nb; i++)
{
Element f = arr[i] ;
int nl = NumberParser.getAsInt(f.getAttribute("PosLine"));
if (curline != nl)
{
curLineElem = createHBox(doc, eBody);
curline = nl ;
curCol = 1 ;
}
int nc = NumberParser.getAsInt(f.getAttribute("PosCol"));
int nlen = NumberParser.getAsInt(f.getAttribute("Length"));
if (nc > curCol +1)
{
createBlank(doc, curLineElem, nc - curCol) ;
}
curCol = nc + nlen ;
curLineElem.appendChild(f);
}
return doc;
}
示例11: list
import java.util.SortedSet; //导入方法依赖的package包/类
private PartialListing list(String prefix, String delimiter,
int maxListingLength, String priorLastKey) throws IOException {
if (prefix.length() > 0 && !prefix.endsWith(PATH_DELIMITER)) {
prefix += PATH_DELIMITER;
}
List<FileMetadata> metadata = new ArrayList<FileMetadata>();
SortedSet<String> commonPrefixes = new TreeSet<String>();
for (String key : dataMap.keySet()) {
if (key.startsWith(prefix)) {
if (delimiter == null) {
metadata.add(retrieveMetadata(key));
} else {
int delimIndex = key.indexOf(delimiter, prefix.length());
if (delimIndex == -1) {
metadata.add(retrieveMetadata(key));
} else {
String commonPrefix = key.substring(0, delimIndex);
commonPrefixes.add(commonPrefix);
}
}
}
if (metadata.size() + commonPrefixes.size() == maxListingLength) {
new PartialListing(key, metadata.toArray(new FileMetadata[0]),
commonPrefixes.toArray(new String[0]));
}
}
return new PartialListing(null, metadata.toArray(new FileMetadata[0]),
commonPrefixes.toArray(new String[0]));
}
示例12: getImageNames
import java.util.SortedSet; //导入方法依赖的package包/类
public String[] getImageNames() {
final SortedSet<String> s = getImageNameSet();
return s.toArray(new String[s.size()]);
}
示例13: createListView
import java.util.SortedSet; //导入方法依赖的package包/类
/**
* Create a list or combo box model suitable for {@link javax.swing.JList} from a source group
* showing all Java packages in the source group.
* To display it you will also need {@link #listRenderer}.
* <p>No particular guarantees are made as to the nature of the model objects themselves,
* except that {@link Object#toString} will give the fully-qualified package name
* (or <code>""</code> for the default package), regardless of what the renderer
* actually displays.</p>
* @param group a Java-like source group
* @return a model of its packages
* @since org.netbeans.modules.java.project/1 1.3
*/
public static ComboBoxModel createListView(SourceGroup group) {
Parameters.notNull("group", group); //NOI18N
SortedSet<PackageItem> data = new TreeSet<PackageItem>();
findNonExcludedPackages(null, data, group.getRootFolder(), group, false);
return new DefaultComboBoxModel(data.toArray(new PackageItem[data.size()]));
}
示例14: getSortedModules
import java.util.SortedSet; //导入方法依赖的package包/类
/**
* Returns (naturally sorted) array of all module entries pertaining to
* <code>this</code> NetBeans platform. This is just a convenient delegate
* to the {@link ModuleList#findOrCreateModuleListFromBinaries}.
*
* This may be a time-consuming method, consider using much faster
* ModuleList#getModules instead, which doesn't sort the modules. Do not call
* from AWT thread (not checked so that it may be used in tests).
*/
public ModuleEntry[] getSortedModules() {
SortedSet<ModuleEntry> set = new TreeSet<ModuleEntry>(getModules());
ModuleEntry[] entries = new ModuleEntry[set.size()];
set.toArray(entries);
return entries;
}
示例15: transformedSortedSet
import java.util.SortedSet; //导入方法依赖的package包/类
/**
* Factory method to create a transforming sorted set that will transform
* existing contents of the specified sorted set.
* <p>
* If there are any elements already in the set being decorated, they
* will be transformed by this method.
* Contrast this with {@link #transformingSortedSet(SortedSet, Transformer)}.
*
* @param <E> the element type
* @param set the set to decorate, must not be null
* @param transformer the transformer to use for conversion, must not be null
* @return a new transformed {@link SortedSet}
* @throws NullPointerException if set or transformer is null
* @since 4.0
*/
public static <E> TransformedSortedSet<E> transformedSortedSet(final SortedSet<E> set,
final Transformer<? super E, ? extends E> transformer) {
final TransformedSortedSet<E> decorated = new TransformedSortedSet<E>(set, transformer);
if (set.size() > 0) {
@SuppressWarnings("unchecked") // set is type E
final E[] values = (E[]) set.toArray(); // NOPMD - false positive for generics
set.clear();
for (final E value : values) {
decorated.decorated().add(transformer.transform(value));
}
}
return decorated;
}