001: /*
002: * DCSeriesNumber.java
003: *
004: * Version: $Revision: 1189 $
005: *
006: * Date: $Date: 2005-04-20 09:23:44 -0500 (Wed, 20 Apr 2005) $
007: *
008: * Copyright (c) 2002-2005, Hewlett-Packard Company and Massachusetts
009: * Institute of Technology. All rights reserved.
010: *
011: * Redistribution and use in source and binary forms, with or without
012: * modification, are permitted provided that the following conditions are
013: * met:
014: *
015: * - Redistributions of source code must retain the above copyright
016: * notice, this list of conditions and the following disclaimer.
017: *
018: * - Redistributions in binary form must reproduce the above copyright
019: * notice, this list of conditions and the following disclaimer in the
020: * documentation and/or other materials provided with the distribution.
021: *
022: * - Neither the name of the Hewlett-Packard Company nor the name of the
023: * Massachusetts Institute of Technology nor the names of their
024: * contributors may be used to endorse or promote products derived from
025: * this software without specific prior written permission.
026: *
027: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
028: * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
029: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
030: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
031: * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
032: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
033: * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
034: * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
035: * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
036: * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
037: * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
038: * DAMAGE.
039: */
040: package org.dspace.content;
041:
042: /**
043: * Series and report number, as stored in relation.ispartofseries
044: *
045: * @author Robert Tansley
046: * @version $Id: DCSeriesNumber.java 1189 2005-04-20 14:23:44Z rtansley $
047: */
048: public class DCSeriesNumber {
049: /** Series */
050: private String series;
051:
052: /** Number */
053: private String number;
054:
055: /** Construct clean series number */
056: public DCSeriesNumber() {
057: series = null;
058: number = null;
059: }
060:
061: /**
062: * Construct from raw DC value
063: *
064: * @param value
065: * value from database
066: */
067: public DCSeriesNumber(String value) {
068: this ();
069:
070: int semicolon = -1;
071:
072: if (value != null) {
073: semicolon = value.indexOf(';');
074: }
075:
076: if (semicolon >= 0) {
077: series = value.substring(0, semicolon);
078: number = value.substring(semicolon + 1);
079: } else {
080: series = value;
081: }
082: }
083:
084: /**
085: * Construct from given values
086: *
087: * @param s
088: * the series
089: * @param n
090: * the number
091: */
092: public DCSeriesNumber(String s, String n) {
093: series = s;
094: number = n;
095: }
096:
097: /**
098: * Write as raw DC value
099: *
100: * @return the series and number as they should be stored in the DB
101: */
102: public String toString() {
103: if (series == null) {
104: return (null);
105: } else if (number == null) {
106: return (series);
107: } else {
108: return (series + ";" + number);
109: }
110: }
111:
112: /**
113: * Get the series name - guaranteed non-null
114: */
115: public String getSeries() {
116: return ((series == null) ? "" : series);
117: }
118:
119: /**
120: * Get the number - guaranteed non-null
121: */
122: public String getNumber() {
123: return ((number == null) ? "" : number);
124: }
125: }
|