Java Code Examples for java.util.Vector#remove()

The following examples show how to use java.util.Vector#remove() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DataBindingManager.java    From tlaplus with MIT License 6 votes vote down vote up
/**
 * Given an attribute name, remove all binding to it and its section.
 * 
 * @param attributeName
 */
public void unbindSectionAndAttribute(final String attributeName) {
	viewerForAttribute.remove(attributeName);
	
	final String sectionId = sectionForAttribute.remove(attributeName);
	if (sectionId != null) {
		sectionParts.remove(sectionId);
		
		final String pageId = pageForSection.remove(sectionId);
		if (pageId != null) {
			final Vector<String> sectionIds = sectionsForPage.get(pageId);
			if (sectionIds != null) {
				sectionIds.remove(sectionId);
			}
		}
	}
}
 
Example 2
Source File: Window.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private static void removeFromWindowList(AppContext context, WeakReference<Window> weakThis) {
    synchronized (Window.class) {
        @SuppressWarnings("unchecked")
        Vector<WeakReference<Window>> windowList = (Vector<WeakReference<Window>>)context.get(Window.class);
        if (windowList != null) {
            windowList.remove(weakThis);
        }
    }
}
 
Example 3
Source File: Window.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static void removeFromWindowList(AppContext context, WeakReference<Window> weakThis) {
    synchronized (Window.class) {
        @SuppressWarnings("unchecked")
        Vector<WeakReference<Window>> windowList = (Vector<WeakReference<Window>>)context.get(Window.class);
        if (windowList != null) {
            windowList.remove(weakThis);
        }
    }
}
 
Example 4
Source File: PostConstructService.java    From classchecks with Apache License 2.0 5 votes vote down vote up
/**
 * 卸载已经装载的dll
 * 
 * @param dllName
 *            库名,如Decode.dll
 **/
