private String[] getStringProperty(String name, Object value) { // Don't log a warning if the value is null. The filter guarantees at least one of the necessary // properties // is there. If others are not, this method will get called with value equal to null. if (value == null) return new String[0]; if (value instanceof String) { return new String[] {(String) value}; } if (value instanceof String[]) { return (String[]) value; } Exception e = null; if (value instanceof Collection) { @SuppressWarnings("unchecked") Collection<String> temp = (Collection<String>) value; try { return temp.toArray(new String[temp.size()]); } catch (ArrayStoreException ase) { e = ase; } } log.log( LogService.LOG_WARNING, NLS.bind( MetaTypeMsg.INVALID_PID_METATYPE_PROVIDER_IGNORED, new Object[] {_bundle.getSymbolicName(), _bundle.getBundleId(), name, value}), e); return new String[0]; }
public EquinoxObjectClassDefinition getObjectClassDefinition(String id, String locale) { if (_bundle.getState() != Bundle.ACTIVE) return null; // return none if not active MetaTypeProviderWrapper[] wrappers = getMetaTypeProviders(); for (int i = 0; i < wrappers.length; i++) { if (id.equals(wrappers[i].pid)) // found a matching pid now call the actual provider return wrappers[i].getObjectClassDefinition(id, locale); } return null; }
private String[] getPids(boolean factory) { if (_bundle.getState() != Bundle.ACTIVE) return new String[0]; // return none if not active MetaTypeProviderWrapper[] wrappers = getMetaTypeProviders(); ArrayList<String> results = new ArrayList<String>(); for (int i = 0; i < wrappers.length; i++) { // return only the correct type of pids (regular or factory) if (factory == wrappers[i].factory) results.add(wrappers[i].pid); } return results.toArray(new String[results.size()]); }
public String[] getLocales() { if (_bundle.getState() != Bundle.ACTIVE) return new String[0]; // return none if not active MetaTypeProviderWrapper[] wrappers = getMetaTypeProviders(); ArrayList<String> locales = new ArrayList<String>(); // collect all the unique locales from all providers we found for (int i = 0; i < wrappers.length; i++) { String[] wrappedLocales = wrappers[i].getLocales(); if (wrappedLocales == null) continue; for (int j = 0; j < wrappedLocales.length; j++) if (!locales.contains(wrappedLocales[j])) locales.add(wrappedLocales[j]); } return locales.toArray(new String[locales.size()]); }