com.topologi.diffx.event.impl.DiffXEventBase Maven / Gradle / Ivy
Show all versions of docx4j Show documentation
/*
* This file is part of the DiffX library.
*
* For licensing information please see the file license.txt included in the release.
* A copy of this licence can also be found at
* http://www.opensource.org/licenses/artistic-license-2.0.php
*/
package com.topologi.diffx.event.impl;
import com.topologi.diffx.event.DiffXEvent;
import com.topologi.diffx.xml.esc.XMLEscape;
import com.topologi.diffx.xml.esc.XMLEscapeUTF8;
/**
* A base class for DiffX events.
*
*
* This class is purely provided for convenience and consistency, it is best, althouhg not strictly
* required, that most DiffXEvent
implementations extend this class.
*
* @author Christophe Lauret
* @version 3 February 2005
*/
abstract class DiffXEventBase implements DiffXEvent {
/**
* For use by the events to escape XML chars.
*/
static final XMLEscape ESC = XMLEscapeUTF8.UTF8_ESCAPE;
/**
*
*/
int weight = 1;
/**
* {@inheritDoc}
*/
@Override
public abstract int hashCode();
/**
* {@inheritDoc}
*/
@Override
public abstract boolean equals(DiffXEvent e);
/**
* Invokes the {@link DiffXEvent#equals(DiffXEvent)} method if the specified object if not
* null
and is an instance of {@link DiffXEvent}.
*
* @param o The object to compare.
*
* @return true
if the specified object is equal;
* false
otherwise.
*/
@Override
public final boolean equals(Object o) {
if (o == null)
return false;
if (!(o instanceof DiffXEvent))
return false;
return equals((DiffXEvent) o);
}
@Override
public String toXML() {
return this.toXML(new StringBuffer()).toString();
}
@Override
public int getWeight() {
return this.weight;
}
@Override
public void setWeight(int weight) {
this.weight = weight;
}
}