List of usage examples for java.util Hashtable Hashtable
public Hashtable()
From source file:edu.ku.brc.specify.tasks.DataEntryConfigDlg.java
@Override protected void addItem(final JList list, final Vector<TaskConfigItemIFace> itemList) { // Hash all the names so we can figure out which forms are not used Hashtable<String, Object> hash = new Hashtable<String, Object>(); ListModel model = stdPanel.getOrderModel(); for (int i = 0; i < model.getSize(); i++) { DataEntryView dev = (DataEntryView) model.getElementAt(i); hash.put(dev.getView(), dev);//from w w w.j a v a 2 s .co m } model = miscPanel.getOrderModel(); for (int i = 0; i < model.getSize(); i++) { DataEntryView dev = (DataEntryView) model.getElementAt(i); hash.put(dev.getView(), dev); } // Add only the unused forms (does NOT return internal views). List<String> uniqueList = new Vector<String>(); List<ViewIFace> views = ((SpecifyAppContextMgr) AppContextMgr.getInstance()).getAllViews(); Hashtable<String, ViewIFace> newAvailViews = new Hashtable<String, ViewIFace>(); for (ViewIFace view : views) { //System.out.println("["+view.getName()+"]["+view.getTitle()+"]"); if (hash.get(view.getName()) == null) { DBTableInfo ti = DBTableIdMgr.getInstance().getByClassName(view.getClassName()); if (ti != null) { if (!ti.isHidden() && !InteractionsTask.isInteractionTable(ti.getTableId())) { hash.put(view.getName(), view); String title = StringUtils.isNotEmpty(view.getObjTitle()) ? view.getObjTitle() : ti != null ? ti.getTitle() : view.getName(); if (newAvailViews.get(title) != null) { title = view.getName(); } uniqueList.add(title); newAvailViews.put(title, view); } } else { System.err.println("DBTableInfo was null for class[" + view.getClassName() + "]"); } } } if (uniqueList.size() == 0) { JOptionPane.showMessageDialog(this, getResourceString("DET_DEV_NONE_AVAIL"), getResourceString("DET_DEV_NONE_AVAIL_TITLE"), JOptionPane.INFORMATION_MESSAGE); return; } Collections.sort(uniqueList); ToggleButtonChooserDlg<String> dlg = new ToggleButtonChooserDlg<String>((Frame) UIRegistry.getTopWindow(), "DET_AVAIL_VIEWS", uniqueList); dlg.setUseScrollPane(true); UIHelper.centerAndShow(dlg); if (!dlg.isCancelled()) { model = list.getModel(); for (String title : dlg.getSelectedObjects()) { ViewIFace view = newAvailViews.get(title); DBTableInfo ti = DBTableIdMgr.getInstance().getByClassName(view.getClassName()); String frmTitle = StringUtils.isNotEmpty(view.getObjTitle()) ? view.getObjTitle() : ti != null ? ti.getTitle() : view.getName(); DataEntryView dev = new DataEntryView(frmTitle, // Title view.getName(), // Name ti != null ? ti.getName() : null, // Icon Name view.getObjTitle(), // ToolTip model.getSize(), // Order true); dev.setTableInfo(ti); ((DefaultListModel) model).addElement(dev); itemList.add(dev); } //pack(); } setHasChanged(true); }
From source file:com.mirth.connect.connectors.jms.JmsMessageUtils.java
public static Object getObjectForMessage(Message source) throws JMSException { Object result = null;/*from ww w .j a v a 2s .c om*/ try { if (source instanceof ObjectMessage) { result = ((ObjectMessage) source).getObject(); } else if (source instanceof MapMessage) { Hashtable map = new Hashtable(); MapMessage m = (MapMessage) source; for (Enumeration e = m.getMapNames(); e.hasMoreElements();) { String name = (String) e.nextElement(); Object obj = m.getObject(name); map.put(name, obj); } result = map; } else if (source instanceof javax.jms.BytesMessage) { javax.jms.BytesMessage bm = (javax.jms.BytesMessage) source; java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream(); byte[] buffer = new byte[1024 * 4]; int len = 0; bm.reset(); while ((len = bm.readBytes(buffer)) != -1) { baos.write(buffer, 0, len); } baos.flush(); result = baos.toByteArray(); baos.close(); if (result != null) { if (logger.isDebugEnabled()) logger.debug("JMSToObject: extracted " + ((byte[]) result).length + " bytes from JMS BytesMessage"); } } else if (source instanceof TextMessage) { result = ((TextMessage) source).getText(); } else if (source instanceof BytesMessage) { byte[] bytes = getBytesFromMessage(source); return CompressionHelper.uncompressByteArray(bytes); } else if (source instanceof StreamMessage) { StreamMessage sm = (javax.jms.StreamMessage) source; result = new java.util.Vector(); try { Object obj = null; while ((obj = sm.readObject()) != null) { ((java.util.Vector) result).addElement(obj); } } catch (MessageEOFException eof) { } catch (Exception e) { throw new JMSException("Failed to extract information from JMS Stream Message: " + e); } } else { result = source; } } catch (Exception e) { throw new JMSException("Failed to transform message: " + e.getMessage()); } return result; }
From source file:hd.controller.AddImageToProjectServlet.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.// w w w.ja v a 2 s . c om * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("UTF-8"); response.setCharacterEncoding("UTF-8"); response.setContentType("text/html; charset=UTF-8"); PrintWriter out = response.getWriter(); try { boolean isMultipart = ServletFileUpload.isMultipartContent(request); if (!isMultipart) { //to do } else { FileItemFactory factory = new DiskFileItemFactory(); ServletFileUpload upload = new ServletFileUpload(factory); List items = null; try { items = upload.parseRequest(request); } catch (FileUploadException e) { e.printStackTrace(); } Iterator iter = items.iterator(); Hashtable params = new Hashtable(); String fileName = null; while (iter.hasNext()) { FileItem item = (FileItem) iter.next(); if (item.isFormField()) { params.put(item.getFieldName(), item.getString("UTF-8")); } else if (!item.isFormField()) { try { long time = System.currentTimeMillis(); String itemName = item.getName(); fileName = time + itemName.substring(itemName.lastIndexOf("\\") + 1); String RealPath = getServletContext().getRealPath("/") + "images\\" + fileName; File savedFile = new File(RealPath); item.write(savedFile); String localPath = "D:\\Project\\TestHouseDecor-Merge\\web\\images\\" + fileName; // savedFile = new File(localPath); // item.write(savedFile); } catch (Exception e) { e.printStackTrace(); } } } //Init Jpa CategoryJpaController categoryJpa = new CategoryJpaController(emf); StyleJpaController styleJpa = new StyleJpaController(emf); ProjectJpaController projectJpa = new ProjectJpaController(emf); IdeaBookPhotoJpaController photoJpa = new IdeaBookPhotoJpaController(emf); // get Object Category by categoryId int cateId = Integer.parseInt((String) params.get("ddlCategory")); Category cate = categoryJpa.findCategory(cateId); // get Object Style by styleId int styleId = Integer.parseInt((String) params.get("ddlStyle")); Style style = styleJpa.findStyle(styleId); // get Object Project by projectId int projectId = Integer.parseInt((String) params.get("txtProjectId")); Project project = projectJpa.findProject(projectId); project.setStatus(Constant.STATUS_WAIT); projectJpa.edit(project); //Get param String title = (String) params.get("title"); String description = (String) params.get("description"); String url = "images/" + fileName; //Init IdeabookPhoto IdeaBookPhoto photo = new IdeaBookPhoto(title, url, description, cate, style, project); photoJpa.create(photo); url = "ViewMyProjectDetailServlet?txtProjectId=" + projectId; //System HDSystem system = new HDSystem(); system.setNotificationProject(request); response.sendRedirect(url); } } catch (Exception e) { log("Error at AddImageToProjectServlet: " + e.getMessage()); } finally { out.close(); } }
From source file:components.SliderDemo2.java
public SliderDemo2() { super(new BorderLayout()); delay = 1000 / FPS_INIT;/* w w w . j av a2 s.com*/ //Create the slider. JSlider framesPerSecond = new JSlider(JSlider.VERTICAL, FPS_MIN, FPS_MAX, FPS_INIT); framesPerSecond.addChangeListener(this); framesPerSecond.setMajorTickSpacing(10); framesPerSecond.setPaintTicks(true); //Create the label table. Hashtable<Integer, JLabel> labelTable = new Hashtable<Integer, JLabel>(); //PENDING: could use images, but we don't have any good ones. labelTable.put(new Integer(0), new JLabel("Stop")); //new JLabel(createImageIcon("images/stop.gif")) ); labelTable.put(new Integer(FPS_MAX / 10), new JLabel("Slow")); //new JLabel(createImageIcon("images/slow.gif")) ); labelTable.put(new Integer(FPS_MAX), new JLabel("Fast")); //new JLabel(createImageIcon("images/fast.gif")) ); framesPerSecond.setLabelTable(labelTable); framesPerSecond.setPaintLabels(true); framesPerSecond.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 10)); //Create the label that displays the animation. picture = new JLabel(); picture.setHorizontalAlignment(JLabel.CENTER); picture.setAlignmentX(Component.CENTER_ALIGNMENT); picture.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLoweredBevelBorder(), BorderFactory.createEmptyBorder(10, 10, 10, 10))); updatePicture(0); //display first frame //Put everything together. add(framesPerSecond, BorderLayout.LINE_START); add(picture, BorderLayout.CENTER); setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); //Set up a timer that calls this object's action handler. timer = new Timer(delay, this); timer.setInitialDelay(delay * 7); //We pause animation twice per cycle //by restarting the timer timer.setCoalesce(true); }
From source file:com.fluidinfo.fom.Namespace.java
@Override public void getItem() throws FluidException, IOException, FOMException, JSONException { Hashtable<String, String> args = new Hashtable<String, String>(); args.put("returnDescription", "True"); args.put("returnNamespaces", "True"); args.put("returnTags", "True"); FluidResponse response = this.Call(Method.GET, 200, "", args); JSONObject jsonResult = this.getJsonObject(response); this.id = jsonResult.getString("id"); this.description = jsonResult.getString("description"); this.namespaces = StringUtil.getStringArrayFromJSONArray(jsonResult.getJSONArray("namespaceNames")); this.tags = StringUtil.getStringArrayFromJSONArray(jsonResult.getJSONArray("tagNames")); }
From source file:org.sakaiproject.metaobj.shared.control.XmlControllerBase.java
protected ModelAndView handleNonSubmit(ElementBean bean, Map request, Map session, Map application, Errors errors) {/*from ww w .ja v a 2 s . co m*/ return handleNonSubmit(bean, request, session, application, errors, new Hashtable()); }
From source file:edu.harvard.mcz.imagecapture.encoder.LabelEncoder.java
private BitMatrix getQRCodeMatrix() { BitMatrix result = null;/* ww w . j a v a2 s . c o m*/ QRCodeWriter writer = new QRCodeWriter(); try { String data = label.toJSONString(); Hashtable<EncodeHintType, ErrorCorrectionLevel> hints = new Hashtable<EncodeHintType, ErrorCorrectionLevel>(); // set ErrorCorrectionLevel here hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H); result = writer.encode(data, BarcodeFormat.QR_CODE, 200, 200, hints); } catch (WriterException e) { // TODO Auto-generated catch block e.printStackTrace(); } return result; }
From source file:com.panet.imeta.job.JobEntryLoader.java
private JobEntryLoader() { pluginList = new ArrayList<JobPlugin>(); classLoaders = new Hashtable<String, URLClassLoader>(); initialized = false;// ww w . ja va 2 s .com }
From source file:de.iew.spring.integration.SpringIntegrationMessageStoreTest.java
@Test public void testMessageStore() throws Exception { AssertMessageStore assertMessageStore = new AssertMessageStore(); this.incoming.subscribe(assertMessageStore); Map<String, Object> headers = new Hashtable<String, Object>(); GenericMessage<String> jdbcTestMessage = new GenericMessage<String>( "If you can read this, the junit test was successful.", headers); this.outgoing.send(jdbcTestMessage); Thread.sleep(5000);// w w w.j a v a 2s . c om assertEquals(1, assertMessageStore.messageCount); }
From source file:org.eclipse.swordfish.core.event.EventHandlerRegistry.java
protected Dictionary<String, Object> getEventHanlderProperties(EventHandler<T> handler) { Dictionary<String, Object> props = new Hashtable<String, Object>(); props.put(EventConstants.EVENT_TOPIC, handler.getSubscribedTopic()); if (handler.getEventFilter() != null) { props.put(EventConstants.EVENT_FILTER, handler.getEventFilter().getExpression()); }//from w w w . j av a 2s .c om return props; }