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

The following examples show how to use java.util.Vector#equals() . 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: SetNativesTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public void verifyNewMappings() {
    // Enumerate through all natives
    for (Enumeration e = hashVerify.keys() ; e.hasMoreElements() ;) {
        String key = (String)e.nextElement();

        java.util.List listFlavors = flavorMap.getFlavorsForNative(key);
        Vector vectorFlavors = new Vector(listFlavors);

        // Compare the list of DataFlavors
        if ( !vectorFlavors.equals((Vector)hashVerify.get(key))) {
            throw new RuntimeException("\n*** Error in verifyNewMappings()" +
                "\nmethod1: setFlavorsForNative(String nat, DataFlavors[] flavors)" +
                "\nmethod2: List getFlavorsForNative(String nat)" +
                "\nString native: " + key +
                "\nThe Returned List did not match the original set of DataFlavors.");
        }
    }
    System.out.println("*** native size = " + hashVerify.size());
}
 
Example 2
Source File: SimpleSerialization.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(final String[] args) throws Exception {
    final Vector<String> v1 = new Vector<>();

    v1.add("entry1");
    v1.add("entry2");

    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    final ObjectOutputStream oos = new ObjectOutputStream(baos);

    oos.writeObject(v1);
    oos.close();

    final byte[] data = baos.toByteArray();
    final ByteArrayInputStream bais = new ByteArrayInputStream(data);
    final ObjectInputStream ois = new ObjectInputStream(bais);

    final Object deserializedObject = ois.readObject();
    ois.close();

    if (false == v1.equals(deserializedObject)) {
        throw new RuntimeException(getFailureText(v1, deserializedObject));
    }
}
 
Example 3
Source File: SimpleSerialization.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(final String[] args) throws Exception {
    final Vector<String> v1 = new Vector<>();

    v1.add("entry1");
    v1.add("entry2");

    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    final ObjectOutputStream oos = new ObjectOutputStream(baos);

    oos.writeObject(v1);
    oos.close();

    final byte[] data = baos.toByteArray();
    final ByteArrayInputStream bais = new ByteArrayInputStream(data);
    final ObjectInputStream ois = new ObjectInputStream(bais);

    final Object deserializedObject = ois.readObject();
    ois.close();

    if (false == v1.equals(deserializedObject)) {
        throw new RuntimeException(getFailureText(v1, deserializedObject));
    }
}
 
Example 4
Source File: SimpleSerialization.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(final String[] args) throws Exception {
    final Vector<String> v1 = new Vector<>();

    v1.add("entry1");
    v1.add("entry2");

    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    final ObjectOutputStream oos = new ObjectOutputStream(baos);

    oos.writeObject(v1);
    oos.close();

    final byte[] data = baos.toByteArray();
    final ByteArrayInputStream bais = new ByteArrayInputStream(data);
    final ObjectInputStream ois = new ObjectInputStream(bais);

    final Object deserializedObject = ois.readObject();
    ois.close();

    if (false == v1.equals(deserializedObject)) {
        throw new RuntimeException(getFailureText(v1, deserializedObject));
    }
}
 
Example 5
Source File: SimpleSerialization.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(final String[] args) throws Exception {
    final Vector<String> v1 = new Vector<>();

    v1.add("entry1");
    v1.add("entry2");

    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    final ObjectOutputStream oos = new ObjectOutputStream(baos);

    oos.writeObject(v1);
    oos.close();

    final byte[] data = baos.toByteArray();
    final ByteArrayInputStream bais = new ByteArrayInputStream(data);
    final ObjectInputStream ois = new ObjectInputStream(bais);

    final Object deserializedObject = ois.readObject();
    ois.close();

    if (false == v1.equals(deserializedObject)) {
        throw new RuntimeException(getFailureText(v1, deserializedObject));
    }
}
 
Example 6
Source File: SimpleSerialization.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public static void main(final String[] args) throws Exception {
    final Vector<String> v1 = new Vector<>();

    v1.add("entry1");
    v1.add("entry2");

    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    final ObjectOutputStream oos = new ObjectOutputStream(baos);

    oos.writeObject(v1);
    oos.close();

    final byte[] data = baos.toByteArray();
    final ByteArrayInputStream bais = new ByteArrayInputStream(data);
    final ObjectInputStream ois = new ObjectInputStream(bais);

    final Object deserializedObject = ois.readObject();
    ois.close();

    if (false == v1.equals(deserializedObject)) {
        throw new RuntimeException(getFailureText(v1, deserializedObject));
    }
}
 
