use of java.util.LinkedHashSet in project tdi-studio-se by Talend.
the class CpuProfiler method getProfiledPackages.
/*
* @see ICpuProfiler#getProfiledPackages()
*/
@Override
public Set<String> getProfiledPackages() throws JvmCoreException {
if (type == ProfilerType.BCI) {
validateAgent();
Set<String> packages = new LinkedHashSet<String>();
ProfilerState state = getState();
if (state != ProfilerState.READY && state != ProfilerState.RUNNING) {
return packages;
}
ObjectName objectName = jvm.getMBeanServer().getObjectName(PROFILER_MXBEAN_NAME);
if (jvm.isConnected()) {
for (String item : (String[]) jvm.getMBeanServer().getAttribute(objectName, PROFILED_PACKAGES)) {
if (!item.isEmpty()) {
packages.add(item);
}
}
}
return packages;
}
return profiledPackages;
}
use of java.util.LinkedHashSet in project tdi-studio-se by Talend.
the class TalendEditorPaletteFactory method getRelatedComponentNamesFromHelp.
protected static Set<String> getRelatedComponentNamesFromHelp(final String keyword) {
if (keyword == null || keyword.isEmpty()) {
return null;
}
// This method will cost lots of time to complete when it is called the first time
final List<SearchHit> querySearchResult = new ArrayList<SearchHit>();
if (searchInHelpJob != null && searchInHelpJob.getState() != Job.NONE) {
searchInHelpJob.cancel();
}
searchInHelpJob = new Job(SEARCHING_FROM_HELP) {
@SuppressWarnings("restriction")
@Override
protected IStatus run(IProgressMonitor monitor) {
String helpKeyword = keyword;
try {
TalendPaletteSearchIndex searchIndex = TalendPaletteSearchIndex.getInstance();
LocalSearchManager localSearchManager = BaseHelpSystem.getLocalSearchManager();
// if not work or null, maybe should throw a warn to inform user and help us trace
// if (searchIndex != null && localSearchManager != null) {
localSearchManager.ensureIndexUpdated(monitor, searchIndex);
//$NON-NLS-1$
final String WHITESPACE = " ";
//$NON-NLS-1$//$NON-NLS-2$
helpKeyword = helpKeyword + WHITESPACE + "OR" + WHITESPACE + helpKeyword + "*";
ISearchQuery searchQuery = new SearchQuery(helpKeyword, false, new ArrayList<String>(), Platform.getNL());
searchIndex.search(searchQuery, new ISearchHitCollector() {
@Override
public void addQTCException(QueryTooComplexException exception) throws QueryTooComplexException {
// nothing need to do
}
@Override
public void addHits(List<SearchHit> hits, String wordsSearched) {
querySearchResult.addAll(hits);
}
});
// }
} catch (Throwable e) {
CommonExceptionHandler.process(e, Priority.WARN);
}
return Status.OK_STATUS;
}
@Override
public boolean belongsTo(Object family) {
return family.equals(FederatedSearchJob.FAMILY);
}
};
try {
searchInHelpJob.setPriority(Job.INTERACTIVE);
searchInHelpJob.schedule();
searchInHelpJob.join();
} catch (Throwable e) {
CommonExceptionHandler.process(e, Priority.WARN);
}
Set<String> componentNames = new LinkedHashSet<String>();
// the limitation has been moved to it's caller
// int limit = PaletteSettingsPreferencePage.getPaletteSearchResultLimitFromHelp();
// int i = 1;
Iterator<SearchHit> iter = querySearchResult.iterator();
while (iter.hasNext()) {
// if (limit < i) {
// break;
// }
SearchHit result = iter.next();
String label = result.getLabel();
if (label == null || label.trim().length() == 0) {
continue;
}
componentNames.add(label);
// i++;
}
return componentNames;
}
use of java.util.LinkedHashSet in project ACS by ACS-Community.
the class DOMJavaClassIntrospector method getAccessibleFields.
/*
public static String[] getChildren(Object node) {
if (node instanceof Map)
return getSubnodes(node);
else if (node instanceof Element)
{
// TODO
return null;
}
else
return getFields(node);
}
*/
public static String[] getAccessibleFields(Object node, boolean primitivesOnly) {
Set<String> subnodes = new LinkedHashSet<String>();
final Class nodeType = node.getClass();
Class type = nodeType;
while (type != null) {
Field[] fields = type.getDeclaredFields();
for (Field field : fields) {
boolean isPrimitive = isPrimitive(field.getType());
if ((isPrimitive ^ !primitivesOnly) && getAccessorMethod(nodeType, field.getName()) != null) {
// do not add null non-primitives check
if (isPrimitive || getChild(field.getName(), node) != null)
subnodes.add(field.getName());
}
}
type = type.getSuperclass();
}
// and subnodesMap map
if (!primitivesOnly) {
Object subnodesMap = getChild(SUBNODES_MAP_NAME, node);
if (subnodesMap instanceof Map) {
Set keySet = ((Map) subnodesMap).keySet();
for (Object key : keySet) subnodes.add(key.toString());
}
subnodesMap = getChild(SUBNODES_MAP_NAME_ALTERNATIVE, node);
if (subnodesMap instanceof Map) {
Set keySet = ((Map) subnodesMap).keySet();
for (Object key : keySet) subnodes.add(key.toString());
}
}
return subnodes.toArray(new String[subnodes.size()]);
}
use of java.util.LinkedHashSet in project ACS by ACS-Community.
the class DOMJavaClassIntrospector method getSubnodes.
public static String[] getSubnodes(Object node) {
if (node instanceof alma.TMCDB.maci.ComponentNode)
return getAccessibleFields(node, false);
if (node instanceof Map && !(node instanceof InternalElementsMap)) {
Set<String> subnodes = new LinkedHashSet<String>();
Set keySet = ((Map) node).keySet();
for (Object key : keySet) subnodes.add(key.toString());
return subnodes.toArray(new String[subnodes.size()]);
} else
return new String[0];
}
use of java.util.LinkedHashSet in project ACS by ACS-Community.
the class DOMJavaClassIntrospector method getNodes.
public static String[] getNodes(Object node, String nodeName, Logger log) {
if (node instanceof DAOImpl) {
return getNodes(((DAOImpl) node).getRootNode().getNodesMap());
} else if (node instanceof XMLTreeNode) {
return getNodes(((XMLTreeNode) node).getNodesMap());
} else if (node instanceof Map) {
Set<String> subnodes = new LinkedHashSet<String>();
Set keySet = ((Map) node).keySet();
for (Object key : keySet) subnodes.add(key.toString());
return subnodes.toArray(new String[subnodes.size()]);
} else if (node instanceof Element) {
List<String> list = new ArrayList<String>();
for (Node childNode = ((Element) node).getFirstChild(); childNode != null; childNode = childNode.getNextSibling()) {
if (childNode.getNodeType() == Element.ELEMENT_NODE)
list.add(childNode.getNodeName());
}
return list.toArray(new String[list.size()]);
} else if (node instanceof ExtraDataFeature) {
String[] extraFields = null;
Element extraData = ((ExtraDataFeature) node).getExtraData();
if (extraData != null)
extraFields = getNodes(extraData);
String[] fields = getAccessibleFields(node, false);
if (extraFields == null)
return fields;
// concat and remove duplicates
LinkedHashSet<String> set = new LinkedHashSet<String>(Arrays.asList(fields));
for (String ef : extraFields) if (!set.add(ef))
if (log != null)
log.warning("Duplicate node '" + nodeName + "/" + ef + "'.");
return set.toArray(new String[0]);
} else
return getAccessibleFields(node, false);
}
Aggregations