001package com.hfg.citation; 002 003 004import java.util.ArrayList; 005import java.util.Date; 006import java.util.List; 007 008import com.hfg.util.StringBuilderPlus; 009 010//------------------------------------------------------------------------------ 011/** 012 Citation data object. 013 <div> 014 @author J. Alex Taylor, hairyfatguy.com 015 </div> 016 */ 017//------------------------------------------------------------------------------ 018// com.hfg XML/HTML Coding Library 019// 020// This library is free software; you can redistribute it and/or 021// modify it under the terms of the GNU Lesser General Public 022// License as published by the Free Software Foundation; either 023// version 2.1 of the License, or (at your option) any later version. 024// 025// This library is distributed in the hope that it will be useful, 026// but WITHOUT ANY WARRANTY; without even the implied warranty of 027// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 028// Lesser General Public License for more details. 029// 030// You should have received a copy of the GNU Lesser General Public 031// License along with this library; if not, write to the Free Software 032// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 033// 034// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com 035// jataylor@hairyfatguy.com 036//------------------------------------------------------------------------------ 037 038public class Citation 039{ 040 private CitationType mType; 041 042 private String mAbstract; 043 private Date mAccessDate; 044 private List<Author> mAuthors; 045 private String mCallNumber; 046 private String mArticleNumber; 047 private String mDOI; 048 private String mISBN; 049 private String mISSN; 050 private String mIssue; 051 private Journal mJournal; 052 private MediaType mMediaType; 053 private String mNote; 054 private String mPages; 055 private String mPlaceOfPublication; 056 private String mPublisher; 057 private String mRepository; 058 private String mSource; 059 private String mTitle; 060 private String mURI; 061 private String mURL; 062 private String mVersion; 063 private String mVolume; 064 private String mWebsiteTitle; 065 private Integer mYear; 066 private String mLanguage; 067 private String mInstitution; 068 069 private PatentData mPatentData; 070 071 private String mRawContent; 072 073 //########################################################################### 074 // CONSTRUCTORS 075 //########################################################################### 076 077 //--------------------------------------------------------------------------- 078 public Citation() 079 { 080 init(); 081 } 082 083 //--------------------------------------------------------------------------- 084 public Citation(String inValue) 085 { 086 this(); 087 setRawContent(inValue); 088 } 089 090 //--------------------------------------------------------------------------- 091 private void init() 092 { 093 setType(CitationType.general); 094 } 095 096 //########################################################################### 097 // PUBLIC METHODS 098 //########################################################################### 099 100 //--------------------------------------------------------------------------- 101 @Override 102 public String toString() 103 { 104 String output; 105 if (mRawContent != null) 106 { 107 output = mRawContent; 108 } 109 else 110 { 111 output = new APA().generateAsString(this); 112 } 113 114 return output; 115 } 116 117 118 //--------------------------------------------------------------------------- 119 public Citation setRawContent(String inValue) 120 { 121 mRawContent = inValue; 122 return this; 123 } 124 125 //--------------------------------------------------------------------------- 126 public Citation appendRawContent(String inValue) 127 { 128 mRawContent = (mRawContent != null ? mRawContent + " " : "") + inValue; 129 return this; 130 } 131 132 133 //--------------------------------------------------------------------------- 134 public Citation setType(CitationType inValue) 135 { 136 mType = inValue; 137 return this; 138 } 139 140 //--------------------------------------------------------------------------- 141 public CitationType getType() 142 { 143 return mType; 144 } 145 146 147 //--------------------------------------------------------------------------- 148 public Citation setAbstract(String inValue) 149 { 150 mAbstract = inValue; 151 return this; 152 } 153 154 //--------------------------------------------------------------------------- 155 public String getAbstract() 156 { 157 return mAbstract; 158 } 159 160 161 //--------------------------------------------------------------------------- 162 public Citation setAccessDate(Date inValue) 163 { 164 mAccessDate = inValue; 165 return this; 166 } 167 168 //--------------------------------------------------------------------------- 169 public Date getAccessDate() 170 { 171 return mAccessDate; 172 } 173 174 //--------------------------------------------------------------------------- 175 public Citation addAuthor(Author inValue) 176 { 177 if (null == mAuthors) 178 { 179 mAuthors = new ArrayList<>(5); 180 } 181 182 mAuthors.add(inValue); 183 return this; 184 } 185 186 //--------------------------------------------------------------------------- 187 public List<Author> getAuthors() 188 { 189 return mAuthors; 190 } 191 192 193 194 //--------------------------------------------------------------------------- 195 /** 196 Specify the library call number for the citation source. 197 @param inValue the library call number 198 @return this Citation object to facilitate method chaining. 199 */ 200 public Citation setCallNumber(String inValue) 201 { 202 mCallNumber = inValue; 203 return this; 204 } 205 206 //--------------------------------------------------------------------------- 207 public String getCallNumber() 208 { 209 return mCallNumber; 210 } 211 212 213 //--------------------------------------------------------------------------- 214 /** 215 Specify the article number for the citation source. Often used by online-only publishers. 216 @param inValue the article number 217 @return this Citation object to facilitate method chaining. 218 */ 219 public Citation setArticleNumber(String inValue) 220 { 221 mArticleNumber = inValue; 222 return this; 223 } 224 225 //--------------------------------------------------------------------------- 226 public String getArticleNumber() 227 { 228 return mArticleNumber; 229 } 230 231 232 //--------------------------------------------------------------------------- 233 public Citation setYear(Integer inValue) 234 { 235 mYear = inValue; 236 return this; 237 } 238 239 //--------------------------------------------------------------------------- 240 public Integer getYear() 241 { 242 return mYear; 243 } 244 245 246 //--------------------------------------------------------------------------- 247 public Citation setJournal(Journal inValue) 248 { 249 mJournal = inValue; 250 if (inValue != null) 251 { 252 setType(CitationType.journal); 253 } 254 255 return this; 256 } 257 258 //--------------------------------------------------------------------------- 259 public Journal getJournal() 260 { 261 return mJournal; 262 } 263 264 265 //--------------------------------------------------------------------------- 266 public Citation setIssue(String inValue) 267 { 268 mIssue = inValue; 269 return this; 270 } 271 272 //--------------------------------------------------------------------------- 273 public String getIssue() 274 { 275 return mIssue; 276 } 277 278 279 //--------------------------------------------------------------------------- 280 /** 281 Specify the media type for the citation source material. 282 @param inValue the media type for the citation source material 283 @return this Citation object to facilitate method chaining. 284 */ 285 public Citation setMediaType(MediaType inValue) 286 { 287 mMediaType = inValue; 288 return this; 289 } 290 291 //--------------------------------------------------------------------------- 292 public MediaType getMediaType() 293 { 294 return mMediaType; 295 } 296 297 //--------------------------------------------------------------------------- 298 /** 299 Specify additional citation details, commentary, or summary. 300 @param inValue the note contents 301 @return this Citation object to facilitate method chaining. 302 */ 303 public Citation setNote(String inValue) 304 { 305 mNote = inValue; 306 return this; 307 } 308 309 //--------------------------------------------------------------------------- 310 public String getNote() 311 { 312 return mNote; 313 } 314 315 316 //--------------------------------------------------------------------------- 317 public Citation setPages(String inValue) 318 { 319 mPages = inValue; 320 return this; 321 } 322 323 //--------------------------------------------------------------------------- 324 public String getPages() 325 { 326 return mPages; 327 } 328 329 330 //--------------------------------------------------------------------------- 331 public Citation setPublisher(String inValue) 332 { 333 mPublisher = inValue; 334 return this; 335 } 336 337 //--------------------------------------------------------------------------- 338 public String getPublisher() 339 { 340 return mPublisher; 341 } 342 343 344 //--------------------------------------------------------------------------- 345 public Citation setPlaceOfPublication(String inValue) 346 { 347 mPlaceOfPublication = inValue; 348 return this; 349 } 350 351 //--------------------------------------------------------------------------- 352 public String getPlaceOfPublication() 353 { 354 return mPlaceOfPublication; 355 } 356 357 358 //--------------------------------------------------------------------------- 359 /** 360 Specifies the digital object identifier (DOI) for the citation. 361 The DOI is a unique alphanumeric string assigned by a registration agency 362 (the International DOI Foundation) to identify content and provide a persistent 363 link to its location on the Internet. 364 @param inValue the DOI string 365 @return this Citation object to facilitate method chaining. 366 */ 367 public Citation setDOI(String inValue) 368 { 369 mDOI = inValue; 370 return this; 371 } 372 373 //--------------------------------------------------------------------------- 374 public String getDOI() 375 { 376 return mDOI; 377 } 378 379 380 //--------------------------------------------------------------------------- 381 /** 382 Specifies the international standard book number (ISBN) for the citation. 383 @param inValue the ISBN string 384 @return this Citation object to facilitate method chaining. 385 */ 386 public Citation setISBN(String inValue) 387 { 388 mISBN = inValue; 389 return this; 390 } 391 392 //--------------------------------------------------------------------------- 393 public String getISBN() 394 { 395 return mISBN; 396 } 397 398 399 //--------------------------------------------------------------------------- 400 /** 401 Specifies the international standard serial number (ISSN) for the citation. 402 From the issn.org website: "An ISSN is an 8-digit code used to identify 403 newspapers, journals, magazines and periodicals of all kinds and on all 404 media–print and electronic." 405 @param inValue the ISSN string 406 @return this Citation object to facilitate method chaining. 407 */ 408 public Citation setISSN(String inValue) 409 { 410 mISSN = inValue; 411 return this; 412 } 413 414 //--------------------------------------------------------------------------- 415 public String getISSN() 416 { 417 return mISSN; 418 } 419 420 421 //--------------------------------------------------------------------------- 422 /** 423 Specifies the repository in which the citation source was accessed. 424 @param inValue the name of the repository 425 @return this Citation object to facilitate method chaining. 426 */ 427 public Citation setRepository(String inValue) 428 { 429 mRepository = inValue; 430 return this; 431 } 432 433 //--------------------------------------------------------------------------- 434 public String getRepository() 435 { 436 return mRepository; 437 } 438 439 //--------------------------------------------------------------------------- 440 /** 441 Specifies the origin of the citation material. 442 @param inValue the citation source 443 @return this Citation object to facilitate method chaining. 444 */ 445 public Citation setSource(String inValue) 446 { 447 mSource = inValue; 448 return this; 449 } 450 451 //--------------------------------------------------------------------------- 452 public String getSource() 453 { 454 return mSource; 455 } 456 457 458 //--------------------------------------------------------------------------- 459 public Citation setTitle(String inValue) 460 { 461 mTitle = inValue; 462 return this; 463 } 464 465 //--------------------------------------------------------------------------- 466 public String getTitle() 467 { 468 return mTitle; 469 } 470 471 472 //--------------------------------------------------------------------------- 473 public Citation setURI(String inValue) 474 { 475 mURI = inValue; 476 return this; 477 } 478 479 //--------------------------------------------------------------------------- 480 public String getURI() 481 { 482 return mURI; 483 } 484 485 486 //--------------------------------------------------------------------------- 487 public Citation setURL(String inValue) 488 { 489 mURL = inValue; 490 return this; 491 } 492 493 //--------------------------------------------------------------------------- 494 public String getURL() 495 { 496 return mURL; 497 } 498 499 500 //--------------------------------------------------------------------------- 501 public Citation setVersion(String inValue) 502 { 503 mVersion = inValue; 504 return this; 505 } 506 507 //--------------------------------------------------------------------------- 508 public String getVersion() 509 { 510 return mVersion; 511 } 512 513 514 //--------------------------------------------------------------------------- 515 public Citation setVolume(String inValue) 516 { 517 mVolume = inValue; 518 return this; 519 } 520 521 //--------------------------------------------------------------------------- 522 public String getVolume() 523 { 524 return mVolume; 525 } 526 527 528 //--------------------------------------------------------------------------- 529 public Citation setWebsiteTitle(String inValue) 530 { 531 mWebsiteTitle = inValue; 532 return this; 533 } 534 535 //--------------------------------------------------------------------------- 536 public String getWebsiteTitle() 537 { 538 return mWebsiteTitle; 539 } 540 541 542 //--------------------------------------------------------------------------- 543 public Citation setLanguage(String inValue) 544 { 545 mLanguage = inValue; 546 return this; 547 } 548 549 //--------------------------------------------------------------------------- 550 public String getLanguage() 551 { 552 return mLanguage; 553 } 554 555 556 //--------------------------------------------------------------------------- 557 public Citation setInstitution(String inValue) 558 { 559 mInstitution = inValue; 560 return this; 561 } 562 563 //--------------------------------------------------------------------------- 564 public String getInstitution() 565 { 566 return mInstitution; 567 } 568 569 570 //--------------------------------------------------------------------------- 571 public Citation setPatentData(PatentData inValue) 572 { 573 mPatentData = inValue; 574 return this; 575 } 576 577 //--------------------------------------------------------------------------- 578 public PatentData getPatentData() 579 { 580 return mPatentData; 581 } 582 583 584}