java.util.Dictionary Java Examples

The following examples show how to use java.util.Dictionary. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RouteStoreImpl.java    From onos with Apache License 2.0 6 votes vote down vote up
@Modified
public void modified(ComponentContext context) {
    Dictionary<?, ?> properties = context.getProperties();
    if (properties == null) {
        return;
    }

    String strDistributed = Tools.get(properties, DISTRIBUTED);
    boolean expectDistributed = Boolean.parseBoolean(strDistributed);

    // Start route store during first start or config change
    // NOTE: new route store will be empty
    if (currentRouteStore == null || expectDistributed != distributed) {
        if (expectDistributed) {
            currentRouteStore = distributedRouteStore;
        } else {
            currentRouteStore = localRouteStore;
        }

        this.distributed = expectDistributed;
        log.info("Switched to {} route store", distributed ? "distributed" : "local");
    }

}
 
Example #2
Source File: HomematicBinding.java    From openhab1-addons with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Updates the configuration for the binding and (re-)starts the
 * communicator.
 */
@Override
public void updated(Dictionary<String, ?> config) throws ConfigurationException {
    if (config != null) {
        setProperlyConfigured(false);
        communicator.stop();

        context.getConfig().parse(config);
        logger.info(context.getConfig().toString());

        if (context.getConfig().isValid()) {
            communicator.start();
            setProperlyConfigured(true);

            for (HomematicBindingProvider hmProvider : providers) {
                for (String itemName : hmProvider.getItemNames()) {
                    informCommunicator(hmProvider, itemName);
                }
            }
        }
    }
}
 
Example #3
Source File: AuthenticationServiceBase.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/**
	  @see PropertySetCallback#validate
	*/
	public boolean validate(String key, Serializable value, Dictionary p)	{
// GemStone changes BEGIN
	        boolean isUserProp = key.startsWith(com.pivotal.gemfirexd.internal.iapi
                    .reference.Property.USER_PROPERTY_PREFIX)
                   //SQLF:BC
                  || key.startsWith(com.pivotal.gemfirexd.internal.iapi
                                      .reference.Property.SQLF_USER_PROPERTY_PREFIX);
                if (GemFireXDUtils.TraceAuthentication) {
                  if (isUserProp) {
                    SanityManager.DEBUG_PRINT(AuthenticationTrace, key
                        + " recognized as database user & credentials "
                        + "will be stored.");
                  }
                  else {
                    SanityManager.DEBUG_PRINT(AuthenticationTrace, key
                        + " not recognized as a database user & therefore "
                        + "credentials won't be stored in GemFireXD.");
                  }
                }
// GemStone changes END
		return isUserProp;
	}
 
Example #4
Source File: PlugwiseBinding.java    From openhab1-addons with Eclipse Public License 2.0 6 votes vote down vote up
private Stick setupStick(Dictionary<String, ?> config) {

        String port = ObjectUtils.toString(config.get("stick.port"), null);

        if (port == null) {
            return null;
        }

        Stick stick = new Stick(port, this);
        logger.debug("Plugwise added Stick connected to serial port {}", port);

        String interval = ObjectUtils.toString(config.get("stick.interval"), null);
        if (interval != null) {
            stick.setInterval(Integer.valueOf(interval));
            logger.debug("Setting the interval to send ZigBee PDUs to {} ms", interval);
        }

        String retries = ObjectUtils.toString(config.get("stick.retries"), null);
        if (retries != null) {
            stick.setRetries(Integer.valueOf(retries));
            logger.debug("Setting the maximum number of attempts to send a message to ", retries);
        }

        return stick;
    }
 
