FileDocCategorySizeDatePackage
Connection.javaAPI DocExample4681Sun Jul 07 09:43:06 BST 2002javajaxb.generated.config

Connection.java

package javajaxb.generated.config;

import java.io.IOException;
import java.io.InputStream;
import javajaxb.generated.config.Host;
import javajaxb.generated.config.Url;
import javax.xml.bind.Dispatcher;
import javax.xml.bind.InvalidAttributeException;
import javax.xml.bind.LocalValidationException;
import javax.xml.bind.MarshallableRootElement;
import javax.xml.bind.Marshaller;
import javax.xml.bind.MissingContentException;
import javax.xml.bind.RootElement;
import javax.xml.bind.StructureValidationException;
import javax.xml.bind.UnmarshalException;
import javax.xml.bind.Unmarshaller;
import javax.xml.bind.Validator;
import javax.xml.marshal.XMLScanner;
import javax.xml.marshal.XMLWriter;


public class Connection
    extends MarshallableRootElement
    implements RootElement
{

    private Host _Host;
    private Url _Url;

    public Host getHost() {
        return _Host;
    }

    public void setHost(Host _Host) {
        this._Host = _Host;
        if (_Host == null) {
            invalidate();
        }
    }

    public Url getUrl() {
        return _Url;
    }

    public void setUrl(Url _Url) {
        this._Url = _Url;
        if (_Url == null) {
            invalidate();
        }
    }

    public void validateThis()
        throws LocalValidationException
    {
        if (_Host == null) {
            throw new MissingContentException("host");
        }
        if (_Url == null) {
            throw new MissingContentException("url");
        }
    }

    public void validate(Validator v)
        throws StructureValidationException
    {
        v.validate(_Host);
        v.validate(_Url);
    }

    public void marshal(Marshaller m)
        throws IOException
    {
        XMLWriter w = m.writer();
        w.start("connection");
        m.marshal(_Host);
        m.marshal(_Url);
        w.end("connection");
    }

    public void unmarshal(Unmarshaller u)
        throws UnmarshalException
    {
        XMLScanner xs = u.scanner();
        Validator v = u.validator();
        xs.takeStart("connection");
        while (xs.atAttribute()) {
            String an = xs.takeAttributeName();
            throw new InvalidAttributeException(an);
        }
        _Host = ((Host) u.unmarshal());
        _Url = ((Url) u.unmarshal());
        xs.takeEnd("connection");
    }

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

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

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

    public boolean equals(Object ob) {
        if (this == ob) {
            return true;
        }
        if (!(ob instanceof Connection)) {
            return false;
        }
        Connection tob = ((Connection) ob);
        if (_Host!= null) {
            if (tob._Host == null) {
                return false;
            }
            if (!_Host.equals(tob._Host)) {
                return false;
            }
        } else {
            if (tob._Host!= null) {
                return false;
            }
        }
        if (_Url!= null) {
            if (tob._Url == null) {
                return false;
            }
            if (!_Url.equals(tob._Url)) {
                return false;
            }
        } else {
            if (tob._Url!= null) {
                return false;
            }
        }
        return true;
    }

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

    public String toString() {
        StringBuffer sb = new StringBuffer("<<connection");
        if (_Host!= null) {
            sb.append(" host=");
            sb.append(_Host.toString());
        }
        if (_Url!= null) {
            sb.append(" url=");
            sb.append(_Url.toString());
        }
        sb.append(">>");
        return sb.toString();
    }

    public static Dispatcher newDispatcher() {
        Dispatcher d = new Dispatcher();
        d.register("connection", (Connection.class));
        d.register("host", (Host.class));
        d.register("url", (Url.class));
        d.freezeElementNameMap();
        return d;
    }

}