java.util.Hashtable.get()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(8.4k)|赞(0)|评价(0)|浏览(159)

本文整理了Java中java.util.Hashtable.get()方法的一些代码示例,展示了Hashtable.get()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Hashtable.get()方法的具体详情如下:
包路径:java.util.Hashtable
类名称:Hashtable
方法名:get

Hashtable.get介绍

[英]Returns the value associated with the specified key in this Hashtable.
[中]返回与此哈希表中指定键关联的值。

代码示例

代码示例来源:origin: redisson/redisson

/**
 * Undocumented method.  Do not use; internal-use only.
 *
 * @param name      the name of <code>$cflow</code> variable
 */
public Object[] lookupCflow(String name) {
  if (cflow == null)
    cflow = new Hashtable();
  return (Object[])cflow.get(name);
}

代码示例来源:origin: wildfly/wildfly

/** {@inheritDoc} */
public Object addToEnvironment(String propName, Object propVal) throws NamingException {
  final Object existing = environment.get(propName);
  environment.put(propName, propVal);
  return existing;
}

代码示例来源:origin: stackoverflow.com

Hashtable<Integer, String> table = ...

Enumeration<Integer> enumKey = table.keys();
while(enumKey.hasMoreElements()) {
  Integer key = enumKey.nextElement();
  String val = table.get(key);
  if(key==0 && val.equals("0"))
    table.remove(key);
}

代码示例来源:origin: xalan/xalan

/**
 * This method starts at a given node, traverses all namespace mappings,
 * and assembles a list of all prefixes that (for the given node) maps
 * to _ANY_ namespace URI. Used by literal result elements to determine
 */
public Enumeration getNamespaceScope(SyntaxTreeNode node) {
Hashtable all = new Hashtable();

while (node != null) {
  Hashtable mapping = node.getPrefixMapping();
  if (mapping != null) {
  Enumeration prefixes = mapping.keys();
  while (prefixes.hasMoreElements()) {
    String prefix = (String)prefixes.nextElement();
    if (!all.containsKey(prefix)) {
    all.put(prefix, mapping.get(prefix));
    }
  }
  }
  node = node.getParent();
}
return(all.keys());
}

代码示例来源:origin: stackoverflow.com

private static String getPostParamString(Hashtable<String, String> params) {
  if(params.size() == 0)
    return "";

  StringBuffer buf = new StringBuffer();
  Enumeration<String> keys = params.keys();
  while(keys.hasMoreElements()) {
    buf.append(buf.length() == 0 ? "" : "&");
    String key = keys.nextElement();
    buf.append(key).append("=").append(params.get(key));
  }
  return buf.toString();
}

代码示例来源:origin: robovm/robovm

private void addCDATAElement(String uri, String localName) 
{
  if (m_CdataElems == null) {
    m_CdataElems = new java.util.Hashtable();
  }
  
  java.util.Hashtable h = (java.util.Hashtable) m_CdataElems.get(localName);
  if (h == null) {
    h = new java.util.Hashtable();
    m_CdataElems.put(localName,h);
  }
  h.put(uri,uri);
  
}

代码示例来源:origin: robovm/robovm