Example #5
Source File: ScaleTestManager.java    From onos with Apache License 2.0 6 votes vote down vote up
@Modified
public void modified(ComponentContext context) {
    if (context == null) {
        return;
    }

    Dictionary<?, ?> properties = context.getProperties();
    try {
        String s = get(properties, FLOW_COUNT);
        flowCount = isNullOrEmpty(s) ? flowCount : Integer.parseInt(s.trim());

        s = get(properties, ROUTE_COUNT);
        routeCount = isNullOrEmpty(s) ? routeCount : Integer.parseInt(s.trim());

        log.info("Reconfigured; flowCount={}; routeCount={}", flowCount, routeCount);

        adjustFlows();
        adjustRoutes();

    } catch (NumberFormatException | ClassCastException e) {
        log.warn("Misconfigured", e);
    }
}
 
Example #6
Source File: ImageView.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Loads the image from the URL <code>getImageURL</code>. This should
 * only be invoked from <code>refreshImage</code>.
 */
private void loadImage() {
    URL src = getImageURL();
    Image newImage = null;
    if (src != null) {
        Dictionary cache = (Dictionary)getDocument().
                                getProperty(IMAGE_CACHE_PROPERTY);
        if (cache != null) {
            newImage = (Image)cache.get(src);
        }
        else {
            newImage = Toolkit.getDefaultToolkit().createImage(src);
            if (newImage != null && getLoadsSynchronously()) {
                // Force the image to be loaded by using an ImageIcon.
                ImageIcon ii = new ImageIcon();
                ii.setImage(newImage);
            }
        }
    }
    image = newImage;
}
 
Example #7
Source File: BasicSliderUI.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns the smallest value that has an entry in the label table.
 *
 * @return smallest value that has an entry in the label table, or
 *         null.
 * @since 1.6
 */
protected Integer getLowestValue() {
    Dictionary dictionary = slider.getLabelTable();

    if (dictionary == null) {
        return null;
    }

    Enumeration keys = dictionary.keys();

    Integer min = null;

    while (keys.hasMoreElements()) {
        Integer i = (Integer) keys.nextElement();

        if (min == null || i < min) {
            min = i;
        }
    }

    return min;
}
 
Example #8
Source File: ComponentConfigManager.java    From onos with Apache License 2.0 6 votes vote down vote up
private void triggerUpdate(String componentName) {
    try {
        Configuration cfg = cfgAdmin.getConfiguration(componentName, null);
        Map<String, ConfigProperty> map = properties.get(componentName);
        if (map == null) {
            //  Prevent NPE if the component isn't there
            log.warn("Component not found for " + componentName);
            return;
        }
        Dictionary<String, Object> props = new Hashtable<>();
        map.values().stream().filter(p -> p.value() != null)
                .forEach(p -> props.put(p.name(), p.value()));
        cfg.update(props);
    } catch (IOException e) {
        log.warn("Unable to update configuration for " + componentName, e);
    }
}
 
Example #9
Source File: BasicSliderUI.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * Returns the smallest value that has an entry in the label table.
 *
 * @return smallest value that has an entry in the label table, or
 *         null.
 * @since 1.6
 */
protected Integer getLowestValue() {
    Dictionary dictionary = slider.getLabelTable();

    if (dictionary == null) {
        return null;
    }

    Enumeration keys = dictionary.keys();

    Integer min = null;

    while (keys.hasMoreElements()) {
        Integer i = (Integer) keys.nextElement();

        if (min == null || i < min) {
            min = i;
        }
    }

    return min;
}
 
Example #10
Source File: RFC1960Filter.java    From concierge with Eclipse Public License 1.0 6 votes vote down vote up
protected final static Map<String, ?> dict2map(
		final Dictionary<String, ?> dict) {
	if (dict == null) {
		return null;
	}

	if (dict instanceof Hashtable) {
		return (Hashtable<String, ?>) dict;
	}

	// legacy dictionary...
	// don't care about the performance...
	final HashMap<String, Object> map = new HashMap<String, Object>();
	for (final Enumeration<String> e = dict.keys(); e.hasMoreElements();) {
		final String key = e.nextElement();
		map.put(key, dict.get(key));
	}
	return map;
}
 
Example #11
Source File: Scenario14TestSuite.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * run the test
 */
