Make List type safe. Remove/suppress all warnings.
[marc4j.git] / src / org / marc4j / marc / impl / ControlFieldImpl.java
1 // $Id: ControlFieldImpl.java,v 1.4 2006/08/04 12:31:41 bpeters Exp $\r
2 /**\r
3  * Copyright (C) 2004 Bas Peters\r
4  *\r
5  * This file is part of MARC4J\r
6  *\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
11  *\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
16  *\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
20  */\r
21 package org.marc4j.marc.impl;\r
22 \r
23 import java.util.regex.Matcher;\r
24 import java.util.regex.Pattern;\r
25 \r
26 import org.marc4j.marc.ControlField;\r
27 \r
28 /**\r
29  * Represents a control field in a MARC record.\r
30  * \r
31  * @author Bas Peters\r
32  * @version $Revision: 1.4 $\r
33  */\r
34 public class ControlFieldImpl extends VariableFieldImpl implements ControlField {\r
35 \r
36     /**\r
37    * \r
38    */\r
39   private static final long serialVersionUID = 8072900114616013850L;\r
40 \r
41     private Long id;\r
42     \r
43     private String data;\r
44 \r
45     /**\r
46      * Creates a new <code>ControlField</code>.\r
47      */\r
48     public ControlFieldImpl() {\r
49     }\r
50 \r
51     /**\r
52      * Creates a new <code>ControlField</code> and sets the tag name.\r
53      */\r
54     public ControlFieldImpl(String tag) {\r
55         this.setTag(tag);\r
56     }\r
57 \r
58     /**\r
59      * Creates a new <code>ControlField</code> and sets the tag name and the\r
60      * data element.\r
61      * \r
62      */\r
63     public ControlFieldImpl(String tag, String data) {\r
64         this.setTag(tag);\r
65         this.setData(data);\r
66     }\r
67 \r
68     public void setData(String data) {\r
69         this.data = data;\r
70     }\r
71 \r
72     public String getData() {\r
73         return data;\r
74     }\r
75 \r
76     /**\r
77      * Returns a string representation of this control field.\r
78      * \r
79      * <p>\r
80      * Example:\r
81      * \r
82      * <pre>\r
83      *     001 12883376\r
84      * </pre>\r
85      * \r
86      * @return String - a string representation of this control field\r
87      */\r
88     public String toString() {\r
89         return super.toString() + " " + getData();\r
90     }\r
91 \r
92     public boolean find(String pattern) {\r
93         Pattern p = Pattern.compile(pattern);\r
94         Matcher m = p.matcher(getData());\r
95         return m.find();\r
96     }\r
97 \r
98     public void setId(Long id) {\r
99         this.id = id;\r
100     }\r
101 \r
102     public Long getId() {\r
103         return id;\r
104     }\r
105 \r
106 }