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

jadex.xml.stax.XmlUtil 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: 3.0.117
Show newest version
package jadex.xml.stax;

/**
 *  Class holding stax-compatible constants and
 *  utility functions.
 *
 */
public class XmlUtil
{
	/**
	   * Indicates an event is a start element.
	   */
	  public static final int START_ELEMENT = 1; // = javax.xml.stream.XMLStreamConstants.START_ELEMENT
	  
	  /**
	   * Indicates an event is an end element.
	   */
	  public static final int END_ELEMENT = 2; // = javax.xml.stream.XMLStreamConstants.END_ELEMENT
	  
	  /**
	   * Indicates an event is characters.
	   */
	  public static final int CHARACTERS = 4; // = javax.xml.stream.XMLStreamConstants.CHARACTERS

	  public static final int COMMENT = 5; // = javax.xml.stream.XMLStreamConstants.COMMENT

	  public static final int CDATA = 12; // = javax.xml.stream.XMLStreamConstants.CDATA

	/**
		 *  Unescapes strings for xml.
		 */
		public static final String unescapeString(String string)
		{
			StringBuilder ret = new StringBuilder();
			boolean escapemode = false;
			for (int i = 0; i < string.length(); ++i)
			{
				String c = string.substring(i, i + 1);
				if (escapemode)
				{
					if (c.equals("n"))
					{
						ret.append("\n");
					}
					else
					{
						ret.append(c);
					}
					escapemode = false;
				}
				else
				{
					if (c.equals("\\"))
					{
						escapemode = true;
					}
					else
					{
						ret.append(c);
					}
				}
			}
			return ret.toString();
		}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy