jadex.xml.AbstractInfo Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jadex-xml Show documentation
Show all versions of jadex-xml Show documentation
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.
package jadex.xml;
import java.util.Comparator;
import jadex.commons.IFilter;
import jadex.commons.SReflect;
import jadex.xml.stax.QName;
/**
* Superclass for XML object type/link infos.
*/
public class AbstractInfo
{
//-------- attributes --------
protected XMLInfo xmlinfo;
/** The xml path elements without tag. */
protected QName[] xmlpathelementswithouttag;
/** The info id. */
protected int id;
/** The id cnt. */
protected static int idcnt;
//-------- constructors --------
/**
* Create an abstract OAV info.
*/
public AbstractInfo(XMLInfo xmlinfo)
{
this.xmlinfo = xmlinfo;
synchronized(AbstractInfo.class)
{
this.id = idcnt++;
}
}
//-------- methods --------
/**
* Get the xmlinfo.
* @return The xmlinfo.
*/
public XMLInfo getXMLInfo()
{
return xmlinfo;
}
/**
* Get the xmlpath
*/
public String getXMLPath()
{
return xmlinfo!=null? xmlinfo.getXMLPath(): null;
}
/**
* Get the xml tag
*/
public QName getXMLTag()
{
return xmlinfo!=null && xmlinfo.getXMLPathElements()!=null? xmlinfo.getXMLPathElements()[xmlinfo.getXMLPathElements().length-1]: null;
}
/**
* Get the xmlpath as string array.
* @return The xmlpath.
*/
public QName[] getXMLPathElements()
{
return xmlinfo!=null && xmlinfo.getXMLPathElements()!=null? xmlinfo.getXMLPathElements(): null;
}
/**
* Get the xml path without element.
*/
public QName[] getXMLPathElementsWithoutElement()
{
if(xmlpathelementswithouttag==null && xmlinfo!=null)
{
xmlpathelementswithouttag = new QName[xmlinfo.getXMLPathElements().length-1];
System.arraycopy(xmlinfo.getXMLPathElements(), 0, xmlpathelementswithouttag, 0, xmlinfo.getXMLPathElements().length-1);
}
return xmlpathelementswithouttag;
}
/**
* Get the xml path without element.
* /
public String getXMLPathWithoutElement()
{
String ret = "";
String xmlpath = getXMLPath();
if(xmlpath!=null)
{
int idx = xmlpath.lastIndexOf("/");
if(idx!=-1)
ret = xmlpath.substring(0, idx-1);
}
return ret;
}*/
/**
* Get the path depth.
*/
public int getXMLPathDepth()
{
return xmlinfo!=null && xmlinfo.getXMLPathElements()!=null? xmlinfo.getXMLPathElements().length-1: 0;
}
/**
* Get the filter.
* @return the filter
*/
public IFilter
© 2015 - 2025 Weber Informatics LLC | Privacy Policy