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

jadex.xml.writer.WriteObjectInfo Maven / Gradle / Ivy

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 - 2024 Weber Informatics LLC | Privacy Policy