public BagAttribute(URI type, Collection bag) {
        super(type);

        if (type == null)
            throw new IllegalArgumentException("Bags require a non-null " +
                                               "type be provided");

        // see if the bag is empty/null
        if ((bag == null) || (bag.size() == 0)) {
            // empty bag
            this.bag = new ArrayList();
        } else {
            // go through the collection to make sure it's a valid bag
            Iterator it = bag.iterator();
            
            while (it.hasNext()) {
                AttributeValue attr = (AttributeValue)(it.next());

                // a bag cannot contain other bags, so make sure that each
                // value isn't actually another bag
                if (attr.isBag())
                    throw new IllegalArgumentException("bags cannot contain " +
                                                       "other bags");
                    
                // make sure that they're all the same type
                if (! type.equals(attr.getType()))
                    throw new
                        IllegalArgumentException("Bag items must all be of " +
                                                 "the same type");
            }

            // if we get here, then they're all the same type
            this.bag = bag;
        }
    }