FileDocCategorySizeDatePackage
Url.javaAPI DocExample6399Sun Jul 07 09:43:06 BST 2002javajaxb.generated.config

Url.java

package javajaxb.generated.config;

import java.io.IOException;
import java.io.InputStream;
import javax.xml.bind.Dispatcher;
import javax.xml.bind.DuplicateAttributeException;
import javax.xml.bind.Element;
import javax.xml.bind.InvalidAttributeException;
import javax.xml.bind.LocalValidationException;
import javax.xml.bind.MarshallableObject;
import javax.xml.bind.Marshaller;
import javax.xml.bind.MissingAttributeException;
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 Url
    extends MarshallableObject
    implements Element
{

    private String _Context;
    private String _ServletPrefix;
    private String _ServletName;

    public String getContext() {
        return _Context;
    }

    public void setContext(String _Context) {
        this._Context = _Context;
        if (_Context == null) {
            invalidate();
        }
    }

    public String getServletPrefix() {
        return _ServletPrefix;
    }

    public void setServletPrefix(String _ServletPrefix) {
        this._ServletPrefix = _ServletPrefix;
        if (_ServletPrefix == null) {
            invalidate();
        }
    }

    public String getServletName() {
        return _ServletName;
    }

    public void setServletName(String _ServletName) {
        this._ServletName = _ServletName;
        if (_ServletName == null) {
            invalidate();
        }
    }

    public void validateThis()
        throws LocalValidationException
    {
        if (_Context == null) {
            throw new MissingAttributeException("context");
        }
        if (_ServletPrefix == null) {
            throw new MissingAttributeException("servletPrefix");
        }
        if (_ServletName == null) {
            throw new MissingAttributeException("servletName");
        }
    }

    public void validate(Validator v)
        throws StructureValidationException
    {
    }

    public void marshal(Marshaller m)
        throws IOException
    {
        XMLWriter w = m.writer();
        w.start("url");
        w.attribute("context", _Context.toString());
        w.attribute("servletPrefix", _ServletPrefix.toString());
        w.attribute("servletName", _ServletName.toString());
        w.end("url");
    }

    public void unmarshal(Unmarshaller u)
        throws UnmarshalException
    {
        XMLScanner xs = u.scanner();
        Validator v = u.validator();
        xs.takeStart("url");
        while (xs.atAttribute()) {
            String an = xs.takeAttributeName();
            if (an.equals("context")) {
                if (_Context!= null) {
                    throw new DuplicateAttributeException(an);
                }
                _Context = xs.takeAttributeValue();
                continue;
            }
            if (an.equals("servletPrefix")) {
                if (_ServletPrefix!= null) {
                    throw new DuplicateAttributeException(an);
                }
                _ServletPrefix = xs.takeAttributeValue();
                continue;
            }
            if (an.equals("servletName")) {
                if (_ServletName!= null) {
                    throw new DuplicateAttributeException(an);
                }
                _ServletName = xs.takeAttributeValue();
                continue;
            }
            throw new InvalidAttributeException(an);
        }
        xs.takeEnd("url");
    }

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

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

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

    public boolean equals(Object ob) {
        if (this == ob) {
            return true;
        }
        if (!(ob instanceof Url)) {
            return false;
        }
        Url tob = ((Url) ob);
        if (_Context!= null) {
            if (tob._Context == null) {
                return false;
            }
            if (!_Context.equals(tob._Context)) {
                return false;
            }
        } else {
            if (tob._Context!= null) {
                return false;
            }
        }
        if (_ServletPrefix!= null) {
            if (tob._ServletPrefix == null) {
                return false;
            }
            if (!_ServletPrefix.equals(tob._ServletPrefix)) {
                return false;
            }
        } else {
            if (tob._ServletPrefix!= null) {
                return false;
            }
        }
        if (_ServletName!= null) {
            if (tob._ServletName == null) {
                return false;
            }
            if (!_ServletName.equals(tob._ServletName)) {
                return false;
            }
        } else {
            if (tob._ServletName!= null) {
                return false;
            }
        }
        return true;
    }

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

    public String toString() {
        StringBuffer sb = new StringBuffer("<<url");
        if (_Context!= null) {
            sb.append(" context=");
            sb.append(_Context.toString());
        }
        if (_ServletPrefix!= null) {
            sb.append(" servletPrefix=");
            sb.append(_ServletPrefix.toString());
        }
        if (_ServletName!= null) {
            sb.append(" servletName=");
            sb.append(_ServletName.toString());
        }
        sb.append(">>");
        return sb.toString();
    }

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

}