java.util.Dictionary#get ( )源码实例Demo

下面列出了java.util.Dictionary#get ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: carbon-apimgt   文件: RestApiUtil.java
public static Boolean checkETagSkipList(String path, String httpMethod) {
    //Check if the accessing URI is ETag skipped
    try {
        Dictionary<org.wso2.uri.template.URITemplate, List<String>> eTagSkipListToMethodsMap = RestApiUtil.getETagSkipListToMethodsMap();
        Enumeration<org.wso2.uri.template.URITemplate> uriTemplateSet = eTagSkipListToMethodsMap.keys();

        while (uriTemplateSet.hasMoreElements()) {
            org.wso2.uri.template.URITemplate uriTemplate = uriTemplateSet.nextElement();
            if (uriTemplate.matches(path, new HashMap<String, String>())) {
                List<String> ETagDisableHttpVerbs = eTagSkipListToMethodsMap.get(uriTemplate);
                return ETagDisableHttpVerbs.contains(httpMethod);
            }
        }
    } catch (APIManagementException e) {
        RestApiUtil.handleInternalServerError("Unable to resolve ETag skip list in api-manager.xml", e, log);
    }
    return false;
}
 
源代码2 项目: knopflerfish.org   文件: RepositoryCommandGroup.java
public int cmdList(Dictionary<String,?> opts, Reader in, PrintWriter out,
    Session session) {
  final String [] selection = (String[]) opts.get("repository");
  final SortedSet<RepositoryInfo> repos = getRepoSelection(selection);
  final boolean verbose = (opts.get("-l") != null);

  if (repos.isEmpty()) {
    if (selection != null) {
      out.println("No matching repository.");
    } else {
      out.println("No repositories found.");
    }
    return 1;
  } else {
    printRepos(out, repos, null, verbose);
    return 0;
  }
}
 
源代码3 项目: TencentKona-8   文件: ImageView.java
/**
 * 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;
}
 
源代码4 项目: openhab1-addons   文件: TTSServiceGoogleTTS.java
/**
 * {@inheritDoc}
 */
public void updated(Dictionary<String, ?> properties) throws ConfigurationException {
    if (properties != null) {
        String language = (String) properties.get(LANGUAGE_PROPERTY);
        if (!StringUtils.isBlank(language)) {
            logger.debug("Using TTS language from config: " + ttsLanguage);
            ttsLanguage = language;
        }

        String delimiters = (String) properties.get(SENTENCE_DELIMITERS_PROPERTY);
        if (!StringUtils.isBlank(delimiters)) {
            logger.debug("Using custom sentence delimiters from config: " + delimiters);
            textProcessor.setCustomSentenceDelimiters(delimiters);
        }

        String configTranslateUrl = (String) properties.get(TRANSLATE_URL_PROPERTY);
        if (!StringUtils.isBlank(configTranslateUrl)) {
            logger.debug("Using custom translate URL from config: " + configTranslateUrl);
            translateUrl = configTranslateUrl;
        }
    }
}
 
源代码5 项目: openhab1-addons   文件: MailControlBinding.java
/**
 * {@inheritDoc}
 */
@Override
public void updated(Dictionary<String, ?> config) throws ConfigurationException {
    if (config != null) {
        this.config = config;
        this.connectorBuilder = new ConnectorBuilder(config);
        connectorBuilder.createAndCheckMailConnector();

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

        setProperlyConfigured(true);
    }
}
 
源代码6 项目: openhab1-addons   文件: MaxCulBinding.java
/**
 * {@inheritDoc}
 */
@Override
public void updated(Dictionary<String, ?> config) throws ConfigurationException {
    logger.debug("MaxCUL Reading config");
    if (config != null) {

        // handle timezone configuration
        // maxcul:timezone=Europe/London
        String timezoneString = (String) config.get("timezone");
        if (StringUtils.isNotBlank(timezoneString)) {
            this.tzStr = timezoneString;
        } else {
            this.tzStr = "Europe/London";
        }

        culHandlerLifecycle.config(config);
    }
}
 
