public void fireEvent(NCCPConnection.ConnectionEvent e) { ConnectionListener l; int max = listeners.size(); for (int i = 0; i < max; ++i) { ExpCoordinator.print( new String( "NCCPConnection.fireEvent (" + toString() + ") event: " + e.getType() + " max:" + max + " i:" + i), 2); l = (ConnectionListener) (listeners.elementAt(i)); switch (e.getType()) { case ConnectionEvent.CONNECTION_FAILED: l.connectionFailed(e); break; case ConnectionEvent.CONNECTION_CLOSED: l.connectionClosed(e); break; case ConnectionEvent.CONNECTION_OPENED: ExpCoordinator.printer.print( new String("Opened control connection (" + toString() + ")")); l.connectionOpened(e); } } }
static void writeDoc1(Document doc, PrintStream out) throws IOException { Vector<Annotation> entities = doc.annotationsOfType("entity"); if (entities == null) { System.err.println("No Entity: " + doc); return; } Iterator<Annotation> entityIt = entities.iterator(); int i = 0; while (entityIt.hasNext()) { Annotation entity = entityIt.next(); Vector mentions = (Vector) entity.get("mentions"); Iterator mentionIt = mentions.iterator(); String nameType = (String) entity.get("nameType"); while (mentionIt.hasNext()) { Annotation mention1 = (Annotation) mentionIt.next(); Annotation mention2 = new Annotation("refobj", mention1.span(), new FeatureSet()); mention2.put("objid", Integer.toString(i)); if (nameType != null) { mention2.put("netype", nameType); } doc.addAnnotation(mention2); } i++; } // remove other annotations. String[] annotypes = doc.getAnnotationTypes(); for (i = 0; i < annotypes.length; i++) { String t = annotypes[i]; if (!(t.equals("tagger") || t.equals("refobj") || t.equals("ENAMEX"))) { doc.removeAnnotationsOfType(t); } } writeDocRaw(doc, out); return; }
protected void finished() { logger.log(LogService.LOG_DEBUG, "Here is OcdHandler():finished()"); // $NON-NLS-1$ if (!_isParsedDataValid) return; if (_ad_vector.size() == 0) { // Schema defines at least one AD is required. _isParsedDataValid = false; logger.log( LogService.LOG_ERROR, NLS.bind( MetaTypeMsg.MISSING_ELEMENT, new Object[] { AD, OCD, elementId, _dp_url, _dp_bundle.getBundleId(), _dp_bundle.getSymbolicName() })); return; } // OCD gets all parsed ADs. Enumeration<AttributeDefinitionImpl> adKey = _ad_vector.elements(); while (adKey.hasMoreElements()) { AttributeDefinitionImpl ad = adKey.nextElement(); _ocd.addAttributeDefinition(ad, ad._isRequired); } _ocd.setIcons(icons); _parent_OCDs_hashtable.put(_refID, _ocd); }
public void removeConnectionListener(NCCPConnection.ConnectionListener l) { if (listeners.contains(l)) { // ExpCoordinator.printer.print(new String("NCCPConnection.removeConnectionListener to " + // toString()), 2); listeners.remove(l); } }
public void setConnected(boolean b, boolean process_pending) { if (b && state != ConnectionEvent.CONNECTION_OPENED) { if (host.length() > 0) ExpCoordinator.print( "NCCPConnection open connection to ipaddress " + host + " port " + port); state = ConnectionEvent.CONNECTION_OPENED; // connected = true; fireEvent(new ConnectionEvent(this, state)); ExpCoordinator.printer.print("NCCPConnection.setConnected " + b + " event fired", 8); if (process_pending) { int max = pendingMessages.size(); ExpCoordinator.printer.print(new String(" pendingMessages " + max + " elements"), 8); for (int i = 0; i < max; ++i) { sendMessage((NCCP.Message) pendingMessages.elementAt(i)); } pendingMessages.removeAllElements(); } } else { if (!b && (state != ConnectionEvent.CONNECTION_CLOSED || state != ConnectionEvent.CONNECTION_FAILED)) { if (host.length() > 0) ExpCoordinator.print( new String( "NCCPConnection.setConnected -- Closed control socket for " + host + "." + port)); state = ConnectionEvent.CONNECTION_CLOSED; fireEvent(new ConnectionEvent(this, state)); } } }
/** INTERNAL: Transform the object-level value into a database-level value */ public Object getFieldValue(Object objectValue, AbstractSession session) { DatabaseMapping mapping = getMapping(); Object fieldValue = objectValue; if ((mapping != null) && (mapping.isDirectToFieldMapping() || mapping.isDirectCollectionMapping())) { // CR#3623207, check for IN Collection here not in mapping. if (objectValue instanceof Collection) { // This can actually be a collection for IN within expressions... however it would be better // for expressions to handle this. Collection values = (Collection) objectValue; Vector fieldValues = new Vector(values.size()); for (Iterator iterator = values.iterator(); iterator.hasNext(); ) { Object value = iterator.next(); if (!(value instanceof Expression)) { value = getFieldValue(value, session); } fieldValues.add(value); } fieldValue = fieldValues; } else { if (mapping.isDirectToFieldMapping()) { fieldValue = ((AbstractDirectMapping) mapping).getFieldValue(objectValue, session); } else if (mapping.isDirectCollectionMapping()) { fieldValue = ((DirectCollectionMapping) mapping).getFieldValue(objectValue, session); } } } return fieldValue; }
/* * In text: a string seperate by comma (,) Out a collection of elements * without (between) comma */ static Collection parseIPaddresses(String text) { Vector prefixes = new Vector(); if (text == null || "".equals(text)) { return prefixes; } String tempStr = text.toUpperCase(); String currentLabel = null; int index = tempStr.indexOf(","); while (index != -1) { currentLabel = tempStr.substring(0, index).trim(); if (!"".equals(currentLabel)) { prefixes.addElement(currentLabel); } tempStr = tempStr.substring(index + 1); index = tempStr.indexOf(","); } // Last label currentLabel = tempStr.trim(); if (!"".equals(currentLabel)) { prefixes.addElement(currentLabel); } return prefixes; }
public void actionPerformed(java.awt.event.ActionEvent arg0) { if (JTable1.getSelectedRowCount() != 1) { Utilities.errorMessage(resourceBundle.getString("Please select a view to delete")); return; } if (JOptionPane.showConfirmDialog( null, resourceBundle.getString("Are you sure you want to delete the selected view "), resourceBundle.getString("Warning!"), JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null) == JOptionPane.NO_OPTION) return; Vector viewvec = model.getAllViews(); for (int i = 0; i < viewvec.size(); i++) { String viewname = ((AuthViewWithOperations) viewvec.elementAt(i)).getAuthorizedViewName(); if (JTable1.getValueAt(JTable1.getSelectedRow(), 0).toString().equals(viewname)) { AuthViewWithOperations avop = (AuthViewWithOperations) viewvec.elementAt(i); model.delViewOp( avop.getAuthorizedViewName(), avop.getViewProperties(), avop.getOperations()); } } disableButtons(); }
public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { res.setContentType("text/html"); try { PrintWriter pw = res.getWriter(); pw.println("<html><head><TITLE>Web-Enabled Automated Manufacturing System</TITLE></head>"); pw.println( "<body><br><br><br><form name=modifyuser method=post action='http://peers:8080/servlet/showUser')"); v = U.allUsers(); pw.println("<table align='center' border=0> <tr><td>"); pw.println( "Select User Name To Modify</td><td><SELECT id=select1 name=uid style='HEIGHT: 22px; LEFT: 74px; TOP: 222px; WIDTH: 155px'>"); pw.println("<OPTION selected value=''></OPTION>"); for (i = 0; i < v.size(); i++) pw.println( "<OPTION value=" + (String) v.elementAt(i) + ">" + (String) v.elementAt(i) + "</OPTION>"); pw.println( "</SELECT></td></tr><tr><td></td><td><input type='submit' name='submit' value='Submit'></td></tr></table></form></body></html>"); pw.flush(); pw.close(); } catch (Exception e) { } }
/** * Registers a reaction on this tuple space. * * @param rxn The reaction to register * @param listener The reaction callback function */ public void registerReaction(Reaction rxn, ReactionListener listener) { reactions.add(new RegisteredReaction(rxn, listener)); for (int i = 0; i < ts.size(); i++) { Tuple t = (Tuple) ts.get(i); if (rxn.getTemplate().matches(t)) listener.reactionFired(t); } }
public Tuple rdp(Tuple template) { for (int i = 0; i < ts.size(); i++) { Tuple tuple = (Tuple) ts.get(i); if (template.matches(tuple)) return tuple; } return null; }
/* Add a manifest file at current position in a stream */ public void stream(OutputStream os, Vector extraFiles) throws IOException { /* the first header in the file should be the global one. * It should say "Manifest-Version: x.x"; barf if not */ MessageHeader globals = (MessageHeader) entries.elementAt(0); if (globals.findValue("Manifest-Version") == null) { throw new IOException("Manifest file requires " + "Manifest-Version: 1.0 in 1st header"); } PrintWriter ps = new PrintWriter(os); globals.print(ps); for (int i = 1; i < entries.size(); ++i) { MessageHeader mh = (MessageHeader) entries.elementAt(i); mh.print(ps); /* REMIND: could be adding files twice!!! */ String name = mh.findValue("name"); if (extraFiles != null && name != null) { extraFiles.addElement(name); } } }
public String toString() { StringBuffer st = new StringBuffer(); st.append(" Cut Panels: "); for (int i = 0; i < visibleViewIds.size(); i++) { st.append(" " + Constants.cpNames[((Integer) visibleViewIds.elementAt(i)).intValue()]); } st.append(" \nCutPanelSize: "); st.append(cutPanelSize); st.append(" \nlonReference: "); st.append(lonReference); st.append(" \ngeoDisplayFormat: "); st.append(geoDisplayFormat); st.append(" \nuseCenterWidthOrMinMax: "); st.append(useCenterWidthOrMinMax); st.append(" \ntimeDisplayFormat: "); st.append(timeDisplayFormat); st.append(" \ntimeAxisMode: "); st.append(timeAxisMode); st.append(" \ntimeAxisReference: "); st.append(timeAxisReference); st.append(" \ntimeSinceUnits: "); st.append(timeSinceUnits); st.append(" \ndisplayPanelAxes: "); st.append(displayPanelAxes); st.append(" \nindependentHandles: "); st.append(independentHandles); return st.toString(); }
public Properties internalToProperties() { Properties props = new Properties(); StringBuffer st = new StringBuffer(); st.append(" "); for (int i = 0; i < visibleViewIds.size(); i++) { st.append(" " + Constants.cpNames[((Integer) visibleViewIds.elementAt(i)).intValue()]); } // System.out.println(" visibleViewIds: " + st.toString()); props.setProperty("ndedit.visibleViewIds", st.toString()); props.setProperty("ndedit.cutPanelSizeW", (new Integer(cutPanelSize.width).toString())); props.setProperty("ndedit.cutPanelSizeH", (new Integer(cutPanelSize.height).toString())); props.setProperty("ndedit.cutPanelWMin", (new Integer(cutPanelMinSize.width).toString())); props.setProperty("ndedit.cutPanelHMin", (new Integer(cutPanelMinSize.height).toString())); props.setProperty("ndedit.cutPanelWMax", (new Integer(cutPanelMaxSize.width).toString())); props.setProperty("ndedit.cutPanelHMax", (new Integer(cutPanelMaxSize.height).toString())); props.setProperty("ndedit.lonReference", (new Double(lonReference).toString())); props.setProperty("ndedit.geoDisplayFormat", (new Integer(geoDisplayFormat).toString())); props.setProperty("ndedit.timeDisplayFormat", (new Integer(timeDisplayFormat).toString())); props.setProperty("ndedit.timeAxisMode", (new Integer(timeAxisMode).toString())); props.setProperty("ndedit.timeAxisReference", (new Double(timeAxisReference).toString())); String dpa = new Boolean(displayPanelAxes).toString(); props.setProperty("ndedit.displayPanelAxes", dpa); dpa = new Boolean(independentHandles).toString(); props.setProperty("ndedit.independentHandles", dpa); return props; }
float printCPT(int startVertex) { CPP bestGraph = null, g; float bestCost = 0, cost; int i = 0; do { g = new CPP(N + 1); for (int j = 0; j < arcs.size(); j++) { Arc it = (Arc) arcs.elementAt(j); g.addArc(it.lab, it.u, it.v, it.cost); } cost = g.basicCost; g.findUnbalanced(); // initialise g.neg on original graph g.addArc("Virtual start", N, startVertex, cost); g.addArc( "Virtual end", // graph is Eulerian if neg.length=0 g.neg.length == 0 ? startVertex : g.neg[i], N, cost); g.solve(); if (bestGraph == null || bestCost > g.cost()) { bestCost = g.cost(); bestGraph = g; } } while (++i < g.neg.length); System.out.println("Open CPT from " + startVertex + "(ignore virtual arcs)"); bestGraph.printCPT(N); return cost + bestGraph.phi(); }
/** Creates a new instance of AccountPicker */ public AccountSelect(Display display, boolean enableQuit) { super(); // this.display=display; setTitleItem(new Title(SR.MS_ACCOUNTS)); accountList = new Vector(); Account a; int index = 0; activeAccount = Config.getInstance().accountIndex; do { a = Account.createFromStorage(index); if (a != null) { accountList.addElement(a); a.active = (activeAccount == index); index++; } } while (a != null); if (accountList.isEmpty()) { a = Account.createFromJad(); if (a != null) { // a.updateJidCache(); accountList.addElement(a); rmsUpdate(); } } attachDisplay(display); addCommand(cmdAdd); if (enableQuit) addCommand(cmdQuit); commandState(); setCommandListener(this); }
public void actionPerformed(java.awt.event.ActionEvent arg0) { if (JTable1.getSelectedRowCount() != 1) { Utilities.errorMessage(resourceBundle.getString("Please select a view to edit")); return; } views = new ViewsWizard(ViewConfig.this, applet); views.setSecurityModel(model); Point p = JLabel1.getLocationOnScreen(); views.setLocation(p); views.init(); views.setState(false); Vector viewvec = model.getAllViews(); for (int i = 0; i < viewvec.size(); i++) { String viewname = ((AuthViewWithOperations) viewvec.elementAt(i)).getAuthorizedViewName(); if (JTable1.getValueAt(JTable1.getSelectedRow(), 0).toString().equals(viewname)) { views.setValues((AuthViewWithOperations) viewvec.elementAt(i)); } } disableButtons(); views.setVisible(true); }
/** * This method queries the database to get the list of the Billing Systems. * * @exception SQLException, if query fails * @author */ public Vector getYears(String year) { String query; Vector years = new Vector(); PreparedStatement pstmt = null; ResultSet rs = null; query = "select yr||'-'||(yr+1),yr from fung_yr where yr > ?"; try { pstmt = conn.prepareStatement(query); pstmt.setString(1, year); rs = pstmt.executeQuery(); while (rs.next()) { years.addElement(rs.getString(1)); years.addElement(rs.getString(2)); } if (rs != null) rs.close(); if (pstmt != null) pstmt.close(); } catch (SQLException ex) { USFEnv.getLog().writeCrit("Dinvjrnl: Years List not Retreived ", this, ex); try { if (rs != null) rs.close(); if (pstmt != null) pstmt.close(); } catch (SQLException e) { USFEnv.getLog().writeCrit("Unable to close the resultset/prepared statement", this, e); } } return years; }
// ---------------------------------------------------------------------- // for "SrvTypeRqst" // get the list of service types for specified scope & naming authority // ---------------------------------------------------------------------- public synchronized String getServiceTypeList(String na, String scope) { Vector typelist = new Vector(5); Iterator values = table.values().iterator(); while (values.hasNext()) { Entry e = (Entry) values.next(); if (!e.getDeleted() && // nor deleted scope.equalsIgnoreCase(e.getScope()) && // match scope (na.equals("*") || // NA wildcard na.equalsIgnoreCase(e.getNA())) && // match NA !typelist.contains(e.getType())) { typelist.addElement(e.getType()); } } StringBuffer tl = new StringBuffer(); for (int i = 0; i < typelist.size(); i++) { String s = (String) typelist.elementAt(i); if (tl.length() > 0) tl.append(","); tl.append(s); } return tl.toString(); }
/** * This method queries the database to get the details related to the bp_id passed. * * @exception SQLException, if query fails * @author */ public Vector getBpdet(String bpid) { String query; Vector bpdet = new Vector(); PreparedStatement pstmt = null; ResultSet rs = null; query = "select rtrim(bs_id_fk||bp_rgn),bp_month from blg_prd where bp_id = ?"; try { pstmt = conn.prepareStatement(query); pstmt.setString(1, bpid); rs = pstmt.executeQuery(); while (rs.next()) { bpdet.addElement(rs.getString(1)); bpdet.addElement(rs.getString(2)); } if (rs != null) rs.close(); if (pstmt != null) pstmt.close(); } catch (SQLException ex) { USFEnv.getLog().writeCrit("Dinvjrnl: BP_ID details not Retreived ", this, ex); try { if (rs != null) rs.close(); if (pstmt != null) pstmt.close(); } catch (SQLException e) { USFEnv.getLog().writeCrit("Unable to close the resultset/prepared statement", this, e); } } return bpdet; }
public static String[] parseString(String text, String seperator) { Vector vResult = new Vector(); if (text == null || "".equals(text)) { return null; } String tempStr = text.trim(); String currentLabel = null; int index = tempStr.indexOf(seperator); while (index != -1) { currentLabel = tempStr.substring(0, index).trim(); if (!"".equals(currentLabel)) { vResult.addElement(currentLabel); } tempStr = tempStr.substring(index + 1); index = tempStr.indexOf(seperator); } // Last label currentLabel = tempStr.trim(); if (!"".equals(currentLabel)) { vResult.addElement(currentLabel); } String[] re = new String[vResult.size()]; Iterator it = vResult.iterator(); index = 0; while (it.hasNext()) { re[index] = (String) it.next(); index++; } return re; }
/** Sends a figure to the back of the drawing. */ public synchronized void sendToBack(Figure figure) { if (fFigures.contains(figure)) { fFigures.removeElement(figure); fFigures.insertElementAt(figure, 0); figure.changed(); } }
// keyboard discovery code private void _mapKey(char charCode, int keyindex, boolean shift, boolean altgraph) { log("_mapKey: " + charCode); // if character is not in map, add it if (!charMap.containsKey(new Integer(charCode))) { log("Notified: " + (char) charCode); KeyEvent event = new KeyEvent( applet(), 0, 0, (shift ? KeyEvent.SHIFT_MASK : 0) + (altgraph ? KeyEvent.ALT_GRAPH_MASK : 0), ((Integer) vkKeys.get(keyindex)).intValue(), (char) charCode); charMap.put(new Integer(charCode), event); log("Mapped char " + (char) charCode + " to KeyEvent " + event); if (((char) charCode) >= 'a' && ((char) charCode) <= 'z') { // put shifted version of a-z in automatically int uppercharCode = (int) Character.toUpperCase((char) charCode); event = new KeyEvent( applet(), 0, 0, KeyEvent.SHIFT_MASK + (altgraph ? KeyEvent.ALT_GRAPH_MASK : 0), ((Integer) vkKeys.get(keyindex)).intValue(), (char) uppercharCode); charMap.put(new Integer(uppercharCode), event); log("Mapped char " + (char) uppercharCode + " to KeyEvent " + event); } } }
/** Brings a figure to the front. */ public synchronized void bringToFront(Figure figure) { if (fFigures.contains(figure)) { fFigures.removeElement(figure); fFigures.addElement(figure); figure.changed(); } }
public void addConnectionListener(NCCPConnection.ConnectionListener l) { if (!listeners.contains(l)) { ExpCoordinator.printer.print( new String("NCCPConnection.addConnectionListener to " + toString()), 6); listeners.add(l); } }
/** Adds a figure to the list of figures. Initializes the the figure's container. */ public Figure add(Figure figure) { if (!fFigures.contains(figure)) { fFigures.addElement(figure); figure.addToContainer(this); } return figure; }
/** * Removes a figure from the composite. * * @see #removeAll */ public Figure remove(Figure figure) { if (fFigures.contains(figure)) { figure.removeFromContainer(this); fFigures.removeElement(figure); } return figure; }
/** * Read a list of space-separated "flag_extension" sequences and return the list as a array of * Strings. An empty list is returned as null. This is an IMAP-ism, and perhaps this method should * moved into the IMAP layer. */ public String[] readSimpleList() { skipSpaces(); if (buffer[index] != '(') // not what we expected return null; index++; // skip '(' Vector v = new Vector(); int start; for (start = index; buffer[index] != ')'; index++) { if (buffer[index] == ' ') { // got one item v.addElement(ASCIIUtility.toString(buffer, start, index)); start = index + 1; // index gets incremented at the top } } if (index > start) // get the last item v.addElement(ASCIIUtility.toString(buffer, start, index)); index++; // skip ')' int size = v.size(); if (size > 0) { String[] s = new String[size]; v.copyInto(s); return s; } else // empty list return null; }
public void startElement(String uri, String localName, String qName, Attributes atts) { logger.log( LogService.LOG_DEBUG, "Here is AttributeDefinitionHandler:startElement():" //$NON-NLS-1$ + qName); if (!_isParsedDataValid) return; String name = getName(localName, qName); if (name.equalsIgnoreCase(OPTION)) { OptionHandler optionHandler = new OptionHandler(this); optionHandler.init(name, atts); if (optionHandler._isParsedDataValid) { // Only add valid Option _optionLabel_vector.addElement(optionHandler._label_val); _optionValue_vector.addElement(optionHandler._value_val); } } else { logger.log( LogService.LOG_WARNING, NLS.bind( MetaTypeMsg.UNEXPECTED_ELEMENT, new Object[] { name, atts.getValue(ID), _dp_url, _dp_bundle.getBundleId(), _dp_bundle.getSymbolicName() })); } }
void tagV(String name, Vector attrs) { String s[] = new String[attrs.size()]; for (int i = 0; i < attrs.size(); i++) { s[i] = (String) attrs.elementAt(i); } startTagPrim(name, s, true); }