Example 7
Source File: SimpleSerialization.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public static void main(final String[] args) throws Exception {
    final Vector<String> v1 = new Vector<>();

    v1.add("entry1");
    v1.add("entry2");

    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    final ObjectOutputStream oos = new ObjectOutputStream(baos);

    oos.writeObject(v1);
    oos.close();

    final byte[] data = baos.toByteArray();
    final ByteArrayInputStream bais = new ByteArrayInputStream(data);
    final ObjectInputStream ois = new ObjectInputStream(bais);

    final Object deserializedObject = ois.readObject();
    ois.close();

    if (false == v1.equals(deserializedObject)) {
        throw new RuntimeException(getFailureText(v1, deserializedObject));
    }
}
 
Example 8
Source File: SimpleSerialization.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(final String[] args) throws Exception {
    final Vector<String> v1 = new Vector<>();

    v1.add("entry1");
    v1.add("entry2");

    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    final ObjectOutputStream oos = new ObjectOutputStream(baos);

    oos.writeObject(v1);
    oos.close();

    final byte[] data = baos.toByteArray();
    final ByteArrayInputStream bais = new ByteArrayInputStream(data);
    final ObjectInputStream ois = new ObjectInputStream(bais);

    final Object deserializedObject = ois.readObject();
    ois.close();

    if (false == v1.equals(deserializedObject)) {
        throw new RuntimeException(getFailureText(v1, deserializedObject));
    }
}
 
Example 9
Source File: SimpleSerialization.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(final String[] args) throws Exception {
    final Vector<String> v1 = new Vector<>();

    v1.add("entry1");
    v1.add("entry2");

    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    final ObjectOutputStream oos = new ObjectOutputStream(baos);

    oos.writeObject(v1);
    oos.close();

    final byte[] data = baos.toByteArray();
    final ByteArrayInputStream bais = new ByteArrayInputStream(data);
    final ObjectInputStream ois = new ObjectInputStream(bais);

    final Object deserializedObject = ois.readObject();
    ois.close();

    if (false == v1.equals(deserializedObject)) {
        throw new RuntimeException(getFailureText(v1, deserializedObject));
    }
}
 
Example 10
Source File: SimpleSerialization.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(final String[] args) throws Exception {
    final Vector<String> v1 = new Vector<>();

    v1.add("entry1");
    v1.add("entry2");

    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    final ObjectOutputStream oos = new ObjectOutputStream(baos);

    oos.writeObject(v1);
    oos.close();

    final byte[] data = baos.toByteArray();
    final ByteArrayInputStream bais = new ByteArrayInputStream(data);
    final ObjectInputStream ois = new ObjectInputStream(bais);

    final Object deserializedObject = ois.readObject();
    ois.close();

    if (false == v1.equals(deserializedObject)) {
        throw new RuntimeException(getFailureText(v1, deserializedObject));
    }
}
 
Example 11
Source File: SimpleSerialization.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public static void main(final String[] args) throws Exception {
    final Vector<String> v1 = new Vector<>();

    v1.add("entry1");
    v1.add("entry2");

    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    final ObjectOutputStream oos = new ObjectOutputStream(baos);

    oos.writeObject(v1);
    oos.close();

    final byte[] data = baos.toByteArray();
    final ByteArrayInputStream bais = new ByteArrayInputStream(data);
    final ObjectInputStream ois = new ObjectInputStream(bais);

    final Object deserializedObject = ois.readObject();
    ois.close();

    if (false == v1.equals(deserializedObject)) {
        throw new RuntimeException(getFailureText(v1, deserializedObject));
    }
}
 
Example 12
Source File: SimpleSerialization.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public static void main(final String[] args) throws Exception {
    final Vector<String> v1 = new Vector<>();

    v1.add("entry1");
    v1.add("entry2");

    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    final ObjectOutputStream oos = new ObjectOutputStream(baos);

    oos.writeObject(v1);
    oos.close();

    final byte[] data = baos.toByteArray();
    final ByteArrayInputStream bais = new ByteArrayInputStream(data);
    final ObjectInputStream ois = new ObjectInputStream(bais);

    final Object deserializedObject = ois.readObject();
    ois.close();

    if (false == v1.equals(deserializedObject)) {
        throw new RuntimeException(getFailureText(v1, deserializedObject));
    }
}
 