源代码7 项目: cxf   文件: ConfigAdminHttpConduitConfigurer.java
@SuppressWarnings("unchecked")
public void updated(String pid, @SuppressWarnings("rawtypes") Dictionary properties)
    throws ConfigurationException {
    if (pid == null) {
        return;
    }
    deleted(pid);

    String url = (String)properties.get("url");
    String name = (String)properties.get("name");
    Matcher matcher = url == null ? null : Pattern.compile(url).matcher("");
    String p = (String)properties.get("order");
    int order = 50;
    if (p != null) {
        order = Integer.parseInt(p);
    }

    PidInfo info = new PidInfo(properties, matcher, order);

    props.put(pid, info);
    if (url != null) {
        props.put(url, info);
    }
    if (name != null) {
        props.put(name, info);
    }
    addToSortedInfos(info);
}
 
/**
 * Called by the framework when a report has been received. This method calls all the listeners
 * <i>changedMeasuredValue</i> methods.
 */
public void receivedReport(final String endPointId, final short clusterId,
                           final Dictionary<Attribute, Object> reports) {
    if (reports.get(bridged) == null) {
        return;
    }
    synchronized (listeners) {
        for (MeasuredValueListener listener : listeners) {
            listener.changedMeasuredValue(new MeasuredValueEventImpl(cluster, (Integer) reports.get(bridged)));
        }
    }
}
 
源代码9 项目: knopflerfish.org   文件: LogConfigCommandGroup.java
public int cmdOut(Dictionary<String, ?> opts, Reader in, PrintWriter out, Session session)
{

  // Get log configuration service
  final LogConfig configuration =
    LogCommands.logConfigTracker.getService();
  if (configuration == null) {
    out.println("Unable to get a LogConfigService");
    return 1;
  }

  if (!configuration.isDefaultConfig()) {
    out.println("  This command is no persistent. (No valid configuration has been received)");
  }

  boolean optionFound = false;
  // System.out logging on/off
  if (opts.get("-on") != null) {
    optionFound = true;
    configuration.setOut(true);
  } else if (opts.get("-off") != null) {
    optionFound = true;
    configuration.setOut(false);
  }
  // Show current config
  if (!optionFound) {
    final boolean isOn = configuration.getOut();
    out.println("  Logging to standard out is " + (isOn ? "on" : "off") + ".");
  }
  return 0;
}
 
源代码10 项目: jdk8u-jdk   文件: BasicSliderUI.java
protected int getHeightOfTallestLabel() {
    Dictionary dictionary = slider.getLabelTable();
    int tallest = 0;
    if ( dictionary != null ) {
        Enumeration keys = dictionary.keys();
        while ( keys.hasMoreElements() ) {
            JComponent label = (JComponent) dictionary.get(keys.nextElement());
            tallest = Math.max( label.getPreferredSize().height, tallest );
        }
    }
    return tallest;
}
 