@SuppressWarnings("unchecked")
private synchronized void freeDll(String dllName) {
	try {
		ClassLoader classLoader = this.getClass().getClassLoader();
		Field field = ClassLoader.class.getDeclaredField("nativeLibraries");
		field.setAccessible(true);
		Vector<Object> libs = (Vector<Object>) field.get(classLoader);
		Iterator<Object> it = libs.iterator();
		Object o;

		while (it.hasNext()) {
			o = it.next();
			Field[] fs = o.getClass().getDeclaredFields();
			boolean hasInit = false;
			for (int k = 0; k < fs.length; k++) {
				if (fs[k].getName().equals("name")) {
					fs[k].setAccessible(true);
					String dllPath = fs[k].get(o).toString();
					if (dllPath.endsWith(dllName)) {
						hasInit = true;
					}
				}
			}
			if (hasInit) {
				Method finalize = o.getClass().getDeclaredMethod("finalize", new Class[0]);
				finalize.setAccessible(true);
				finalize.invoke(o, new Object[0]);
				it.remove();
				libs.remove(o);
			}
		}
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
Example 5
Source File: Window.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void removeFromWindowList(AppContext context, WeakReference<Window> weakThis) {
    synchronized (Window.class) {
        @SuppressWarnings("unchecked")
        Vector<WeakReference<Window>> windowList = (Vector<WeakReference<Window>>)context.get(Window.class);
        if (windowList != null) {
            windowList.remove(weakThis);
        }
    }
}
 
Example 6
Source File: SystemTray.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 7
Source File: SystemTray.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 8
Source File: Window.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private static void removeFromWindowList(AppContext context, WeakReference<Window> weakThis) {
    synchronized (Window.class) {
        @SuppressWarnings("unchecked")
        Vector<WeakReference<Window>> windowList = (Vector<WeakReference<Window>>)context.get(Window.class);
        if (windowList != null) {
            windowList.remove(weakThis);
        }
    }
}
 
Example 9
Source File: NonPRFunctionExecuteTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public synchronized static void HydraTask_initializeWithDifferentDP() {
  if (testInstance == null) {
    testInstance = new NonPRFunctionExecuteTest();
  }
  Vector regionNames = (Vector)ParRegBB.getBB().getSharedMap().get(REG_NAMES);
  String regionForThisNode = (String)regionNames.remove(0);
  Log.getLogWriter().info(
      "Region description for this node " + regionForThisNode);
  testInstance.initialize(regionForThisNode);
  testInstance.initialize("partitionedRegion");
  ParRegBB.getBB().getSharedMap().put(REG_NAMES, regionNames);
}
 
Example 10
Source File: XWindowPeer.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
static Vector<XWindowPeer> collectJavaToplevels() {
    Vector<XWindowPeer> javaToplevels = new Vector<XWindowPeer>();
    Vector<Long> v = new Vector<Long>();
    X11GraphicsEnvironment ge =
        (X11GraphicsEnvironment)GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] gds = ge.getScreenDevices();
    if (!ge.runningXinerama() && (gds.length > 1)) {
        for (GraphicsDevice gd : gds) {
            int screen = ((X11GraphicsDevice)gd).getScreen();
            long rootWindow = XlibWrapper.RootWindow(XToolkit.getDisplay(), screen);
            v.add(rootWindow);
        }
    } else {
        v.add(XToolkit.getDefaultRootWindow());
    }
    final int windowsCount = windows.size();
    while ((v.size() > 0) && (javaToplevels.size() < windowsCount)) {
        long win = v.remove(0);
        XQueryTree qt = new XQueryTree(win);
        try {
            if (qt.execute() != 0) {
                int nchildren = qt.get_nchildren();
                long children = qt.get_children();
                // XQueryTree returns window children ordered by z-order
                for (int i = 0; i < nchildren; i++) {
                    long child = Native.getWindow(children, i);
                    XBaseWindow childWindow = XToolkit.windowToXWindow(child);
                    // filter out Java non-toplevels
                    if ((childWindow != null) && !(childWindow instanceof XWindowPeer)) {
                        continue;
                    } else {
                        v.add(child);
                    }
                    if (childWindow instanceof XWindowPeer) {
                        XWindowPeer np = (XWindowPeer)childWindow;
                        javaToplevels.add(np);
                        // XQueryTree returns windows sorted by their z-order. However,
                        // if WM has not handled transient for hint for a child window,
                        // it may appear in javaToplevels before its owner. Move such
                        // children after their owners.
                        int k = 0;
                        XWindowPeer toCheck = javaToplevels.get(k);
                        while (toCheck != np) {
                            XWindowPeer toCheckOwnerPeer = toCheck.getOwnerPeer();
                            if (toCheckOwnerPeer == np) {
                                javaToplevels.remove(k);
                                javaToplevels.add(toCheck);
                            } else {
                                k++;
                            }
                            toCheck = javaToplevels.get(k);
                        }
                    }
                }
            }
        } finally {
            qt.dispose();
        }
    }
    return javaToplevels;
}
 
Example 11
Source File: SetOfIntegerSyntax.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Accumulate the given range (lb .. ub) into the canonical array form
 * into the given vector of int[] objects.
 */
private static void accumulate(Vector<int[]> ranges, int lb,int ub) {
    // Make sure range is non-null.
    if (lb <= ub) {
        // Stick range at the back of the vector.
        ranges.add(new int[] {lb, ub});

        // Work towards the front of the vector to integrate the new range
        // with the existing ranges.
        for (int j = ranges.size()-2; j >= 0; -- j) {
        // Get lower and upper bounds of the two ranges being compared.
            int[] rangea = ranges.elementAt (j);
            int lba = rangea[0];
            int uba = rangea[1];
            int[] rangeb = ranges.elementAt (j+1);
            int lbb = rangeb[0];
            int ubb = rangeb[1];

            /* If the two ranges overlap or are adjacent, coalesce them.
             * The two ranges overlap if the larger lower bound is less
             * than or equal to the smaller upper bound. The two ranges
             * are adjacent if the larger lower bound is one greater
             * than the smaller upper bound.
             */
            if (Math.max(lba, lbb) - Math.min(uba, ubb) <= 1) {
                // The coalesced range is from the smaller lower bound to
                // the larger upper bound.
                ranges.setElementAt(new int[]
                                       {Math.min(lba, lbb),
                                            Math.max(uba, ubb)}, j);
                ranges.remove (j+1);
            } else if (lba > lbb) {

                /* If the two ranges don't overlap and aren't adjacent but
                 * are out of order, swap them.
                 */
                ranges.setElementAt (rangeb, j);
                ranges.setElementAt (rangea, j+1);
            } else {
            /* If the two ranges don't overlap and aren't adjacent and
             * aren't out of order, we're done early.
             */
                break;
            }
        }
    }
}
 
Example 12
Source File: XWindowPeer.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
static Vector<XWindowPeer> collectJavaToplevels() {
    Vector<XWindowPeer> javaToplevels = new Vector<XWindowPeer>();
    Vector<Long> v = new Vector<Long>();
    X11GraphicsEnvironment ge =
        (X11GraphicsEnvironment)GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] gds = ge.getScreenDevices();
    if (!ge.runningXinerama() && (gds.length > 1)) {
        for (GraphicsDevice gd : gds) {
            int screen = ((X11GraphicsDevice)gd).getScreen();
            long rootWindow = XlibWrapper.RootWindow(XToolkit.getDisplay(), screen);
            v.add(rootWindow);
        }
    } else {
        v.add(XToolkit.getDefaultRootWindow());
    }
    final int windowsCount = windows.size();
    while ((v.size() > 0) && (javaToplevels.size() < windowsCount)) {
        long win = v.remove(0);
        XQueryTree qt = new XQueryTree(win);
        try {
            if (qt.execute() != 0) {
                int nchildren = qt.get_nchildren();
                long children = qt.get_children();
                // XQueryTree returns window children ordered by z-order
                for (int i = 0; i < nchildren; i++) {
                    long child = Native.getWindow(children, i);
                    XBaseWindow childWindow = XToolkit.windowToXWindow(child);
                    // filter out Java non-toplevels
                    if ((childWindow != null) && !(childWindow instanceof XWindowPeer)) {
                        continue;
                    } else {
                        v.add(child);
                    }
                    if (childWindow instanceof XWindowPeer) {
                        XWindowPeer np = (XWindowPeer)childWindow;
                        javaToplevels.add(np);
                        // XQueryTree returns windows sorted by their z-order. However,
                        // if WM has not handled transient for hint for a child window,
                        // it may appear in javaToplevels before its owner. Move such
                        // children after their owners.
                        int k = 0;
                        XWindowPeer toCheck = javaToplevels.get(k);
                        while (toCheck != np) {
                            XWindowPeer toCheckOwnerPeer = toCheck.getOwnerPeer();
                            if (toCheckOwnerPeer == np) {
                                javaToplevels.remove(k);
                                javaToplevels.add(toCheck);
                            } else {
                                k++;
                            }
                            toCheck = javaToplevels.get(k);
                        }
                    }
                }
            }
        } finally {
            qt.dispose();
        }
    }
    return javaToplevels;
}
 
Example 13
Source File: Whitespace.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Orders a set or rules by priority, removes redundant rules and rules
 * that are shadowed by stronger, contradicting rules.
 */
private static int prioritizeRules(Vector rules) {
    WhitespaceRule currentRule;
    int defaultAction = PRESERVE_SPACE;

    // Sort all rules with regard to priority
    quicksort(rules, 0, rules.size()-1);

    // Check if there are any "xsl:strip-space" elements at all.
    // If there are no xsl:strip elements we can ignore all xsl:preserve
    // elements and signal that all whitespaces should be preserved
    boolean strip = false;
    for (int i = 0; i < rules.size(); i++) {
        currentRule = (WhitespaceRule)rules.elementAt(i);
        if (currentRule.getAction() == STRIP_SPACE) {
            strip = true;
        }
    }
    // Return with default action: PRESERVE_SPACE
    if (!strip) {
        rules.removeAllElements();
        return PRESERVE_SPACE;
    }

    // Remove all rules that are contradicted by rules with higher priority
    for (int idx = 0; idx < rules.size(); ) {
        currentRule = (WhitespaceRule)rules.elementAt(idx);

        // Remove this single rule if it has no purpose
        if (findContradictingRule(rules,currentRule) != null) {
            rules.remove(idx);
        }
        else {
            // Remove all following rules if this one overrides all
            if (currentRule.getStrength() == RULE_ALL) {
                defaultAction = currentRule.getAction();
                for (int i = idx; i < rules.size(); i++) {
                    rules.removeElementAt(i);
                }
            }
            // Skip to next rule (there might not be any)...
            idx++;
        }
    }

    // The rules vector could be empty if first rule has strength RULE_ALL
    if (rules.size() == 0) {
        return defaultAction;
    }

    // Now work backwards and strip away all rules that have the same
    // action as the default rule (no reason the check them at the end).
    do {
        currentRule = (WhitespaceRule)rules.lastElement();
        if (currentRule.getAction() == defaultAction) {
            rules.removeElementAt(rules.size() - 1);
        }
        else {
            break;
        }
    } while (rules.size() > 0);

    // Signal that whitespace detection predicate must be used.
    return defaultAction;
}
 
