|
40 | 40 | @FluxCommand("handle-generic-xml")
|
41 | 41 | public final class GenericXmlHandler extends DefaultXmlPipe<StreamReceiver> {
|
42 | 42 |
|
| 43 | + public static final String DEFAULT_RECORD_TAG = "record"; |
| 44 | + |
43 | 45 | private static final Pattern TABS = Pattern.compile("\t+");
|
44 |
| - private final String recordTagName; |
| 46 | + |
| 47 | + private String recordTagName = DEFAULT_RECORD_TAG; |
| 48 | + |
45 | 49 | private boolean inRecord;
|
46 | 50 | private StringBuilder valueBuffer = new StringBuilder();
|
47 | 51 |
|
48 | 52 | public GenericXmlHandler() {
|
49 | 53 | super();
|
50 |
| - this.recordTagName = System.getProperty( |
| 54 | + final String recordTagNameProperty = System.getProperty( |
51 | 55 | "org.culturegraph.metamorph.xml.recordtag");
|
52 |
| - if (recordTagName == null) { |
53 |
| - throw new MetafactureException("Missing name for the tag marking a record."); |
| 56 | + if (recordTagNameProperty != null) { |
| 57 | + recordTagName = recordTagNameProperty; |
54 | 58 | }
|
55 | 59 | }
|
56 | 60 |
|
| 61 | + /** |
| 62 | + * Creates a new {@ode GenericXmlReader} with the given tag name as |
| 63 | + * marker for records. |
| 64 | + * |
| 65 | + * @deprecated Use default constructor and set the tag name latter |
| 66 | + * with {@link #setRecordTagName(String)}. |
| 67 | + * |
| 68 | + * @param recordTagName tag name marking the start of a record. |
| 69 | + */ |
| 70 | + @Deprecated |
57 | 71 | public GenericXmlHandler(final String recordTagName) {
|
58 | 72 | super();
|
59 | 73 | this.recordTagName = recordTagName;
|
60 | 74 | }
|
61 | 75 |
|
| 76 | + /** |
| 77 | + * Sets the tag name which marks the start of a record. |
| 78 | + * <p> |
| 79 | + * This value may only be changed between records. If it is changed |
| 80 | + * while processing a record the behaviour of this module is undefined. |
| 81 | + * <p> |
| 82 | + * <strong>Default value: {@value DEFAULT_RECORD_TAG}</strong> |
| 83 | + * |
| 84 | + * @param recordTagName the tag name which marks the start of a record. |
| 85 | + */ |
| 86 | + public void setRecordTagName(String recordTagName) { |
| 87 | + this.recordTagName = recordTagName; |
| 88 | + } |
| 89 | + |
| 90 | + public String getRecordTagName() { |
| 91 | + return recordTagName; |
| 92 | + } |
| 93 | + |
62 | 94 | @Override
|
63 | 95 | public void startElement(final String uri, final String localName,
|
64 | 96 | final String qName, final Attributes attributes) {
|
|
0 commit comments