Ejemplo n.º 1
0
        public virtual Item addDaughter(Item item)
        {
            Item         newItem;
            ItemContents itemContents;

            Item p = getLastDaughter();

            if (p != null)
            {
                newItem = p.appendItem(item);
            }
            else
            {
                if (item == null)
                {
                    itemContents = new ItemContents();
                }
                else
                {
                    itemContents = item.getSharedContents();
                }
                newItem        = new Item(getOwnerRelation(), itemContents);
                newItem.parent = this;
                daughter       = newItem;
            }
            return(newItem);
        }
Ejemplo n.º 2
0
        public virtual Item appendItem(Item originalItem)
        {
            ItemContents contents;
            Item         newItem;

            if (originalItem == null)
            {
                contents = null;
            }
            else
            {
                contents = originalItem.getSharedContents();
            }

            newItem      = new Item(getOwnerRelation(), contents);
            newItem.next = next;
            if (next != null)
            {
                next.prev = newItem;
            }

            attach(newItem);

            if (ownerRelation.getTail() == this)
            {
                ownerRelation.setTail(newItem);
            }
            return(newItem);
        }
Ejemplo n.º 3
0
        public virtual Item prependItem(Item originalItem)
        {
            ItemContents contents;
            Item         newItem;

            if (originalItem == null)
            {
                contents = null;
            }
            else
            {
                contents = originalItem.getSharedContents();
            }

            newItem      = new Item(getOwnerRelation(), contents);
            newItem.prev = prev;
            if (prev != null)
            {
                prev.next = newItem;
            }
            newItem.next = this;
            prev         = newItem;
            if (parent != null)
            {
                parent.daughter = newItem;
                newItem.parent  = parent;
                parent          = null;
            }
            if (ownerRelation.getHead() == this)
            {
                ownerRelation.setHead(newItem);
            }
            return(newItem);
        }
Ejemplo n.º 4
0
        public Item(Relation relation, ItemContents sharedContents)
        {
            ownerRelation = relation;
            if (sharedContents != null)
            {
                contents = sharedContents;
            }
            else
            {
                contents = new ItemContents();
            }
            parent   = null;
            daughter = null;
            next     = null;
            prev     = null;

            getSharedContents().addItemRelation(relation.getName(), this);
        }