while (keys.hasMoreElements()) {
  String key = (String) keys.nextElement();
  sb.append(key);
  sb.append('=');
  String property = (String) super.get(key);
  Properties def = defaults;
  while (property == null) {

代码示例来源:origin: javax.servlet/servlet-api

throw new IllegalArgumentException();
Hashtable ht = new Hashtable();
StringBuffer sb = new StringBuffer();
StringTokenizer st = new StringTokenizer(s, "&");
  if (ht.containsKey(key)) {
  String oldVals[] = (String []) ht.get(key);
  valArray = new String[oldVals.length + 1];
  for (int i = 0; i < oldVals.length; i++) 
  valArray[0] = val;
  ht.put(key, valArray);

代码示例来源:origin: spotbugs/spotbugs

public void hashtablesCantContainNull(Hashtable h) {
    h.put("a", null);
    h.put(null, "a");
    h.get(null);
    h.contains(null);
    h.containsKey(null);
    h.containsValue(null);
    h.remove(null);

  }
}

代码示例来源:origin: gocd/gocd

public final void topoSort(final CaseInsensitiveString root, final PipelineDependencyState pipelineDependencyState) throws Exception {
  Hashtable<CaseInsensitiveString, CycleState> state = new Hashtable<>();
  Stack<CaseInsensitiveString> visiting = new Stack<>();
  if (!state.containsKey(root)) {
    tsort(root, pipelineDependencyState, state, visiting);
  } else if (state.get(root) == CycleState.VISITING) {
    throw ExceptionUtils.bomb("Unexpected node in visiting state: " + root);
  }
  assertHasVisitedAllNodesInTree(state);
}

代码示例来源:origin: log4j/log4j

Hashtable filters = new Hashtable();
Enumeration e = props.keys();
String name = "";
while (e.hasMoreElements()) {
 String key = (String) e.nextElement();
 if (key.startsWith(filterPrefix)) {
  int dotIdx = key.indexOf('.', fIdx);
   name = key.substring(dotIdx+1);
  Vector filterOpts = (Vector) filters.get(filterKey);
  if (filterOpts == null) {
   filterOpts = new Vector();
   filters.put(filterKey, filterOpts);
while (g.hasMoreElements()) {
 String key = (String) g.nextElement();
 String clazz = props.getProperty(key);
 if (clazz != null) {
  LogLog.debug("Filter key: ["+key+"] class: ["+props.getProperty(key) +"] props: "+filters.get(key));
  Filter filter = (Filter) OptionConverter.instantiateByClassName(clazz, Filter.class, null);
  if (filter != null) {
   PropertySetter propSetter = new PropertySetter(filter);
   Vector v = (Vector)filters.get(key);
   Enumeration filterProps = v.elements();
   while (filterProps.hasMoreElements()) {
    NameValue kv = (NameValue)filterProps.nextElement();
    propSetter.setProperty(kv.key, kv.value);

代码示例来源:origin: xalan/xalan

private void appendTemplateCode(InstructionList body) {
final Enumeration templates = _neededTemplates.keys();
while (templates.hasMoreElements()) {
  final Object iList =
  _templateILs.get(templates.nextElement());
  if (iList != null) {
  body.append((InstructionList)iList);
  }
}
}

代码示例来源:origin: plutext/docx4j

private void addCDATAElement(String uri, String localName) 
{
  if (m_CdataElems == null) {
    m_CdataElems = new java.util.Hashtable();
  }
  
  java.util.Hashtable h = (java.util.Hashtable) m_CdataElems.get(localName);
  if (h == null) {
    h = new java.util.Hashtable();
    m_CdataElems.put(localName,h);
  }
  h.put(uri,uri);
  
}

代码示例来源:origin: robovm/robovm

/**
 * Reset configuration.
 *
 * <p>All handlers are closed and removed from any named loggers. All loggers'
 * level is set to null, except the root logger's level is set to
 * {@code Level.INFO}.
 */
public synchronized void reset() {
  checkAccess();
  props = new Properties();
  Enumeration<String> names = getLoggerNames();
  while (names.hasMoreElements()) {
    String name = names.nextElement();
    Logger logger = getLogger(name);
    if (logger != null) {
      logger.reset();
    }
  }
  Logger root = loggers.get("");
  if (root != null) {
    root.setLevel(Level.INFO);
  }
}

代码示例来源:origin: Sable/soot

handler2header.put(handler, pred);
 if (try2nop.containsKey(trap.getBeginUnit())) {
  ehnop = try2nop.get(trap.getBeginUnit());
 } else {
  ehnop = new EHNopStmt();
  try2nop.put(trap.getBeginUnit(), ehnop);
Hashtable<Unit, Boolean> nop2added = new Hashtable<Unit, Boolean>();
 Unit b = trap.getBeginUnit();
 Unit handler = trap.getHandlerUnit();
 handler = handler2header.get(handler);
 Unit ehnop = try2nop.get(b);
 if (!nop2added.containsKey(ehnop)) {
  List<Unit> predsOfB = getPredsOf(b);
  List<Unit> predsOfehnop = new ArrayList<Unit>(predsOfB);
 nop2added.put(ehnop, Boolean.TRUE);

代码示例来源:origin: JCTools/JCTools

public void checkedPut(final long id, final int type, final int hash)
{
  _size++;
  final TestKey item = new TestKey(id, type, hash);
  if (!_items.containsKey(type))
  {
    _items.put(type, new LinkedList<>());
  }
  _items.get(type).add(item);
}

代码示例来源:origin: Atmosphere/atmosphere

@SuppressWarnings("unchecked")
public static Method[] findMethods(Class<?> c) {
  Method methods[] = (Method[]) objectMethods.get(c);
  if (methods != null)
    return methods;
  methods = c.getMethods();
  objectMethods.put(c, methods);
  return methods;
}

代码示例来源:origin: org.javassist/javassist

/**
 * Undocumented method.  Do not use; internal-use only.
 *
 * @param name      the name of <code>$cflow</code> variable
 */
public Object[] lookupCflow(String name) {
  if (cflow == null)
    cflow = new Hashtable();
  return (Object[])cflow.get(name);
}

代码示例来源:origin: alibaba/druid

Dimension size = header.getSize();
Rectangle cellRect = new Rectangle(0, 0, size.width, size.height);
Hashtable<ColumnGroup, Rectangle> h = new Hashtable<ColumnGroup, Rectangle>();
int columnMargin = header.getColumnModel().getColumnMargin();
Enumeration<TableColumn> enumeration = header.getColumnModel().getColumns();
while (enumeration.hasMoreElements()) {
  cellRect.height = size.height;
  cellRect.y = 0;
  TableColumn aColumn = enumeration.nextElement();
  Enumeration<ColumnGroup> cGroups = ((GroupableTableHeader) header).getColumnGroups(aColumn);
  if (cGroups != null) {
    int groupHeight = 0;
    while (cGroups.hasMoreElements()) {
      ColumnGroup cGroup = cGroups.nextElement();
      Rectangle groupRect = (Rectangle) h.get(cGroup);
      if (groupRect == null) {
        groupRect = new Rectangle(cellRect);
        h.put(cGroup, groupRect);

代码示例来源:origin: plutext/docx4j

/**
 * Removes the mapping associated to the specified prefix.
 *
 * @param prefix The prefix which mapping should be removed.
 */
private void removeIfNeeded(String prefix) {
 // remove the previous mapping to the prefix
 if (this.prefixMapping.containsValue(prefix)) {
  Object key = null;
  for (Enumeration<String> e = this.prefixMapping.keys(); e.hasMoreElements();) {
   key = e.nextElement();
   if (this.prefixMapping.get(key).equals(prefix)) {
    break;
   }
  }
  this.prefixMapping.remove(key); // we know key should have a value
 }
}

相关文章