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

jadex.xml.writer.WriteObjectInfo 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.writer;

import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import jadex.commons.collection.Tree;
import jadex.commons.collection.TreeNode;
import jadex.xml.stax.QName;

/**
 *  Info for writing an object.
 */
public class WriteObjectInfo
{
	//-------- attributes --------
	
	/** The comment. */
	protected String comment;
	
	/** The attribute values. */
	protected Map attributes;

	/** The content. */
	protected String content;
	
	/** The subobjects tree. */
	protected Tree subobjects;
	
	//-------- methods --------

	/**
	 *  Get the comment.
	 *  @return The comment.
	 */
	public String getComment()
	{
		return this.comment;
	}

	/**
	 *  Set the comment.
	 *  @param comment The comment to set.
	 */
	public void setComment(String comment)
	{
		this.comment = comment;
	}
	
	/**
	 *  Get the attributes.
	 *  @return The attributes.
	 */
	public Map getAttributes()
	{
		return this.attributes;
	}

	/**
	 *  Add an attribute.
	 *  @param name The name.
	 *  @param value The value.
	 */
	public void addAttribute(Object name, String value)
	{
		if(attributes==null)
			attributes = new LinkedHashMap();
		else if(attributes.containsKey(name))
			throw new RuntimeException("Duplicate attribute: "+name);
		attributes.put(name, value);
	}

	/**
	 *  Get the content.
	 *  @return The content.
	 */
	public String getContent()
	{
		return this.content;
	}
	
	/**
	 *  Set the content.
	 *  @param content The content to set.
	 */
	public void setContent(String content)
	{
		this.content = content;
	}

	/**
	 *  Get the subobjects.
	 *  @return The subobjects.
	 */
	public Tree getSubobjects()
	{
		return this.subobjects;
	}
	
	/**
	 *  Add a subobject.
	 */
	public void addSubobject(QName[] pathname, Object subobject, boolean flatten)
	{
//		System.out.println("added: "+SUtil.arrayToString(pathname)+" "+subobject+" "+flatten);
		if(subobjects==null)
			subobjects = new Tree();
		
		// Build the path in the tree (on each level a decision about flattening needs to be done)
		TreeNode node = subobjects.getRootNode();
		for(int i=0; i children = node.getChildren();
			if(children!=null)
			{
				for(int i=0; i




© 2015 - 2025 Weber Informatics LLC | Privacy Policy