1 // $Id: SubfieldImpl.java,v 1.4 2006/08/04 12:31:41 bpeters Exp $
\r
3 * Copyright (C) 2004 Bas Peters
\r
5 * This file is part of MARC4J
\r
7 * MARC4J is free software; you can redistribute it and/or
\r
8 * modify it under the terms of the GNU Lesser General Public
\r
9 * License as published by the Free Software Foundation; either
\r
10 * version 2.1 of the License, or (at your option) any later version.
\r
12 * MARC4J is distributed in the hope that it will be useful,
\r
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
\r
15 * Lesser General Public License for more details.
\r
17 * You should have received a copy of the GNU Lesser General Public
\r
18 * License along with MARC4J; if not, write to the Free Software
\r
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
\r
21 package org.marc4j.marc.impl;
\r
23 import java.util.regex.Matcher;
\r
24 import java.util.regex.Pattern;
\r
26 import org.marc4j.marc.Subfield;
\r
29 * Represents a subfield in a MARC record.
\r
31 * @author Bas Peters
\r
32 * @version $Revision: 1.4 $
\r
34 public class SubfieldImpl implements Subfield {
\r
39 private static final long serialVersionUID = -5652216007819993017L;
\r
45 private String data;
\r
48 * Creates a new <code>Subfield</code>.
\r
50 public SubfieldImpl() {
\r
54 * Creates a new <code>Subfield</code> and sets the data element
\r
58 * the data element identifier
\r
60 public SubfieldImpl(char code) {
\r
65 * Creates a new <code>Subfield</code> and sets the data element
\r
66 * identifier and the data element.
\r
69 * the data element identifier
\r
73 public SubfieldImpl(char code, String data) {
\r
78 public void setCode(char code) {
\r
82 public char getCode() {
\r
86 public void setData(String data) {
\r
90 public String getData() {
\r
94 public boolean find(String pattern) {
\r
95 Pattern p = Pattern.compile(pattern);
\r
96 Matcher m = p.matcher(getData());
\r
101 * Returns a string representation of this subfield.
\r
110 * @return String - a string representation of this subfield
\r
112 public String toString() {
\r
113 return "$" + getCode() + getData();
\r
116 public void setId(Long id) {
\r
120 public Long getId() {
\r