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

jadex.xml.stax.JadexLocationWrapper Maven / Gradle / Ivy

package jadex.xml.stax;

/**
 * Wraps a jadex.xml.ILocation Object to provide the javax.xml.stream.Location
 * API.
 */
public class JadexLocationWrapper implements javax.xml.stream.Location
{
	// -------- attributes --------
	/** wrapped location object */
	private ILocation location;

	// -------- constructors --------

	/**
	 * Constructor
	 * 
	 * @param loc
	 *            The location to be wrapped.
	 */
	public JadexLocationWrapper(ILocation loc)
	{
		this.location = loc;
	}

	// -------- methods --------

	/**
	 * Return the line number where the current event ends, returns -1 if none
	 * is available.
	 * 
	 * @return the current line number
	 */
	public int getLineNumber()
	{
		return location.getLineNumber();
	}

	/**
	 * Return the column number where the current event ends, returns -1 if none
	 * is available.
	 * 
	 * @return the current column number
	 */
	public int getColumnNumber()
	{
		return location.getColumnNumber();
	}

	/**
	 * Return the byte or character offset into the input source this location
	 * is pointing to. If the input source is a file or a byte stream then this
	 * is the byte offset into that stream, but if the input source is a
	 * character media then the offset is the character offset. Returns -1 if
	 * there is no offset available.
	 * 
	 * @return the current offset
	 */
	public int getCharacterOffset()
	{
		return location.getCharacterOffset();
	}

	/**
	 * Returns the public ID of the XML
	 * 
	 * @return the public ID, or null if not available
	 */
	public String getPublicId()
	{
		return location.getPublicId();
	}

	/**
	 * Returns the system ID of the XML
	 * 
	 * @return the system ID, or null if not available
	 */
	public String getSystemId()
	{
		return location.getSystemId();
	}

	/**
	 * Static method to wrap a Location object.
	 * 
	 * @param loc
	 * @return Wrapped Object
	 */
	public static javax.xml.stream.Location fromLocation(ILocation loc)
	{
		return new JadexLocationWrapper(loc);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy