// Sample code file: ObjectEntry.java
// Warning: This code has been marked up for HTML
/***************************************************************************
$name: ObjectEntry.java
$version: 1.0
$date_modified: 210104
$description:
$owner: Beans for Novell Services Team
Copyright (c) 1998 Novell, Inc. All Rights Reserved.
THIS WORK IS SUBJECT TO U.S. AND INTERNATIONAL COPYRIGHT LAWS AND TREATIES.
USE AND REDISTRIBUTION OF THIS WORK IS SUBJECT TO THE LICENSE AGREEMENT
ACCOMPANYING THE SOFTWARE DEVELOPMENT KIT (SDK) THAT CONTAINS THIS WORK.
PURSUANT TO THE SDK LICENSE AGREEMENT, NOVELL HEREBY GRANTS TO DEVELOPER A
ROYALTY-FREE, NON-EXCLUSIVE LICENSE TO INCLUDE NOVELL'S SAMPLE CODE IN ITS
PRODUCT. NOVELL GRANTS DEVELOPER WORLDWIDE DISTRIBUTION RIGHTS TO MARKET,
DISTRIBUTE, OR SELL NOVELL'S SAMPLE CODE AS A COMPONENT OF DEVELOPER'S
PRODUCTS. NOVELL SHALL HAVE NO OBLIGATIONS TO DEVELOPER OR DEVELOPER'S
CUSTOMERS WITH RESPECT TO THIS CODE.
****************************************************************************/
import javax.swing.*;
import java.util.StringTokenizer;
public class ObjectEntry
{
String m_fullName = null;
String m_shortName = null;
String m_className = null;
String m_context = null;
Icon m_imageIcon = null;
boolean m_toplevel = false;
ObjectEntry(String fname, String cname)
{
m_fullName = fname;
int index = fname.lastIndexOf("=");
int length = fname.length();
m_shortName = fname.substring(index+1,length);
m_context = fname.substring(7,length);
m_className = cname;
m_imageIcon = getImageIcon();
}
ObjectEntry(String fname, String cname, boolean top)
{
m_fullName = fname;
int index = fname.lastIndexOf("=");
int length = fname.length();
m_shortName = fname.substring(index+1,length);
m_context = fname.substring(7,length);
m_toplevel = top;
m_className = cname;
m_imageIcon = getImageIcon();
}
Icon getImageIcon()
{
String cname = m_className;
if ((cname == null) || "".equalsIgnoreCase(cname))
return null;
if (cname.equalsIgnoreCase("Organization"))
return new ImageIcon("./images/organization.gif");
else if (cname.equalsIgnoreCase("Organizational Unit"))
return new ImageIcon("./images/organizationalunit.gif");
else if (cname.equalsIgnoreCase("Group"))
return new ImageIcon("./images/group.gif");
else if (cname.equalsIgnoreCase("inetOrgPerson"))
return new ImageIcon("./images/inetOrgPerson.gif");
else if (cname.equalsIgnoreCase("top"))
return new ImageIcon("./images/MyWorldIcon.gif");
else if (cname.equalsIgnoreCase("uamPosixWorkStation"))
return new ImageIcon("./images/workstation.gif");
return null;
}
public String toString()
{
if (m_className.equalsIgnoreCase("top"))
return "My World";
else if (m_toplevel)
return m_context;
else
return m_shortName;
}
String getFullName()
{
return m_fullName;
}
String getClassName()
{
return m_className;
}
}