Example 14
Source File: SetOfIntegerSyntax.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
/**
 * Accumulate the given range (lb .. ub) into the canonical array form
 * into the given vector of int[] objects.
 */
private static void accumulate(Vector ranges, int lb,int ub) {
    // Make sure range is non-null.
    if (lb <= ub) {
        // Stick range at the back of the vector.
        ranges.add(new int[] {lb, ub});

        // Work towards the front of the vector to integrate the new range
        // with the existing ranges.
        for (int j = ranges.size()-2; j >= 0; -- j) {
        // Get lower and upper bounds of the two ranges being compared.
            int[] rangea = (int[]) ranges.elementAt (j);
            int lba = rangea[0];
            int uba = rangea[1];
            int[] rangeb = (int[]) ranges.elementAt (j+1);
            int lbb = rangeb[0];
            int ubb = rangeb[1];

            /* If the two ranges overlap or are adjacent, coalesce them.
             * The two ranges overlap if the larger lower bound is less
             * than or equal to the smaller upper bound. The two ranges
             * are adjacent if the larger lower bound is one greater
             * than the smaller upper bound.
             */
            if (Math.max(lba, lbb) - Math.min(uba, ubb) <= 1) {
                // The coalesced range is from the smaller lower bound to
                // the larger upper bound.
                ranges.setElementAt(new int[]
                                       {Math.min(lba, lbb),
                                            Math.max(uba, ubb)}, j);
                ranges.remove (j+1);
            } else if (lba > lbb) {

                /* If the two ranges don't overlap and aren't adjacent but
                 * are out of order, swap them.
                 */
                ranges.setElementAt (rangeb, j);
                ranges.setElementAt (rangea, j+1);
            } else {
            /* If the two ranges don't overlap and aren't adjacent and
             * aren't out of order, we're done early.
             */
                break;
            }
        }
    }
}
 
Example 15
Source File: Whitespace.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Orders a set or rules by priority, removes redundant rules and rules
 * that are shadowed by stronger, contradicting rules.
 */
