/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Copyright 1999-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id: StringVector.java,v 1.2.4.1 2005/09/15 08:15:56 suresh_emailid Exp $
*/
/**
* A very simple table that stores a list of strings, optimized
* for small lists.
* @xsl.usage internal
*/
{
/** @serial Size of blocks to allocate */
protected int m_blocksize;
/** @serial Array of strings this contains */
/** @serial Number of strings this contains */
/** @serial Size of the array */
protected int m_mapSize;
/**
* Default constructor. Note that the default
* block size is very small, for small lists.
*/
public StringVector()
{
m_blocksize = 8;
}
/**
* Construct a StringVector, using the given block size.
*
* @param blocksize Size of the blocks to allocate
*/
{
}
/**
* Get the length of the list.
*
* @return Number of strings in the list
*/
public int getLength()
{
return m_firstFree;
}
/**
* Get the length of the list.
*
* @return Number of strings in the list
*/
public final int size()
{
return m_firstFree;
}
/**
* Append a string onto the vector.
*
* @param value Sting to add to the vector
*/
{
{
m_mapSize += m_blocksize;
}
m_firstFree++;
}
/**
* Get the nth element.
*
* @param i Index of string to find
*
* @return String at given index
*/
{
return m_map[i];
}
/**
* Tell if the table contains the given string.
*
* @param s String to look for
*
* @return True if the string is in this table
*/
{
if (null == s)
return false;
for (int i = 0; i < m_firstFree; i++)
{
return true;
}
return false;
}
/**
* Tell if the table contains the given string. Ignore case.
*
* @param s String to find
*
* @return True if the String is in this vector
*/
{
if (null == s)
return false;
for (int i = 0; i < m_firstFree; i++)
{
if (m_map[i].equalsIgnoreCase(s))
return true;
}
return false;
}
/**
* Tell if the table contains the given string.
*
* @param s String to push into the vector
*/
{
{
m_mapSize += m_blocksize;
}
m_map[m_firstFree] = s;
m_firstFree++;
}
/**
* Pop the tail of this vector.
*
* @return The String last added to this vector or null not found.
* The string is removed from the vector.
*/
{
if (m_firstFree <= 0)
return null;
m_firstFree--;
return s;
}
/**
* Get the string at the tail of this vector without popping.
*
* @return The string at the tail of this vector.
*/
{
}
}