本文整理汇总了Java中java.util.Hashtable类的典型用法代码示例。如果您正苦于以下问题:Java Hashtable类的具体用法?Java Hashtable怎么用?Java Hashtable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Hashtable类属于java.util包,在下文中一共展示了Hashtable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: extractLocales
import java.util.Hashtable; //导入依赖的package包/类
private static void extractLocales(Hashtable languages, Vector q,Vector l)
{
// XXX We will need to order by q value Vector in the Future ?
Enumeration e = q.elements();
while (e.hasMoreElements()) {
Vector v =
(Vector)languages.get(((Double)e.nextElement()).toString());
Enumeration le = v.elements();
while (le.hasMoreElements()) {
String language = (String)le.nextElement();
String country = "";
int countryIndex = language.indexOf("-");
if (countryIndex > -1) {
country = language.substring(countryIndex + 1).trim();
language = language.substring(0, countryIndex).trim();
}
l.addElement(new Locale(language, country));
}
}
}
示例2: writeObject
import java.util.Hashtable; //导入依赖的package包/类
/**
* @serialData Default fields.
*/
/*
* Writes the contents of the permsMap field out as a Hashtable for
* serialization compatibility with earlier releases. allPermission
* unchanged.
*/
private void writeObject(ObjectOutputStream out) throws IOException {
// Don't call out.defaultWriteObject()
// Copy perms into a Hashtable
Hashtable<Class<?>, PermissionCollection> perms =
new Hashtable<>(permsMap.size()*2); // no sync; estimate
synchronized (this) {
perms.putAll(permsMap);
}
// Write out serializable fields
ObjectOutputStream.PutField pfields = out.putFields();
pfields.put("allPermission", allPermission); // no sync; staleness OK
pfields.put("perms", perms);
out.writeFields();
}
示例3: registerDataSource
import java.util.Hashtable; //导入依赖的package包/类
/**
* This method is separated from the rest of the example since you normally
* would NOT register a JDBC driver in your code. It would likely be
* configered into your naming and directory service using some GUI.
*
* @throws Exception
* if an error occurs
*/
private void registerDataSource() throws Exception {
this.tempDir = File.createTempFile("jnditest", null);
this.tempDir.delete();
this.tempDir.mkdir();
this.tempDir.deleteOnExit();
com.mysql.jdbc.jdbc2.optional.MysqlDataSource ds;
Hashtable<String, String> env = new Hashtable<String, String>();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.fscontext.RefFSContextFactory");
env.put(Context.PROVIDER_URL, this.tempDir.toURI().toString());
this.ctx = new InitialContext(env);
assertTrue("Naming Context not created", this.ctx != null);
ds = new com.mysql.jdbc.jdbc2.optional.MysqlDataSource();
ds.setUrl(dbUrl); // from BaseTestCase
this.ctx.bind("_test", ds);
}
示例4: createHandler
import java.util.Hashtable; //导入依赖的package包/类
@Override
protected ThingHandler createHandler(Thing thing) {
ThingTypeUID thingTypeUID = thing.getThingTypeUID();
if (thingTypeUID.equals(THING_TYPE_HOME)) {
TadoHomeHandler tadoHomeHandler = new TadoHomeHandler((Bridge) thing);
TadoDiscoveryService discoveryService = new TadoDiscoveryService(tadoHomeHandler);
bundleContext.registerService(DiscoveryService.class.getName(), discoveryService,
new Hashtable<String, Object>());
return tadoHomeHandler;
} else if (thingTypeUID.equals(THING_TYPE_ZONE)) {
return new TadoZoneHandler(thing);
} else if (thingTypeUID.equals(THING_TYPE_MOBILE_DEVICE)) {
return new TadoMobileDeviceHandler(thing);
}
return null;
}
示例5: createQRCode
import java.util.Hashtable; //导入依赖的package包/类
public static Bitmap createQRCode(String str,int widthAndHeight) throws WriterException {
Hashtable<EncodeHintType, String> hints = new Hashtable<EncodeHintType, String>();
hints.put(EncodeHintType.CHARACTER_SET, "utf-8");
BitMatrix matrix = new MultiFormatWriter().encode(str,
BarcodeFormat.QR_CODE, widthAndHeight, widthAndHeight);
int width = matrix.getWidth();
int height = matrix.getHeight();
int[] pixels = new int[width * height];
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
if (matrix.get(x, y)) {
pixels[y * width + x] = BLACK;
}
}
}
Bitmap bitmap = Bitmap.createBitmap(width, height,
Bitmap.Config.ARGB_8888);
bitmap.setPixels(pixels, 0, width, 0, 0, width, height);
return bitmap;
}
示例6: generate
import java.util.Hashtable; //导入依赖的package包/类
/**
*
**/
public void generate (Hashtable symbolTable, ForwardValueEntry v, PrintWriter str)
{
this.symbolTable = symbolTable;
this.v = v;
openStream ();
if (stream == null)
return;
generateHelper ();
generateHolder ();
generateStub ();
writeHeading ();
writeBody ();
writeClosing ();
closeStream ();
}
示例7: getObjectInstance
import java.util.Hashtable; //导入依赖的package包/类
/**
* Creates a jdbcDatasource object using the location or reference
* information specified.<p>
*
* The Reference object should support the properties, database, user,
* password.
*
* @param obj The reference information used in creating a
* jdbcDatasource object.
* @param name ignored
* @param nameCtx ignored
* @param environment ignored
* @return A newly created jdbcDataSource object; null if an object
* cannot be created.
* @exception Exception never
*/
public Object getObjectInstance(Object obj, Name name, Context nameCtx,
Hashtable environment) throws Exception {
String dsClass = "org.hsqldb.jdbc.jdbcDataSource";
Reference ref = (Reference) obj;
if (ref.getClassName().equals(dsClass)) {
jdbcDataSource ds = new jdbcDataSource();
ds.setDatabase((String) ref.get("database").getContent());
ds.setUser((String) ref.get("user").getContent());
ds.setPassword((String) ref.get("password").getContent());
return ds;
} else {
return null;
}
}
示例8: CGIProcessEnvironment
import java.util.Hashtable; //导入依赖的package包/类
/**
* Creates a ProcessEnvironment and derives the necessary environment,
* working directory, command, etc.
* @param req HttpServletRequest for information provided by
* the Servlet API
* @param context ServletContext for information provided by
* the Servlet API
* @param cgiPathPrefix subdirectory of webAppRootDir below which the
* web app's CGIs may be stored; can be null or "".
* @param debug int debug level (0 == none, 6 == lots)
*/
public CGIProcessEnvironment(HttpServletRequest req,
ServletContext context, String cgiPathPrefix, int debug) {
super(req, context, debug);
this.cgiPathPrefix = cgiPathPrefix;
queryParameters = new Hashtable();
Enumeration paramNames = req.getParameterNames();
while (paramNames != null && paramNames.hasMoreElements()) {
String param = paramNames.nextElement().toString();
if (param != null) {
queryParameters.put(param,
URLEncoder.encode(req.getParameter(param)));
}
}
this.valid = deriveProcessEnvironment(req);
}
示例9: lookup
import java.util.Hashtable; //导入依赖的package包/类
public Object lookup(Name name) throws NamingException {
PartialCompositeContext ctx = this;
Hashtable<?,?> env = p_getEnvironment();
Continuation cont = new Continuation(name, env);
Object answer;
Name nm = name;
try {
answer = ctx.p_lookup(nm, cont);
while (cont.isContinue()) {
nm = cont.getRemainingName();
ctx = getPCContext(cont);
answer = ctx.p_lookup(nm, cont);
}
} catch (CannotProceedException e) {
Context cctx = NamingManager.getContinuationContext(e);
answer = cctx.lookup(e.getRemainingName());
}
return answer;
}
示例10: addBindings
import java.util.Hashtable; //导入依赖的package包/类
/**
* method merging env into nenv
*
* @throws UnifyException
*/
public static void addBindings(Environment env, Environment nenv)
throws UnifyException {
Hashtable<String, Value> eTable = env.getTable();
Set<String> keys = eTable.keySet();
Iterator<String> it = keys.iterator();
while (it.hasNext()) {
// we look if the variable is bound
String eVar = it.next();
Value val = new Value(Value.VAR, eVar);
Value eVal = env.deref(val);
if (!(eVal.equals(val))) {
// if it is, we unify the bound values in the new environment
Value.unify(val, eVal, nenv);
}
}
}
示例11: getAvailableFormats
import java.util.Hashtable; //导入依赖的package包/类
/**
* Gets all possible metadata formats that may be disiminated by this RepositoryManager. This includes
* formats that are available by conversion from the native format via the XMLConversionService.
*
* @return The metadataFormats available.
* @see #getConfiguredFormats
*/
public final Hashtable getAvailableFormats() {
if (index.getLastModifiedCount() > formatsLastUpdatedTime) {
formatsLastUpdatedTime = index.getLastModifiedCount();
formats.clear();
List indexedFormats = index.getTerms("metadatapfx");
if (indexedFormats == null)
return formats;
String format = null;
for (int i = 0; i < indexedFormats.size(); i++) {
format = (String) indexedFormats.get(i);
// remove the '0' in the doctype
format = format.substring(1, format.length());
formats.putAll(getMetadataFormatsConversions(format));
}
}
return formats;
}
示例12: select
import java.util.Hashtable; //导入依赖的package包/类
public void select(Hashtable<String,Field> params){
ArrayList<String> param_list = new ArrayList<String>();
Enumeration<String> llaves = params.keys();
while(llaves.hasMoreElements()){
String llave = llaves.nextElement();
if(GEOM.class.isAssignableFrom(params.get(llave).getType())){
param_list.add(GEOM.GetSQL(llave));
}
else if(CENTROID.class.isAssignableFrom(params.get(llave).getType())){
param_list.add(CENTROID.GetSQL(llave));
}
else
{
param_list.add(llave);
}
}
String parametros = String.join(",", param_list);
this.query = "SELECT "+parametros+" FROM "+this.table;
}
示例13: getContinuationDirContext
import java.util.Hashtable; //导入依赖的package包/类
/**
* Creates a context in which to continue a <tt>DirContext</tt> operation.
* Operates just like <tt>NamingManager.getContinuationContext()</tt>,
* only the continuation context returned is a <tt>DirContext</tt>.
*
* @param cpe
* The non-null exception that triggered this continuation.
* @return A non-null <tt>DirContext</tt> object for continuing the operation.
* @exception NamingException If a naming exception occurred.
*
* @see NamingManager#getContinuationContext(CannotProceedException)
*/
@SuppressWarnings("unchecked")
public static DirContext getContinuationDirContext(
CannotProceedException cpe) throws NamingException {
Hashtable<Object,Object> env = (Hashtable<Object,Object>)cpe.getEnvironment();
if (env == null) {
env = new Hashtable<>(7);
} else {
// Make a (shallow) copy of the environment.
env = (Hashtable<Object,Object>) env.clone();
}
env.put(CPE, cpe);
return (new ContinuationDirContext(cpe, env));
}
示例14: testStickinessWhenABetterServiceIsAvailable
import java.util.Hashtable; //导入依赖的package包/类
public void testStickinessWhenABetterServiceIsAvailable() throws Exception {
interceptor.setSticky(true);
interceptor.afterPropertiesSet();
ServiceListener sl = (ServiceListener) bundleContext.getServiceListeners().iterator().next();
Dictionary props = new Hashtable();
// increase service ranking
props.put(Constants.SERVICE_RANKING, 10);
ServiceReference ref = new MockServiceReference(null, props, null);
ServiceEvent event = new ServiceEvent(ServiceEvent.REGISTERED, ref);
assertEquals(1, SimpleTargetSourceLifecycleListener.BIND);
assertEquals(0, SimpleTargetSourceLifecycleListener.UNBIND);
sl.serviceChanged(event);
assertEquals("the proxy is not sticky", 1, SimpleTargetSourceLifecycleListener.BIND);
assertEquals(0, SimpleTargetSourceLifecycleListener.UNBIND);
}
示例15: registerServices
import java.util.Hashtable; //导入依赖的package包/类
private void registerServices(BundleContext context) {
// store services with low ranking such that they can be overridden
// during testing or the like
Dictionary<String, Object> preferences = new Hashtable<String, Object>();
preferences.put(Constants.SERVICE_RANKING, 1);
Dictionary<String, Object> priorityPreferences = new Hashtable<String, Object>();
priorityPreferences.put(Constants.SERVICE_RANKING, 2);
// register all services (override the ProcessStreamsProvider registered in the core plugin)
this.loggerService = registerService(context, Logger.class, createLogger(), preferences);
}