/** * Implements the <tt>ListCellRenderer</tt> method. Returns this panel that has been configured to * display bundle name, version and description. * * @param table the parent table * @param value the value of the rendered cell * @param isSelected indicates if the rendered cell is selected * @param hasFocus indicates if the rendered cell has the focus * @param rowIndex the row index of the rendered cell * @param vColIndex the column index of the rendered cell * @return the rendering component */ public Component getTableCellRendererComponent( JTable table, Object value, boolean isSelected, boolean hasFocus, int rowIndex, int vColIndex) { Bundle bundle = (Bundle) value; Dictionary<?, ?> headers = bundle.getHeaders(); Object bundleName = headers.get(Constants.BUNDLE_NAME); Object bundleVersion = headers.get(Constants.BUNDLE_VERSION); Object bundleDescription = headers.get(Constants.BUNDLE_DESCRIPTION); Icon stateIcon = getStateIcon(bundle.getState()); if (bundleName != null) this.nameLabel.setText(bundleName.toString()); else this.nameLabel.setText("unknown"); if (bundleVersion != null) this.versionLabel.setText(bundleVersion.toString()); else this.versionLabel.setText(""); if (bundleDescription != null) this.descriptionLabel.setText(bundleDescription.toString()); else this.descriptionLabel.setText(""); if (stateIcon != null) this.stateLabel.setIcon(stateIcon); this.nameVersionPanel.remove(systemLabel); if (PluginManagerActivator.isSystemBundle(bundle)) this.nameVersionPanel.add(systemLabel); this.isSelected = isSelected; return this; }
public void loadSecondStage(Dictionary dictionaries) { Dictionary laneDictionary = (Dictionary) (dictionaries.get("lane")), nodeDictionary = (Dictionary) (dictionaries.get("node")); tl = ((Drivelane) (laneDictionary.get(new Integer(loadData.oldTlId)))).getSign(); tl_new = ((Drivelane) (laneDictionary.get(new Integer(loadData.newTlId)))).getSign(); destination = (Node) (nodeDictionary.get(new Integer(loadData.destNodeId))); }
/** * * First time that I hit a -1 in dictionary * * @param dict * @param target * @return */ private int rangeHelper(Dictionary dict, int target) { int curIndex = 1; while (dict.get(curIndex) != null && dict.get(curIndex).intValue() <= target) { curIndex *= 2; } return curIndex / 2; }
/** * Internal match routine. Dictionary parameter must support case-insensitive get. * * @param properties A dictionary whose keys are used in the match. * @return If the Dictionary's keys match the filter, return <code>true</code>. Otherwise, return * <code>false</code>. */ private boolean match0(Dictionary properties) { switch (op) { case AND: { FilterImpl[] filters = (FilterImpl[]) value; for (int i = 0, size = filters.length; i < size; i++) { if (!filters[i].match0(properties)) { return false; } } return true; } case OR: { FilterImpl[] filters = (FilterImpl[]) value; for (int i = 0, size = filters.length; i < size; i++) { if (filters[i].match0(properties)) { return true; } } return false; } case NOT: { FilterImpl filter = (FilterImpl) value; return !filter.match0(properties); } case SUBSTRING: case EQUAL: case GREATER: case LESS: case APPROX: case SUBSET: case SUPERSET: { Object prop = (properties == null) ? null : properties.get(attr); return compare(op, prop, value); } case PRESENT: { Object prop = (properties == null) ? null : properties.get(attr); return prop != null; } } return false; }
/** @param aProperties the updated properties. */ @SuppressWarnings("rawtypes") final void setProperties(final Dictionary aProperties) { final Map<String, String> newProps = new HashMap<String, String>(); Enumeration keys = aProperties.keys(); while (keys.hasMoreElements()) { final String key = (String) keys.nextElement(); if (!KNOWN_KEYS.contains(key) && !IGNORED_KEYS.contains(key)) { LOG.log(Level.WARNING, "Unknown/unsupported profile key: " + key); continue; } final String value = aProperties.get(key).toString(); newProps.put(key, value.trim()); } // Verify whether all known keys are defined... final List<String> checkedKeys = new ArrayList<String>(KNOWN_KEYS); checkedKeys.removeAll(newProps.keySet()); if (!checkedKeys.isEmpty()) { throw new IllegalArgumentException( "Profile settings not complete! Missing keys are: " + checkedKeys.toString()); } this.properties.putAll(newProps); LOG.log( Level.INFO, "New device profile settings applied for {1} ({0}) ...", // new Object[] {getType(), getDescription()}); }
public ServiceRegistrationImpl( BundleImpl bundle, long serviceId, String[] classNames, Object service, Dictionary<String, ?> properties) { this.bundle = bundle; this.serviceId = serviceId; this.classNames = classNames; this.service = service; if ((properties == null) || properties.isEmpty()) this.properties = EMPTY_PROPERTIES; else { Enumeration<String> keys = properties.keys(); Map<String, Object> thisProperties = newCaseInsensitiveMapInstance(); while (keys.hasMoreElements()) { String key = keys.nextElement(); if (Constants.OBJECTCLASS.equalsIgnoreCase(key) || Constants.SERVICE_ID.equalsIgnoreCase(key)) continue; else if (thisProperties.containsKey(key)) throw new IllegalArgumentException(key); else thisProperties.put(key, properties.get(key)); } this.properties = thisProperties.isEmpty() ? EMPTY_PROPERTIES : thisProperties; } }
public String get(Object key) { if (!(key instanceof String)) return null; String sKey = (String) key; if (Constants.EXPORT_PACKAGE.equalsIgnoreCase(sKey) || Constants.PROVIDE_CAPABILITY.equalsIgnoreCase(sKey)) { String systemProvideHeader = getEquinoxContainer() .getConfiguration() .getConfiguration( EquinoxConfiguration.PROP_SYSTEM_PROVIDE_HEADER, EquinoxConfiguration.SYSTEM_PROVIDE_HEADER_SYSTEM_EXTRA); boolean useSystemExtra = systemProvideHeader.equals(EquinoxConfiguration.SYSTEM_PROVIDE_HEADER_SYSTEM_EXTRA); boolean useSystem = systemProvideHeader.equals(EquinoxConfiguration.SYSTEM_PROVIDE_HEADER_SYSTEM) || useSystemExtra; String systemProp = useSystem ? (Constants.EXPORT_PACKAGE.equalsIgnoreCase(sKey) ? Constants.FRAMEWORK_SYSTEMPACKAGES : Constants.FRAMEWORK_SYSTEMCAPABILITIES) : null; String systemExtraProp = useSystemExtra ? (Constants.EXPORT_PACKAGE.equalsIgnoreCase(sKey) ? Constants.FRAMEWORK_SYSTEMPACKAGES_EXTRA : Constants.FRAMEWORK_SYSTEMCAPABILITIES_EXTRA) : null; return getExtra(sKey, systemProp, systemExtraProp); } return headers.get(key); }
protected Sign getSign(Dictionary laneDictionary, int id) { Drivelane tmp = (Drivelane) (laneDictionary.get(new Integer(id))); if (tmp == null) { return null; } else { return tmp.getSign(); } }
public Object get(Object o) { String k = (String) o; for (int i = 0, length = keys.length; i < length; i++) { String key = keys[i]; if (key.equalsIgnoreCase(k)) { return dictionary.get(key); } } return null; }
/** * Returns the priority of events belonging to a specific class. * * @param eventClass is a string with the full class name of the event type to get the priority * from. * @return the event priority of the specified event class. * @see robocode.Event#getPriority() */ public int getEventPriority(String eventClass) { if (eventClass == null) { return -1; } final Event event = eventNames.get(eventClass); if (event == null) { return -1; } return event.getPriority(); }
public int search(Dictionary dict, int target) { // two steps: // (1) jump out, and get a ranch where the target number might be sitting // (2) do binary search, and check the existence of the number // sanity check if (dict.get(0) == null) { return -1; } if (dict.get(0).intValue() == target) { return 0; } int left = rangeHelper(dict, target); int right = left * 2; // binary search while (left <= right) { int mid = left + (right - left) / 2; if (dict.get(mid) != null && dict.get(mid) == target) { return mid; } else if (dict.get(mid) != null && dict.get(mid) < target) { left = mid + 1; } else { right = mid - 1; } } return -1; }
public void loadSecondStage(Dictionary dictionaries) throws XMLInvalidInputException, XMLTreeException { super.loadSecondStage(dictionaries); // Load roads Dictionary roadDictionary = (Dictionary) (dictionaries.get("road")); allRoads = new Road[loadData.roads.length]; for (int t = 0; t < loadData.roads.length; t++) { allRoads[t] = (Road) (roadDictionary.get(new Integer(loadData.roads[t]))); if (allRoads[t] == null && loadData.roads[t] != -1) System.out.println("Warning : " + getName() + " could not find road " + loadData.roads[t]); } // Load normal signs Dictionary laneDictionary = (Dictionary) (dictionaries.get("lane")); signs = new Sign[loadData.signs.length]; for (int t = 0; t < loadData.signs.length; t++) signs[t] = getSign(laneDictionary, loadData.signs[t]); // Load Signconfigurations signconfigs = new Sign[loadData.signconfigs.length][2]; for (int t = 0; t < signconfigs.length; t++) { signconfigs[t] = new Sign[loadData.signconfigs[t].length]; for (int u = 0; u < signconfigs[t].length; u++) { signconfigs[t][u] = getSign(laneDictionary, loadData.signconfigs[t][u]); } } // Tell *all* roads to load themselves // It's possible that this Node has a BetaLane that has not been SecondStageLoaded // And so we cant do an UpdateLanes() as that one needs secondStageData to proceed. // Hence, we need to 2ndStage all Roads. Enumeration e = new ArrayEnumeration(allRoads); Road tmpRoad; while (e.hasMoreElements()) { tmpRoad = (Road) e.nextElement(); if (tmpRoad != null) tmpRoad.loadSecondStage(dictionaries); } try { // System.out.println("Trying to updateLanes()"); updateLanes(); } catch (InfraException x) { throw new XMLInvalidInputException("Cannot initialize lanes of node " + nodeId); } }
/** * Updates the UIs for the labels in the label table by calling {@code updateUI} on each label. * The UIs are updated from the current look and feel. The labels are also set to their preferred * size. * * @see #setLabelTable * @see JComponent#updateUI */ protected void updateLabelUIs() { Dictionary labelTable = getLabelTable(); if (labelTable == null) { return; } Enumeration labels = labelTable.keys(); while (labels.hasMoreElements()) { JComponent component = (JComponent) labelTable.get(labels.nextElement()); component.updateUI(); component.setSize(component.getPreferredSize()); } }
/** * Sets the event priority of events belonging to a specific class. * * @param eventClass is a string with the full class name of the event type to set the priority * for. * @param priority is the new priority */ public void setEventPriority(String eventClass, int priority) { if (eventClass == null) { return; } final Event event = eventNames.get(eventClass); if (event == null) { robotProxy.println("SYSTEM: Unknown event class: " + eventClass); return; } if (HiddenAccess.isCriticalEvent(event)) { robotProxy.println("SYSTEM: You may not change the priority of a system event."); } HiddenAccess.setEventPriority(event, priority); }
public static void toJSON(ConfigurationAdmin admin, Writer osw, String filter) throws Exception { Configuration[] list = admin.listConfigurations(filter); Encoder encoder = codec.enc().to(osw); Protocol p = new Protocol(); p.version = 1; p.date = new Date(); p.size = list.length; encoder.put(p).append('\n'); if (list != null) for (Configuration c : list) { Dictionary<String, Object> d = c.getProperties(); Export export = new Export(); export.values = new HashMap<String, Object>(); export.factoryPid = c.getFactoryPid(); export.pid = c.getPid(); for (Enumeration<String> e = d.keys(); e.hasMoreElements(); ) { String k = e.nextElement(); Object v = d.get(k); if (!(v instanceof String)) { if (export.types == null) export.types = new HashMap<String, Type>(); Type type = new Type(); Class<?> clazz = v.getClass(); if (v instanceof Collection) { Collection<?> coll = (Collection<?>) v; clazz = String.class; if (coll.size() > 0) type.vectorOf = shortName(coll.iterator().next().getClass()); else type.vectorOf = shortName(String.class); } else if (v.getClass().isArray()) { type.arrayOf = shortName(clazz.getComponentType()); } else type.scalar = shortName(v.getClass()); export.types.put(k, type); } export.values.put(k, v); } encoder.mark().put(export); // encoder.put(encoder.digest()); encoder.append('\n'); } osw.flush(); }
/** * Compares the specified Object with this Dictionary for equality, * * @return true if the specified Object is equal to this Dictionary. */ public synchronized boolean equals(Object o) { if (o == this) return true; if (!(o instanceof Dictionary)) return false; Dictionary dict = (Dictionary) o; int max = size(); if (dict.size() != max) return false; Enumeration k = keys(); Enumeration e = elements(); for (int i = 0; i < max; i++) { Object key = k.nextElement(); Object value = e.nextElement(); if (!value.equals(dict.get(key))) { return false; } } return true; }
private String getExtra(String header, String systemProp, String systemExtraProp) { String systemValue = systemProp != null ? getEquinoxContainer().getConfiguration().getConfiguration(systemProp) : null; String systemExtraValue = systemExtraProp != null ? getEquinoxContainer().getConfiguration().getConfiguration(systemExtraProp) : null; if (systemValue == null) systemValue = systemExtraValue; else if (systemExtraValue != null && systemExtraValue.trim().length() > 0) systemValue += ", " + systemExtraValue; // $NON-NLS-1$ String result = headers.get(header); if (systemValue != null && systemValue.trim().length() > 0) { if (result != null) result += ", " + systemValue; // $NON-NLS-1$ else result = systemValue; } return result; }
public Map getBundleManifest(long bundleId) { Bundle b = Activator.bc.getBundle(bundleId); Dictionary d = b.getHeaders(); Map result = new HashMap(); int i = 0; for (Enumeration e = d.keys(); e.hasMoreElements(); ) { String key = (String) e.nextElement(); String val = (String) d.get(key); result.put(key, val); i += 2; } result.remove("Application-Icon"); return result; }
private static synchronized String getSymbolicName(String path) { if (fCachedLocations == null) fCachedLocations = new HashMap(); File file = new File(path); if (file.exists() && !fCachedLocations.containsKey(path)) { try { Dictionary dictionary = MinimalState.loadManifest(file); String value = (String) dictionary.get(Constants.BUNDLE_SYMBOLICNAME); if (value != null) { ManifestElement[] elements = ManifestElement.parseHeader(Constants.BUNDLE_SYMBOLICNAME, value); String id = elements.length > 0 ? elements[0].getValue() : null; if (id != null) fCachedLocations.put(path, elements[0].getValue()); } } catch (IOException e) { } catch (BundleException e) { } } return (String) fCachedLocations.get(path); }
public void loadSecondStage (Dictionary dictionaries) throws XMLInvalidInputException { Dictionary laneDictionary=(Dictionary)(dictionaries.get("lane")), nodeDictionary=(Dictionary)(dictionaries.get("node")); Drivelane lane=(Drivelane)(laneDictionary.get(new Integer(loadData.oldTlId))); if ( ! ((Hashtable)(laneDictionary)).containsKey (new Integer(loadData.oldTlId))) throw new XMLInvalidInputException ("Trying to load non-existant TL with id "+ loadData.oldTlId); tl=((Drivelane)(laneDictionary.get( new Integer(loadData.oldTlId)))).getSign(); tl_new=((Drivelane)(laneDictionary.get( new Integer(loadData.newTlId)))).getSign(); destination=(Node)(nodeDictionary.get( new Integer(loadData.destNodeId))); }
private BundleResourceBundle lookupResourceBundle(String localeString) { // get the localization header as late as possible to avoid accessing the raw headers // getting the first value from the raw headers forces the manifest to be parsed (bug 332039) String localizationHeader = rawHeaders.get(Constants.BUNDLE_LOCALIZATION); if (localizationHeader == null) localizationHeader = Constants.BUNDLE_LOCALIZATION_DEFAULT_BASENAME; BundleResourceBundle result = cache.get(localeString); if (result != null) return result.isEmpty() ? null : result; // Collect all the necessary inputstreams to create the resource bundle without // holding any locks. Finding resources and inputstreams from the wirings requires a // read lock on the module database. We must not hold the cache lock while doing this; // otherwise out of order locks will be possible when the resolver needs to clear the cache String[] nlVarients = buildNLVariants(localeString); InputStream[] nlStreams = new InputStream[nlVarients.length]; for (int i = nlVarients.length - 1; i >= 0; i--) { URL url = findResource( localizationHeader + (nlVarients[i].equals("") ? nlVarients[i] : '_' + nlVarients[i]) + ".properties"); //$NON-NLS-1$ //$NON-NLS-2$ if (url != null) { try { nlStreams[i] = url.openStream(); } catch (IOException e) { // ignore } } } synchronized (cache) { BundleResourceBundle parent = null; for (int i = nlVarients.length - 1; i >= 0; i--) { BundleResourceBundle varientBundle = null; InputStream varientStream = nlStreams[i]; if (varientStream == null) { varientBundle = cache.get(nlVarients[i]); } else { try { varientBundle = new LocalizationResourceBundle(varientStream); } catch (IOException e) { // ignore and continue } finally { if (varientStream != null) { try { varientStream.close(); } catch (IOException e3) { // Ignore exception } } } } if (varientBundle == null) { varientBundle = new EmptyResouceBundle(nlVarients[i]); } if (parent != null) varientBundle.setParent((ResourceBundle) parent); cache.put(nlVarients[i], varientBundle); parent = varientBundle; } result = cache.get(localeString); return result.isEmpty() ? null : result; } }
public Object getAttribute(String attributeName) { Dictionary<String, Object> attributes = proxyContext.getContextAttributes(httpContext); return attributes.get(attributeName); }
public void loadSecondStage (Dictionary dictionaries) { Dictionary laneDictionary=(Dictionary)(dictionaries.get("lane")); tl=((Drivelane)(laneDictionary.get( new Integer(loadData.tlId)))).getSign(); }
/** * Return the properly capitalized spelling of a variable name, given any capitalization of the * name. * * @return the properly capitalized spelling of a variable name, given any capitalization of the * name. */ public String getVariableName(String s) { return (String) variableNames.get(s.toLowerCase()); }
/** * Return the properly capitalized spelling of a class name, given any capitalization of the name. * * @return the properly capitalized spelling of a class name, given any capitalization of the * name. */ public String getClassName(String s) { return (String) classNames.get(s.toLowerCase()); }
public void loadSecondStage(Dictionary dictionaries) throws XMLInvalidInputException, XMLTreeException { Dictionary laneDictionary = (Dictionary) (dictionaries.get("lane")); tl = ((Drivelane) (laneDictionary.get(new Integer(loadData.tlId)))).getSign(); }