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

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

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

Hashtable.clone介绍

[英]Returns a new Hashtable with the same key/value pairs, capacity and load factor.
[中]返回具有相同键/值对、容量和负载因子的新哈希表。

代码示例

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

public
 final
 Object childValue(Object parentValue) {
  Hashtable ht = (Hashtable) parentValue;
  if(ht != null) {
   return ht.clone();
  } else {
   return null;
  }
 }
}

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

@SuppressWarnings("unchecked")
public WrapperInitialContext(final Hashtable<Object,Object> environment) {
  if (environment != null) {
    this.environment = (Hashtable<Object,Object>) environment.clone();
  } else {
    this.environment = null;
  }
}

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

@Override
public Hashtable<String, Object> getEnvironment() throws NamingException {
 return (Hashtable<String, Object>) environment.clone();
}

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

public Object clone() {
  return super.clone();
}

代码示例来源:origin: apache/activemq

public Hashtable<String, Object> getEnvironment() throws NamingException {
  return (Hashtable<String, Object>)environment.clone();
}

代码示例来源:origin: kiegroup/drools

@SuppressWarnings("rawtypes")
  public Context getInitialContext(Hashtable environment) throws NamingException {

    return new MemoryContext((Hashtable) environment.clone()) {
      @Override
      public Object lookup(String name) throws NamingException {
        Object toReturn = super.lookup(name);
        if (toReturn == null) {
          throw new NamingException("Name not found: " + name);
        }
        return toReturn;
      }

      @Override
      public void close() throws NamingException {
        // simple-jndi will close your context: http://meri-stuff.blogspot.co.uk/2012/01/running-jndi-and-jpa-without-j2ee.html
      }
    };
  }
}

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

/**
 * Returns the current environment.
 *
 * @return Environment.
 */
public Hashtable getEnvironment() throws NamingException {
  if (_env == null) {
    return new Hashtable(5, 0.75f);
  } else {
    return (Hashtable) _env.clone();
  }
}

代码示例来源:origin: kiegroup/jbpm

@SuppressWarnings("rawtypes")
  public Context getInitialContext(Hashtable environment) throws NamingException {
  
    return new MemoryContext((Hashtable)environment.clone()) {
      @Override
      public Object lookup(String name) throws NamingException {
        Object toReturn = super.lookup(name);
        if (toReturn == null) {
          throw new NamingException("Name not found: " + name);
        }
        return toReturn;
      }

      @Override
      public void close() throws NamingException {
        // simple-jndi will close your context: http://meri-stuff.blogspot.co.uk/2012/01/running-jndi-and-jpa-without-j2ee.html
      }
    };
  }
}

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

public java.lang.Object removeFromEnvironment(String propName)
    throws NamingException {
  if (_env != null && _env.get(propName) != null) {
    // copy-on-write
    _env = (Hashtable) _env.clone();
    return _env.remove(propName);
  }
  return null;
}

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

/**
  Obtain a copy of this thread's MDC prior to serialization or
  asynchronous logging.  
*/
public
void getMDCCopy() {
 if(mdcCopyLookupRequired) {
  mdcCopyLookupRequired = false;
  // the clone call is required for asynchronous logging.
  // See also bug #5932.
  Hashtable t = (Hashtable) MDC.getContext();
  if(t != null) {
 mdcCopy = (Hashtable) t.clone();
  }
 }
}

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

/**
  Obtain a copy of this thread's MDC prior to serialization or
  asynchronous logging.  
*/
public
void getMDCCopy() {
 if(mdcCopyLookupRequired) {
  mdcCopyLookupRequired = false;
  // the clone call is required for asynchronous logging.
  // See also bug #5932.
  Hashtable t = (Hashtable) MDC.getContext();
  if(t != null) {
 mdcCopy = (Hashtable) t.clone();
  }
 }
}

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

/**
 * Adds to the environment for the current context.
 * Record change but do not reinitialize ORB.
 *
 * @param propName The property name.
 * @param propValue  The ORB.
 * @return the previous value of this property if any.
 */
public java.lang.Object addToEnvironment(String propName,
                     java.lang.Object propValue)
    throws NamingException {
  if (_env == null) {
    _env = new Hashtable(7, 0.75f);
  } else {
    // copy-on-write
    _env = (Hashtable) _env.clone();
  }
  return _env.put(propName, propValue);
}

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