Example 13
Source File: SimpleSerialization.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(final String[] args) throws Exception {
    final Vector<String> v1 = new Vector<>();

    v1.add("entry1");
    v1.add("entry2");

    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    final ObjectOutputStream oos = new ObjectOutputStream(baos);

    oos.writeObject(v1);
    oos.close();

    final byte[] data = baos.toByteArray();
    final ByteArrayInputStream bais = new ByteArrayInputStream(data);
    final ObjectInputStream ois = new ObjectInputStream(bais);

    final Object deserializedObject = ois.readObject();
    ois.close();

    if (false == v1.equals(deserializedObject)) {
        throw new RuntimeException(getFailureText(v1, deserializedObject));
    }
}
 
Example 14
Source File: SimpleSerialization.java    From native-obfuscator with GNU General Public License v3.0 6 votes vote down vote up
public static void main(final String[] args) throws Exception {
    final Vector<String> v1 = new Vector<>();

    v1.add("entry1");
    v1.add("entry2");

    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    final ObjectOutputStream oos = new ObjectOutputStream(baos);

    oos.writeObject(v1);
    oos.close();

    final byte[] data = baos.toByteArray();
    final ByteArrayInputStream bais = new ByteArrayInputStream(data);
    final ObjectInputStream ois = new ObjectInputStream(bais);

    final Object deserializedObject = ois.readObject();
    ois.close();

    if (false == v1.equals(deserializedObject)) {
        throw new RuntimeException(getFailureText(v1, deserializedObject));
    }
}
 
Example 15
Source File: SimpleSerialization.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(final String[] args) throws Exception {
    final Vector<String> v1 = new Vector<>();

    v1.add("entry1");
    v1.add("entry2");

    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    final ObjectOutputStream oos = new ObjectOutputStream(baos);

    oos.writeObject(v1);
    oos.close();

    final byte[] data = baos.toByteArray();
    final ByteArrayInputStream bais = new ByteArrayInputStream(data);
    final ObjectInputStream ois = new ObjectInputStream(bais);

    final Object deserializedObject = ois.readObject();
    ois.close();

    if (false == v1.equals(deserializedObject)) {
        throw new RuntimeException(getFailureText(v1, deserializedObject));
    }
}
 
Example 16
Source File: DocumentEntrySet.java    From org.openntf.domino with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("rawtypes")
@Override
public boolean equals(final Object obj) {
	if (this == obj) {
		return true;
	}
	if (!(obj instanceof DocumentEntrySet)) {
		return false;
	}
	DocumentEntrySet other = (DocumentEntrySet) obj;
	Set<String> myKeySet = doc.keySet();
	Object otherKeySet = other.doc.keySet();
	if (!myKeySet.equals(otherKeySet))
		return false;
	for (String key : myKeySet) {
		Vector myVal = doc.getItemValue(key);
		Vector otherVal = other.doc.getItemValue(key);
		if (myVal == null && otherVal == null) {
			// nop
		} else if (myVal == null || otherVal == null) {
			return false;
		} else if (!myVal.equals(otherVal)) {
			return false;
		}
	}
	return true;

}
 
Example 17
Source File: GetNativesForNewFlavorTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void doTest() throws Exception {
    // Initialize DataFlavors and arrays used for test data
    initMappings();

    boolean passed = true;
    flavorMap = (SystemFlavorMap)SystemFlavorMap.getDefaultFlavorMap();

    // Get all the native strings and preferred DataFlavor mappings
    hash = new Hashtable(flavorMap.getFlavorsForNatives(null));
    hashSize = hash.size();

    // GetNativesForFlavor using unknown DataFlavor (verify 2-way mapping)
    //
    // If a new DataFlavor is specified, the method should establish a mapping
    // in both directions between specified DataFlavor and an encoded
    // version of its MIME type as its native.
    System.out.println("GetNativesForFlavor using new DataFlavor");

    comp1 = new Vector(Arrays.asList(test_natives_set));
    comp2 = new Vector(flavorMap.getNativesForFlavor(test_flavor1));

    comp3 = new Vector(Arrays.asList(test_flavors_set));
    comp4 = new Vector(flavorMap.getFlavorsForNative(test_encoded));

    if ( !comp1.equals(comp2) || !comp3.equals(comp4) ) {
        throw new RuntimeException("\n*** After passing a new DataFlavor" +
            "\nwith getNativesForFlavor(DataFlavor flav)" +
            "\nthe mapping in both directions was not established.");
    }
    else
       System.out.println("GetNativesForFlavor using new DataFlavor: Test Passes");
}
 
