⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 printdata.java

📁 Java写的ERP系统
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/******************************************************************************
 * The contents of this file are subject to the   Compiere License  Version 1.1
 * ("License"); You may not use this file except in compliance with the License
 * You may obtain a copy of the License at http://www.compiere.org/license.html
 * Software distributed under the License is distributed on an  "AS IS"  basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
 * the specific language governing rights and limitations under the License.
 * The Original Code is                  Compiere  ERP & CRM  Business Solution
 * The Initial Developer of the Original Code is Jorg Janke  and ComPiere, Inc.
 * Portions created by Jorg Janke are Copyright (C) 1999-2002 Jorg Janke, parts
 * created by ComPiere are Copyright (C) ComPiere, Inc.;   All Rights Reserved.
 * Contributor(s): ______________________________________.
 *****************************************************************************/
package org.compiere.print;

import java.io.*;
import java.util.*;

import org.w3c.dom.*;
import javax.xml.parsers.*;
import javax.xml.transform.*;
import javax.xml.transform.stream.*;
import javax.xml.transform.dom.*;
import org.xml.sax.*;
import org.xml.sax.helpers.*;

import org.compiere.*;
import org.compiere.util.*;

/**
 *	Print Data Structure.
 * 	Created by DataEngine
 *  A Structure has rows, wich contain elements.
 *  Elements can be end nodes (PrintDataElements) or data structures (PrintData).
 *  The row data is sparse - i.e. null if not existing.
 *  A Structure has optional meta info about content (PrintDataColumn).
 *
 * 	@author 	Jorg Janke
 * 	@version 	$Id: PrintData.java,v 1.13 2003/04/24 06:15:05 jjanke Exp $
 */
public class PrintData implements Serializable
{
	/**
	 * 	Data Parent Constructor
	 * 	@param name data element name
	 */
	public PrintData (Properties ctx, String name)
	{
		if (name == null)
			throw new IllegalArgumentException("PrintData - Name cannot be null");
		m_ctx = ctx;
		m_name = name;
	}	//	PrintData

	/**
	 * 	Data Parent Constructor
	 * 	@param name data element name
	 *  @param nodes ArrayList with nodes (content not checked)
	 */
	public PrintData (Properties ctx, String name, ArrayList nodes)
	{
		if (name == null)
			throw new IllegalArgumentException("PrintData - Name cannot be null");
		m_ctx = ctx;
		m_name = name;
		if (nodes != null)
			m_nodes = nodes;
	}	//	PrintData

	/**	Context						*/
	private Properties	m_ctx;
	/**	Data Structure Name			*/
	private String 		m_name;
	/** Data Structure rows			*/
	private ArrayList	m_rows = new ArrayList();
	/** Current Row Data Structure elements		*/
	private ArrayList	m_nodes = null;
	/**	Current Row					*/
	private int			m_row = -1;
	/**	List of Function Rows		*/
	private ArrayList	m_functionRows = new ArrayList();

	/**	Table has LevelNo			*/
	private boolean		m_hasLevelNo = false;
	/**	Level Number Indicator		*/
	private static final String	LEVEL_NO = "LEVELNO";

	/**	Optional Column Meta Data	*/
	private PrintDataColumn[]	m_columnInfo = null;
	/**	Optional sql				*/
	private String				m_sql = null;
	/** Optional TableName			*/
	private String				m_TableName = null;

	/**	XML Element Name			*/
	public static final String	XML_TAG = "compiereData";
	/**	XML Row Name				*/
	public static final String	XML_ROW_TAG = "row";
	/**	XML Attribute Name			*/
	public static final String	XML_ATTRIBUTE_NAME = "name";
	/** XML Attribute Count			*/
	public static final String	XML_ATTRIBUTE_COUNT = "count";
	/** XML Attribute Number		*/
	public static final String	XML_ATTRIBUTE_NO = "no";
	/** XML Attribute Function Row	*/
	public static final String	XML_ATTRIBUTE_FUNCTION_ROW = "function_row";

	/**
	 * 	Get Context
	 * 	@return context
	 */
	public Properties getCtx()
	{
		return m_ctx;
	}	//	getName

	/**
	 * 	Get Name
	 * 	@return name
	 */
	public String getName()
	{
		return m_name;
	}	//	getName

	/*************************************************************************/

	/**
	 * 	Set optional Column Info
	 * 	@param newInfo Column Info
	 */
	public void setColumnInfo (PrintDataColumn[] newInfo)
	{
		m_columnInfo = newInfo;
	}	//	setColumnInfo

	/**
	 * 	Get optional Column Info
	 * 	@return Column Info
	 */
	public PrintDataColumn[] getColumnInfo()
	{
		return m_columnInfo;
	}	//	getColumnInfo

	/**
	 * 	Set SQL (optional)
	 * 	@param sql SQL
	 */
	public void setSQL (String sql)
	{
		m_sql = sql;
	}	//	setSQL

	/**
	 * 	Get optional SQL
	 * 	@return SQL
	 */
	public String getSQL()
	{
		return m_sql;
	}	//	getSQL

	/**
	 * 	Set TableName (optional)
	 * 	@param TableName TableName
	 */
	public void setTableName (String TableName)
	{
		m_TableName = TableName;
	}	//	setTableName

	/**
	 * 	Get optional TableName
	 * 	@return TableName
	 */
	public String getTableName()
	{
		return m_TableName;
	}	//	getTableName

	/**
	 * 	String representation
	 * 	@return info
	 */
	public String toString()
	{
		StringBuffer sb = new StringBuffer("PrintData[");
		sb.append(m_name).append(",Rows=").append(m_rows.size());
		if (m_TableName != null)
			sb.append(",TableName=").append(m_TableName);
		sb.append("]");
		return sb.toString();
	}	//	toString


	/*************************************************************************/

	/**
	 * 	Returns true if no Nodes in row
	 * 	@return true if no Nodes in row
	 */
	public boolean isEmpty()
	{
		if (m_nodes == null)
			return true;
		return m_nodes.size() == 0;
	}	//	isEmpty

	/**
	 * 	Return Number of nodes in row
	 * 	@return number of nodes in row
	 */
	public int getNodeCount()
	{
		if (m_nodes == null)
			return 0;
		return m_nodes.size();
	}	//	getNodeCount

	/*************************************************************************/

	/**
	 * 	Add Row
	 *  @param functionRow true if function row
	 * 	@param levelNo	Line detail Level Number 0=Normal
	 */
	public void addRow (boolean functionRow, int levelNo)
	{
		m_nodes = new ArrayList();
		m_row = m_rows.size();
		m_rows.add (m_nodes);
		if (functionRow)
			m_functionRows.add(new Integer(m_row));
		if (m_hasLevelNo && levelNo != 0)
			addNode(new PrintDataElement(LEVEL_NO, new Integer(levelNo), DisplayType.Integer));
	}	//	addRow

	/**
	 * 	Set Row Index
	 * 	@param row row index
	 * 	@return true if success
	 */
	public boolean setRowIndex (int row)
	{
		if (row < 0 || row >= m_rows.size())
			return false;
		m_row = row;
		m_nodes = (ArrayList)m_rows.get(m_row);
		return true;
	}

	/**
	 * 	Set Row Index to next
	 * 	@return true if success
	 */
	public boolean setRowNext()
	{
		return setRowIndex(m_row+1);
	}	//	setRowNext

	/**
	 * 	Get Row Count
	 * 	@return row count
	 */
	public int getRowCount()
	{
		return m_rows.size();
	}	//	getRowCount

	/**
	 * 	Get Current Row Index
	 * 	@return row index
	 */
	public int getRowIndex()
	{
		return m_row;
	}	//	getRowIndex

	/**
	 * 	Is the Row a Function Row
	 * 	@param row row no
	 * 	@return true if function row
	 */
	public boolean isFunctionRow (int row)
	{
		return m_functionRows.contains(new Integer(row));
	}	//	isFunctionRow

	/**
	 * 	Is the current Row a Function Row
	 * 	@return true if function row
	 */
	public boolean isFunctionRow ()
	{
		return m_functionRows.contains(new Integer(m_row));
	}	//	isFunctionRow

	/**
	 * 	Is the current Row a Function Row
	 * 	@return true if function row
	 */
	public boolean isPageBreak ()
	{
		//	page break requires function and meta data
		if (isFunctionRow() && m_nodes != null)
		{
			for (int i = 0; i < m_nodes.size(); i++)
			{
				Object o = m_nodes.get(i);
				if (o instanceof PrintDataElement)
				{
					PrintDataElement pde = (PrintDataElement)o;
					if (pde.isPageBreak())
						return true;
				}
			}
		}
		return false;
	}	//	isPageBreak

	/**
	 * 	PrintData has Level No
	 * 	@param hasLevelNo true if sql contains LevelNo
	 */
	public void setHasLevelNo (boolean hasLevelNo)
	{
		m_hasLevelNo = hasLevelNo;
	}	//	hasLevelNo

	/**
	 * 	PrintData has Level No
	 * 	@return true if sql contains LevelNo
	 */
	public boolean hasLevelNo()
	{
		return m_hasLevelNo;
	}	//	hasLevelNo

	/**
	 * 	Get Line Level Number for current row
	 * 	@return line level no 0 = default
	 */
	public int getLineLevelNo ()
	{
		if (m_nodes == null || !m_hasLevelNo)
			return 0;

		for (int i = 0; i < m_nodes.size(); i++)
		{
			Object o = m_nodes.get (i);
			if (o instanceof PrintDataElement)
			{
				PrintDataElement pde = (PrintDataElement)o;
				if (LEVEL_NO.equals (pde.getColumnName()))
				{
					Integer ii = (Integer)pde.getValue();
					return ii.intValue();
				}
			}
		}
		return 0;
	}	//	getLineLevel

	/*************************************************************************/

	/**
	 * 	Add Parent node to Data Structure row
	 * 	@param parent parent
	 */
	public void addNode (PrintData parent)
	{
		if (parent == null)
			throw new IllegalArgumentException("PrintData.addNode - Parent cannot be null");
		if (m_nodes == null)
			addRow(false, 0);
		m_nodes.add (parent);
	}	//	addNode

	/**
	 * 	Add node to Data Structure row
	 * 	@param node node
	 */
	public void addNode (PrintDataElement node)
	{
		if (node == null)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -