package com.ctc.wstx.evt;
import java.io.IOException;
import java.io.Writer;
import javax.xml.stream.Location;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.events.EntityDeclaration;
import org.codehaus.stax2.XMLStreamWriter2;
import org.codehaus.stax2.ri.evt.BaseEventImpl;
import com.ctc.wstx.ent.EntityDecl;
import com.ctc.wstx.exc.WstxIOException;
public abstract class WEntityDeclaration
extends BaseEventImpl
implements EntityDeclaration
{
public WEntityDeclaration(Location loc)
{
super(loc);
}
@Override
public abstract String getBaseURI();
@Override
public abstract String getName();
@Override
public abstract String getNotationName();
@Override
public abstract String getPublicId();
@Override
public abstract String getReplacementText();
@Override
public abstract String getSystemId();
@Override
public int getEventType() {
return ENTITY_DECLARATION;
}
public abstract void writeEnc(Writer w) throws IOException;
@Override
public void writeAsEncodedUnicode(Writer w) throws XMLStreamException
{
try {
writeEnc(w);
} catch (IOException ie) {
throw new WstxIOException(ie);
}
}
@Override
public void writeUsing(XMLStreamWriter2 w) throws XMLStreamException
{
throw new XMLStreamException("Can not write entity declarations using an XMLStreamWriter");
}
@Override
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())
;
}
@Override
public int hashCode()
{
return getName().hashCode();
}
}