/**
 * Copy on write for the internal tables in this context.
 *
 * <p>This class is optimized for the normal case where most
 * elements do not contain Namespace declarations. In that case,
 * the Context2 will share data structures with its parent.
 * New tables are obtained only when new declarations are issued,
 * so they can be popped off the stack.</p>
 *
 * <p> JJK: **** Alternative: each Context2 might declare
 *  _only_ its local bindings, and delegate upward if not found.</p>
 */     
private void copyTables ()
{
  // Start by copying our parent's bindings
  prefixTable = (Hashtable)prefixTable.clone();
  uriTable = (Hashtable)uriTable.clone();
  // Replace the caches with empty ones, rather than
  // trying to determine which bindings should be flushed.
  // As far as I can tell, these caches are never actually
  // used in Xalan... More efficient to remove the whole
  // cache system? ****
  if(elementNameTable!=null)
    elementNameTable=new Hashtable(); 
  if(attributeNameTable!=null)
    attributeNameTable=new Hashtable(); 
  tablesDirty = true;
}

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

/**
 * Copy on write for the internal tables in this context.
 *
 * <p>This class is optimized for the normal case where most
 * elements do not contain Namespace declarations.</p>
 */
private void copyTables ()
{
  if (prefixTable != null) {
  prefixTable = (Hashtable)prefixTable.clone();
  } else {
  prefixTable = new Hashtable();
  }
  if (uriTable != null) {
  uriTable = (Hashtable)uriTable.clone();
  } else {
  uriTable = new Hashtable();
  }
  elementNameTable = new Hashtable();
  attributeNameTable = new Hashtable();
  declSeen = true;
}

代码示例来源:origin: apache/groovy

public synchronized Object clone() {
  return project.getProperties().clone();
}

代码示例来源:origin: org.netbeans.api/org-openide-util

@Override
  public void setProperties(Hashtable props) {
    props = (Hashtable) props.clone();
    consumer.setProperties(props);
  }
}

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

/**
 * Create a CNCtx object. Gets the initial naming
 * reference for the COS Naming Service from the ORB.
 * The ORB can be passed in via the java.naming.corba.orb property
 * or be created using properties in the environment properties.
 *
 * @param env Environment properties for initializing name service.
 * @throws NamingException Cannot initialize ORB or naming context.
 */
CNCtx(Hashtable env) throws NamingException {
  if (env != null) {
    env = (Hashtable) env.clone();
  }
  _env = env;
  federation = "true".equals(env != null ? env.get(FED_PROP) : null);
  initOrbAndRootContext(env);
}

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

@Override
public Object lookup(final String name) throws NamingException {
  try {
    final int index = name.indexOf('#');
    if (index != -1) {
      final String server = name.substring(0, index);
      final String lookup = name.substring(index + 1);
      @SuppressWarnings("unchecked")
      final Hashtable<Object,Object> environment = (Hashtable<Object,Object>) this.environment.clone();
      environment.put(Context.PROVIDER_URL, server);
      environment.put(ORBConstants.ORB_SERVER_ID_PROPERTY, "1");
      return CNCtxFactory.INSTANCE.getInitialContext(environment).lookup(lookup);
    } else {
      return CNCtxFactory.INSTANCE.getInitialContext(environment).lookup(name);
    }
  } catch (NamingException e) {
    throw e;
  } catch (Exception e) {
    throw new NamingException(e.getMessage());
  }
}

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

/**
 * This method makes a clone of this object.
 *
 */
public Object clone() throws CloneNotSupportedException {
  NamespaceMappings clone = new NamespaceMappings();
  clone.m_nodeStack = (NamespaceMappings.Stack) m_nodeStack.clone();        
  clone.count = this.count;
  clone.m_namespaces = (Hashtable) m_namespaces.clone();
  
  clone.count = count;
  return clone;
  
}

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

/**
 * This method is used by the iiop and iiopname URL Context factories.
 */
public static ResolveResult createUsingURL(String url, Hashtable env)
    throws NamingException {
  CNCtx ctx = new CNCtx();
  if (env != null) {
    env = (Hashtable) env.clone();
  }
  ctx._env = env;
  String rest = ctx.initUsingUrl(env != null ? (org.omg.CORBA.ORB) env.get("java.naming.corba.orb") : null,
      url, env);
  // rest is the INS name
  // Return the parsed form to prevent subsequent lookup
  // from parsing the string as a composite name
  // The caller should be aware that a toString() of the name
  // will yield its INS syntax, rather than a composite syntax
  return new ResolveResult(ctx, parser.parse(rest));
}

相关文章