源代码11 项目: knopflerfish.org   文件: OCD.java
/**
 * 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);
  }

}
 
源代码12 项目: karaf-decanter   文件: CsvMarshaller.java
@Activate
public void activate(ComponentContext componentContext) {
    Dictionary<String, Object> config = componentContext.getProperties();
    separator = (config.get("separator") != null) ? (String) config.get("separator") : ",";
}
 
源代码13 项目: knopflerfish.org   文件: LogConfigCommandGroup.java
public int cmdFile(final Dictionary<String, ?> opts,
                   final Reader in,
                   final PrintWriter out,
                   final Session session)
{

  // Get log configuration service
  final LogConfig configuration =
    LogCommands.logConfigTracker.getService();
  if (configuration == null) {
    out.println("Unable to get a LogConfigService");
    return 1;
  }

  if (configuration.getDir() == null) {
    out.println(" This command is disabled; "
                + "writable filesystem not available.");
    return 1;
  }

  boolean optionFound = false;
  // File logging on/off
  if (opts.get("-on") != null) {
    optionFound = true;
    configuration.setFile(true);
  } else if (opts.get("-off") != null) {
    optionFound = true;
    configuration.setFile(false);
  }
  // Flush
  if (opts.get("-flush") != null) {
    optionFound = true;
    configuration.setFlush(true);
  } else if (opts.get("-noflush") != null) {
    optionFound = true;
    configuration.setFlush(false);
  }
  // Log size
  String value = (String) opts.get("-size");
  if (value != null) {
    optionFound = true;
    try {
      configuration.setFileSize(Integer.parseInt(value));
    } catch (final NumberFormatException nfe1) {
      out.println("Cannot set log size (" + nfe1 + ").");
    }
  }
  // Log generations
  value = (String) opts.get("-gen");
  if (value != null) {
    optionFound = true;
    try {
      configuration.setMaxGen(Integer.parseInt(value));
    } catch (final NumberFormatException nfe2) {
      out.println("Cannot set generation count (" + nfe2 + ").");
    }
  }

  if (optionFound) {
    // Create persistent CM-config
    configuration.commit();
  } else {
    // Show current config
    final boolean isOn = configuration.getFile();
    out.println("  file logging is " + (isOn ? "on" : "off") + ".");
    out.println("  file size:    " + configuration.getFileSize());
    out.println("  generations:  " + configuration.getMaxGen());
    out.println("  flush:        " + configuration.getFlush());
    out.println("  log location: " + configuration.getDir());
  }
  return 0;
}
 
源代码14 项目: knopflerfish.org   文件: ScrCommandGroup.java
public int cmdShow(final Dictionary<String, ?> opts,
                   final Reader in,
                   final PrintWriter out,
                   final Session session)
{
  final ScrService scr = scrService;
  int failed = 0;
  if (scr == null) {
    out.println("SCR commands are currently inactive");
    return 1;
  }
  Comparator<Component> order;
  if (opts.get("-b") != null) {
    order = new OrderBundle();
  } else if (opts.get("-n") != null) {
    order = new OrderName();
  } else {
    order = new OrderId();
  }
  final TreeSet<Component> comps = new TreeSet<Component>(order);
  final String[] cids = (String[]) opts.get("component");
  if (cids != null) {
    for (final String cid : cids) {
      final Component[] components = getComponents(scr, cid, out);
      if (components != null) {
        for (final Component component : components) {
          comps.add(component);
        }
      } else {
        failed++;
      }
    }
  } else {
    final Component[] cs = scr.getComponents();
    if (cs != null) {
      for (final Component element : cs) {
        comps.add(element);
      }
    }
  }
  final int format = opts.get("-f") != null ? FORMAT_FULL : FORMAT_DYNAMIC;
  final boolean reverse = opts.get("-r") != null;
  showInfo(comps, format, reverse, out);

  return failed > 0 ? 1 : 0;
}
 
源代码15 项目: jdk1.8-source-analysis   文件: BasicSliderUI.java
public void paintLabels( Graphics g ) {
    Rectangle labelBounds = labelRect;

    Dictionary dictionary = slider.getLabelTable();
    if ( dictionary != null ) {
        Enumeration keys = dictionary.keys();
        int minValue = slider.getMinimum();
        int maxValue = slider.getMaximum();
        boolean enabled = slider.isEnabled();
        while ( keys.hasMoreElements() ) {
            Integer key = (Integer)keys.nextElement();
            int value = key.intValue();
            if (value >= minValue && value <= maxValue) {
                JComponent label = (JComponent) dictionary.get(key);
                label.setEnabled(enabled);

                if (label instanceof JLabel) {
                    Icon icon = label.isEnabled() ? ((JLabel) label).getIcon() : ((JLabel) label).getDisabledIcon();

                    if (icon instanceof ImageIcon) {
                        // Register Slider as an image observer. It allows to catch notifications about
                        // image changes (e.g. gif animation)
                        Toolkit.getDefaultToolkit().checkImage(((ImageIcon) icon).getImage(), -1, -1, slider);
                    }
                }

                if ( slider.getOrientation() == JSlider.HORIZONTAL ) {
                    g.translate( 0, labelBounds.y );
                    paintHorizontalLabel( g, value, label );
                    g.translate( 0, -labelBounds.y );
                }
                else {
                    int offset = 0;
                    if (!BasicGraphicsUtils.isLeftToRight(slider)) {
                        offset = labelBounds.width -
                            label.getPreferredSize().width;
                    }
                    g.translate( labelBounds.x + offset, 0 );
                    paintVerticalLabel( g, value, label );
                    g.translate( -labelBounds.x - offset, 0 );
                }
            }
        }
    }

}
 
源代码16 项目: karaf-decanter   文件: OrientDBAppender.java
private String getValue(Dictionary<String, Object> config, String key, String defaultValue) {
    String value = (String)config.get(key);
    return (value != null) ? value :  defaultValue;
}
 
源代码17 项目: knopflerfish.org   文件: KFLegacyMetaTypeParser.java
/**
 * Overwrite default values in MTP using a set of dictionaries.
 * 
 * @param mtp
 *          MetaTypeProvider containing instances of <tt>AD</tt>
 * @param propList
 *          List of Dictionary
 */
