Feb 25 2006 | 7:19 pm
    hi, I'm still working at deattaching/reattaching to hidden objects
    from mxj. according to the javadoc, getAllObjects() returns a set of
    MaxObjects. however when I go to iterate over the set I get a bunch
    of Map.Entry objects instead, and have to 'unbox' them to get the
    MaxObjects. is this the intended behaviour? if so maybe the javadoc
    should be updated. here's some sample code to demonstrate:
    Set objects = getContext().getAllObjects();
    post(debugString + ": objects: " + objects.toString());
    Iterator objiter = objects.iterator();
    post(debugString + ": searching for x_iter");
    while(objiter.hasNext()) {
    Map.Entry entry = (Map.Entry);
    Object key = entry.getKey();
    Object val = entry.getValue();
    post(debugString + ": key: " + key.toString());
    post(debugString + ": val: " + val.toString());
    if (val instanceof xboxless) {
    post(debugString + ": found: " + ((xboxless)val).getName());
    } else {
    post(debugString + ": found: " + obj.getClass());
    curiously the key and val appear always to be identical, and
    objects.toString() dumps a lot of redundant info because of this (one
    [boxed[name: 'boxed_1'; 1 in; 1 out]=boxed[name: 'boxed_1'; 1 in; 1
    out], ..]
    presumably this is [key=val, ..]
    this is on max4.5.6 java1.5.0_06 os10.4.5

    • Feb 25 2006 | 8:12 pm
      On 06-02-25, at 1519, ritchie wrote:
      > ...
      > this is on max4.5.6 java1.5.0_06 os10.4.5
      and fwiw I just noticed that mxj is v1.0 for java 1.4 so I tested on
      java 1.4.2 and get the same thing.
    • Feb 26 2006 | 1:42 pm
      it returns a set. that fact that you are using an iterator to iterate
      over your set is why you get Map.Entry objects. This makes sense to
      me. The javadoc states that the method returns a set which it does. I
      guess I don't understand what you are trying to get at. Given that
      objects in a set are untyped you are always going to have to unbox
      them or in java 1.5 use templates or whatever they are called.
    • Feb 26 2006 | 2:16 pm
      On 26 Feb 2006, at 14:42, topher lafata wrote:
      > it returns a set. that fact that you are using an iterator to
      > iterate over your set is why you get Map.Entry objects.
      If I were iterating over a Set, I'd expect to be getting E's:
      Set.iterator() returns an Iterator, which delivers E's.
      On the other hand, transforming a Map into a Set will result in a set
      containing pairs of key and value (Set
      Since the MXJ API is still in the Java 1.4 world, it's not possible
      to tell from the type specs what kind of set getContext
      ().getAllObjects() returns, but the documentation suggests it should
      be Set, rather than anything with map entries.
      -- N.
      nick rothwell -- composition, systems, performance -- http://
    • Feb 26 2006 | 2:56 pm
      thanks for articulating this better, nick. the behaviour described in
      the javadoc is probably more useful for end-users, however as long as
      the doc and the api are consistent then either way is fine. I'm just
      trying to save others the trouble of figuring out why they might be
      getting classcast exceptions, or never finding that the set objects
      match a given MaxObject subtype via instanceof.