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

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

Go to download

Jadex XML is an XML data binding framework for Java and also for other representations. The main idea of Jadex XML is that neither the XML-Schema on the one side nor the Java classes on the other side should define other binding. Instead, a separate mapping between both is used as a mediation. This allows designing the XML representation independent of the Java side but still being able to connect both as desired. This idea was first put forward by the JiBX data binding framework. Jadex XML pushes it further by combining it with the configuration by exception principle. The framework can detect obvious correspondences between both sides automatically and only needs configuration information when translations are necessary. The configuration information is currently specified directly in form of Java configuration classes.

There is a newer version: 4.0.267
Show newest version
package jadex.xml.stax;

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

	// -------- constructors --------
	
	/**
	 * Constructor.
	 * @param loc The location to be wrapped.
	 */
	public StaxLocationWrapper(javax.xml.stream.Location 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 The location object to be wrapped
	 * @return the wrapped Location
	 */
	public static ILocation fromLocation(javax.xml.stream.Location loc)
	{
		return new StaxLocationWrapper(loc);
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy