下面列出了java.util.Vector#contains ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Adds a <code>LookAndFeel</code> to the list of auxiliary look and feels.
* The auxiliary look and feels tell the multiplexing look and feel what
* other <code>LookAndFeel</code> classes for a component instance are to be used
* in addition to the default <code>LookAndFeel</code> class when creating a
* multiplexing UI. The change will only take effect when a new
* UI class is created or when the default look and feel is changed
* on a component instance.
* <p>Note these are not the same as the installed look and feels.
*
* @param laf the <code>LookAndFeel</code> object
* @see #removeAuxiliaryLookAndFeel
* @see #setLookAndFeel
* @see #getAuxiliaryLookAndFeels
* @see #getInstalledLookAndFeels
*/
static public void addAuxiliaryLookAndFeel(LookAndFeel laf) {
maybeInitialize();
if (!laf.isSupportedLookAndFeel()) {
// Ideally we would throw an exception here, but it's too late
// for that.
return;
}
Vector<LookAndFeel> v = getLAFState().auxLookAndFeels;
if (v == null) {
v = new Vector<LookAndFeel>();
}
if (!v.contains(laf)) {
v.addElement(laf);
laf.initialize();
getLAFState().auxLookAndFeels = v;
if (getLAFState().multiLookAndFeel == null) {
getLAFState().multiLookAndFeel = getMultiLookAndFeel();
}
}
}
protected void gatherNodes(NameNode initiallyRequestedNode, final NameNode node, final Vector vect) {
addInListIfNeeded(initiallyRequestedNode, node.getLessTree(), vect);
addInListIfNeeded(initiallyRequestedNode, node.getGrtrTree(), vect);
addInListIfNeeded(initiallyRequestedNode, node.getSubTree(), vect);
if (NameNode.Federation.class.isInstance(initiallyRequestedNode.getObject())) { // tomcat mainly
for (final Context c : NameNode.Federation.class.cast(initiallyRequestedNode.getObject())) {
if (c == IvmContext.this || !IvmContext.class.isInstance(c)) {
continue;
}
final IvmContext ctx = IvmContext.class.cast(c);
if (ctx.mynode == node || vect.contains(ctx.mynode)) {
continue;
}
addInListIfNeeded(ctx.mynode, ctx.mynode.getGrtrTree(), vect);
addInListIfNeeded(ctx.mynode, ctx.mynode.getLessTree(), vect);
addInListIfNeeded(ctx.mynode, ctx.mynode.getSubTree(), vect);
}
}
}
/**
*
* @param adapter
* The listadapter (containing the list of apps) to control.
*/
public TagSelectionListener(ListAdapter adapter) {
this.adapter = adapter;
int count = adapter.getCount();
Vector<String> collect = new Vector<String>();
for (int i = 0; i < count; i++) {
SortablePackageInfo spi = (SortablePackageInfo) adapter.getItem(i);
String[] tags = MainActivity.noNull(spi.tags).split(",");
for (String tag : tags) {
String tmp = tag.trim();
if (tmp.length() > 0 && !collect.contains(tmp)) {
collect.add(tmp);
}
}
}
items = collect.toArray(new String[0]);
states = new boolean[items.length];
Arrays.sort(items);
}
private Vector expandComponents(XSObject[] components, Map<String, Vector> dependencies) {
Vector newComponents = new Vector();
for (int i=0; i<components.length; i++) {
if (!newComponents.contains(components[i])) {
newComponents.add(components[i]);
}
}
for (int i=0; i<newComponents.size(); i++) {
final XSObject component = (XSObject) newComponents.elementAt(i);
expandRelatedComponents(component, newComponents, dependencies);
}
return newComponents;
}
private Vector expandComponents(XSObject[] components, Map<String, Vector> dependencies) {
Vector newComponents = new Vector();
for (int i=0; i<components.length; i++) {
if (!newComponents.contains(components[i])) {
newComponents.add(components[i]);
}
}
for (int i=0; i<newComponents.size(); i++) {
final XSObject component = (XSObject) newComponents.elementAt(i);
expandRelatedComponents(component, newComponents, dependencies);
}
return newComponents;
}
/**
* Adds a <code>TrayIcon</code> to the <code>SystemTray</code>.
* The tray icon becomes visible in the system tray once it is
* added. The order in which icons are displayed in a tray is not
* specified - it is platform and implementation-dependent.
*
* <p> All icons added by the application are automatically
* removed from the <code>SystemTray</code> upon application exit
* and also when the desktop system tray becomes unavailable.
*
* @param trayIcon the <code>TrayIcon</code> to be added
* @throws NullPointerException if <code>trayIcon</code> is
* <code>null</code>
* @throws IllegalArgumentException if the same instance of
* a <code>TrayIcon</code> is added more than once
* @throws AWTException if the desktop system tray is missing
* @see #remove(TrayIcon)
* @see #getSystemTray
* @see TrayIcon
* @see java.awt.Image
*/
public void add(TrayIcon trayIcon) throws AWTException {
if (trayIcon == null) {
throw new NullPointerException("adding null TrayIcon");
}
TrayIcon[] oldArray = null, newArray = null;
Vector<TrayIcon> icons = null;
synchronized (this) {
oldArray = systemTray.getTrayIcons();
icons = (Vector<TrayIcon>)AppContext.getAppContext().get(TrayIcon.class);
if (icons == null) {
icons = new Vector<TrayIcon>(3);
AppContext.getAppContext().put(TrayIcon.class, icons);
} else if (icons.contains(trayIcon)) {
throw new IllegalArgumentException("adding TrayIcon that is already added");
}
icons.add(trayIcon);
newArray = systemTray.getTrayIcons();
trayIcon.setID(++currentIconID);
}
try {
trayIcon.addNotify();
} catch (AWTException e) {
icons.remove(trayIcon);
throw e;
}
firePropertyChange("trayIcons", oldArray, newArray);
}
private Set<Airing> forceIntoSchedule(Vector<Airing> schedVec, Airing insertMe)
{
Set<Airing> rv = new HashSet<Airing>();
if (schedVec.contains(insertMe)) return rv;
long insertMeStart = getSchedulingStart(insertMe);
long insertMeEnd = getSchedulingEnd(insertMe);
for (int i = 0; i< schedVec.size(); i++)
{
Airing testAir = schedVec.elementAt(i);
if (doesSchedulingOverlap(testAir, insertMeStart, insertMeEnd))
{
Airing deadAir = schedVec.remove(i--);
removeFromDontSchedule(deadAir);
rv.add(deadAir);
}
else if (getSchedulingStart(testAir) > insertMeStart)
{
schedVec.insertElementAt(insertMe, i);
addToDontSchedule(insertMe);
return rv;
}
}
schedVec.addElement(insertMe);
addToDontSchedule(insertMe);
return rv;
}
private void addRelatedAttribute(XSAttributeDeclaration decl, Vector componentList, String namespace, Map<String, Vector> dependencies) {
if (decl.getScope() == XSConstants.SCOPE_GLOBAL) {
if (!componentList.contains(decl)) {
Vector importedNamespaces = findDependentNamespaces(namespace, dependencies);
addNamespaceDependency(namespace, decl.getNamespace(), importedNamespaces);
componentList.add(decl);
}
}
else {
expandRelatedAttributeComponents(decl, componentList, namespace, dependencies);
}
}
public Enumeration prefixes() {
Vector v = new Vector();
for (PrefixMapping p = prefixMapping; p != null; p = p.next) {
if (!v.contains(p.prefix)) {
v.addElement(p.prefix);
}
}
return v.elements();
}
/**
*
**/
private void buildIDList (InterfaceEntry entry, Vector list)
{
if (!entry.fullName ().equals ("org/omg/CORBA/Object"))
{
String id = Util.stripLeadingUnderscoresFromID (entry.repositoryID ().ID ());
if (!list.contains (id))
list.addElement (id);
Enumeration e = entry.derivedFrom ().elements ();
while (e.hasMoreElements ())
buildIDList ((InterfaceEntry)e.nextElement (), list);
}
}
@Override
public synchronized void addDocumentListener(DocumentListener l) {
@SuppressWarnings("unchecked")
Vector<DocumentListener> v = documentListeners == null
? new Vector<DocumentListener>(2)
: (Vector<DocumentListener>)documentListeners.clone();
if(!v.contains(l)) {
v.addElement(l);
documentListeners = v;
}
}
public void buildInformEntries(Hashtable<InetAddress, Vector<String>> dest) {
JDMHostInform host= (JDMHostInform) jjtGetParent();
JDMInformInterestedHost hosts= (JDMInformInterestedHost) host.jjtGetParent();
JDMInformItem inform = (JDMInformItem) hosts.jjtGetParent();
JDMInformCommunity community = inform.getCommunity();
String comm = community.getCommunity();
InetAddress add = null;
try {
add = java.net.InetAddress.getByName(getHname());
} catch(UnknownHostException e) {
if (SNMP_LOGGER.isLoggable(Level.FINEST)) {
SNMP_LOGGER.logp(Level.FINEST, Host.class.getName(),
"buildTrapEntries",
"Cannot create INFORM entry; got exception", e);
}
return;
}
Vector<String> list = null;
if (dest.containsKey(add)){
list = dest.get(add);
if (!list.contains(comm)){
list.addElement(comm);
}
} else {
list = new Vector<String>();
list.addElement(comm);
dest.put(add,list);
}
}
/**
* Adds a <code>TrayIcon</code> to the <code>SystemTray</code>.
* The tray icon becomes visible in the system tray once it is
* added. The order in which icons are displayed in a tray is not
* specified - it is platform and implementation-dependent.
*
* <p> All icons added by the application are automatically
* removed from the <code>SystemTray</code> upon application exit
* and also when the desktop system tray becomes unavailable.
*
* @param trayIcon the <code>TrayIcon</code> to be added
* @throws NullPointerException if <code>trayIcon</code> is
* <code>null</code>
* @throws IllegalArgumentException if the same instance of
* a <code>TrayIcon</code> is added more than once
* @throws AWTException if the desktop system tray is missing
* @see #remove(TrayIcon)
* @see #getSystemTray
* @see TrayIcon
* @see java.awt.Image
*/
public void add(TrayIcon trayIcon) throws AWTException {
if (trayIcon == null) {
throw new NullPointerException("adding null TrayIcon");
}
TrayIcon[] oldArray = null, newArray = null;
Vector<TrayIcon> icons = null;
synchronized (this) {
oldArray = systemTray.getTrayIcons();
icons = (Vector<TrayIcon>)AppContext.getAppContext().get(TrayIcon.class);
if (icons == null) {
icons = new Vector<TrayIcon>(3);
AppContext.getAppContext().put(TrayIcon.class, icons);
} else if (icons.contains(trayIcon)) {
throw new IllegalArgumentException("adding TrayIcon that is already added");
}
icons.add(trayIcon);
newArray = systemTray.getTrayIcons();
trayIcon.setID(++currentIconID);
}
try {
trayIcon.addNotify();
} catch (AWTException e) {
icons.remove(trayIcon);
throw e;
}
firePropertyChange("trayIcons", oldArray, newArray);
}
private static void getClassesAux(Class<?> currentClass, Vector<String> v) {
if (!v.contains(currentClass.getName())) {
v.addElement(currentClass.getName());
}
currentClass = currentClass.getSuperclass();
while (currentClass != null) {
getTypeNames(currentClass, v);
currentClass = currentClass.getSuperclass();
}
}
public synchronized void addRelationSetListener(RelationSetListener l) {
@SuppressWarnings("unchecked")
Vector<RelationSetListener> v =
listeners == null
? new Vector<RelationSetListener>(2)
: (Vector<RelationSetListener>)listeners.clone();
if(!v.contains(l)) {
v.addElement(l);
listeners = v;
}
}
/**
* Adds a <code>TrayIcon</code> to the <code>SystemTray</code>.
* The tray icon becomes visible in the system tray once it is
* added. The order in which icons are displayed in a tray is not
* specified - it is platform and implementation-dependent.
*
* <p> All icons added by the application are automatically
* removed from the <code>SystemTray</code> upon application exit
* and also when the desktop system tray becomes unavailable.
*
* @param trayIcon the <code>TrayIcon</code> to be added
* @throws NullPointerException if <code>trayIcon</code> is
* <code>null</code>
* @throws IllegalArgumentException if the same instance of
* a <code>TrayIcon</code> is added more than once
* @throws AWTException if the desktop system tray is missing
* @see #remove(TrayIcon)
* @see #getSystemTray
* @see TrayIcon
* @see java.awt.Image
*/
public void add(TrayIcon trayIcon) throws AWTException {
if (trayIcon == null) {
throw new NullPointerException("adding null TrayIcon");
}
TrayIcon[] oldArray = null, newArray = null;
Vector<TrayIcon> icons = null;
synchronized (this) {
oldArray = systemTray.getTrayIcons();
icons = (Vector<TrayIcon>)AppContext.getAppContext().get(TrayIcon.class);
if (icons == null) {
icons = new Vector<TrayIcon>(3);
AppContext.getAppContext().put(TrayIcon.class, icons);
} else if (icons.contains(trayIcon)) {
throw new IllegalArgumentException("adding TrayIcon that is already added");
}
icons.add(trayIcon);
newArray = systemTray.getTrayIcons();
trayIcon.setID(++currentIconID);
}
try {
trayIcon.addNotify();
} catch (AWTException e) {
icons.remove(trayIcon);
throw e;
}
firePropertyChange("trayIcons", oldArray, newArray);
}
private void writeVerifyDefault()
{
Vector labels = vectorizeLabels (u.branches (), true);
if (Util.javaName(utype).equals ("boolean")) {
stream.println( "" ) ;
stream.println( " private void verifyDefault (boolean discriminator)" ) ;
stream.println( " {" ) ;
if (labels.contains ("true"))
stream.println (" if ( discriminator )");
else
stream.println (" if ( !discriminator )");
stream.println( " throw new org.omg.CORBA.BAD_OPERATION();" ) ;
stream.println( " }" ) ;
return;
}
stream.println( "" ) ;
stream.println( " private void verifyDefault( " + Util.javaName(utype) +
" value )" ) ;
stream.println( " {" ) ;
if (unionIsEnum)
stream.println( " switch (value.value()) {" ) ;
else
stream.println( " switch (value) {" ) ;
Enumeration e = labels.elements() ;
while (e.hasMoreElements()) {
String str = (String)(e.nextElement()) ;
stream.println( " case " + str + ":" ) ;
}
stream.println( " throw new org.omg.CORBA.BAD_OPERATION() ;" ) ;
stream.println( "" ) ;
stream.println( " default:" ) ;
stream.println( " return;" ) ;
stream.println( " }" ) ;
stream.println( " }" ) ;
}
/**
* Invoked before sending the specified notification to the listener.
* <P>If:
* <P>- the ObjectName of the concerned MBean is selected (explicitly OR
* (implicitly and not explicitly deselected))
* <P>AND
* <P>- the type of the operation (registration or unregistration) is
* selected
* <P>then the notification is sent to the listener.
*
* @param notif The notification to be sent.
*
* @return true if the notification has to be sent to the listener, false
* otherwise.
*
* @exception IllegalArgumentException if null parameter
*/
public synchronized boolean isNotificationEnabled(Notification notif)
throws IllegalArgumentException {
if (notif == null) {
String excMsg = "Invalid parameter.";
throw new IllegalArgumentException(excMsg);
}
RELATION_LOGGER.entering(MBeanServerNotificationFilter.class.getName(),
"isNotificationEnabled", notif);
// Checks the type first
String ntfType = notif.getType();
Vector<String> enabledTypes = getEnabledTypes();
if (!(enabledTypes.contains(ntfType))) {
RELATION_LOGGER.logp(Level.FINER,
MBeanServerNotificationFilter.class.getName(),
"isNotificationEnabled",
"Type not selected, exiting");
return false;
}
// We have a MBeanServerNotification: downcasts it
MBeanServerNotification mbsNtf = (MBeanServerNotification)notif;
// Checks the ObjectName
ObjectName objName = mbsNtf.getMBeanName();
// Is it selected?
boolean isSelectedFlg = false;
if (selectedNames != null) {
// Not all are implicitly selected:
// checks for explicit selection
if (selectedNames.size() == 0) {
// All are explicitly not selected
RELATION_LOGGER.logp(Level.FINER,
MBeanServerNotificationFilter.class.getName(),
"isNotificationEnabled",
"No ObjectNames selected, exiting");
return false;
}
isSelectedFlg = selectedNames.contains(objName);
if (!isSelectedFlg) {
// Not in the explicit selected list
RELATION_LOGGER.logp(Level.FINER,
MBeanServerNotificationFilter.class.getName(),
"isNotificationEnabled",
"ObjectName not in selected list, exiting");
return false;
}
}
if (!isSelectedFlg) {
// Not explicitly selected: is it deselected?
if (deselectedNames == null) {
// All are implicitly deselected and it is not explicitly
// selected
RELATION_LOGGER.logp(Level.FINER,
MBeanServerNotificationFilter.class.getName(),
"isNotificationEnabled",
"ObjectName not selected, and all " +
"names deselected, exiting");
return false;
} else if (deselectedNames.contains(objName)) {
// Explicitly deselected
RELATION_LOGGER.logp(Level.FINER,
MBeanServerNotificationFilter.class.getName(),
"isNotificationEnabled",
"ObjectName explicitly not selected, exiting");
return false;
}
}
RELATION_LOGGER.logp(Level.FINER,
MBeanServerNotificationFilter.class.getName(),
"isNotificationEnabled",
"ObjectName selected, exiting");
return true;
}
/**
* put a schema grammar and any grammars imported by it (directly or
* inderectly) into the registry. when a grammar with the same target
* namespace is already in the bucket, and different from the one being
* added, no grammar will be added into the bucket.
*
* @param grammar the grammar to put in the registry
* @param deep whether to add imported grammars
* @param ignoreConflict whether to ignore grammars that already exist in the grammar
* bucket or not - including 'grammar' parameter.
* @return whether the process succeeded
*/
public boolean putGrammar(SchemaGrammar grammar, boolean deep, boolean ignoreConflict) {
if (!ignoreConflict) {
return putGrammar(grammar, deep);
}
// if grammar already exist in the bucket, we ignore the request
SchemaGrammar sg = getGrammar(grammar.fTargetNamespace);
if (sg == null) {
putGrammar(grammar);
}
// not adding the imported grammars
if (!deep) {
return true;
}
// get all imported grammars, and make a copy of the Vector, so that
// we can recursively process the grammars, and add distinct ones
// to the same vector
Vector currGrammars = (Vector)grammar.getImportedGrammars();
if (currGrammars == null) {
return true;
}
Vector grammars = ((Vector)currGrammars.clone());
SchemaGrammar sg1, sg2;
Vector gs;
// for all (recursively) imported grammars
for (int i = 0; i < grammars.size(); i++) {
// get the grammar
sg1 = (SchemaGrammar)grammars.elementAt(i);
// check whether the bucket has one with the same tns
sg2 = getGrammar(sg1.fTargetNamespace);
if (sg2 == null) {
// we need to add grammars imported by sg1 too
gs = sg1.getImportedGrammars();
// for all grammars imported by sg2, but not in the vector
// we add them to the vector
if(gs == null) continue;
for (int j = gs.size() - 1; j >= 0; j--) {
sg2 = (SchemaGrammar)gs.elementAt(j);
if (!grammars.contains(sg2))
grammars.addElement(sg2);
}
}
// we found one with the same target namespace, ignore it
else {
grammars.remove(sg1);
}
}
// now we have all imported grammars stored in the vector. add them
for (int i = grammars.size() - 1; i >= 0; i--) {
putGrammar((SchemaGrammar)grammars.elementAt(i));
}
return true;
}
public String getMeetWith(Class_ clazz, Vector<Class_> exclude) {
TreeSet<Class_> classes = new TreeSet(new Comparator<Class_>() {
public int compare(Class_ c1, Class_ c2) {
if (c1.getSchedulingSubpart().equals(c2.getSchedulingSubpart())) {
String sx1 = (iUseClassSuffix?c1.getClassSuffix():c1.getSectionNumberString());
String sx2 = (iUseClassSuffix?c2.getClassSuffix():c2.getSectionNumberString());
if (sx1!=null && sx2!=null) return sx1.compareTo(sx2);
return c1.getSectionNumber().compareTo(c2.getSectionNumber());
}
return new SchedulingSubpartComparator().compare(c1.getSchedulingSubpart(), c2.getSchedulingSubpart());
}
});
for (Iterator i=clazz.getDistributionObjects().iterator();i.hasNext();) {
DistributionObject dObj = (DistributionObject)i.next();
if (!"MEET_WITH".equals(dObj.getDistributionPref().getDistributionType().getReference())) continue;
for (Iterator j=dObj.getDistributionPref().getDistributionObjects().iterator();j.hasNext();) {
DistributionObject xObj = (DistributionObject)j.next();
if (exclude!=null && exclude.contains(xObj.getPrefGroup())) continue;
if (xObj.getPrefGroup() instanceof Class_) {
classes.add((Class_)xObj.getPrefGroup());
} else {
classes.addAll(((SchedulingSubpart)xObj.getPrefGroup()).getClasses());
}
}
}
if (classes.isEmpty()) return "";
Class_ prev = clazz;
String ret = "";
for (Class_ c : classes) {
if (ret.length()==0)
ret+=genName(ApplicationProperty.ExamNameClass.value(),c);
else if (prev.getSchedulingSubpart().getControllingCourseOffering().getSubjectArea().equals(c.getSchedulingSubpart().getControllingCourseOffering().getSubjectArea())) {
//same subject area
if (prev.getSchedulingSubpart().getControllingCourseOffering().equals(c.getSchedulingSubpart().getControllingCourseOffering())) {
//same course number
if (prev.getSchedulingSubpart().equals(c.getSchedulingSubpart()))
ret+=genName(ApplicationProperty.ExamNameSameSubpartClass.value(), c);
else
ret+=genName(ApplicationProperty.ExamNameSameCourseClass.value(), c);
} else {
//different course number
ret+=genName(ApplicationProperty.ExamNameSameSubjectClass.value(), c);
}
} else {
ret+=genName(ApplicationProperty.ExamNameSeparator.value(),prev);
ret+=genName(ApplicationProperty.ExamNameClass.value(),c);
}
prev = c;
}
return ret;
}