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)); } } }
/** * @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(); }
/** * 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); }
@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; }
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; }
/** * **/ 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 (); }
/** * 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; } }
/** * 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); }
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; }
/** * 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); } } }
/** * 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; }
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; }
/** * 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)); }
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); }
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); }
/** * @serialData Serialized fields. Convert Maps to Hashtables for backward * compatibility. */ private void writeObject(ObjectOutputStream out) throws IOException { // Convert Maps to Hashtables Hashtable<Node, Hashtable<String, UserDataRecord>> nud = null; if (nodeUserData != null) { nud = new Hashtable<>(); for (Map.Entry<Node, Map<String, UserDataRecord>> e : nodeUserData.entrySet()) { //e.getValue() will not be null since an entry is always put with a non-null value nud.put(e.getKey(), new Hashtable<>(e.getValue())); } } Hashtable<String, Node> ids = (identifiers == null)? null : new Hashtable<>(identifiers); Hashtable<Node, Integer> nt = (nodeTable == null)? null : new Hashtable<>(nodeTable); // Write serialized fields ObjectOutputStream.PutField pf = out.putFields(); pf.put("docType", docType); pf.put("docElement", docElement); pf.put("fFreeNLCache", fFreeNLCache); pf.put("encoding", encoding); pf.put("actualEncoding", actualEncoding); pf.put("version", version); pf.put("standalone", standalone); pf.put("fDocumentURI", fDocumentURI); //userData is the original name. It has been changed to nodeUserData, refer to the corrsponding @serialField pf.put("userData", nud); pf.put("identifiers", ids); pf.put("changes", changes); pf.put("allowGrammarAccess", allowGrammarAccess); pf.put("errorChecking", errorChecking); pf.put("ancestorChecking", ancestorChecking); pf.put("xmlVersionChanged", xmlVersionChanged); pf.put("documentNumber", documentNumber); pf.put("nodeCounter", nodeCounter); pf.put("nodeTable", nt); pf.put("xml11Version", xml11Version); out.writeFields(); }
public static Hashtable<Long,Set<Long>> findConflictingStudents(Long classId, int startSlot, int length, List<Date> dates) { Hashtable<Long,Set<Long>> table = new Hashtable(); if (dates.isEmpty()) return table; String datesStr = ""; for (int i=0; i<dates.size(); i++) { if (i>0) datesStr += ", "; datesStr += ":date"+i; } Query q = LocationDAO.getInstance().getSession() .createQuery("select distinct e.clazz.uniqueId, e.student.uniqueId "+ "from StudentClassEnrollment e, ClassEvent c inner join c.meetings m, StudentClassEnrollment x "+ "where x.clazz.uniqueId=:classId and x.student=e.student and " + // only look among students of the given class "e.clazz=c.clazz and " + // link ClassEvent c with StudentClassEnrollment e "m.stopPeriod>:startSlot and :endSlot>m.startPeriod and " + // meeting time within given time period "m.meetingDate in ("+datesStr+") and m.approvalStatus = 1") .setLong("classId",classId) .setInteger("startSlot", startSlot) .setInteger("endSlot", startSlot + length); for (int i=0; i<dates.size(); i++) { q.setDate("date"+i, dates.get(i)); } for (Iterator i = q.setCacheable(true).list().iterator();i.hasNext();) { Object[] o = (Object[])i.next(); Set<Long> set = table.get((Long)o[0]); if (set==null) { set = new HashSet<Long>(); table.put((Long)o[0], set); } set.add((Long)o[1]); } return table; }
/** * Returns the initialized attribute table. * * @return the initialized attribute table */ private Hashtable<String, Object> getTable() { if (this.table == null) { this.table = new Hashtable<>(); } return this.table; }
public Hashtable<String, Object> handleFunction(String sessionId, String function, Hashtable<String, Object> input) throws JLIException { if (function==null) return null; if (function.equals(FUNC_BOUND_BOX)) return actionBoundingBox(sessionId, input); else if (function.equals(FUNC_GET_SURFACES)) return actionGetSurfaces(sessionId, input); else if (function.equals(FUNC_GET_EDGES)) return actionGetEdges(sessionId, input); else { throw new JLIException("Unknown function name: " + function); } }
public static Hashtable loadReasonsByTag(JSONObject json) throws JSONException { Hashtable reasonsByTagHt = new Hashtable(); // Enumeration en = json.keys(); Iterator en = json.keys(); // while ( en.hasMoreElements() ) { while (en.hasNext()) { // String transType = (String) en.nextElement(); String transType = (String) en.next(); JSONObject tagsByTransJson = json.getJSONObject(transType); if (tagsByTransJson == null) { continue; } Iterator enTags = tagsByTransJson.keys(); // Enumeration enTags = tagsByTransJson.keys(); Hashtable tagsHt = new Hashtable(); // while ( enTags.hasMoreElements() ) { // String tag = (String) enTags.nextElement(); while (enTags.hasNext()) { String tag = (String) enTags.next(); String value = null; if ((value = (String) tagsByTransJson.get(tag)) != null && !value.equals("")) { tagsHt.put(tag, value); } } reasonsByTagHt.put(transType, tagsHt); } return reasonsByTagHt; }
public void setProperties(Hashtable<?,?> props) { if (src != null) { src.checkSecurity(null, false); } image.setProperties(props); newInfo(image, ImageObserver.PROPERTIES, 0, 0, 0, 0); }
public Hashtable<String, Object> handleFunction(String sessionId, String function, Hashtable<String, Object> input) throws JLIException { if (function==null) return null; if (function.equals(FUNC_EXISTS)) return actionExists(sessionId, input); else if (function.equals(FUNC_DELETE)) return actionDelete(sessionId, input); else if (function.equals(FUNC_DELETE_INST)) return actionDeleteInst(sessionId, input); else if (function.equals(FUNC_GET_HEADER)) return actionGetHeader(sessionId, input); else if (function.equals(FUNC_GET_ROW)) return actionGetRow(sessionId, input); else if (function.equals(FUNC_GET_CELL)) return actionGetCell(sessionId, input); else if (function.equals(FUNC_SET_CELL)) return actionSetCell(sessionId, input); else if (function.equals(FUNC_ADD_INST)) return actionAddInst(sessionId, input); else if (function.equals(FUNC_REPLACE)) return actionReplace(sessionId, input); else if (function.equals(FUNC_LIST)) return actionList(sessionId, input); else if (function.equals(FUNC_LIST_TREE)) return actionListTree(sessionId, input); else if (function.equals(FUNC_CREATE_INST)) return actionCreateInst(sessionId, input); else if (function.equals(FUNC_GET_PARENTS)) return actionGetParents(sessionId, input); else { throw new JLIException("Unknown function name: " + function); } }
private Hashtable<String, Object> actionExportProgram(String sessionId, Hashtable<String, Object> input) throws JLIException { String model = checkStringParameter(input, PARAM_MODEL, false); ExportResults results = intfHandler.exportProgram(model, sessionId); if (results!=null) { Hashtable<String, Object> out = new Hashtable<String, Object>(); out.put(OUTPUT_DIRNAME, results.getDirname()); out.put(OUTPUT_FILENAME, results.getFilename()); return out; } return null; }
private String initUsingUrl(ORB orb, String url, Hashtable<?,?> env) throws NamingException { if (url.startsWith("iiop://") || url.startsWith("iiopname://")) { return initUsingIiopUrl(orb, url, env); } else { return initUsingCorbanameUrl(orb, url, env); } }
/** * Removes all the components from this container. * * @since 1.5 */ public void removeAll() { Component[] children = getComponents(); Hashtable<Component, Integer> cToL = getComponentToLayer(); for (int counter = children.length - 1; counter >= 0; counter--) { Component c = children[counter]; if (c != null && !(c instanceof JComponent)) { cToL.remove(c); } } super.removeAll(); }
private Hashtable<Row, Boolean> getStreamsBuff(Row function) { Hashtable<Row, Boolean> stream = functionStreamsBuff.get(function); if (stream == null) { stream = new Hashtable<Row, Boolean>(); functionStreamsBuff.put(function, stream); } return stream; }
private Hashtable<String, Object> actionBackup(String sessionId, Hashtable<String, Object> input) throws JLIException { String filename = checkStringParameter(input, PARAM_MODEL, true); String targetdir = checkStringParameter(input, PARAM_TARGETDIR, true); fileHandler.backup(filename, targetdir, sessionId); return null; }
@SuppressWarnings("unchecked") public Map<Long, String> getValues(UserContext user) { Map<Long, String> ret = new Hashtable<Long, String>(); for (RefTableEntry ref: (List<RefTableEntry>)SessionDAO.getInstance().getSession().createCriteria(iReference).list()) ret.put(ref.getUniqueId(), ref.getLabel()); return ret; }
@Override public void start ( final BundleContext context ) throws Exception { Activator.context = context; this.executor = ScheduledExportedExecutorService.newSingleThreadExportedScheduledExecutor ( context.getBundle ().getSymbolicName () ); this.factory = new BufferedDatasourceFactory ( context, this.executor ); final Dictionary<String, String> properties = new Hashtable<String, String> (); properties.put ( Constants.SERVICE_DESCRIPTION, "A counter of changes on an item over a defined timeframe" ); properties.put ( Constants.SERVICE_VENDOR, "Eclipse SCADA Project" ); properties.put ( ConfigurationAdministrator.FACTORY_ID, context.getBundle ().getSymbolicName () ); context.registerService ( ConfigurationFactory.class.getName (), this.factory, properties ); }
/** * */ public void removeAllOverlays(Hashtable<Object, mxICellOverlay[]> map) { Iterator<Map.Entry<Object, mxICellOverlay[]>> it = map.entrySet().iterator(); while (it.hasNext()) { Map.Entry<Object, mxICellOverlay[]> entry = it.next(); mxICellOverlay[] c = entry.getValue(); for (int i = 0; i < c.length; i++) { removeCellOverlayComponent(c[i], entry.getKey()); } } }
/** * Check the expression if it appears as an lvalue. * We just pass it on to our unparenthesized subexpression. * (Part of fix for 4090372) */ public Vset checkAssignOp(Environment env, Context ctx, Vset vset, Hashtable exp, Expression outside) { vset = right.checkAssignOp(env, ctx, vset, exp, outside); type = right.type; return vset; }
private String createProfile(String userId) throws SignatureException, IOException { Hashtable<String, String> params = new Hashtable<String, String>(); params.put("method", "profile.create"); params.put("user_id", userId); return callRest(params); }
@Override protected Entry<ProxyMonitorQuery> createService ( final UserInformation userInformation, final String configurationId, final BundleContext context, final Map<String, String> parameters ) throws Exception { logger.info ( "Creating new proxy query: {}", configurationId ); final ProxyMonitorQuery service = new ProxyMonitorQuery ( context, this.executor ); final Hashtable<String, Object> properties = new Hashtable<String, Object> (); properties.put ( Constants.SERVICE_PID, configurationId ); final ServiceRegistration<MonitorQuery> handle = context.registerService ( MonitorQuery.class, service, properties ); service.update ( userInformation, parameters ); return new Entry<ProxyMonitorQuery> ( configurationId, service, handle ); }
/** * Convert a 3D coordinate into a generic JSON structure * @param x * @param y * @param z * @return The JSON data as a Hashtable */ protected Hashtable<String, Object> writePoint(double x, double y, double z) { Hashtable<String, Object> out = new Hashtable<String, Object>(); out.put(JLFileResponseParams.OUTPUT_X, x); out.put(JLFileResponseParams.OUTPUT_Y, y); out.put(JLFileResponseParams.OUTPUT_Z, z); return out; }
public VariableHeightLayoutCache() { super(); tempStacks = new Stack<Stack<TreePath>>(); visibleNodes = new Vector<Object>(); boundsBuffer = new Rectangle(); treePathMapping = new Hashtable<TreePath, TreeStateNode>(); }
/** * Converts a Hashtable to a String array by converting each * key/value pair in the Hashtable to two consecutive Strings * * @param h Hashtable to convert * @return converted string array * @exception NullPointerException if a hash key has a null value */ public static String[] hashToStringArray(Hashtable h) throws NullPointerException { Vector v = new Vector(); Enumeration e = h.keys(); while (e.hasMoreElements()) { String k = e.nextElement().toString(); v.add(k); v.add(h.get(k)); } String[] strArr = new String[v.size()]; v.copyInto(strArr); return strArr; }
private Hashtable<String, Object> actionSet(String sessionId, Hashtable<String, Object> input) throws JLIException { String modelname = checkStringParameter(input, PARAM_MODEL, false); String dimname = checkStringParameter(input, PARAM_NAME, true); Object value = checkParameter(input, PARAM_VALUE, false); boolean encoded = checkFlagParameter(input, PARAM_ENCODED, false, false); dimHandler.set(modelname, dimname, value, encoded, sessionId); return null; }
/** * Initialize the lookup table. */ private void initialize() { fgKeys = new Hashtable<String, Integer>(); Integer k = new Integer(JavaLineStyler.KEY); for (int i = 0; i < fgKeywords.length; i++) fgKeys.put(fgKeywords[i], k); loadClassColor(); }
@DataProvider(name = "Maps", parallel = true) private static Iterator<Object[]> makeMaps() { return Arrays.asList( // Test maps that CME new Object[]{new HashMap<>(), true}, new Object[]{new Hashtable<>(), true}, new Object[]{new LinkedHashMap<>(), true}, // Test default Map methods - no CME new Object[]{new Defaults.ExtendsAbstractMap<>(), false} ).iterator(); }