Example usage for java.util Dictionary get

List of usage examples for java.util Dictionary get

Introduction

In this page you can find the example usage for java.util Dictionary get.

Prototype

public abstract V get(Object key);

Source Link

Document

Returns the value to which the key is mapped in this dictionary.

Usage

From source file:org.openhab.binding.astro.internal.common.AstroConfig.java

/**
 * Parses and validates the properties in the openhab.cfg.
 *///from   w ww .j a  va 2 s.  c  o m
public void parse(Dictionary<String, ?> properties) throws ConfigurationException {
    valid = false;

    String cfgLatitude = (String) properties.get(AstroConfig.CONFIG_KEY_LATITUDE);
    String cfgLongitude = (String) properties.get(AstroConfig.CONFIG_KEY_LONGITUDE);

    if (StringUtils.isBlank(cfgLatitude) || StringUtils.isBlank(cfgLongitude)) {
        throw new ConfigurationException("astro",
                "Parameters latitude and longitude are mandatory and must be configured. Please check your openhab.cfg!");
    }

    try {
        latitude = Double.parseDouble(cfgLatitude);
        longitude = Double.parseDouble(cfgLongitude);
    } catch (NumberFormatException ex) {
        throw new ConfigurationException("astro",
                "Parameters latitude and/or longitude in wrong format. Please check your openhab.cfg!");
    }

    interval = parseInt(properties, CONFIG_KEY_INTERVAL, 0);

    valid = true;
}

From source file:com.whizzosoftware.hobson.openweathermap.OpenWeatherMapPlugin.java

private void createUri(Dictionary config) throws Exception {
    if (config != null) {
        String s = (String) config.get("city.state");
        if (s != null && (cityState == null || !cityState.equals(s))) {
            this.cityState = s;
            uri = new URI("http", "api.openweathermap.org", "/data/2.5/weather", "q=" + cityState, null);
        }//from   w  w  w .j  av a2s  .c om
    }

    if (uri != null) {
        logger.debug("Using URI: {}", uri.toASCIIString());
        setStatus(new PluginStatus(PluginStatus.Status.RUNNING));
        if (!varsPublished) {
            publishGlobalVariable(VariableConstants.TEMP_C, null, HobsonVariable.Mask.READ_ONLY);
            publishGlobalVariable(VariableConstants.TEMP_F, null, HobsonVariable.Mask.READ_ONLY);
            varsPublished = true;
        }
        onRefresh();
    } else {
        logger.debug("No plugin configuration; unable to query OpenWeatherMap server");
        setStatus(new PluginStatus(PluginStatus.Status.NOT_CONFIGURED,
                "City/state is not set in plugin configuration"));
    }
}

From source file:org.apache.sling.jcr.classloader.internal.RepositoryClassLoaderProviderImpl.java

protected void activate(ComponentContext componentContext) {
    @SuppressWarnings("unchecked")
    Dictionary properties = componentContext.getProperties();

    Object prop = properties.get(CLASS_PATH_PROP);
    this.classPath = (prop instanceof String[]) ? (String[]) prop : CLASS_PATH_DEFAULT;

    prop = properties.get(OWNER_PROP);//from   www .  ja  v  a2s . co  m
    this.classLoaderOwner = (prop instanceof String) ? (String) prop : OWNER_DEFAULT;

    Bundle owner = componentContext.getUsingBundle();

    // if there is no using bundle, we have an error !!
    if (owner == null) {
        throw new IllegalStateException("Using Bundle expected. Is this a servicefactory component ?");
    }

    this.parent = new BundleProxyClassLoader(owner, null);
}

From source file:org.openhab.binding.sagercaster.internal.SagerCasterBinding.java

@Override
public void updated(Dictionary<String, ?> properties) throws ConfigurationException {
    String latitude = (String) properties.get(LATITUDE);
    sagerWeatherCaster.setLatitude(Double.parseDouble(latitude));

    String persistence = (String) properties.get(PERSISTENCE);
    if (!isBlank(persistence)) {
        persistenceService = persistence;
    }/*w  w  w.  jav  a2s. c  om*/
    ;
}

From source file:org.apache.sling.hc.core.impl.servlet.ResultHtmlSerializer.java

@Activate
protected final void activate(final ComponentContext context) {
    final Dictionary<?, ?> properties = context.getProperties();
    this.styleString = PropertiesUtil.toString(properties.get(PROPERTY_CSS_STYLE), CSS_STYLE_DEFAULT);
}

