/* 
______________________________________________________________________
*
* Copyright (c) 1996-2004 QUEST SOFTWARE INC.  All Rights Reserved.
* http://java.quest.com
*
* This software is the confidential and proprietary information of
* Quest Software Inc. ("Confidential Information").  You shall not disclose
* such Confidential Information and shall use it only in accordance with the
* terms of the license agreement you entered into with Quest Software.
*
* QUEST SOFTWARE MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY
* OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
* TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE, OR NON-INFRINGEMENT. QUEST SOFTWARE SHALL NOT BE LIABLE FOR ANY
* DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
* DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
* ______________________________________________________________________
*/

// RCSID -- $RCSfile: CharMetricsPCL.java,v $ $Revision: 1.2 $ $Date: 2006-03-17 21:13:25 $ $Locker:  $  Quest Software Inc.

package com.klg.jclass.page.pcl;

import java.util.Hashtable;
import java.util.Vector;
import java.util.Enumeration;

/**
 * This class encapsulates the data and methods necessary to get per-character
 * metrics about loaded PCL fonts
 */
public class CharMetricsPCL {

Vector chars 	            = new Vector();
Hashtable charSetEntries	= new Hashtable();


public CharSetEntryPCL findEntryByIndex(short index) {
    return (CharSetEntryPCL) charSetEntries.get(new Short(index));
}
public CharSetEntryPCL findEntryByCode(short code) {
	for (Enumeration e= charSetEntries.elements(); e.hasMoreElements(); ) {
		CharSetEntryPCL entry = (CharSetEntryPCL) e.nextElement();
		if (entry.code == code) {
			return entry;
		}
	}
	// TFMParser does special handling if space char not found
	if (code == 0x20) {
		return null;
	}
	else {
		// otherwise, didn't find char, so use the space char
		return findEntryByIndex((short) 32);
	}
}

public CharacterPCL findCharByIndex(short index) {
	for (Enumeration e= chars.elements(); e.hasMoreElements(); ) {
		CharacterPCL entry = (CharacterPCL) e.nextElement();
		if (entry.index == index) {
            return entry;
		}
	}
	return null;
}


}
