/** Serialize an instance, restore it, and check for equality. */
  public void testSerialization() {

    List u1 = new java.util.ArrayList();
    u1.add("URL A1");
    u1.add("URL A2");
    u1.add("URL A3");

    List u2 = new java.util.ArrayList();
    u2.add("URL B1");
    u2.add("URL B2");
    u2.add("URL B3");

    CustomXYURLGenerator g1 = new CustomXYURLGenerator();
    CustomXYURLGenerator g2 = null;

    g1.addURLSeries(u1);
    g1.addURLSeries(u2);

    try {
      ByteArrayOutputStream buffer = new ByteArrayOutputStream();
      ObjectOutput out = new ObjectOutputStream(buffer);
      out.writeObject(g1);
      out.close();

      ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
      g2 = (CustomXYURLGenerator) in.readObject();
      in.close();
    } catch (Exception e) {
      System.out.println(e.toString());
    }
    assertEquals(g1, g2);
  }
  /**
   * Tests this generator for equality with an arbitrary object.
   *
   * @param obj the object (<code>null</code> permitted).
   * @return A boolean.
   */
  @Override
  public boolean equals(Object obj) {
    if (obj == this) {
      return true;
    }
    if (!(obj instanceof CustomXYURLGenerator)) {
      return false;
    }
    CustomXYURLGenerator that = (CustomXYURLGenerator) obj;
    int listCount = getListCount();
    if (listCount != that.getListCount()) {
      return false;
    }

    for (int series = 0; series < listCount; series++) {
      int urlCount = getURLCount(series);
      if (urlCount != that.getURLCount(series)) {
        return false;
      }

      for (int item = 0; item < urlCount; item++) {
        String u1 = getURL(series, item);
        String u2 = that.getURL(series, item);
        if (u1 != null) {
          if (!u1.equals(u2)) {
            return false;
          }
        } else {
          if (u2 != null) {
            return false;
          }
        }
      }
    }
    return true;
  }
 /**
  * Returns a new generator that is a copy of, and independent from, this generator.
  *
  * @return A clone.
  * @throws CloneNotSupportedException if there is a problem with cloning.
  */
 @Override
 public Object clone() throws CloneNotSupportedException {
   CustomXYURLGenerator clone = (CustomXYURLGenerator) super.clone();
   clone.urlSeries = new java.util.ArrayList(this.urlSeries);
   return clone;
 }