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.Actor;
import javax.xml.bind.Dispatcher;
import javax.xml.bind.Element;
import javax.xml.bind.InvalidAttributeException;
import javax.xml.bind.InvalidContentObjectException;
import javax.xml.bind.LocalValidationException;
import javax.xml.bind.MarshallableObject;
import javax.xml.bind.Marshaller;
import javax.xml.bind.MissingContentException;
import javax.xml.bind.PredicatedLists;
import javax.xml.bind.PredicatedLists.Predicate;
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 Cast
extends MarshallableObject
implements Element
{
private List _Actor = PredicatedLists.createInvalidating(this, new ActorPredicate(), new ArrayList());
private PredicatedLists.Predicate pred_Actor = new ActorPredicate();
public List getActor() {
return _Actor;
}
public void deleteActor() {
_Actor = null;
invalidate();
}
public void emptyActor() {
_Actor = PredicatedLists.createInvalidating(this, pred_Actor, new ArrayList());
}
public void validateThis()
throws LocalValidationException
{
if (_Actor == null) {
throw new MissingContentException("actor");
}
}
public void validate(Validator v)
throws StructureValidationException
{
for (Iterator i = _Actor.iterator(); i.hasNext(); ) {
v.validate(((ValidatableObject) i.next()));
}
}
public void marshal(Marshaller m)
throws IOException
{
XMLWriter w = m.writer();
w.start("cast");
for (Iterator i = _Actor.iterator(); i.hasNext(); ) {
m.marshal(((MarshallableObject) i.next()));
}
w.end("cast");
}
public void unmarshal(Unmarshaller u)
throws UnmarshalException
{
XMLScanner xs = u.scanner();
Validator v = u.validator();
xs.takeStart("cast");
while (xs.atAttribute()) {
String an = xs.takeAttributeName();
throw new InvalidAttributeException(an);
}
{
List l = PredicatedLists.create(this, pred_Actor, new ArrayList());
while (xs.atStart("actor")) {
l.add(((Actor) u.unmarshal()));
}
_Actor = PredicatedLists.createInvalidating(this, pred_Actor, l);
}
xs.takeEnd("cast");
}
public static Cast unmarshal(InputStream in)
throws UnmarshalException
{
return unmarshal(XMLScanner.open(in));
}
public static Cast unmarshal(XMLScanner xs)
throws UnmarshalException
{
return unmarshal(xs, newDispatcher());
}
public static Cast unmarshal(XMLScanner xs, Dispatcher d)
throws UnmarshalException
{
return ((Cast) d.unmarshal(xs, (Cast.class)));
}
public boolean equals(Object ob) {
if (this == ob) {
return true;
}
if (!(ob instanceof Cast)) {
return false;
}
Cast tob = ((Cast) ob);
if (_Actor!= null) {
if (tob._Actor == null) {
return false;
}
if (!_Actor.equals(tob._Actor)) {
return false;
}
} else {
if (tob._Actor!= null) {
return false;
}
}
return true;
}
public int hashCode() {
int h = 0;
h = ((127 *h)+((_Actor!= null)?_Actor.hashCode(): 0));
return h;
}
public String toString() {
StringBuffer sb = new StringBuffer("<<cast");
if (_Actor!= null) {
sb.append(" actor=");
sb.append(_Actor.toString());
}
sb.append(">>");
return sb.toString();
}
public static Dispatcher newDispatcher() {
return Actor.newDispatcher();
}
private static class ActorPredicate
implements PredicatedLists.Predicate
{
public void check(Object ob) {
if (!(ob instanceof Actor)) {
throw new InvalidContentObjectException(ob, (Actor.class));
}
}
}
}
|