public static void setDefaultValues(MetaTypeProvider mtp,
    List<Dictionary<String, Object>> propList) {

  for (final Dictionary<String, Object> dictionary : propList) {
    final Dictionary<?, ?> props = dictionary;
    String pid = (String) props.get(SERVICE_PID);
    if (pid == null) {
      pid = (String) props.get("factory.pid");
    }

    ObjectClassDefinition ocd = null;
    try {
      ocd = mtp.getObjectClassDefinition(pid, null);
    } catch (final Exception ignored) {
    }

    if (ocd == null) {
      throw new IllegalArgumentException("No definition for pid '" + pid
          + "'");
    } else {
      final AttributeDefinition[] ads = ocd
          .getAttributeDefinitions(ObjectClassDefinition.ALL);

      for (int i = 0; ads != null && i < ads.length; i++) {
        final Object val = props.get(ads[i].getID());

        if (!(ads[i] instanceof AD)) {
          throw new IllegalArgumentException(
              "AttributeDefinitions must be instances of AD, otherwise default values cannot be set");
        }

        final AD ad = (AD) ads[i];

        if (val instanceof Vector) {
          ad.setDefaultValue(toStringArray((Vector<?>) val));
        } else if (val.getClass().isArray()) {
          ad.setDefaultValue(toStringArray((Object[]) val));
        } else {
          ad.setDefaultValue(new String[] { val.toString() });
        }
      }
    }
  }
}
 
源代码18 项目: jdk8u_jdk   文件: BasicSliderUI.java
public void paintLabels( Graphics g ) {
    Rectangle labelBounds = labelRect;

    Dictionary dictionary = slider.getLabelTable();
    if ( dictionary != null ) {
        Enumeration keys = dictionary.keys();
        int minValue = slider.getMinimum();
        int maxValue = slider.getMaximum();
        boolean enabled = slider.isEnabled();
        while ( keys.hasMoreElements() ) {
            Integer key = (Integer)keys.nextElement();
            int value = key.intValue();
            if (value >= minValue && value <= maxValue) {
                JComponent label = (JComponent) dictionary.get(key);
                label.setEnabled(enabled);

                if (label instanceof JLabel) {
                    Icon icon = label.isEnabled() ? ((JLabel) label).getIcon() : ((JLabel) label).getDisabledIcon();

                    if (icon instanceof ImageIcon) {
                        // Register Slider as an image observer. It allows to catch notifications about
                        // image changes (e.g. gif animation)
                        Toolkit.getDefaultToolkit().checkImage(((ImageIcon) icon).getImage(), -1, -1, slider);
                    }
                }

                if ( slider.getOrientation() == JSlider.HORIZONTAL ) {
                    g.translate( 0, labelBounds.y );
                    paintHorizontalLabel( g, value, label );
                    g.translate( 0, -labelBounds.y );
                }
                else {
                    int offset = 0;
                    if (!BasicGraphicsUtils.isLeftToRight(slider)) {
                        offset = labelBounds.width -
                            label.getPreferredSize().width;
                    }
                    g.translate( labelBounds.x + offset, 0 );
                    paintVerticalLabel( g, value, label );
                    g.translate( -labelBounds.x - offset, 0 );
                }
            }
        }
    }

}
 
