001package com.hfg.citation; 002 003 004import com.hfg.util.CompareUtil; 005import com.hfg.util.StringUtil; 006 007//------------------------------------------------------------------------------ 008/** 009 Journal object for use with citations. 010 <div> 011 @author J. Alex Taylor, hairyfatguy.com 012 </div> 013 */ 014//------------------------------------------------------------------------------ 015// com.hfg XML/HTML Coding Library 016// 017// This library is free software; you can redistribute it and/or 018// modify it under the terms of the GNU Lesser General Public 019// License as published by the Free Software Foundation; either 020// version 2.1 of the License, or (at your option) any later version. 021// 022// This library is distributed in the hope that it will be useful, 023// but WITHOUT ANY WARRANTY; without even the implied warranty of 024// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 025// Lesser General Public License for more details. 026// 027// You should have received a copy of the GNU Lesser General Public 028// License along with this library; if not, write to the Free Software 029// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 030// 031// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com 032// jataylor@hairyfatguy.com 033//------------------------------------------------------------------------------ 034 035public class Journal implements Comparable 036{ 037 private String mTitle; 038 private String mAbbrev; 039 private String mISSN; 040 041 //########################################################################### 042 // CONSTRUCTORS 043 //########################################################################### 044 045 //--------------------------------------------------------------------------- 046 public Journal() 047 { 048 } 049 050 //--------------------------------------------------------------------------- 051 public Journal(String inValue) 052 { 053 setTitle(inValue); 054 } 055 056 057 //########################################################################### 058 // PUBLIC METHODS 059 //########################################################################### 060 061 //--------------------------------------------------------------------------- 062 @Override 063 public String toString() 064 { 065 return (StringUtil.isSet(mAbbrev) ? mAbbrev : mTitle); 066 } 067 068 //--------------------------------------------------------------------------- 069 @Override 070 public boolean equals(Object inObj2) 071 { 072 return (0 == compareTo(inObj2)); 073 } 074 075 //--------------------------------------------------------------------------- 076 @Override 077 public int hashCode() 078 { 079 int value = 1; 080 081 if (StringUtil.isSet(getTitle())) 082 { 083 value = getTitle().hashCode(); 084 } 085 else if (StringUtil.isSet(getAbbrev())) 086 { 087 value = getAbbrev().hashCode(); 088 } 089 090 return value; 091 } 092 093 //--------------------------------------------------------------------------- 094 @Override 095 public int compareTo(Object inObj2) 096 { 097 int result = -1; 098 if (inObj2 != null 099 && inObj2 instanceof Journal) 100 { 101 Journal journal2 = (Journal) inObj2; 102 103 if (StringUtil.isSet(getTitle()) 104 && StringUtil.isSet(journal2.getTitle())) 105 { 106 result = CompareUtil.compare(getTitle(), journal2.getTitle()); 107 } 108 else if (StringUtil.isSet(getAbbrev()) 109 && StringUtil.isSet(journal2.getAbbrev())) 110 { 111 result = CompareUtil.compare(getAbbrev(), journal2.getAbbrev()); 112 } 113 } 114 115 return result; 116 } 117 118 //--------------------------------------------------------------------------- 119 public Journal setTitle(String inValue) 120 { 121 mTitle = inValue; 122 return this; 123 } 124 125 //--------------------------------------------------------------------------- 126 public String getTitle() 127 { 128 return mTitle; 129 } 130 131 132 //--------------------------------------------------------------------------- 133 public Journal setAbbrev(String inValue) 134 { 135 mAbbrev = inValue; 136 return this; 137 } 138 139 //--------------------------------------------------------------------------- 140 public String getAbbrev() 141 { 142 return mAbbrev; 143 } 144 145 146 //--------------------------------------------------------------------------- 147 public Journal setISSN(String inValue) 148 { 149 mISSN = inValue; 150 return this; 151 } 152 153 //--------------------------------------------------------------------------- 154 /** 155 Returns the ISSN (International Standard Serial Number) for the Journal. 156 An ISSN is an 8-digit code used to identify journals, newspapers, magazines, 157 and other types of periodicals in either print or electronic form. 158 The 8 digits are arranged as two groups of four digits separated by a hyphen. 159 The eighth digits is a checksum calculated as a modulus 11 of the first 7 digits. 160 The eighth digit is displayed as an 'X' if the modulus value is 10. 161 @return the ISSN value for the Journal 162 */ 163 public String getISSN() 164 { 165 return mISSN; 166 } 167 168}