FileDocCategorySizeDatePackage
Movies.javaAPI DocExample6112Sun Jul 07 09:31:54 BST 2002javajaxb.generated.movies

Movies.java

package javajaxb.generated.movies;

import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javajaxb.generated.movies.Movie;
import javax.xml.bind.Dispatcher;
import javax.xml.bind.DuplicateAttributeException;
import javax.xml.bind.InvalidAttributeException;
import javax.xml.bind.InvalidContentObjectException;
import javax.xml.bind.LocalValidationException;
import javax.xml.bind.MarshallableObject;
import javax.xml.bind.MarshallableRootElement;
import javax.xml.bind.Marshaller;
import javax.xml.bind.MissingAttributeException;
import javax.xml.bind.MissingContentException;
import javax.xml.bind.PredicatedLists;
import javax.xml.bind.PredicatedLists.Predicate;
import javax.xml.bind.RootElement;
import javax.xml.bind.StructureValidationException;
import javax.xml.bind.UnmarshalException;
import javax.xml.bind.Unmarshaller;
import javax.xml.bind.ValidatableObject;
import javax.xml.bind.Validator;
import javax.xml.marshal.XMLScanner;
import javax.xml.marshal.XMLWriter;


public class Movies
    extends MarshallableRootElement
    implements RootElement
{

    private String _Version;
    private List _Movie = PredicatedLists.createInvalidating(this, new MoviePredicate(), new ArrayList());
    private PredicatedLists.Predicate pred_Movie = new MoviePredicate();

    public String getVersion() {
        return _Version;
    }

    public void setVersion(String _Version) {
        this._Version = _Version;
        if (_Version == null) {
            invalidate();
        }
    }

    public List getMovie() {
        return _Movie;
    }

    public void deleteMovie() {
        _Movie = null;
        invalidate();
    }

    public void emptyMovie() {
        _Movie = PredicatedLists.createInvalidating(this, pred_Movie, new ArrayList());
    }

    public void validateThis()
        throws LocalValidationException
    {
        if (_Version == null) {
            throw new MissingAttributeException("version");
        }
        if (_Movie == null) {
            throw new MissingContentException("movie");
        }
    }

    public void validate(Validator v)
        throws StructureValidationException
    {
        for (Iterator i = _Movie.iterator(); i.hasNext(); ) {
            v.validate(((ValidatableObject) i.next()));
        }
    }

    public void marshal(Marshaller m)
        throws IOException
    {
        XMLWriter w = m.writer();
        w.start("movies");
        w.attribute("version", _Version.toString());
        for (Iterator i = _Movie.iterator(); i.hasNext(); ) {
            m.marshal(((MarshallableObject) i.next()));
        }
        w.end("movies");
    }

    public void unmarshal(Unmarshaller u)
        throws UnmarshalException
    {
        XMLScanner xs = u.scanner();
        Validator v = u.validator();
        xs.takeStart("movies");
        while (xs.atAttribute()) {
            String an = xs.takeAttributeName();
            if (an.equals("version")) {
                if (_Version!= null) {
                    throw new DuplicateAttributeException(an);
                }
                _Version = xs.takeAttributeValue();
                continue;
            }
            throw new InvalidAttributeException(an);
        }
        {
            List l = PredicatedLists.create(this, pred_Movie, new ArrayList());
            while (xs.atStart("movie")) {
                l.add(((Movie) u.unmarshal()));
            }
            _Movie = PredicatedLists.createInvalidating(this, pred_Movie, l);
        }
        xs.takeEnd("movies");
    }

    public static Movies unmarshal(InputStream in)
        throws UnmarshalException
    {
        return unmarshal(XMLScanner.open(in));
    }

    public static Movies unmarshal(XMLScanner xs)
        throws UnmarshalException
    {
        return unmarshal(xs, newDispatcher());
    }

    public static Movies unmarshal(XMLScanner xs, Dispatcher d)
        throws UnmarshalException
    {
        return ((Movies) d.unmarshal(xs, (Movies.class)));
    }

    public boolean equals(Object ob) {
        if (this == ob) {
            return true;
        }
        if (!(ob instanceof Movies)) {
            return false;
        }
        Movies tob = ((Movies) ob);
        if (_Version!= null) {
            if (tob._Version == null) {
                return false;
            }
            if (!_Version.equals(tob._Version)) {
                return false;
            }
        } else {
            if (tob._Version!= null) {
                return false;
            }
        }
        if (_Movie!= null) {
            if (tob._Movie == null) {
                return false;
            }
            if (!_Movie.equals(tob._Movie)) {
                return false;
            }
        } else {
            if (tob._Movie!= null) {
                return false;
            }
        }
        return true;
    }

    public int hashCode() {
        int h = 0;
        h = ((127 *h)+((_Version!= null)?_Version.hashCode(): 0));
        h = ((127 *h)+((_Movie!= null)?_Movie.hashCode(): 0));
        return h;
    }

    public String toString() {
        StringBuffer sb = new StringBuffer("<<movies");
        if (_Version!= null) {
            sb.append(" version=");
            sb.append(_Version.toString());
        }
        if (_Movie!= null) {
            sb.append(" movie=");
            sb.append(_Movie.toString());
        }
        sb.append(">>");
        return sb.toString();
    }

    public static Dispatcher newDispatcher() {
        return Actor.newDispatcher();
    }


    private static class MoviePredicate
        implements PredicatedLists.Predicate
    {


        public void check(Object ob) {
            if (!(ob instanceof Movie)) {
                throw new InvalidContentObjectException(ob, (Movie.class));
            }
        }

    }

}