源代码19 项目: knopflerfish.org   文件: Loader.java
/**
 * Overwrite default values in MTP using a set of dictionaries.
 *
 * @param mtp
 *          MetaTypeProvider containing instances of <tt>AD</tt>
 * @param propList
 *          List of Dictionary
 */
public static void setDefaultValues(MetaTypeProvider mtp,
                                    List<Dictionary<String, Object>> propList)
{

  for (final Dictionary<String, Object> dictionary : propList) {
 final Dictionary<?, ?> props = dictionary;
 String pid = (String) props.get(SERVICE_PID);
 if (pid == null) {
  pid = (String) props.get("factory.pid");
 }

 ObjectClassDefinition ocd = null;
 try {
  ocd = mtp.getObjectClassDefinition(pid, null);
 } catch (final Exception ignored) {
 }

 if (ocd == null) {
  throw new IllegalArgumentException("No definition for pid '" + pid
                                     + "'");
 } else {
  final AttributeDefinition[] ads =
    ocd.getAttributeDefinitions(ObjectClassDefinition.ALL);

  for (int i = 0; ads != null && i < ads.length; i++) {
    final Object val = props.get(ads[i].getID());

    if (!(ads[i] instanceof AD)) {
      throw new IllegalArgumentException(
                                         "AttributeDefinitions must be instances of AD, otherwise default values cannot be set");
    }

    final AD ad = (AD) ads[i];

    if (val instanceof Vector) {
      ad.setDefaultValue(toStringArray((Vector<?>) val));
    } else if (val.getClass().isArray()) {
      ad.setDefaultValue(toStringArray((Object[]) val));
    } else {
      ad.setDefaultValue(new String[] { val.toString() });
    }
  }
 }
}
}
 
源代码20 项目: openhab1-addons   文件: PulseaudioBinding.java
@Override
@SuppressWarnings("rawtypes")
public void updated(Dictionary<String, ?> config) throws ConfigurationException {

    if (config != null) {
        Enumeration keys = config.keys();
        while (keys.hasMoreElements()) {
            String key = (String) keys.nextElement();

            // the config-key enumeration contains additional keys that we
            // don't want to process here ...
            if ("service.pid".equals(key)) {
                continue;
            }

            Matcher matcher = EXTRACT_CONFIG_PATTERN.matcher(key);
            if (!matcher.matches()) {
                logger.debug("given pulseaudio-config-key '" + key
                        + "' does not follow the expected pattern '<serverId>.<host|port>'");
                continue;
            }

            matcher.reset();
            matcher.find();

            String serverId = matcher.group(1);

            PulseaudioServerConfig serverConfig = serverConfigCache.get(serverId);
            if (serverConfig == null) {
                serverConfig = new PulseaudioServerConfig();
                serverConfigCache.put(serverId, serverConfig);
            }

            String configKey = matcher.group(2);
            String value = (String) config.get(key);

            if ("host".equals(configKey)) {
                serverConfig.host = value;
            } else if ("port".equals(configKey)) {
                serverConfig.port = Integer.valueOf(value);
            } else {
                throw new ConfigurationException(configKey, "the given configKey '" + configKey + "' is unknown");
            }
        }
        connectAllPulseaudioServers();
    }
}