Monday, December 28, 2009

Remove Alias Names from Design Element Names - Java

/**
* Method to remove the part of strings from string objects in a string vector (Vector<String>)
* which correspond to the alias names of the design elements
* @param designElementNames - an ArrayList with String Objects
* @return ArrayList
* @author Karthikeyan_a
* @since 30-April-2009
*/

public ArrayList removeAlias(ArrayList designElementNames) {
//if the input param in null then return null
if (designElementNames==null)return null;
//initialize the return value
ArrayList filteredDsgnElements=new ArrayList();
String dsgnName=null;
Object[] buffer=designElementNames.toArray();
int countItr=0;
/**
* loop through all the string objects in the input vector and remove the part of stirngs in
* string objects that correspond to the alias names of the design elements
*/
for(countItr=0;countItr<buffer.length;countItr++) {
dsgnName=buffer[countItr].toString().trim();
if(dsgnName.indexOf("|")==-1) {
filteredDsgnElements.add(dsgnName);
} else {
filteredDsgnElements.add(dsgnName.substring(0, dsgnName.indexOf("|")).trim());
}
}
//recycle objects
dsgnName=null;
designElementNames=null;

return filteredDsgnElements;
} //end of function::removeAlias

No comments:

Post a Comment