From source file:it.txt.ens.client.publisher.example.osgi.PublisherFilter.java

@Override
public boolean match(Dictionary<String, ?> dictionary) {
    return matches(
            dictionary.get(it.txt.ens.client.publisher.osgi.FilterAttributes.PUBLISHER_IMPLEMENTATION_KEY),
            dictionary.get(ENSResourceFactory.NAMESPACE), dictionary.get(ENSResourceFactory.PATTERN),
            (Long) dictionary.get(it.txt.ens.client.publisher.osgi.FilterAttributes.PUBLISHER_OWNER_KEY));
}

From source file:it.txt.ens.client.publisher.example.osgi.PublisherFilter.java

@Override
public boolean matchCase(Dictionary<String, ?> dictionary) {
    return matches(
            dictionary.get(it.txt.ens.client.publisher.osgi.FilterAttributes.PUBLISHER_IMPLEMENTATION_KEY),
            dictionary.get(ENSResourceFactory.NAMESPACE), dictionary.get(ENSResourceFactory.PATTERN),
            (Long) dictionary.get(it.txt.ens.client.publisher.osgi.FilterAttributes.PUBLISHER_OWNER_KEY));
}

From source file:org.ops4j.pax.web.itest.jetty.WarJSFIntegrationTest.java

/**
 * You will get a list of bundles installed by default plus your testcase,
 * wrapped into a bundle called pax-exam-probe
 *//* w  w w  . j av a2  s .c  o m*/
// @Test
public void listBundles() {
    for (Bundle b : bundleContext.getBundles()) {
        if (b.getState() != Bundle.ACTIVE) {
            fail("Bundle should be active: " + b);
        }

        Dictionary<?, ?> headers = b.getHeaders();
        String ctxtPath = (String) headers.get(WEB_CONTEXT_PATH);
        if (ctxtPath != null) {
            System.out.println("Bundle " + b.getBundleId() + " : " + b.getSymbolicName() + " : " + ctxtPath);
        } else {
            System.out.println("Bundle " + b.getBundleId() + " : " + b.getSymbolicName());
        }
    }
}

From source file:org.openhab.io.gcal.internal.GCalConfiguration.java

/**
 * {@inheritDoc}//from w  w w .j  a va2 s.c  om
 */
@SuppressWarnings("rawtypes")
public void updated(Dictionary config) throws ConfigurationException {
    if (config != null) {
        String usernameString = (String) config.get("username");
        username = usernameString;
        if (StringUtils.isBlank(username)) {
            throw new ConfigurationException("gcal:username",
                    "username must not be blank - please configure an aproppriate username in openhab.cfg");
        }

        String passwordString = (String) config.get("password");
        password = passwordString;
        if (StringUtils.isBlank(password)) {
            throw new ConfigurationException("gcal:password",
                    "password must not be blank - please configure an aproppriate password in openhab.cfg");
        }

        String urlString = (String) config.get("url");
        url = urlString;
        if (StringUtils.isBlank(url)) {
            throw new ConfigurationException("gcal:url",
                    "url must not be blank - please configure an aproppriate url in openhab.cfg");
        }

        String refreshString = (String) config.get("refresh");
        if (StringUtils.isNotBlank(refreshString)) {
            refreshInterval = Integer.parseInt(refreshString);
        }

        String offsetString = (String) config.get("offset");
        if (StringUtils.isNotBlank(offsetString)) {
            try {
                offset = Integer.valueOf(offsetString);
            } catch (IllegalArgumentException iae) {
                logger.warn("couldn't parse '{}' to an integer");
            }
        }

        String executeScriptString = (String) config.get("executescript");
        if (StringUtils.isNotBlank(executeScriptString)) {
            executeScript = executeScriptString;
        }

        initialized = true;
    }
}

From source file:org.openhab.binding.astro.internal.common.AstroConfig.java

/**
 * Parses a integer property.//from w ww . j a v a  2  s  . c  om
 */
private Integer parseInt(Dictionary<String, ?> properties, String key, Integer defaultValue)
        throws ConfigurationException {
    String value = (String) properties.get(key);
    if (StringUtils.isNotBlank(value)) {
        try {
            return Integer.parseInt(value);
        } catch (NumberFormatException ex) {
            throw new ConfigurationException("astro",
                    "Parameter " + key + " in wrong format. Please check your openhab.cfg!");
        }

    } else {
        return defaultValue;
    }
}