1 //$Id: MarcFactoryImpl.java,v 1.3 2006/10/18 21:00:04 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 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
31 * Factory for creating MARC record objects.
\r
33 * @author Bas Peters
\r
34 * @version $Revision: 1.3 $
\r
36 public class MarcFactoryImpl extends MarcFactory {
\r
39 * Default constructor.
\r
42 public MarcFactoryImpl() {
\r
46 * Returns a new control field instance.
\r
48 * @return ControlField
\r
50 public ControlField newControlField() {
\r
51 return new ControlFieldImpl();
\r
55 * Creates a new control field with the given tag and returns the instance.
\r
57 * @return ControlField
\r
59 public ControlField newControlField(String tag) {
\r
60 return new ControlFieldImpl(tag);
\r
64 * Creates a new control field with the given tag and data and returns the
\r
67 * @return ControlField
\r
69 public ControlField newControlField(String tag, String data) {
\r
70 return new ControlFieldImpl(tag, data);
\r
74 * Returns a new data field instance.
\r
78 public DataField newDataField() {
\r
79 return new DataFieldImpl();
\r
83 * Creates a new data field with the given tag and indicators and returns
\r
88 public DataField newDataField(String tag, char ind1, char ind2) {
\r
89 return new DataFieldImpl(tag, ind1, ind2);
\r
93 * Returns a new leader instance.
\r
97 public Leader newLeader() {
\r
98 return new LeaderImpl();
\r
102 * Creates a new leader with the given <code>String</code> object.
\r
106 public Leader newLeader(String ldr) {
\r
107 return new LeaderImpl(ldr);
\r
111 * Returns a new record instance with a default leader.
\r
115 public Record newRecord() {
\r
116 return newRecord(new LeaderImpl("00000nam a2200000 a 4500"));
\r
120 * Returns a new subfield instance.
\r
124 public Subfield newSubfield() {
\r
125 return new SubfieldImpl();
\r
129 * Creates a new subfield with the given identifier.
\r
133 public Subfield newSubfield(char code) {
\r
134 return new SubfieldImpl(code);
\r
138 * Creates a new subfield with the given identifier and data.
\r
142 public Subfield newSubfield(char code, String data) {
\r
143 return new SubfieldImpl(code, data);
\r
146 public Record newRecord(Leader leader) {
\r
147 Record record = new RecordImpl();
\r
148 record.setLeader(leader);
\r
152 public Record newRecord(String leader) {
\r
153 return newRecord(new LeaderImpl(leader));
\r