All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.codehaus.stax2.ri.evt.EntityDeclarationEventImpl Maven / Gradle / Ivy

Go to download

Stax2 API is an extension to basic Stax 1.0 API that adds significant new functionality, such as full-featured bi-direction validation interface and high-performance Typed Access API.

There is a newer version: 4.2.2
Show newest version
package org.codehaus.stax2.ri.evt;

import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;

import javax.xml.stream.*;
import javax.xml.stream.events.EntityDeclaration;

import org.codehaus.stax2.XMLStreamWriter2;

/**
 * Simple base implementation that can be used either as a placeholder,
 * or a base for 'real' entity declaration implementations.
 */
public class EntityDeclarationEventImpl
    extends BaseEventImpl
    implements EntityDeclaration
{
    protected final String mName;

    public EntityDeclarationEventImpl(Location loc, String name)
    {
        super(loc);
        mName = name;
    }

    /*
    ///////////////////////////////////////////
    // EntityDeclaration
    ///////////////////////////////////////////
     */

    public String getBaseURI()
    {
        return "";
    }

    public String getName()
    {
        return mName;
    }

    public String getNotationName()
    {
        return null;
    }

    public String getPublicId()
    {
        return null;
    }

    public String getReplacementText()
    {
        return null;
    }

    public String getSystemId()
    {
        return null;
    }

    /*
    ///////////////////////////////////////////
    // Implementation of abstract base methods
    ///////////////////////////////////////////
     */

    public int getEventType() {
        return ENTITY_DECLARATION;
    }

    public void writeAsEncodedUnicode(Writer w)
        throws XMLStreamException
    {
        try {
            w.write("");
        } catch (IOException ie) {
            throwFromIOE(ie);
        }
    }

    public void writeUsing(XMLStreamWriter2 w) throws XMLStreamException
    {
        // Really shouldn't be output. But if we must...
        StringWriter strw = new StringWriter();
        writeAsEncodedUnicode(strw);
        w.writeRaw(strw.toString());
    }

    /*
    ///////////////////////////////////////////
    // Standard method impl
    ///////////////////////////////////////////
     */

    public boolean equals(Object o)
    {
        if (o == this) return true;
        if (o == null) return false;

        if (!(o instanceof EntityDeclaration)) return false;

        EntityDeclaration other = (EntityDeclaration) o;
        return stringsWithNullsEqual(getName(), other.getName())
            && stringsWithNullsEqual(getBaseURI(), other.getBaseURI())
            && stringsWithNullsEqual(getNotationName(), other.getNotationName())
            && stringsWithNullsEqual(getPublicId(), other.getPublicId())
            && stringsWithNullsEqual(getReplacementText(), other.getReplacementText())
            && stringsWithNullsEqual(getSystemId(), other.getSystemId())
            ;
    }

    public int hashCode()
    {
        // Since we don't have much data, this is easy...
        return mName.hashCode();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy