/** * Invokes the <code>getAccessibleChild</code> method on each UI handled by this object. * * @return the value obtained from the first UI, which is the UI obtained from the default <code> * LookAndFeel</code> */ public Accessible getAccessibleChild(JComponent a, int b) { Accessible returnValue = ((ComponentUI) (uis.elementAt(0))).getAccessibleChild(a, b); for (int i = 1; i < uis.size(); i++) { ((ComponentUI) (uis.elementAt(i))).getAccessibleChild(a, b); } return returnValue; }
/** * Invokes the <code>getMaximumSize</code> method on each UI handled by this object. * * @return the value obtained from the first UI, which is the UI obtained from the default <code> * LookAndFeel</code> */ public Dimension getMaximumSize(JComponent a) { Dimension returnValue = ((ComponentUI) (uis.elementAt(0))).getMaximumSize(a); for (int i = 1; i < uis.size(); i++) { ((ComponentUI) (uis.elementAt(i))).getMaximumSize(a); } return returnValue; }
/** * Invokes the <code>getAccessibleChildrenCount</code> method on each UI handled by this object. * * @return the value obtained from the first UI, which is the UI obtained from the default <code> * LookAndFeel</code> */ public int getAccessibleChildrenCount(JComponent a) { int returnValue = ((ComponentUI) (uis.elementAt(0))).getAccessibleChildrenCount(a); for (int i = 1; i < uis.size(); i++) { ((ComponentUI) (uis.elementAt(i))).getAccessibleChildrenCount(a); } return returnValue; }
public final void addLineListener(LineListener listener) { synchronized (listeners) { if (!(listeners.contains(listener))) { listeners.addElement(listener); } } }
public BreadthFirstEnumeration(TreeNode rootNode) { super(); Vector<TreeNode> v = new Vector<TreeNode>(1); v.addElement(rootNode); // PENDING: don't really need a vector queue = new Queue(); queue.enqueue(v.elements()); }
// // This function is the recursive search of groups for this // implementation of the Group. The search proceeds building up // a vector of already seen groups. Only new groups are considered, // thereby avoiding loops. // boolean isMemberRecurse(Principal member, Vector<Group> alreadySeen) { Enumeration<? extends Principal> e = members(); while (e.hasMoreElements()) { boolean mem = false; Principal p = (Principal) e.nextElement(); // if the member is in this collection, return true if (p.equals(member)) { return true; } else if (p instanceof GroupImpl) { // // if not recurse if the group has not been checked already. // Can call method in this package only if the object is an // instance of this class. Otherwise call the method defined // in the interface. (This can lead to a loop if a mixture of // implementations form a loop, but we live with this improbable // case rather than clutter the interface by forcing the // implementation of this method.) // GroupImpl g = (GroupImpl) p; alreadySeen.addElement(this); if (!alreadySeen.contains(g)) mem = g.isMemberRecurse(member, alreadySeen); } else if (p instanceof Group) { Group g = (Group) p; if (!alreadySeen.contains(g)) mem = g.isMember(member); } if (mem) return mem; } return false; }
static { initialCategories.add(ImageReaderSpi.class); initialCategories.add(ImageWriterSpi.class); initialCategories.add(ImageTranscoderSpi.class); initialCategories.add(ImageInputStreamSpi.class); initialCategories.add(ImageOutputStreamSpi.class); }
/** * Invokes the <code>contains</code> method on each UI handled by this object. * * @return the value obtained from the first UI, which is the UI obtained from the default <code> * LookAndFeel</code> */ public boolean contains(JComponent a, int b, int c) { boolean returnValue = ((ComponentUI) (uis.elementAt(0))).contains(a, b, c); for (int i = 1; i < uis.size(); i++) { ((ComponentUI) (uis.elementAt(i))).contains(a, b, c); } return returnValue; }
/** * adds the specified member to the group. * * @param user The principal to add to the group. * @return true if the member was added - false if the member could not be added. */ public boolean addMember(Principal user) { if (groupMembers.contains(user)) return false; // do not allow groups to be added to itself. if (group.equals(user.toString())) throw new IllegalArgumentException(); groupMembers.addElement(user); return true; }
/** * Enables all the attribute change notifications the attribute name of which equals the specified * name to be sent to the listener. <br> * If the specified name is already in the list of enabled attribute names, this method has no * effect. * * @param name The attribute name. * @exception j86.java.lang.IllegalArgumentException The attribute name parameter is null. */ public synchronized void enableAttribute(String name) throws j86.java.lang.IllegalArgumentException { if (name == null) { throw new j86.java.lang.IllegalArgumentException("The name cannot be null."); } if (!enabledAttributes.contains(name)) { enabledAttributes.addElement(name); } }
/** * Delete all the generated source files made during the execution of this environment (those that * have been registered with the "addGeneratedFile" method). */ public void deleteGeneratedFiles() { synchronized (generatedFiles) { Enumeration<File> enumeration = generatedFiles.elements(); while (enumeration.hasMoreElements()) { File file = enumeration.nextElement(); file.delete(); } generatedFiles.removeAllElements(); } }
/** * Returns a clone of this vector. The copy will contain a reference to a clone of the internal * data array, not a reference to the original internal data array of this {@code Vector} object. * * @return a clone of this vector */ public synchronized Object clone() { try { @SuppressWarnings("unchecked") Vector<E> v = (Vector<E>) super.clone(); v.elementData = Arrays.copyOf(elementData, elementCount); v.modCount = 0; return v; } catch (CloneNotSupportedException e) { // this shouldn't happen, since we are Cloneable throw new InternalError(e); } }
/** * Returns the number of children of this node. * * @return an int giving the number of children of this node */ public int getChildCount() { if (children == null) { return 0; } else { return children.size(); } }
/** * Creates and returns a forward-order enumeration of this node's children. Modifying this node's * child array invalidates any child enumerations created before the modification. * * @return an Enumeration of this node's children */ public Enumeration children() { if (children == null) { return EMPTY_ENUMERATION; } else { return children.elements(); } }
/** * Split a string based on the presence of a specified separator. Returns an array of arbitrary * length. The end of each element in the array is indicated by the separator of the end of the * string. If there is a separator immediately before the end of the string, the final element * will be empty. None of the strings will contain the separator. Useful when separating strings * such as "foo/bar/bas" using separator "/". * * @param sep The separator. * @param s The string to split. * @return An array of strings. Each string in the array is determined by the location of the * provided sep in the original string, s. Whitespace not stripped. */ private String[] splitSeparator(String sep, String s) { Vector v = new Vector(); int tokenStart = 0; int tokenEnd = 0; while ((tokenEnd = s.indexOf(sep, tokenStart)) != -1) { v.addElement(s.substring(tokenStart, tokenEnd)); tokenStart = tokenEnd + 1; } // Add the final element. v.addElement(s.substring(tokenStart)); String[] retVal = new String[v.size()]; v.copyInto(retVal); return retVal; }
/** Return an enumeration of all the accessible applets on this page. */ public Enumeration getApplets() { AppletSecurity security = (AppletSecurity) System.getSecurityManager(); Vector v = new Vector(); SocketPermission panelSp = new SocketPermission(panel.getCodeBase().getHost(), "connect"); for (Enumeration e = appletPanels.elements(); e.hasMoreElements(); ) { AppletPanel p = (AppletPanel) e.nextElement(); if (p.getDocumentBase().equals(panel.getDocumentBase())) { SocketPermission sp = new SocketPermission(p.getCodeBase().getHost(), "connect"); if (panelSp.implies(sp)) { v.addElement(p.applet); } } } return v.elements(); }
protected static URL[] getUrlArray(String codebase) throws MalformedURLException { // Parse codebase into separate URLs StringTokenizer parser = new StringTokenizer(codebase); Vector<String> vec = new Vector<>(10); while (parser.hasMoreTokens()) { vec.addElement(parser.nextToken()); } String[] url = new String[vec.size()]; for (int i = 0; i < url.length; i++) { url[i] = vec.elementAt(i); } URL[] urlArray = new URL[url.length]; for (int i = 0; i < urlArray.length; i++) { urlArray[i] = new URL(url[i]); } return urlArray; }
/** * Returns the index of the specified child in this node's child array. If the specified node is * not a child of this node, returns <code>-1</code>. This method performs a linear search and is * O(n) where n is the number of children. * * @param aChild the TreeNode to search for among this node's children * @exception IllegalArgumentException if <code>aChild</code> is null * @return an int giving the index of the node in this node's child array, or <code>-1</code> if * the specified node is a not a child of this node */ public int getIndex(TreeNode aChild) { if (aChild == null) { throw new IllegalArgumentException("argument is null"); } if (!isNodeChild(aChild)) { return -1; } return children.indexOf(aChild); // linear search }
/** * Invoked before sending the specified notification to the listener. <br> * This filter compares the attribute name of the specified attribute change notification with * each enabled attribute name. If the attribute name equals one of the enabled attribute names, * the notification must be sent to the listener and this method returns <CODE>true</CODE>. * * @param notification The attribute change notification to be sent. * @return <CODE>true</CODE> if the notification has to be sent to the listener, <CODE>false * </CODE> otherwise. */ public synchronized boolean isNotificationEnabled(Notification notification) { String type = notification.getType(); if ((type == null) || (type.equals(AttributeChangeNotification.ATTRIBUTE_CHANGE) == false) || (!(notification instanceof AttributeChangeNotification))) { return false; } String attributeName = ((AttributeChangeNotification) notification).getAttributeName(); return enabledAttributes.contains(attributeName); }
/** * returns true if the passed principal is a member of the group. * * @param member The principal whose membership must be checked for. * @return true if the principal is a member of this group, false otherwise */ public boolean isMember(Principal member) { // // if the member is part of the group (common case), return true. // if not, recursively search depth first in the group looking for the // principal. // if (groupMembers.contains(member)) { return true; } else { Vector<Group> alreadySeen = new Vector<>(10); return isMemberRecurse(member, alreadySeen); } }
private void applyUpdates() throws SAXException { // now handle any updates if (updates.size() > 0) { try { Object upd[]; Iterator<?> i = updates.iterator(); while (i.hasNext()) { upd = (Object[]) i.next(); idx = ((Integer) upd[0]).intValue(); if (!(lastval.equals(upd[1]))) { insertValue((String) (upd[1])); } } rs.updateRow(); } catch (SQLException ex) { throw new SAXException( MessageFormat.format( resBundle.handleGetObject("xmlrch.errupdrow").toString(), ex.getMessage())); } updates.removeAllElements(); } }
/** * Removes <code>newChild</code> from its present parent (if it has a parent), sets the child's * parent to this node, and then adds the child to this node's child array at index <code> * childIndex</code>. <code>newChild</code> must not be null and must not be an ancestor of this * node. * * @param newChild the MutableTreeNode to insert under this node * @param childIndex the index in this node's child array where this node is to be inserted * @exception ArrayIndexOutOfBoundsException if <code>childIndex</code> is out of bounds * @exception IllegalArgumentException if <code>newChild</code> is null or is an ancestor of this * node * @exception IllegalStateException if this node does not allow children * @see #isNodeDescendant */ public void insert(MutableTreeNode newChild, int childIndex) { if (!allowsChildren) { throw new IllegalStateException("node does not allow children"); } else if (newChild == null) { throw new IllegalArgumentException("new child is null"); } else if (isNodeAncestor(newChild)) { throw new IllegalArgumentException("new child is an ancestor"); } MutableTreeNode oldParent = (MutableTreeNode) newChild.getParent(); if (oldParent != null) { oldParent.remove(newChild); } newChild.setParent(this); if (children == null) { children = new Vector(); } children.insertElementAt(newChild, childIndex); }
/** Get an applet by name. */ public Applet getApplet(String name) { AppletSecurity security = (AppletSecurity) System.getSecurityManager(); name = name.toLowerCase(); SocketPermission panelSp = new SocketPermission(panel.getCodeBase().getHost(), "connect"); for (Enumeration e = appletPanels.elements(); e.hasMoreElements(); ) { AppletPanel p = (AppletPanel) e.nextElement(); String param = p.getParameter("name"); if (param != null) { param = param.toLowerCase(); } if (name.equals(param) && p.getDocumentBase().equals(panel.getDocumentBase())) { SocketPermission sp = new SocketPermission(p.getCodeBase().getHost(), "connect"); if (panelSp.implies(sp)) { return p.applet; } } } return null; }
/** * Set up the valid service provider categories and automatically register all available service * providers. * * <p>The constructor is private in order to prevent creation of additional instances. */ private IIORegistry() { super(initialCategories.iterator()); registerStandardSpis(); registerApplicationClasspathSpis(); }
/** * Sets the value for the given element if <code>name</code> is one of the array elements in the * fields <code>properties</code>, <code>colDef</code>, or <code>data</code> and this <code> * XmlReaderContentHandler</code> object's state is not <code>INITIAL</code>. If the state is * <code>INITIAL</code>, this method does nothing. * * <p>If the state is <code>METADATA</code> and the argument supplied is <code>"metadata"</code>, * the rowset's metadata is set. If the state is <code>PROPERTIES</code>, the appropriate property * is set using the given name to determine the appropriate value. If the state is <code>DATA * </code> and the argument supplied is <code>"data"</code>, this method sets the state to <code> * INITIAL</code> and returns. If the argument supplied is one of the elements in the field <code> * data</code>, this method makes the appropriate changes to the rowset's data. * * @param lName the name of the element; either (1) one of the array elements in the fields <code> * properties</code>, <code>colDef</code>, or <code>data</code> or (2) one of the <code>RowSet * </code> elements <code>"properties"</code>, <code>"metadata"</code>, or <code>"data"</code> * @exception SAXException if a general SAX error occurs */ @SuppressWarnings("fallthrough") public void endElement(String uri, String lName, String qName) throws SAXException { int tag; String name = ""; name = lName; switch (getState()) { case PROPERTIES: if (name.equals("properties")) { state = INITIAL; break; } try { tag = propMap.get(name); switch (tag) { case KeycolsTag: if (keyCols != null) { int i[] = new int[keyCols.size()]; for (int j = 0; j < i.length; j++) i[j] = Integer.parseInt(keyCols.elementAt(j)); rs.setKeyColumns(i); } break; case PropClassTag: // Added the handling for Class tags to take care of maps // Makes an entry into the map upon end of class tag try { typeMap.put(Key_map, j86.sun.reflect.misc.ReflectUtil.forName(Value_map)); } catch (ClassNotFoundException ex) { throw new SAXException( MessageFormat.format( resBundle.handleGetObject("xmlrch.errmap").toString(), ex.getMessage())); } break; case MapTag: // Added the handling for Map to take set the typeMap rs.setTypeMap(typeMap); break; default: break; } if (getNullValue()) { setPropertyValue(null); setNullValue(false); } else { setPropertyValue(propertyValue); } } catch (SQLException ex) { throw new SAXException(ex.getMessage()); } // propertyValue need to be reset to an empty string propertyValue = ""; setTag(-1); break; case METADATA: if (name.equals("metadata")) { try { rs.setMetaData(md); state = INITIAL; } catch (SQLException ex) { throw new SAXException( MessageFormat.format( resBundle.handleGetObject("xmlrch.errmetadata").toString(), ex.getMessage())); } } else { try { if (getNullValue()) { setMetaDataValue(null); setNullValue(false); } else { setMetaDataValue(metaDataValue); } } catch (SQLException ex) { throw new SAXException( MessageFormat.format( resBundle.handleGetObject("xmlrch.errmetadata").toString(), ex.getMessage())); } // metaDataValue needs to be reset to an empty string metaDataValue = ""; } setTag(-1); break; case DATA: if (name.equals("data")) { state = INITIAL; return; } if (dataMap.get(name) == null) { tag = NullTag; } else { tag = dataMap.get(name); } switch (tag) { case ColTag: try { idx++; if (getNullValue()) { insertValue(null); setNullValue(false); } else { insertValue(tempStr); } // columnValue now need to be reset to the empty string columnValue = ""; } catch (SQLException ex) { throw new SAXException( MessageFormat.format( resBundle.handleGetObject("xmlrch.errinsertval").toString(), ex.getMessage())); } break; case RowTag: try { rs.insertRow(); rs.moveToCurrentRow(); rs.next(); // Making this as the original to turn off the // rowInserted flagging rs.setOriginalRow(); applyUpdates(); } catch (SQLException ex) { throw new SAXException( MessageFormat.format( resBundle.handleGetObject("xmlrch.errconstr").toString(), ex.getMessage())); } break; case DelTag: try { rs.insertRow(); rs.moveToCurrentRow(); rs.next(); rs.setOriginalRow(); applyUpdates(); rs.deleteRow(); } catch (SQLException ex) { throw new SAXException( MessageFormat.format( resBundle.handleGetObject("xmlrch.errdel").toString(), ex.getMessage())); } break; case InsTag: try { rs.insertRow(); rs.moveToCurrentRow(); rs.next(); applyUpdates(); } catch (SQLException ex) { throw new SAXException( MessageFormat.format( resBundle.handleGetObject("xmlrch.errinsert").toString(), ex.getMessage())); } break; case InsDelTag: try { rs.insertRow(); rs.moveToCurrentRow(); rs.next(); rs.setOriginalRow(); applyUpdates(); } catch (SQLException ex) { throw new SAXException( MessageFormat.format( resBundle.handleGetObject("xmlrch.errinsdel").toString(), ex.getMessage())); } break; case UpdTag: try { if (getNullValue()) { insertValue(null); setNullValue(false); } else if (getEmptyStringValue()) { insertValue(""); setEmptyStringValue(false); } else { updates.add(upd); } } catch (SQLException ex) { throw new SAXException( MessageFormat.format( resBundle.handleGetObject("xmlrch.errupdate").toString(), ex.getMessage())); } break; default: break; } default: break; } }
/** * Removes an audio listener. * * @param listener listener to remove */ public final void removeLineListener(LineListener listener) { listeners.removeElement(listener); }
private void setPropertyValue(String s) throws SQLException { // find out if we are going to be dealing with a null boolean nullValue = getNullValue(); switch (getTag()) { case CommandTag: if (nullValue) ; // rs.setCommand(null); else rs.setCommand(s); break; case ConcurrencyTag: if (nullValue) throw new SQLException(resBundle.handleGetObject("xmlrch.badvalue").toString()); else rs.setConcurrency(getIntegerValue(s)); break; case DatasourceTag: if (nullValue) rs.setDataSourceName(null); else rs.setDataSourceName(s); break; case EscapeProcessingTag: if (nullValue) throw new SQLException(resBundle.handleGetObject("xmlrch.badvalue").toString()); else rs.setEscapeProcessing(getBooleanValue(s)); break; case FetchDirectionTag: if (nullValue) throw new SQLException(resBundle.handleGetObject("xmlrch.badvalue").toString()); else rs.setFetchDirection(getIntegerValue(s)); break; case FetchSizeTag: if (nullValue) throw new SQLException(resBundle.handleGetObject("xmlrch.badvalue").toString()); else rs.setFetchSize(getIntegerValue(s)); break; case IsolationLevelTag: if (nullValue) throw new SQLException(resBundle.handleGetObject("xmlrch.badvalue").toString()); else rs.setTransactionIsolation(getIntegerValue(s)); break; case KeycolsTag: break; case PropColumnTag: if (keyCols == null) keyCols = new Vector<>(); keyCols.add(s); break; case MapTag: break; case MaxFieldSizeTag: if (nullValue) throw new SQLException(resBundle.handleGetObject("xmlrch.badvalue").toString()); else rs.setMaxFieldSize(getIntegerValue(s)); break; case MaxRowsTag: if (nullValue) throw new SQLException(resBundle.handleGetObject("xmlrch.badvalue").toString()); else rs.setMaxRows(getIntegerValue(s)); break; case QueryTimeoutTag: if (nullValue) throw new SQLException(resBundle.handleGetObject("xmlrch.badvalue").toString()); else rs.setQueryTimeout(getIntegerValue(s)); break; case ReadOnlyTag: if (nullValue) throw new SQLException(resBundle.handleGetObject("xmlrch.badvalue").toString()); else rs.setReadOnly(getBooleanValue(s)); break; case RowsetTypeTag: if (nullValue) { throw new SQLException(resBundle.handleGetObject("xmlrch.badvalue").toString()); } else { // rs.setType(getIntegerValue(s)); String strType = getStringValue(s); int iType = 0; if (strType.trim().equals("ResultSet.TYPE_SCROLL_INSENSITIVE")) { iType = 1004; } else if (strType.trim().equals("ResultSet.TYPE_SCROLL_SENSITIVE")) { iType = 1005; } else if (strType.trim().equals("ResultSet.TYPE_FORWARD_ONLY")) { iType = 1003; } rs.setType(iType); } break; case ShowDeletedTag: if (nullValue) throw new SQLException(resBundle.handleGetObject("xmlrch.badvalue").toString()); else rs.setShowDeleted(getBooleanValue(s)); break; case TableNameTag: if (nullValue) // rs.setTableName(null); ; else rs.setTableName(s); break; case UrlTag: if (nullValue) rs.setUrl(null); else rs.setUrl(s); break; case SyncProviderNameTag: if (nullValue) { rs.setSyncProvider(null); } else { String str = s.substring(0, s.indexOf("@") + 1); rs.setSyncProvider(str); } break; case SyncProviderVendorTag: // to be implemented break; case SyncProviderVersionTag: // to be implemented break; case SyncProviderGradeTag: // to be implemented break; case DataSourceLock: // to be implemented break; default: break; } }
public PreorderEnumeration(TreeNode rootNode) { super(); Vector<TreeNode> v = new Vector<TreeNode>(1); v.addElement(rootNode); // PENDING: don't really need a vector stack.push(v.elements()); }
/** * Removes the child at the specified index from this node's children and sets that node's parent * to null. The child node to remove must be a <code>MutableTreeNode</code>. * * @param childIndex the index in this node's child array of the child to remove * @exception ArrayIndexOutOfBoundsException if <code>childIndex</code> is out of bounds */ public void remove(int childIndex) { MutableTreeNode child = (MutableTreeNode) getChildAt(childIndex); children.removeElementAt(childIndex); child.setParent(null); }
/** * Returns the child at the specified index in this node's child array. * * @param index an index into this node's child array * @exception ArrayIndexOutOfBoundsException if <code>index</code> is out of bounds * @return the TreeNode in this node's child array at the specified index */ public TreeNode getChildAt(int index) { if (children == null) { throw new ArrayIndexOutOfBoundsException("node has no children"); } return (TreeNode) children.elementAt(index); }