public void runTest() throws Throwable {
  /* create the hashtable to put properties in */
  Dictionary props = new Hashtable();
  /* put service.pid property in hashtable */
  props.put(EventConstants.EVENT_TOPIC, topicsToConsume);
  /* register the service */
  serviceRegistration = bundleContext.registerService
    (EventHandler.class.getName(), this, props);

  assertNotNull(getName() +" service registration should not be null",
                serviceRegistration);

  if (serviceRegistration == null) {
    fail("Could not get Service Registration ");
  }

}
 
Example #12
Source File: ManagedWorkQueueList.java    From cxf with Apache License 2.0 6 votes vote down vote up
public void updated(String pid, Dictionary<String, ?> props)
    throws ConfigurationException {
    if (pid == null) {
        return;
    }
    Dictionary<String, String> properties = CastUtils.cast(props);
    String queueName = properties.get(AutomaticWorkQueueImpl.PROPERTY_NAME);
    if (queues.containsKey(queueName)) {
        queues.get(queueName).update(properties);
    } else {
        AutomaticWorkQueueImpl wq = new AutomaticWorkQueueImpl(queueName);
        wq.setShared(true);
        wq.update(properties);
        wq.addChangeListener(this);
        queues.put(pid, wq);
    }
}
 
Example #13
Source File: JointSpaceBinding.java    From openhab1-addons with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void updated(Dictionary<String, ?> config) throws ConfigurationException {
    if (config != null) {

        // to override the default refresh interval one has to add a
        // parameter to openhab.cfg like
        // <bindingName>:refresh=<intervalInMs>
        String refreshIntervalString = (String) config.get("refreshinterval");
        if (StringUtils.isNotBlank(refreshIntervalString)) {
            refreshInterval = Long.parseLong(refreshIntervalString);
        }
        String ipString = (String) config.get("ip");
        if (StringUtils.isNotBlank(ipString)) {
            ip = ipString;
            setProperlyConfigured(true);
        }
        String portString = (String) config.get("port");
        if (StringUtils.isNotBlank(portString)) {
            port = portString;
        }

    }
}
 
Example #14
Source File: ImageView.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Loads the image from the URL <code>getImageURL</code>. This should
 * only be invoked from <code>refreshImage</code>.
 */
private void loadImage() {
    URL src = getImageURL();
    Image newImage = null;
    if (src != null) {
        Dictionary cache = (Dictionary)getDocument().
                                getProperty(IMAGE_CACHE_PROPERTY);
        if (cache != null) {
            newImage = (Image)cache.get(src);
        }
        else {
            newImage = Toolkit.getDefaultToolkit().createImage(src);
            if (newImage != null && getLoadsSynchronously()) {
                // Force the image to be loaded by using an ImageIcon.
                ImageIcon ii = new ImageIcon();
                ii.setImage(newImage);
            }
        }
    }
    image = newImage;
}
 
Example #15
Source File: CMCommands.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/***************************************************************************
 * Helper method that gets the editing dictionary of the current configuration
 * from the session. Returns a new empty dictionary if current is set but have
 * no dictionary set yet.
 **************************************************************************/
private Dictionary<String, Object> getEditingDict(Session session)
{
  @SuppressWarnings("unchecked")
  Dictionary<String, Object> dict =
    (Dictionary<String, Object>) session.getProperties().get(EDITED);
  if (dict == null) {
    final Configuration cfg = getCurrent(session);
    long changeCount = Long.MIN_VALUE;
    if (cfg != null) {
      changeCount = cfg.getChangeCount();
      dict = cfg.getProperties();
    }
    if (dict == null) {
      dict = new Hashtable<String, Object>();
    }
    setEditingDict(session, dict, changeCount);
  }
  return dict;
}
 