private static int prioritizeRules(Vector rules) {
    WhitespaceRule currentRule;
    int defaultAction = PRESERVE_SPACE;

    // Sort all rules with regard to priority
    quicksort(rules, 0, rules.size()-1);

    // Check if there are any "xsl:strip-space" elements at all.
    // If there are no xsl:strip elements we can ignore all xsl:preserve
    // elements and signal that all whitespaces should be preserved
    boolean strip = false;
    for (int i = 0; i < rules.size(); i++) {
        currentRule = (WhitespaceRule)rules.elementAt(i);
        if (currentRule.getAction() == STRIP_SPACE) {
            strip = true;
        }
    }
    // Return with default action: PRESERVE_SPACE
    if (!strip) {
        rules.removeAllElements();
        return PRESERVE_SPACE;
    }

    // Remove all rules that are contradicted by rules with higher priority
    for (int idx = 0; idx < rules.size(); ) {
        currentRule = (WhitespaceRule)rules.elementAt(idx);

        // Remove this single rule if it has no purpose
        if (findContradictingRule(rules,currentRule) != null) {
            rules.remove(idx);
        }
        else {
            // Remove all following rules if this one overrides all
            if (currentRule.getStrength() == RULE_ALL) {
                defaultAction = currentRule.getAction();
                for (int i = idx; i < rules.size(); i++) {
                    rules.removeElementAt(i);
                }
            }
            // Skip to next rule (there might not be any)...
            idx++;
        }
    }

    // The rules vector could be empty if first rule has strength RULE_ALL
    if (rules.size() == 0) {
        return defaultAction;
    }

    // Now work backwards and strip away all rules that have the same
    // action as the default rule (no reason the check them at the end).
    do {
        currentRule = (WhitespaceRule)rules.lastElement();
        if (currentRule.getAction() == defaultAction) {
            rules.removeElementAt(rules.size() - 1);
        }
        else {
            break;
        }
    } while (rules.size() > 0);

    // Signal that whitespace detection predicate must be used.
    return defaultAction;
}
 
Example 16
Source File: Stylesheet.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
/**
 * This method returns a vector with variables/params and keys in the
 * order in which they are to be compiled for initialization. The order
 * is determined by analyzing the dependencies between them. The XSLT 1.0
 * spec does not allow a key to depend on a variable. However, for
 * compatibility with Xalan interpretive, that type of dependency is
 * allowed and, therefore, consider to determine the partial order.
 */
private Vector resolveDependencies(Vector input) {
    /* DEBUG CODE - INGORE
    for (int i = 0; i < input.size(); i++) {
        final TopLevelElement e = (TopLevelElement) input.elementAt(i);
        System.out.println("e = " + e + " depends on:");
        Vector dep = e.getDependencies();
        for (int j = 0; j < (dep != null ? dep.size() : 0); j++) {
            System.out.println("\t" + dep.elementAt(j));
        }
    }
    System.out.println("=================================");
    */

    Vector result = new Vector();
    while (input.size() > 0) {
        boolean changed = false;
        for (int i = 0; i < input.size(); ) {
            final TopLevelElement vde = (TopLevelElement) input.elementAt(i);
            final Vector dep = vde.getDependencies();
            if (dep == null || result.containsAll(dep)) {
                result.addElement(vde);
                input.remove(i);
                changed = true;
            }
            else {
                i++;
            }
        }

        // If nothing was changed in this pass then we have a circular ref
        if (!changed) {
            ErrorMsg err = new ErrorMsg(ErrorMsg.CIRCULAR_VARIABLE_ERR,
                                        input.toString(), this);
            getParser().reportError(Constants.ERROR, err);
            return(result);
        }
    }

    /* DEBUG CODE - INGORE
    System.out.println("=================================");
    for (int i = 0; i < result.size(); i++) {
        final TopLevelElement e = (TopLevelElement) result.elementAt(i);
        System.out.println("e = " + e);
    }
    */

    return result;
}
 
Example 17
Source File: JspUtil.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
/**
 * Checks if all mandatory attributes are present and if all attributes
 * present have valid names. Checks attributes specified as XML-style
 * attributes as well as attributes specified using the jsp:attribute
 * standard action.
 */
