org.codehaus.stax2.ri.evt.EntityReferenceEventImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of swagger-all Show documentation
Show all versions of swagger-all Show documentation
swagger-all is a rebundled verison of Swagger as one OSGi bundle.
The newest version!
package org.codehaus.stax2.ri.evt;
import java.io.IOException;
import java.io.Writer;
import javax.xml.stream.*;
import javax.xml.stream.events.EntityReference;
import javax.xml.stream.events.EntityDeclaration;
import org.codehaus.stax2.XMLStreamWriter2;
public class EntityReferenceEventImpl
extends BaseEventImpl
implements EntityReference
{
protected final EntityDeclaration mDecl;
public EntityReferenceEventImpl(Location loc, EntityDeclaration decl)
{
super(loc);
mDecl = decl;
}
public EntityReferenceEventImpl(Location loc, String name)
{
super(loc);
// note: location will be incorrect...
mDecl = new EntityDeclarationEventImpl(loc, name);
}
public EntityDeclaration getDeclaration()
{
return mDecl;
}
public String getName()
{
return mDecl.getName();
}
/*
///////////////////////////////////////////
// Implementation of abstract base methods
///////////////////////////////////////////
*/
public int getEventType() {
return ENTITY_REFERENCE;
}
public boolean isEntityReference() {
return true;
}
public void writeAsEncodedUnicode(Writer w)
throws XMLStreamException
{
try {
w.write('&');
w.write(getName());
w.write(';');
} catch (IOException ie) {
throwFromIOE(ie);
}
}
public void writeUsing(XMLStreamWriter2 w) throws XMLStreamException
{
w.writeEntityRef(getName());
}
/*
///////////////////////////////////////////
// Standard method impl
///////////////////////////////////////////
*/
public boolean equals(Object o)
{
if (o == this) return true;
if (o == null) return false;
if (!(o instanceof EntityReference)) return false;
EntityReference other = (EntityReference) o;
return getName().equals(other.getName());
}
public int hashCode()
{
return getName().hashCode();
}
}