Example #16
Source File: Activator.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void start ( final BundleContext context ) throws Exception
{
    Activator.instance = this;

    if ( !Boolean.getBoolean ( "org.eclipse.scada.core.client.ngp.disableSharedProcessor" ) )
    {
        this.processor = new SimpleIoProcessorPool<> ( NioProcessor.class );
    }
    this.factory = new DriverFactoryImpl ( this.processor );

    final Dictionary<String, String> properties = new Hashtable<String, String> ();
    properties.put ( org.eclipse.scada.core.client.DriverFactory.INTERFACE_NAME, "ca" );
    properties.put ( org.eclipse.scada.core.client.DriverFactory.DRIVER_NAME, "ngp" );
    properties.put ( Constants.SERVICE_DESCRIPTION, "Eclipse SCADA CA NGP Adapter" );
    properties.put ( Constants.SERVICE_VENDOR, "Eclipse SCADA Project" );
    this.handle = context.registerService ( org.eclipse.scada.core.client.DriverFactory.class, this.factory, properties );

}
 
Example #17
Source File: JaxRSServerContainer.java    From JaxRSProviders with Apache License 2.0 5 votes vote down vote up
@Override
protected Map<String, Object> exportRemoteService(RSARemoteServiceRegistration reg) {
	// Create Servlet
	Servlet servlet = createServlet(reg);
	if (servlet == null)
		throw new NullPointerException(
				"Servlet is null.  It cannot be null to export Jax RS servlet.   See subclass implementation of JaxRSServerContainer.createServlet()");
	// Create servletProps
	@SuppressWarnings("rawtypes")
	Dictionary servletProperties = createServletProperties(reg);
	// Create HttpContext
	HttpContext servletContext = createServletContext(reg);
	// Get servlet alias
	String servletAlias = getServletAlias(reg);
	// Get HttpService instance
	HttpService httpService = getHttpService();
	if (httpService == null)
		throw new NullPointerException("HttpService cannot cannot be null");
	synchronized (this.registrations) {
		try {
			httpService.registerServlet(servletAlias, servlet, servletProperties, servletContext);
		} catch (ServletException | NamespaceException e) {
			throw new RuntimeException("Cannot register servlet with alias=" + servletAlias, e);
		}
		this.registrations.put(servletAlias, reg);
	}
	return createExtraExportProperties(servletAlias, reg);
}
 
Example #18
Source File: PreferencesMngrImpl.java    From roboconf-platform with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings( "unchecked" )
public void save( String key, String value ) throws IOException {

	// Log
	this.logger.fine( "Preference with key '" + key + "' is being updated." );
	this.logger.finest( "New preference value: " + key + " = " + value );

	// Update the cache right away
	String realValue = value == null ? "" : value;
	this.cache.put( key, realValue );

	// Update the config admin property.
	// This will invoke (indirectly) the "updateProperties" method.
	// It will simply update the cache, it does not cost a lot.
	if( this.configAdmin != null ) {
		Configuration config = this.configAdmin.getConfiguration( PID, null );

		// Do NOT be too smart here.
		// Felix's implementation returns a new object every time
		// one invoke "config.getProperties()". So, we do not have a direct
		// access to the properties and "config.update()" does not work.
		//
		// So, we store the result of "config.getProperties()" in a variable.
		// We update this temporary map. And then, we pass the map as a parameter
		// to "config.update()". Manual tests with Karaf have shown it does not work
		// otherwise.
		Dictionary<Object,Object> props = config.getProperties();
		props.put( key, realValue );
		config.update( props );

	} else {
		this.logger.warning( "Config Admin is not available." );
	}

	// We need to mix both approaches here so that this API works in
	// both OSGi and non-OSGi environments.
}
 
Example #19
Source File: Activator.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Called by the framework when this bundle is started.
 * 
 * @param bc
 *          Bundle context.
 */
public void start(BundleContext bc)
{
  // Register framework commands
  CommandGroup cg = new FrameworkCommandGroup(bc);
  Dictionary<String, String> props = new Hashtable<String, String>();
  props.put("groupName", cg.getGroupName());
  bc.registerService(COMMAND_GROUP, cg, props);
}
 
Example #20
Source File: InMemoryHandlerWithoutManagerTest.java    From roboconf-platform with Apache License 2.0 5 votes vote down vote up
@Before
public void setMessagingConfiguration() throws Exception {

	this.msgCfg = new LinkedHashMap<>();
	this.msgCfg.put("net.roboconf.messaging.type", "telepathy");
	this.msgCfg.put("mindControl", "false");
	this.msgCfg.put("psychosisProtection", "active");

	this.target = new InMemoryHandler();
	this.target.standardAgentFactory = Mockito.mock( Factory.class );
	this.ipojoInstance = Mockito.mock( ComponentInstance.class );
	Mockito
		.when( this.target.standardAgentFactory.createComponentInstance( Mockito.any( Dictionary.class )))
		.thenReturn( this.ipojoInstance );
}
 
Example #21
Source File: ConfigurationService.java    From openhab-core with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Creates or updates a configuration for a config id.
 *
 * @param configId config id
 * @param newConfiguration the configuration
 * @param override if true, it overrides the old config completely. means it deletes all parameters even if they are
 *            not defined in the given configuration.
 * @return old config or null if no old config existed
 * @throws IOException if configuration can not be stored
 */
public Configuration update(String configId, Configuration newConfiguration, boolean override) throws IOException {
    org.osgi.service.cm.Configuration configuration = null;
    if (newConfiguration.containsKey(ConfigConstants.SERVICE_CONTEXT)) {
        try {
            configuration = getConfigurationWithContext(configId);
        } catch (InvalidSyntaxException e) {
            logger.error("Failed to lookup config for PID '{}'", configId);
        }
        if (configuration == null) {
            configuration = configurationAdmin.createFactoryConfiguration(configId, null);
        }
    } else {
        configuration = configurationAdmin.getConfiguration(configId, null);
    }

    Configuration oldConfiguration = toConfiguration(configuration.getProperties());
    Dictionary<String, Object> properties = getProperties(configuration);
    Set<Entry<String, Object>> configurationParameters = newConfiguration.getProperties().entrySet();
    if (override) {
        Set<String> keySet = oldConfiguration.keySet();
        for (String key : keySet) {
            properties.remove(key);
        }
    }
    for (Entry<String, Object> configurationParameter : configurationParameters) {
        Object value = configurationParameter.getValue();
        if (value == null) {
            properties.remove(configurationParameter.getKey());
        } else if (value instanceof String || value instanceof Integer || value instanceof Boolean
                || value instanceof Object[] || value instanceof Collection) {
            properties.put(configurationParameter.getKey(), value);
        } else {
            // the config admin does not support complex object types, so let's store the string representation
            properties.put(configurationParameter.getKey(), value.toString());
        }
    }
    configuration.update(properties);
    return oldConfiguration;
}
 
Example #22
Source File: MainPanel.java    From java-swing-tips with MIT License 5 votes vote down vote up
private JSlider makeSlider(boolean icon) {
  JSlider slider = new JSlider(0, 100);
  slider.setMajorTickSpacing(10);
  slider.setMinorTickSpacing(5);
  slider.setPaintLabels(true);
  slider.setSnapToTicks(true);
  slider.putClientProperty("Slider.paintThumbArrowShape", Boolean.TRUE);
  if (icon) {
    Dictionary<?, ?> dictionary = slider.getLabelTable();
    if (Objects.nonNull(dictionary)) {
      Icon tick = new TickIcon();
      Collections.list(dictionary.elements()).stream()
          .filter(JLabel.class::isInstance)
          .map(JLabel.class::cast)
          .forEach(label -> {
            label.setBorder(BorderFactory.createEmptyBorder(1, 0, 0, 0));
            label.setIcon(tick);
            label.setIconTextGap(0);
            label.setVerticalAlignment(SwingConstants.TOP);
            label.setVerticalTextPosition(SwingConstants.BOTTOM);
            label.setHorizontalAlignment(SwingConstants.CENTER);
            label.setHorizontalTextPosition(SwingConstants.CENTER);
            label.setForeground(Color.RED);
          });
    }
  } else {
    slider.setPaintTicks(true);
    slider.setForeground(Color.BLUE);
  }
  return slider;
}
 