public static void checkAttributes(String typeOfTag, Node n,
        ValidAttribute[] validAttributes, ErrorDispatcher err)
        throws JasperException {
    Attributes attrs = n.getAttributes();
    Mark start = n.getStart();
    boolean valid = true;

    // AttributesImpl.removeAttribute is broken, so we do this...
    int tempLength = (attrs == null) ? 0 : attrs.getLength();
    Vector<String> temp = new Vector<String>(tempLength, 1);
    for (int i = 0; i < tempLength; i++) {
        @SuppressWarnings("null")  // If attrs==null, tempLength == 0
        String qName = attrs.getQName(i);
        if ((!qName.equals("xmlns")) && (!qName.startsWith("xmlns:"))) {
            temp.addElement(qName);
        }
    }

    // Add names of attributes specified using jsp:attribute
    Node.Nodes tagBody = n.getBody();
    if (tagBody != null) {
        int numSubElements = tagBody.size();
        for (int i = 0; i < numSubElements; i++) {
            Node node = tagBody.getNode(i);
            if (node instanceof Node.NamedAttribute) {
                String attrName = node.getAttributeValue("name");
                temp.addElement(attrName);
                // Check if this value appear in the attribute of the node
                if (n.getAttributeValue(attrName) != null) {
                    err.jspError(n,
                            "jsp.error.duplicate.name.jspattribute",
                            attrName);
                }
            } else {
                // Nothing can come before jsp:attribute, and only
                // jsp:body can come after it.
                break;
            }
        }
    }

    /*
     * First check to see if all the mandatory attributes are present. If so
     * only then proceed to see if the other attributes are valid for the
     * particular tag.
     */
    String missingAttribute = null;

    for (int i = 0; i < validAttributes.length; i++) {
        int attrPos;
        if (validAttributes[i].mandatory) {
            attrPos = temp.indexOf(validAttributes[i].name);
            if (attrPos != -1) {
                temp.remove(attrPos);
                valid = true;
            } else {
                valid = false;
                missingAttribute = validAttributes[i].name;
                break;
            }
        }
    }

    // If mandatory attribute is missing then the exception is thrown
    if (!valid) {
        err.jspError(start, "jsp.error.mandatory.attribute", typeOfTag,
                missingAttribute);
    }

    // Check to see if there are any more attributes for the specified tag.
    int attrLeftLength = temp.size();
    if (attrLeftLength == 0) {
        return;
    }

    // Now check to see if the rest of the attributes are valid too.
    String attribute = null;

    for (int j = 0; j < attrLeftLength; j++) {
        valid = false;
        attribute = temp.elementAt(j);
        for (int i = 0; i < validAttributes.length; i++) {
            if (attribute.equals(validAttributes[i].name)) {
                valid = true;
                break;
            }
        }
        if (!valid) {
            err.jspError(start, "jsp.error.invalid.attribute", typeOfTag,
                    attribute);
        }
    }
    // XXX *could* move EL-syntax validation here... (sb)
}
 
