\r
private CharConverter converterAnsel = null;\r
\r
+ private boolean setBadIndicators = true;\r
+\r
/**\r
* Constructs an instance with the specified input stream.\r
*/\r
inputrec.readFully(byteArray);\r
\r
try {\r
- record.addVariableField(parseDataField(tags[i], byteArray));\r
+ DataField dataField = parseDataField(tags[i], byteArray);\r
+ // dataField could be null if bad indicators\r
+ if (dataField != null) \r
+ record.addVariableField(dataField);\r
} catch (IOException e) {\r
throw new MarcException(\r
"error parsing data field for tag: " + tags[i]\r
\r
DataField dataField = factory.newDataField();\r
dataField.setTag(tag);\r
- dataField.setIndicator1(ind1);\r
- dataField.setIndicator2(ind2);\r
\r
+ boolean badIndicatorFound = false;\r
+ if (setBadIndicators || ind1 >= ' ' )\r
+ dataField.setIndicator1(ind1);\r
+ else\r
+ badIndicatorFound = true;\r
+ if (setBadIndicators || ind2 >= ' ')\r
+ dataField.setIndicator2(ind2);\r
+ else\r
+ badIndicatorFound = true;\r
int code;\r
int size;\r
int readByte;\r
break;\r
}\r
}\r
+ /* Bad Indicators was found, so dropping field */\r
+ if (badIndicatorFound)\r
+ return null;\r
return dataField;\r
}\r
\r
else if (encoding.equals("MARC-8") || encoding.equals("MARC8"))\r
{\r
if (converterAnsel == null) converterAnsel = new AnselToUnicode();\r
+\r
+ for (int index = 0; index < bytes.length; index++)\r
+ if (bytes[index] < 32)\r
+ bytes[index] = ' ';\r
dataElement = converterAnsel.convert(bytes);\r
+ //dataElement = dataElement.replaceAll("\0", " ");\r
}\r
else if (encoding.equals("ISO-8859-1") || encoding.equals("ISO8859_1"))\r
{\r
}\r
return dataElement;\r
}\r
+\r
+ public boolean isBadIndicators() {\r
+ return setBadIndicators;\r
+ }\r
+\r
+ public void setBadIndicators(boolean trueFalse) {\r
+ this.setBadIndicators = trueFalse;\r
+ }\r
\r
}
\ No newline at end of file