org.adempiere.legacy.apache.ecs.xml.XML Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tools Show documentation
Show all versions of tools Show documentation
A tool used for all ADempiere project ans first base library.
/******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
* This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
* For the text or an alternative of this public license, you may reach us *
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
* or via [email protected] or http://www.compiere.org/license.html *
*****************************************************************************/
package org.adempiere.legacy.apache.ecs.xml;
import org.adempiere.legacy.apache.ecs.Element;
import org.adempiere.legacy.apache.ecs.Filter;
import org.adempiere.legacy.apache.ecs.MultiPartElement;
import org.adempiere.legacy.apache.ecs.Printable;
import org.adempiere.legacy.apache.ecs.StringElement;
/**
* This class creates a generic <> tag.
*
* @version $Id: XML.java,v 1.2 2006/07/30 00:54:02 jjanke Exp $
* @author Stephan Nagy
* @author Jon S. Stevens
*/
public class XML extends MultiPartElement
implements Printable
{
/**
*
*/
private static final long serialVersionUID = 7562733665733930129L;
/**
* Default constructor use set* Methods. With this name.
*
* @param element_type
* The name of this element.
*/
public XML (String element_type)
{
setElementType (element_type);
}
/**
* Construct a new XML element with this name,
* and specify if it needs the element tag closed.
*
* @param element_type
* The name of this element.
* @param close
* Should it have a closing tag
*/
public XML (String element_type, boolean close)
{
setElementType (element_type);
setNeedClosingTag (close);
}
/**
* Construct a new XML element with this name, and specify a filter for it.
*
* @param element_type
* The name of this element.
* @param filter
* a new Filter for this element override the default.
*/
public XML (String element_type, Filter filter)
{
setElementType (element_type);
setFilter (filter);
}
/**
* Construct a new XML element with this name, and specify a filter for it.
*
* @param element_type
* The name of this element.
* @param close
* Should it have a closing tag
* @param filter
* Should this element be filtered?
*/
public XML (String element_type, boolean close, boolean filter)
{
setElementType (element_type);
setNeedClosingTag (close);
setFilterState (filter);
}
/**
* Construct a new XML element with this name, and specify a filter for it.
*
* @param element_type
* The name of this element.
* @param close
* Should it have a closing tag
* @param filter
* a new Filter for this element override the default.
*/
public XML (String element_type, boolean close, Filter filter)
{
setElementType (element_type);
setNeedClosingTag (close);
setFilter (filter);
}
/**
* Add a new attribute to this XML tag.
*
* @param attribute
* the attribute name
* @param attribute_value
* the value of the attribute set this to
* "ECS_NO_ATTRIBUTE_VALUE"
if this attribute
* doesn't take a value.
*/
public XML addXMLAttribute (String attribute, String attribute_value)
{
addAttribute (attribute, attribute_value);
return (this);
}
/**
* Add an element to the valuie of <>VALUE</>
*
* @param element
* the value of <>VALUE</>
*/
public XML addElement (String element)
{
addElementToRegistry (element);
return (this);
}
/**
* Adds an Element to the element.
*
* @param hashcode
* name of element for hash table
* @param element
* Adds an Element to the element.
*/
public XML addElement (String hashcode, Element element)
{
addElementToRegistry (hashcode, element);
return (this);
}
/**
* Adds an Element to the element.
*
* @param hashcode
* name of element for hash table
* @param element
* Adds an Element to the element.
*/
public XML addElement (String hashcode, String element)
{
addElementToRegistry (hashcode, element);
return (this);
}
/**
* Add an element to the valuie of <>VALUE</>
*
* @param element
* the value of <>VALUE</>
*/
public XML addElement (Element element)
{
addElementToRegistry (element);
return (this);
}
/**
* Removes an Element from the element.
*
* @param hashcode
* the name of the element to be removed.
*/
public XML removeElement (String hashcode)
{
removeElementFromRegistry (hashcode);
return (this);
}
public boolean getNeedLineBreak ()
{
boolean linebreak = true;
java.util.Enumeration en = elements();
// if this tag has one child, and it's a String, then don't
// do any linebreaks to preserve whitespace
while (en.hasMoreElements ())
{
Object obj = en.nextElement ();
if (obj instanceof StringElement)
{
linebreak = false;
break;
}
}
return linebreak;
}
public boolean getBeginEndModifierDefined ()
{
boolean answer = false;
if (!this.getNeedClosingTag ())
answer = true;
return answer;
}
public char getBeginEndModifier ()
{
return '/';
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy