Revision: 1778
Author:
olso...@gmail.com
Date: Mon Feb 16 20:04:32 2015 UTC
Log: autmatically trim whitespace from LC call number
https://code.google.com/p/solrmarc/source/detail?r=1778
Modified:
/trunk/lib/solrmarc/src/org/solrmarc/callnum/LCCallNumber.java
/trunk/test/src/org/solrmarc/callnum/LCCallNumberUnitTests.java
=======================================
--- /trunk/lib/solrmarc/src/org/solrmarc/callnum/LCCallNumber.java Mon Feb
16 18:24:17 2015 UTC
+++ /trunk/lib/solrmarc/src/org/solrmarc/callnum/LCCallNumber.java Mon Feb
16 20:04:32 2015 UTC
@@ -246,12 +246,16 @@
}
/**
- * This parse can be used in conjunction with the empty constructor
+ * This parse can be used in conjunction with the empty constructor.
+ *
+ * Leading and training whitespace will automatically be trimmed
before call number is stored and parsed.
+ *
+ * @param call call number to parse
*/
@Override
public void parse(String call) {
init();
- this.rawCallNum = call;
+ this.rawCallNum = call.trim();
parse();
}
=======================================
--- /trunk/test/src/org/solrmarc/callnum/LCCallNumberUnitTests.java Mon Feb
16 18:24:17 2015 UTC
+++ /trunk/test/src/org/solrmarc/callnum/LCCallNumberUnitTests.java Mon Feb
16 20:04:32 2015 UTC
@@ -1078,6 +1078,23 @@
callnum = "BF199.";
assertEquals("BF 3199", new LCCallNumber(callnum).getShelfKey());
}
+
+ /**
+ * unit test for getShelfKey: check that leading whitespace
+ * produce the same shelfkey
+ */
+ @Test
+ public void testGetShelfKey_leadingSpaces()
+ {
+ String callnum = " BQ1270";
+ assertEquals("BQ 41270", new LCCallNumber(callnum).getShelfKey());
+ callnum = "BQ 1270";
+ assertEquals("BQ 41270", new LCCallNumber(callnum).getShelfKey());
+ callnum = "\tBQ1270";
+ assertEquals("BQ 41270", new LCCallNumber(callnum).getShelfKey());
+ callnum = " \t BQ 1270";
+ assertEquals("BQ 41270", new LCCallNumber(callnum).getShelfKey());
+ }
/**
* unit test for getShelfKey: check that trailing spaces