blob: 076b4d4908fa7d87ebb77749ea5da3ed64eb87fc [file] [log] [blame]
//------------------------------------------------------------------------------
// Copyright (c) 2005, 2006 IBM Corporation and others.
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// which accompanies this distribution, and is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// Contributors:
// IBM Corporation - initial implementation
//------------------------------------------------------------------------------
package org.eclipse.epf.publishing.services.index;
import java.util.Vector;
//Represents a html file that contains keywords
public class KeyWordFile
{
private String title=null;
private String url=null;
private int nextKeyWord=0;
private Vector keyWordVector=null;
//-------------------------------------------------------------------------------------------------------
// Constructor.
public KeyWordFile(String title, String url, String keyWords)
{
this.title = title;
this.url = url;
createKeyWordVector(keyWords);
}
//------------------------------------------------------------------------------------------------------
public String getNextKeyWord()
{
if(nextKeyWord<keyWordVector.size())
{
String next = (String)keyWordVector.elementAt(nextKeyWord);
nextKeyWord++;
if(next!=null)
{
return next;
}
else
{
return null;
}
}
return null;
}
//------------------------------------------------------------------------------------------------------
public Document getDocument(String keyWord, int noOfDoc)
{
if(noOfDoc>1)
{
return null;
}
return new Document(title, url);
}
//-------------------------------------------------------------------------------------------------------
// Break the keywords up into the component parts and store the individual entries in a vector.
private void createKeyWordVector( String key)
{
if(key==null)
{
System.err.println("KeyWordFile:createKeyWordVector\n" + //$NON-NLS-1$
HelpMessages.INPUT_PARAMETER_NULL);
return;
}
keyWordVector = new Vector();
int start = 0;
while(start<key.length())
{
int index = key.indexOf(KeyWordIndexHelper.defObj.keyWordSeparator,start);
if(index==-1)
{
index = key.length();
}
keyWordVector.addElement(new String(key.substring(start, index).trim()));
start = index+1;
}
}
//----------------------------------------------------------------------------------------------------------
private boolean matchKeyWord(String anchor)
{
for(int i=0;i< keyWordVector.size();i++)
{
if(MiscStatic.getIndex(anchor, (String)keyWordVector.elementAt(i), 0)!=-1)
{
return true;
}
}
return false;
}
}