Original 2.4
[marc4j.git] / src / org / marc4j / marc / impl / MarcFactoryImpl.java
1 //$Id: MarcFactoryImpl.java,v 1.3 2006/10/18 21:00:04 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 org.marc4j.marc.ControlField;\r
24 import org.marc4j.marc.DataField;\r
25 import org.marc4j.marc.Leader;\r
26 import org.marc4j.marc.MarcFactory;\r
27 import org.marc4j.marc.Record;\r
28 import org.marc4j.marc.Subfield;\r
29 \r
30 /**\r
31  * Factory for creating MARC record objects.\r
32  * \r
33  * @author Bas Peters\r
34  * @version $Revision: 1.3 $\r
35  */\r
36 public class MarcFactoryImpl extends MarcFactory {\r
37 \r
38     /**\r
39      * Default constructor.\r
40      * \r
41      */\r
42     public MarcFactoryImpl() {\r
43     }\r
44 \r
45     /**\r
46      * Returns a new control field instance.\r
47      * \r
48      * @return ControlField\r
49      */\r
50     public ControlField newControlField() {\r
51         return new ControlFieldImpl();\r
52     }\r
53 \r
54     /**\r
55      * Creates a new control field with the given tag and returns the instance.\r
56      * \r
57      * @return ControlField\r
58      */\r
59     public ControlField newControlField(String tag) {\r
60         return new ControlFieldImpl(tag);\r
61     }\r
62 \r
63     /**\r
64      * Creates a new control field with the given tag and data and returns the\r
65      * instance.\r
66      * \r
67      * @return ControlField\r
68      */\r
69     public ControlField newControlField(String tag, String data) {\r
70         return new ControlFieldImpl(tag, data);\r
71     }\r
72 \r
73     /**\r
74      * Returns a new data field instance.\r
75      * \r
76      * @return DataField\r
77      */\r
78     public DataField newDataField() {\r
79         return new DataFieldImpl();\r
80     }\r
81 \r
82     /**\r
83      * Creates a new data field with the given tag and indicators and returns\r
84      * the instance.\r
85      * \r
86      * @return DataField\r
87      */\r
88     public DataField newDataField(String tag, char ind1, char ind2) {\r
89         return new DataFieldImpl(tag, ind1, ind2);\r
90     }\r
91 \r
92     /**\r
93      * Returns a new leader instance.\r
94      * \r
95      * @return Leader\r
96      */\r
97     public Leader newLeader() {\r
98         return new LeaderImpl();\r
99     }\r
100 \r
101     /**\r
102      * Creates a new leader with the given <code>String</code> object.\r
103      * \r
104      * @return Leader\r
105      */\r
106     public Leader newLeader(String ldr) {\r
107         return new LeaderImpl(ldr);\r
108     }\r
109 \r
110     /**\r
111      * Returns a new record instance with a default leader.\r
112      * \r
113      * @return Record\r
114      */\r
115     public Record newRecord() {\r
116         return newRecord(new LeaderImpl("00000nam a2200000 a 4500"));\r
117     }\r
118 \r
119     /**\r
120      * Returns a new subfield instance.\r
121      * \r
122      * @return Leader\r
123      */\r
124     public Subfield newSubfield() {\r
125         return new SubfieldImpl();\r
126     }\r
127 \r
128     /**\r
129      * Creates a new subfield with the given identifier.\r
130      * \r
131      * @return Subfield\r
132      */\r
133     public Subfield newSubfield(char code) {\r
134         return new SubfieldImpl(code);\r
135     }\r
136 \r
137     /**\r
138      * Creates a new subfield with the given identifier and data.\r
139      * \r
140      * @return Subfield\r
141      */\r
142     public Subfield newSubfield(char code, String data) {\r
143         return new SubfieldImpl(code, data);\r
144     }\r
145 \r
146     public Record newRecord(Leader leader) {\r
147         Record record = new RecordImpl();\r
148         record.setLeader(leader);\r
149         return record;\r
150     }\r
151 \r
152     public Record newRecord(String leader) {\r
153         return newRecord(new LeaderImpl(leader));\r
154     }\r
155 \r
156 }