Example #23
Source File: ConsoleTcp.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Called by the framework when this bundle is started.
 *
 * @param bc
 *          Bundle context.
 */
@Override
public void start(BundleContext bc)
{
  this.bc = bc;

  // Get config
  final Dictionary<String,Object> p = new Hashtable<String,Object>();
  p.put(Constants.SERVICE_PID, getClass().getName());
  bc.registerService(ManagedService.class.getName(), this, p);
}
 
Example #24
Source File: SatelBinding.java    From openhab1-addons with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void updated(Dictionary<String, ?> config) throws ConfigurationException {
    logger.trace("Binding configuration updated");

    if (config == null) {
        return;
    }

    ConfigurationDictionary configuration = new ConfigurationDictionary(config);

    this.refreshInterval = configuration.getLong("refresh", 10000);
    this.userCode = configuration.getString("user_code");
    this.textEncoding = configuration.getString("encoding", "windows-1250");

    // validate charset
    try {
        Charset.forName(this.textEncoding);
    } catch (Exception e) {
        throw new ConfigurationException("encoding",
                "Specified character set is either incorrect or not supported: " + this.textEncoding);
    }

    int timeout = configuration.getInt("timeout", 5000);
    String host = configuration.getString("host");
    if (StringUtils.isNotBlank(host)) {
        this.satelModule = new Ethm1Module(host, configuration.getInt("port", 7094), timeout,
                configuration.getString("encryption_key"));
    } else {
        this.satelModule = new IntRSModule(configuration.getString("port"), timeout);
    }

    this.satelModule.addEventListener(this);
    this.satelModule.open();
    setProperlyConfigured(true);
    logger.trace("Binding properly configured");
}
 
Example #25
Source File: OCD.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Creates an OCD with attribute definitions from an existing dictionary.
 *
 * @param id
 *          unique ID of the definition.
 * @param name
 *          human-readable name of the definition. If set to <tt>null</tt>,
 *          use <i>id</i> as name.
 * @param desc
 *          human-readable description of the definition
 * @param props
 *          set of key value pairs used for attribute definitions. all entries
 *          in <i>props</i> will be set as REQUIRED attributes.
 * @throws IllegalArgumentException
 *           if <i>id</i> is <null> or empty
 *
 */
public OCD(String id, String name, String desc, Dictionary<String, ?> props)
{
  this(id, name, desc, (URL) null);

  // System.out.println("OCD " + id + ", props=" + props);
  for (final Enumeration<String> e = props.keys(); e.hasMoreElements();) {
    final String key = e.nextElement();
    if ("service.pid".equals(key.toLowerCase())) {
      continue;
    }
    if ("service.factorypid".equals(key.toLowerCase())) {
      continue;
    }
    final Object val = props.get(key);

    int card = 0;
    final int type = AD.getType(val);

    if (val instanceof Vector) {
      card = Integer.MIN_VALUE;
    } else if (val.getClass().isArray()) {
      card = Integer.MAX_VALUE;
    }

    final AD ad =
      new AD(key, type, card, key, card == 0
        ? new String[] { AD.toString(val) }
        : null);

    // System.out.println(" add " + ad);
    add(ad, REQUIRED);
  }

}
 
Example #26
Source File: BasicSliderUI.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * Returns true if all the labels from the label table have the same
 * baseline.
 *
 * @return true if all the labels from the label table have the
 *         same baseline
 * @since 1.6
 */
