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

The following examples show how to use java.util.Vector#equals() . These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
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 2
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
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
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
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
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
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 8
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
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
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
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
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
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
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
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 Project: netbeans   File: KeyMapTest.java    License: 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 17
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
@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 19
Source Project: netbeans   File: KeyMapTest.java    License: 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
@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();
}