com.hfg.citation.Journal Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of com_hfg Show documentation
Show all versions of com_hfg Show documentation
com.hfg xml, html, svg, and bioinformatics utility library
package com.hfg.citation;
import com.hfg.util.CompareUtil;
import com.hfg.util.StringUtil;
//------------------------------------------------------------------------------
/**
Journal object for use with citations.
@author J. Alex Taylor, hairyfatguy.com
*/
//------------------------------------------------------------------------------
// com.hfg XML/HTML Coding Library
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com
// [email protected]
//------------------------------------------------------------------------------
public class Journal implements Comparable
{
private String mTitle;
private String mAbbrev;
private String mISSN;
//###########################################################################
// CONSTRUCTORS
//###########################################################################
//---------------------------------------------------------------------------
public Journal()
{
}
//---------------------------------------------------------------------------
public Journal(String inValue)
{
setTitle(inValue);
}
//###########################################################################
// PUBLIC METHODS
//###########################################################################
//---------------------------------------------------------------------------
@Override
public String toString()
{
return (StringUtil.isSet(mAbbrev) ? mAbbrev : mTitle);
}
//---------------------------------------------------------------------------
@Override
public boolean equals(Object inObj2)
{
return (0 == compareTo(inObj2));
}
//---------------------------------------------------------------------------
@Override
public int hashCode()
{
int value = 1;
if (StringUtil.isSet(getTitle()))
{
value = getTitle().hashCode();
}
else if (StringUtil.isSet(getAbbrev()))
{
value = getAbbrev().hashCode();
}
return value;
}
//---------------------------------------------------------------------------
@Override
public int compareTo(Object inObj2)
{
int result = -1;
if (inObj2 != null
&& inObj2 instanceof Journal)
{
Journal journal2 = (Journal) inObj2;
if (StringUtil.isSet(getTitle())
&& StringUtil.isSet(journal2.getTitle()))
{
result = CompareUtil.compare(getTitle(), journal2.getTitle());
}
else if (StringUtil.isSet(getAbbrev())
&& StringUtil.isSet(journal2.getAbbrev()))
{
result = CompareUtil.compare(getAbbrev(), journal2.getAbbrev());
}
}
return result;
}
//---------------------------------------------------------------------------
public Journal setTitle(String inValue)
{
mTitle = inValue;
return this;
}
//---------------------------------------------------------------------------
public String getTitle()
{
return mTitle;
}
//---------------------------------------------------------------------------
public Journal setAbbrev(String inValue)
{
mAbbrev = inValue;
return this;
}
//---------------------------------------------------------------------------
public String getAbbrev()
{
return mAbbrev;
}
//---------------------------------------------------------------------------
public Journal setISSN(String inValue)
{
mISSN = inValue;
return this;
}
//---------------------------------------------------------------------------
/**
Returns the ISSN (International Standard Serial Number) for the Journal.
An ISSN is an 8-digit code used to identify journals, newspapers, magazines,
and other types of periodicals in either print or electronic form.
The 8 digits are arranged as two groups of four digits separated by a hyphen.
The eighth digits is a checksum calculated as a modulus 11 of the first 7 digits.
The eighth digit is displayed as an 'X' if the modulus value is 10.
@return the ISSN value for the Journal
*/
public String getISSN()
{
return mISSN;
}
}