|
From: <zep...@us...> - 2007-04-21 22:33:48
|
Revision: 307
http://svn.sourceforge.net/pzfilereader/?rev=307&view=rev
Author: zepernick
Date: 2007-04-21 15:33:49 -0700 (Sat, 21 Apr 2007)
Log Message:
-----------
Feature request 1596087. ADded the ability to determine the correct <record> element based
on the number of elements. This only applies to delimited files.
Modified Paths:
--------------
trunk/PZFileReader/src/main/java/net/sf/pzfilereader/util/ParserUtils.java
trunk/PZFileReader/src/main/java/net/sf/pzfilereader/xml/PZMapParser.java
trunk/PZFileReader/src/main/java/net/sf/pzfilereader/xml/XMLRecordElement.java
trunk/PZFileReader/src/main/java/net/sf/pzfilereader/xml/pzfilereader.dtd
Modified: trunk/PZFileReader/src/main/java/net/sf/pzfilereader/util/ParserUtils.java
===================================================================
--- trunk/PZFileReader/src/main/java/net/sf/pzfilereader/util/ParserUtils.java 2007-04-21 22:32:06 UTC (rev 306)
+++ trunk/PZFileReader/src/main/java/net/sf/pzfilereader/util/ParserUtils.java 2007-04-21 22:33:49 UTC (rev 307)
@@ -583,11 +583,17 @@
// others match
}
final XMLRecordElement recordXMLElement = (XMLRecordElement) entry.getValue();
-
- if (recordXMLElement.getElementNumber() > lineElements.size()) {
+
+ if (recordXMLElement.getElementCount() > 0 &&
+ recordXMLElement.getElementCount() == lineElements.size()) {
+ //determing which <record> mapping to use by the number of elements
+ //contained on the line
+ return (String)entry.getKey();
+ } else if (recordXMLElement.getElementNumber() > lineElements.size()) {
// make sure the element referenced in the mapping exists
continue;
}
+
final String lineElement = (String) lineElements.get(recordXMLElement.getElementNumber() - 1);
if (lineElement.equals(recordXMLElement.getIndicator())) {
// we found the MD object we want to return
Modified: trunk/PZFileReader/src/main/java/net/sf/pzfilereader/xml/PZMapParser.java
===================================================================
--- trunk/PZFileReader/src/main/java/net/sf/pzfilereader/xml/PZMapParser.java 2007-04-21 22:32:06 UTC (rev 306)
+++ trunk/PZFileReader/src/main/java/net/sf/pzfilereader/xml/PZMapParser.java 2007-04-21 22:33:49 UTC (rev 307)
@@ -154,11 +154,11 @@
while (recordDescriptors.hasNext()) {
final Element xmlElement = (Element) recordDescriptors.next();
- // make sure the id attribute does not have a value of "detail" this
- // is the harcoded
- // value we are using to mark columns specified outside of a
- // <RECORD> element
if (xmlElement.getAttributeValue("id").equals(PZConstants.DETAIL_ID)) {
+ // make sure the id attribute does not have a value of "detail" this
+ // is the harcoded
+ // value we are using to mark columns specified outside of a
+ // <RECORD> element
throw new IllegalArgumentException(
"The ID 'detail' on the <RECORD> element is reserved, please select another id");
}
@@ -170,6 +170,7 @@
xmlre.setElementNumber(convertAttributeToInt(xmlElement.getAttribute("elementNumber")));
xmlre.setStartPosition(convertAttributeToInt(xmlElement.getAttribute("startPosition")));
xmlre.setEndPositition(convertAttributeToInt(xmlElement.getAttribute("endPosition")));
+ xmlre.setElementCount(convertAttributeToInt(xmlElement.getAttribute("elementCount")));
mdIndex.put(xmlElement.getAttributeValue("id"), xmlre);
}
Modified: trunk/PZFileReader/src/main/java/net/sf/pzfilereader/xml/XMLRecordElement.java
===================================================================
--- trunk/PZFileReader/src/main/java/net/sf/pzfilereader/xml/XMLRecordElement.java 2007-04-21 22:32:06 UTC (rev 306)
+++ trunk/PZFileReader/src/main/java/net/sf/pzfilereader/xml/XMLRecordElement.java 2007-04-21 22:33:49 UTC (rev 307)
@@ -31,6 +31,8 @@
private int endPositition = 0;
private int elementNumber = 0;
+
+ private int elementCount = 0;
private String indicator;
@@ -144,4 +146,24 @@
}
return idx;
}
+
+ /**
+ * Used to determine the <record> mapping the row belongs to. Will
+ * only be evaluated if > 0.
+ *
+ * @return the elementCount
+ */
+ public int getElementCount() {
+ return elementCount;
+ }
+
+ /**
+ * Used to determine the <record> mapping the row belongs to. Will
+ * only be evaluated if > 0.
+ *
+ * @param elementCount the elementCount to set
+ */
+ public void setElementCount(int elementCount) {
+ this.elementCount = elementCount;
+ }
}
Modified: trunk/PZFileReader/src/main/java/net/sf/pzfilereader/xml/pzfilereader.dtd
===================================================================
--- trunk/PZFileReader/src/main/java/net/sf/pzfilereader/xml/pzfilereader.dtd 2007-04-21 22:32:06 UTC (rev 306)
+++ trunk/PZFileReader/src/main/java/net/sf/pzfilereader/xml/pzfilereader.dtd 2007-04-21 22:33:49 UTC (rev 307)
@@ -5,7 +5,8 @@
startPosition CDATA "1"
endPosition CDATA "1"
elementNumber CDATA "1"
- indicator CDATA #REQUIRED>
+ elementCount CDATA "0"
+ indicator CDATA "">
<!ELEMENT COLUMN EMPTY>
<!ATTLIST COLUMN name CDATA #REQUIRED
length CDATA "1" >
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|