HEC-DSS can store text information in two forms: a text string and / or a text table (a table of strings). Text is often used for saving messages, comments or other information. For example, the entire user manual for DSSUTL was stored as text records in a DSS file, and the appropriate text displayed when a user request help on an item.

warning:  DSS  version 6 supports simple text records, and DSS version 7 adds support for text tables.


For the Java implementation, "text" is a regular String, and a text table is a double-dimensioned String array (e.g., String[number rows][number columns]). Since the low-level code for HEC-DSS is written in the C programming language, HEC-DSS stores null terminated strings. There is no limit on the number of characters in a text or text table record (although one needs to be careful with memory) nor a limit on the number of characters per table cell. Table cells do not have to have the same number of characters.
A text table essentially follows a similar convention to paired data. The first column is called the independent column and the remaining are the dependent columns. A text string can be stored with a text table, if desired. A subset to the text table is a "text list". A text list is simply a text table with only one column (e.g., textTable[20][1]) and shows up as a list of Strings


HecDssText is a class used for storing and retrieving text in HEC-DSS. HecDssText follows the conventions of the other HEC-DSS classes, where write() and read() are used to store and retrieve data:
The primary functions for HecDssText are:

public int setDSSFileName (String dssFileName)
public int write (TextContainer textContainer)
public int read(TextContainer textContainer)
public void done()
JAVA

Where zero is returned on a successful call and a negative value for unsuccessful. Do not reuse objects or containers; create a new one for every write or read.
Text tables can have lables for the column headers. If labels are used, they must have the same dimension as the number of columns in the textTable.
The primary functions for TextContainer are:

public void setText(String text)
public void setTextTable(String textTable[][])

public void setLabels(String labels[])

public boolean hasText()
public boolean hasTextTable()
public String getText()
public String[][] getTextTable()

public String[] getLabels()
JAVA

Text and text tables may be displayed and edited using a hec.dataTable.TextTable. This object is similar to the other HEC display objects. The primary functions for hec.dataTable.TextTable are:

public frame hec.dataTable.TextTable(JFrame parent, TextContainer textContainer)
public void setSize(int width, int height)
public void setVisible(boolean b)
public void setEditable(boolean b)
public boolean isModified()
public TextContainer saveToContainer()
JAVA


The display TextTable frame is the same frame used in DSSVue, in which the user can edit and save text.

worddavec6d4af62ed90e2132c28b9d97a9075c.png


Text Tables


import javax.swing.UIManager;

import hec.dataTable.TextTable;
import hec.heclib.dss.*;
import hec.io.TextContainer;

//  Write a text table
public class ExampleText2 {

	public static void main (String args[])  {
		String alpha = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRTSUVWXYZ";
		try {
			javax.swing.UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		}
		catch (Exception ignore) {}
		
		HecDssText dssText1 = new HecDssText();
		dssText1.setDSSFileName("C:/temp/Example7.dss");		
		TextContainer textContainer1 = new TextContainer();	
		textContainer1.setName("/Group/Location/Text Table/d/e/f/");		
		String textTable[][] = new String[20][5];
		for (int i=0; i<20; i++) {
			int n = i/25;
			n = i - (n*25) + 1;			
			for (int j=0; j<5; j++) {
				textTable[i][j] = alpha.substring((j+2), (n+8));
			}
		}
		textContainer1.setTextTable(textTable);
		
		//  Gen column headers
		String labels[] = new String[5];
		for (int j=0; j<5; j++) {
			labels[j] = "Col " + Integer.toString(j+1);
		}
		textContainer1.setLabels(labels);
		
		textContainer1.setText(alpha + "\n" + alpha + "\n" + alpha + "\n" + alpha);	
		
		int status = dssText1.write(textContainer1);
		dssText1.done();
		if (status < 0) return;	
		
		HecDssText dssText2 = new HecDssText();
		dssText2.setDSSFileName("C:/temp/Example7.dss");		
		TextContainer textContainer2 = new TextContainer();	
		textContainer2.setName("/Group/Location/Text Table/d/e/f/");
		status = dssText2.read(textContainer2);
		dssText2.done();
		if (status < 0) return;
		if (textContainer2.hasText()) {
			System.out.println("text ==>" + textContainer2.getText() + "<==");
		}

		if (textContainer2.hasTextTable()) {
			TextTable frame = new TextTable(null, textContainer2);							
			frame.setSize(800, 600); 
			frame.setVisible(true);	
		}
	}
}


JAVA