FileDocCategorySizeDatePackage
StringArray.javaAPI DocExample10519Mon Jul 03 19:15:30 BST 2000None

StringArray

public class StringArray extends Object
Purpose: A vector of Strings
version
1.0 December 96
author
Ilya Tilevich

Fields Summary
private Vector
m_Vector
Constructors Summary
public StringArray(int iCapacity, int iIncr)
Purpose: Constructor

param
iCapacity the initial capacity
param
iIncr the increment

               m_Vector = new Vector(iCapacity, iIncr);
      
public StringArray(int iCapacity)
Purpose: Constructor

param
iCapacity the initial capacity

                m_Vector = new Vector(iCapacity);
       
public StringArray()
Purpose: Constructor

		m_Vector = new Vector();
       
Methods Summary
public synchronized voidWriteOut(java.io.DataOutputStream dos)
Purpose: Writes this object to DataOutputStream

		
		Enumeration enum = elements();
		
		try{
			for(;enum.hasMoreElements();){
				 String str = (String)(enum.nextElement());
				 dos.writeBytes(str);
				 dos.writeByte('\n");
			}
		}
		catch(IOException e){System.out.println("IO error in StringArray WriteOut"); }
	
	
public synchronized voidWriteOut()
purpose: Writes this object to stdio

  //to stdio
		
		Enumeration enum = elements();
		
		for(;enum.hasMoreElements();){
			 String str = (String)(enum.nextElement());
			 System.out.println(str);
        }
	 
	
public synchronized voidaddElement(java.lang.String obj)
Purpose: adds an element to the array

param
obj the Stirng to add

              m_Vector.addElement(obj);
 	
public synchronized voidappendToLastString(java.lang.String strToAppend)
Purpose: appends strToAppend to the last String added to the array if no string were added works like addElement()

param
strToAppend

		if(size() <= 0)
			addElement(strToAppend);
		else{
			String str = new String (elementAt(size()-1));
			str += strToAppend;
			setElementAt(str, m_Vector.size()-1);
		}
	
public synchronized java.lang.Objectclone()
Purpose: clones the array

              return m_Vector.clone();
	
public booleancontains(java.lang.String elem)
Purpose: searches the array for a given String

param
elem

              return m_Vector.contains((Object) elem);
	
protected synchronized voidcopyInto(java.lang.String[] strArray)
Purpose: Copies this object into a given strArray[]

param
strArray the String array to copy the current object to

		strArray = new String[size()];
		for(int i = 0; i < size(); i++)
		     strArray[i] = elementAt(i);
	
public java.lang.StringelementAt(int iIndex)
Purpose: Returns the String at a given index

param
iIndex


		return (String) m_Vector.elementAt(iIndex);
	
public synchronized java.util.Enumerationelements()
Purpose: Returns the enumeration object for this object

return
Enumeration

		return m_Vector.elements();
	
public synchronized booleanremoveElement(java.lang.String obj)
Purpose: Removes the specified element

param
obj

		return m_Vector.removeElement((Object) obj);
	
public voidsetElementAt(java.lang.String obj, int iIndex)
Purpose: sets an element of the array at a given index to a given value

param
obj
param
iIndex

		   m_Vector.setElementAt((Object) obj, iIndex);
	
public intsize()
Purpose: Returns the size for the array

return
int

 return m_Vector.size(); 
public synchronized java.lang.StringtoString()
Purpose: Converts this object to a String

return
String

 		return m_Vector.toString();