LangItem.java :  » XML-UI » xui32 » com » xoetrope » carousel » langed » Java Open Source

Java Open Source » XML UI » xui32 
xui32 » com » xoetrope » carousel » langed » LangItem.java
package com.xoetrope.carousel.langed;

/**
 *  A place holder for the language name and code / id.
 * <p> Copyright (c) Xoetrope Ltd., 2001-2006, This software is licensed under
 * the GNU Public License (GPL), please see license.txt for more details. If
 * you make commercial use of this software you must purchase a commercial
 * license from Xoetrope.</p>
 * <p> $Revision: 1.4 $</p>
 */
public class LangItem
{
  int id;
  String langStr;
  String keyStr;
  boolean hashByName;
  int status;

  public static final int OK = 0;
  public static final int NEW_ITEM = 1;
  public static final int MODIFIED = 2;

  public LangItem()
  {
         hashByName = false;
         status = OK;
  }

  public LangItem( int _id )
  {
         hashByName = false;
         id = _id;
         status = OK;
  }

  public LangItem( boolean hashMethod )
  {
         hashByName = hashMethod;
         status = OK;
  }

  public LangItem( String str, int _id )
  {
         langStr = str;
         id = _id;
         status = OK;
  }

  public String toString()
  {
         return langStr;
  }

  public String getKeyString()
  {
         return keyStr;
  }

  public int hashCode()
  {
          if ( !hashByName )
            return id;
          else
            return langStr.hashCode();
  }

  public boolean equals( Object o )
  {
          if ( !hashByName )
            return (((LangItem)o).id == id );
          else
            return (((LangItem)o).langStr.compareTo( langStr ) == 0 );
  }

  void setLangStr( String newString )
  {
    langStr = newString;
    if ( status != NEW_ITEM )
      status = MODIFIED;
  }

  void setKeyString( String newString )
  {
    keyStr = newString;
    if ( status != NEW_ITEM )
      status = MODIFIED;
  }

  int getStatus()
  {
    return status;
  }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.