Example 18
Source File: XWindowPeer.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
static Vector<XWindowPeer> collectJavaToplevels() {
    Vector<XWindowPeer> javaToplevels = new Vector<XWindowPeer>();
    Vector<Long> v = new Vector<Long>();
    X11GraphicsEnvironment ge =
        (X11GraphicsEnvironment)GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] gds = ge.getScreenDevices();
    if (!ge.runningXinerama() && (gds.length > 1)) {
        for (GraphicsDevice gd : gds) {
            int screen = ((X11GraphicsDevice)gd).getScreen();
            long rootWindow = XlibWrapper.RootWindow(XToolkit.getDisplay(), screen);
            v.add(rootWindow);
        }
    } else {
        v.add(XToolkit.getDefaultRootWindow());
    }
    final int windowsCount = windows.size();
    while ((v.size() > 0) && (javaToplevels.size() < windowsCount)) {
        long win = v.remove(0);
        XQueryTree qt = new XQueryTree(win);
        try {
            if (qt.execute() != 0) {
                int nchildren = qt.get_nchildren();
                long children = qt.get_children();
                // XQueryTree returns window children ordered by z-order
                for (int i = 0; i < nchildren; i++) {
                    long child = Native.getWindow(children, i);
                    XBaseWindow childWindow = XToolkit.windowToXWindow(child);
                    // filter out Java non-toplevels
                    if ((childWindow != null) && !(childWindow instanceof XWindowPeer)) {
                        continue;
                    } else {
                        v.add(child);
                    }
                    if (childWindow instanceof XWindowPeer) {
                        XWindowPeer np = (XWindowPeer)childWindow;
                        javaToplevels.add(np);
                        // XQueryTree returns windows sorted by their z-order. However,
                        // if WM has not handled transient for hint for a child window,
                        // it may appear in javaToplevels before its owner. Move such
                        // children after their owners.
                        int k = 0;
                        XWindowPeer toCheck = javaToplevels.get(k);
                        while (toCheck != np) {
                            XWindowPeer toCheckOwnerPeer = toCheck.getOwnerPeer();
                            if (toCheckOwnerPeer == np) {
                                javaToplevels.remove(k);
                                javaToplevels.add(toCheck);
                            } else {
                                k++;
                            }
                            toCheck = javaToplevels.get(k);
                        }
                    }
                }
            }
        } finally {
            qt.dispose();
        }
    }
    return javaToplevels;
}
 
Example 19
Source File: NonPRFunctionExecuteTest.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
public static synchronized void HydraTask_StartTask() {
  Vector regionNames = TestConfig.tab().vecAt(RegionPrms.names, null);
  regionNames.remove("partitionedRegion");
  ParRegBB.getBB().getSharedMap().put(REG_NAMES, regionNames);
}
 
Example 20
Source File: RepListComp.java    From scelight with Apache License 2.0 4 votes vote down vote up
@Override
public void actionPerformed( final ActionEvent event ) {
 final int[] rows = table.getSelectedModelRows();
 if ( !GuiUtils
               .confirm( Utils.plural( "Are you sure you want to delete %s replay%s?", rows.length ) ) )
  return;
 final List< Integer > deletedList = new ArrayList< >( rows.length );
 // count: Not necessarily the number of selected rows
 int count = 0;
 int errors = 0;
 final XTableModel model = table.getXTableModel();
 @SuppressWarnings( "unchecked" )
 final Vector< Vector > data = model.getDataVector();
 for ( final int row : rows ) {
  final Path file = (Path) data.get( row ).get( fileColIdx );
  try {
   if ( Files.deleteIfExists( file ) )
    count++;
   // Being here means file didn't even exist in the first place
               // First just collect rows, must be removed in descending order!
   deletedList.add( row );
  } catch ( final IOException ie ) {
   Env.LOGGER.error( "Failed to delete replay: " + file, ie );
   errors++;
  }
 }
 // Descending order is a must!
 Collections.sort( deletedList );
 for ( int i = deletedList.size() - 1; i >= 0; i-- )
  data.remove( deletedList.get( i ).intValue() );
 model.fireTableDataChanged();
 table.pack();
 if ( errors == 0 )
  GuiUtils.showInfoMsg( new XLabel( Utils.plural( "Successfully deleted %s replay%s.", count ),
                   Icons.F_TICK.get() ) );
 else
  GuiUtils.showErrorMsg(
                   new XLabel( Utils.plural( "Successfully deleted %s replay%s.", count ),
                           Icons.F_TICK.get() ),
                   new XLabel( Utils.plural( "Failed to delete %s replay%s.", errors ),
                           Icons.F_CROSS.get() ) );
																				
}