protected boolean labelsHaveSameBaselines() {
    if (!checkedLabelBaselines) {
        checkedLabelBaselines = true;
        Dictionary dictionary = slider.getLabelTable();
        if (dictionary != null) {
            sameLabelBaselines = true;
            Enumeration elements = dictionary.elements();
            int baseline = -1;
            while (elements.hasMoreElements()) {
                JComponent label = (JComponent) elements.nextElement();
                Dimension pref = label.getPreferredSize();
                int labelBaseline = label.getBaseline(pref.width,
                                                      pref.height);
                if (labelBaseline >= 0) {
                    if (baseline == -1) {
                        baseline = labelBaseline;
                    }
                    else if (baseline != labelBaseline) {
                        sameLabelBaselines = false;
                        break;
                    }
                }
                else {
                    sameLabelBaselines = false;
                    break;
                }
            }
        }
        else {
            sameLabelBaselines = false;
        }
    }
    return sameLabelBaselines;
}
 
Example #27
Source File: Activator.java    From orion.server with Eclipse Public License 1.0 5 votes vote down vote up
public AuthServiceTracker(BundleContext context) throws InvalidSyntaxException {
	super(context, getAuthFilter(), null);
	// TODO: Filters are case sensitive, we should be too
	if (NoneAuthenticationService.AUTH_TYPE.equalsIgnoreCase(getAuthName())) {
		Dictionary<String, String> properties = new Hashtable<String, String>();
		properties.put(ServerConstants.CONFIG_AUTH_NAME, getAuthName());
		// TODO: shouldn't we always register the none-auth service?
		context.registerService(IAuthenticationService.class, new NoneAuthenticationService(), properties);
	}
}
 
Example #28
Source File: BasicSliderUI.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns true if all the labels from the label table have the same
 * baseline.
 *
 * @return true if all the labels from the label table have the
 *         same baseline
 * @since 1.6
 */
protected boolean labelsHaveSameBaselines() {
    if (!checkedLabelBaselines) {
        checkedLabelBaselines = true;
        Dictionary dictionary = slider.getLabelTable();
        if (dictionary != null) {
            sameLabelBaselines = true;
            Enumeration elements = dictionary.elements();
            int baseline = -1;
            while (elements.hasMoreElements()) {
                JComponent label = (JComponent) elements.nextElement();
                Dimension pref = label.getPreferredSize();
                int labelBaseline = label.getBaseline(pref.width,
                                                      pref.height);
                if (labelBaseline >= 0) {
                    if (baseline == -1) {
                        baseline = labelBaseline;
                    }
                    else if (baseline != labelBaseline) {
                        sameLabelBaselines = false;
                        break;
                    }
                }
                else {
                    sameLabelBaselines = false;
                    break;
                }
            }
        }
        else {
            sameLabelBaselines = false;
        }
    }
    return sameLabelBaselines;
}
 
Example #29
Source File: PropertyConglomerate.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
void savePropertyDefault(TransactionController tc, String key, Serializable value)
	 throws StandardException
{
	if (saveServiceProperty(key,value)) return;

	Dictionary defaults = (Dictionary)readProperty(tc,AccessFactoryGlobals.DEFAULT_PROPERTY_NAME);
	if (defaults == null) defaults = new FormatableHashtable();
	if (value==null)
		defaults.remove(key);
	else
		defaults.put(key,value);
	if (defaults.size() == 0) defaults = null;
	saveProperty(tc,AccessFactoryGlobals.DEFAULT_PROPERTY_NAME,(Serializable)defaults);
}
 
Example #30
Source File: PhasedRecoveryManager.java    From onos with Apache License 2.0 5 votes vote down vote up
@Modified
protected void modified(ComponentContext context) {
    Dictionary<?, ?> properties = context.getProperties();
    if (properties == null) {
        return;
    }

    String strPhasedRecovery = Tools.get(properties, PROP_PHASED_RECOVERY);
    boolean expectPhasedRecovery = Boolean.parseBoolean(strPhasedRecovery);
    if (expectPhasedRecovery != phasedRecovery) {
        phasedRecovery = expectPhasedRecovery;
        log.info("{} phased recovery", phasedRecovery ? "Enabling" : "Disabling");
    }
}