Example 18
Source File: KeyMapTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testProfileRestore() {
    KeyMapOperator kmo = null;
    boolean closed = true;
    try {
        kmo = KeyMapOperator.invoke();
        closed = false;
        Vector<String> shortcuts = kmo.getAllShortcutsForAction("Preview Design");
        kmo.assignShortcutToAction("Preview Design", true, true, false, KeyEvent.VK_W, true, true);
        if (shortcuts.equals(kmo.getAllShortcutsForAction("Preview Design"))) {
            fail("Problem with assigning shortcut to Preview Design");
        }
        kmo.ok().push();
        closed = true;
        kmo = KeyMapOperator.invoke();
        closed = false;
        kmo.actionSearchByName().setText("Preview Design");
        kmo.restoreProfile("NetBeans");
        Vector<String> sc = kmo.getAllShortcutsForAction("Preview Design");
        if (!shortcuts.equals(sc)) {
            // This test currently fails: http://www.netbeans.org/issues/show_bug.cgi?id=151254
            fail("Problem with restoring NetBeans profile (http://www.netbeans.org/issues/show_bug.cgi?id=151254) - \"Preview Design\" action: " + shortcuts.toString() + " vs. " + sc.toString());
        }
        kmo.ok().push();
        closed = true;
    } finally {
        if (!closed && kmo != null) {
            kmo.cancel().push();
        }
    }
}
 
Example 19
Source File: KeyMapTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void testAddDuplicateCancel() {
    KeyMapOperator kmo = null;
    boolean closed = true;
    try {
        kmo = KeyMapOperator.invoke();
        closed = false;
        kmo.selectProfile(PROFILE_DEFAULT);
        Vector<String> shortcuts = kmo.getAllShortcutsForAction("select line");
        kmo.assignShortcutToAction("select line", false, true, true, KeyEvent.VK_F9, true, false);
        shortcuts.equals(kmo.getAllShortcutsForAction("select line"));
        kmo.ok().push();
        closed = true;
        kmo = KeyMapOperator.invoke();
        closed = false;
        kmo.selectProfile(PROFILE_DEFAULT);
        kmo.assignShortcutToAction("select line", false, true, true, KeyEvent.VK_F9, true, true);
        kmo.ok().push();
        closed = true;
        new EventTool().waitNoEvent(2000);
        editor.requestFocus();
        new EventTool().waitNoEvent(100);
        // Check ALT+Shift+G works for select line
        editor.setCaretPosition(55, 1);
        ValueResolver vr = new ValueResolver() {

            @Override
            public Object getValue() {
                editor.pushKey(KeyEvent.VK_F9, KeyEvent.ALT_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK);
                String selected = editor.txtEditorPane().getSelectedText();
                new EventTool().waitNoEvent(100);
                if (selected == null) {
                    return false;
                }
                return selected.startsWith("public class Main {");
            }
        };
        waitMaxMilisForValue(3000, vr, Boolean.TRUE);
        String text = editor.txtEditorPane().getSelectedText();
        assertEquals("public class Main {", text.trim());
    } catch (Exception e) {
        System.out.println("ERROR: testAddDuplicateCancel");
        e.printStackTrace(System.out);
        fail(e);
    } finally {
        if (!closed && kmo != null) {
            kmo.cancel().push();
            editor.close(false);
        }
    }
}
 
Example 20
Source File: MoveChooserService.java    From Shuffle-Move with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void updateGUIFrom(ShuffleMenuUser user) {
   updateTooltips(user);
   updateComponentText(user);
   Collection<SimulationResult> userResults = user.getResults();
   SimulationResult selectResult = user.getSelectedResult();
   if (listener2 != null) {
      table.getSelectionModel().removeListSelectionListener(listener2);
      results.clear();
      resultsMap.clear();
      loadOrderFor(table, user.getPreferencesManager().getStringValue(KEY_COLUMN_ORDER));
      if (model2.getRowCount() > 0) {
         for (int i = model2.getRowCount() - 1; i >= 0; i--) {
            model2.removeRow(i);
         }
      }
      Vector<String> columNames = getColumnNames();
      Vector<String> curNames = new Vector<String>();
      for (int i = 0; i < model2.getColumnCount(); i++) {
         curNames.add(model2.getColumnName(i));
      }
      if (!curNames.equals(columNames)) {
         model2.setColumnIdentifiers(columNames);
      }
      if (userResults != null) {
         for (SimulationResult result : userResults) {
            resultsMap.put(result, results.size());
            model2.addRow(getVectorFor(result, results.size() + 1));
            results.add(result);
         }
      }
      if (selectResult == null) {
         table.clearSelection();
         
      } else {
         int row = resultsMap.get(selectResult);
         table.setRowSelectionInterval(row, row);
      }
      resizeColumnWidth(table);
      table.repaint();
      table.getSelectionModel().addListSelectionListener(listener2);
   }
   ind.repaint();
}