I have a multidimentional array that is for a JTable. But it is not displaying the data correctly in the JTable its displaying like this from up to down on each row :
nidRbc nidRbc nidRbc nidRbc nidRbc nidRbc nidRbc nidRbc nidRbc
INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER
RBC identity RBC identity RBC identity RBC identity RBC identity RBC identity RBC identity RBC identity RBC identity
1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1
0 0 0 0 0 0 0 0 0
NULL NULL NULL NULL NULL NULL NULL NULL NULL
0:16382 0:16382 0:16382 0:16382 0:16382 0:16382 0:16382 0:16382 0:16382
maxRouteLength maxRouteLength maxRouteLength maxRouteLength maxRouteLength maxRouteLength maxRouteLength maxRouteLength maxRouteLength
NUMBER:3 NUMBER:3 NUMBER:3 NUMBER:3 NUMBER:3 NUMBER:3 NUMBER:3 NUMBER:3 NUMBER:3
Maximum length (km) of a locked route Maximum length (km) of a locked route Maximum length (km) of a locked route Maximum length (km) of a locked route Maximum length (km) of a locked route Maximum length (km) of a locked route Maximum length (km) of a locked route Maximum length (km) of a locked route Maximum length (km) of a locked route
1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1
2 2 2 2 2 2 2 2 2
0 0 0 0 0 0 0 0 0
50 50 50 50 50 50 50 50 50
###.### ###.### ###.### ###.### ###.### ###.### ###.### ###.### ###.###
minRouteLength minRouteLength minRouteLength minRouteLength minRouteLength minRouteLength minRouteLength minRouteLength minRouteLength
INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER
Minimum length (m) of a locked route Minimum length (m) of a locked route Minimum length (m) of a locked route Minimum length (m) of a locked route Minimum length (m) of a locked route Minimum length (m) of a locked route Minimum length (m) of a locked route Minimum length (m) of a locked route Minimum length (m) of a locked route
1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1
3 3 3 3 3 3 3 3 3
0 0 0 0 0 0 0 0 0
300 300 300 300 300 300 300 300 300
0:1000 0:1000 0:1000 0:1000 0:1000 0:1000 0:1000 0:1000 0:1000
maxMALength maxMALength maxMALength maxMALength maxMALength maxMALength maxMALength maxMALength maxMALength
NUMBER:3 NUMBER:3 NUMBER:3 NUMBER:3 NUMBER:3 NUMBER:3 NUMBER:3 NUMBER:3 NUMBER:3
Max length (km) for a Movement Authority Max length (km) for a Movement Authority Max length (km) for a Movement Authority Max length (km) for a Movement Authority Max length (km) for a Movement Authority Max length (km) for a Movement Authority Max length (km) for a Movement Authority Max length (km) for a Movement Authority Max length (km) for a Movement Authority
1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1
4 4 4 4 4 4 4 4 4
0 0 0 0 0 0 0 0 0
50 50 50 50 50 50 50 50 50
###.### ###.### ###.### ###.### ###.### ###.### ###.### ###.### ###.###
minMAExtension minMAExtension minMAExtension minMAExtension minMAExtension minMAExtension minMAExtension minMAExtension minMAExtension
INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER
Min length (m) to extend an existing MA Min length (m) to extend an existing MA Min length (m) to extend an existing MA Min length (m) to extend an existing MA Min length (m) to extend an existing MA Min length (m) to extend an existing MA Min length (m) to extend an existing MA Min length (m) to extend an existing MA Min length (m) to extend an existing MA
1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1
5 5 5 5 5 5 5 5 5
0 0 0 0 0 0 0 0 0
NULL NULL NULL NULL NULL NULL NULL NULL NULL
0:1000 0:1000 0:1000 0:1000 0:1000 0:1000 0:1000 0:1000 0:1000
minTrainSeparation minTrainSeparation minTrainSeparation minTrainSeparation minTrainSeparation minTrainSeparation minTrainSeparation minTrainSeparation minTrainSeparation
INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER
Min distance (m) between two trains Min distance (m) between two trains Min distance (m) between two trains Min distance (m) between two trains Min distance (m) between two trains Min distance (m) between two trains Min distance (m) between two trains Min distance (m) between two trains Min distance (m) between two trains
1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1
6 6 6 6 6 6 6 6 6
0 0 0 0 0 0 0 0 0
NULL NULL NULL NULL NULL NULL NULL NULL NULL
0:1000 0:1000 0:1000 0:1000 0:1000 0:1000 0:1000 0:1000 0:1000
siteOwner siteOwner siteOwner siteOwner siteOwner siteOwner siteOwner siteOwner siteOwner
STRING STRING STRING STRING STRING STRING STRING STRING STRING
Country and owner of line (for communication identities) Country and owner of line (for communication identities) Country and owner of line (for communication identities) Country and owner of line (for communication identities) Country and owner of line (for communication identities) Country and owner of line (for communication identities) Country and owner of line (for communication identities) Country and owner of line (for communication identities) Country and owner of line (for communication identities)
1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1
7 7 7 7 7 7 7 7 7
0 0 0 0 0 0 0 0 0
NULL NULL NULL NULL NULL NULL NULL NULL NULL
[^/]{1,5}/[^/]{1,5} [^/]{1,5}/[^/]{1,5} [^/]{1,5}/[^/]{1,5} [^/]{1,5}/[^/]{1,5} [^/]{1,5}/[^/]{1,5} [^/]{1,5}/[^/]{1,5} [^/]{1,5}/[^/]{1,5} [^/]{1,5}/[^/]{1,5} [^/]{1,5}/[^/]{1,5}
siteName siteName siteName siteName siteName siteName siteName siteName siteName
STRING STRING STRING STRING STRING STRING STRING STRING STRING
Name of line (for communication identities) Name of line (for communication identities) Name of line (for communication identities) Name of line (for communication identities) Name of line (for communication identities) Name of line (for communication identities) Name of line (for communication identities) Name of line (for communication identities) Name of line (for communication identities)
1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1
8 8 8 8 8 8 8 8 8
0 0 0 0 0 0 0 0 0
NULL NULL NULL NULL NULL NULL NULL NULL NULL
[^/]{1,15} [^/]{1,15} [^/]{1,15} [^/]{1,15} [^/]{1,15} [^/]{1,15} [^/]{1,15} [^/]{1,15} [^/]{1,15}
docNoSiteDataReport docNoSiteDataReport docNoSiteDataReport docNoSiteDataReport docNoSiteDataReport docNoSiteDataReport docNoSiteDataReport docNoSiteDataReport docNoSiteDataReport
STRING STRING STRING STRING STRING STRING STRING STRING STRING
Document number for site data report Document number for site data report Document number for site data report Document number for site data report Document number for site data report Document number for site data report Document number for site data report Document number for site data report Document number for site data report
1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1
9 9 9 9 9 9 9 9 9
0 0 0 0 0 0 0 0 0
NULL NULL NULL NULL NULL NULL NULL NULL NULL
NULL NULL NULL NULL NULL NULL NULL NULL NULL
docNoBaliseList docNoBaliseList docNoBaliseList docNoBaliseList docNoBaliseList docNoBaliseList docNoBaliseList docNoBaliseList docNoBaliseList
STRING STRING STRING STRING STRING STRING STRING STRING STRING
Document number for balise list Document number for balise list Document number for balise list Document number for balise list Document number for balise list Document number for balise list Document number for balise list Document number for balise list Document number for balise list
1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1
10 10 10 10 10 10 10 10 10
0 0 0 0 0 0 0 0 0
NULL NULL NULL NULL NULL NULL NULL NULL NULL
NULL NULL NULL NULL NULL NULL NULL NULL NULL
docNoGeographicalReport docNoGeographicalReport docNoGeographicalReport docNoGeographicalReport docNoGeographicalReport docNoGeographicalReport docNoGeographicalReport docNoGeographicalReport docNoGeographicalReport
STRING STRING STRING STRING STRING STRING STRING STRING STRING
Document number for geographical report Document number for geographical report Document number for geographical report Document number for geographical report Document number for geographical report Document number for geographical report Document number for geographical report Document number for geographical report Document number for geographical report
1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1
11 11 11 11 11 11 11 11 11
0 0 0 0 0 0 0 0 0
NULL NULL NULL NULL NULL NULL NULL NULL NULL
NULL NULL NULL NULL NULL NULL NULL NULL NULL
nidC nidC nidC nidC nidC nidC nidC nidC nidC
INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER
Country identity Country identity Country identity Country identity Country identity Country identity Country identity Country identity Country identity
0 0 0 0 0 0 0 0 0
1 1 1 1 1 1 1 1 1
12 12 12 12 12 12 12 12 12
0 0 0 0 0 0 0 0 0
NULL NULL NULL NULL NULL NULL NULL NULL NULL
1:1023 1:1023 1:1023 1:1023 1:1023 1:1023 1:1023 1:1023 1:1023
But I want it to display from left to right each data not from up to down
so should be like this :
nidRbc INTEGER RBC 1 1 1 0 NULL 0:16382
maxRouteLength NUMBER:3 Maximum 1 1 2 0 50 ###.###
minRouteLength INTEGER . ... . etc etc..
This is my code right now :
// Create a list of node and compile the xpath expression
NodeList nodeList = (NodeList) xPath.compile(expression).evaluate(
xmlDocument, XPathConstants.NODESET);
System.out.println("nodelist length : " + nodeList.getLength());
System.out.println("constant length : "
+ constants.getParamColumns().length);
// Create a new string for the array
arr = new String[nodeList.getLength()][constants.getParamColumns().length];
// Loop through the list and save the data in a string array.
for (int i = 0; i < nodeList.getLength(); i++) {
for (int j = 0; j < constants.getParamColumns().length; j++) {
System.out.println("content : "
+ nodeList.item(i).getTextContent());
arr[i][j] = nodeList.item(i).getTextContent();
// System.out.println("Param : " + Arrays.toString(arr));
}
}
This is the solution :
for (int i = 0; i < nodeList.getLength()
/ constants.getParamColumns().length; i++) {
for (int j = 0; j < constants.getParamColumns().length; j++) {
arr[i][j] = nodeList.item(
j + (i * constants.getParamColumns().length))
.getTextContent();
}
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments