Parsing through a table - looking for a matching values

Here is the code where I am creating my table values.
 public Object getValueAt(int row, int column) {
      Object o = null;
      try {
         switch (column) {
            case ITEMID_COL: {
               o = rds.get(row).rev.getItem().getStringProperty("item_id");
            case REVID_COL: {
               o = rds.get(row).rev.getStringProperty("item_revision_id");
            case PRL_COL: {
             String prl = getRevPrl(rds.get(row).rev);
             if (isMatrixPRLCellReadOnly == true) {
                o = prl;
             else {
                 if ((prl == null || prl.isEmpty())){
                    o = pmap.get(rds.get(row).rev);
                 else {
                    o = prl;
            case DATASETNAME_COL: {
               o = rds.get(row).componentdataset.getStringProperty("object_string");
            case DATASET_COL: {
               o = rds.get(row).componentdataset.getStringProperty("object_type");
            case COMMENT_COL: {
               o = cmap.get(rds.get(row).rev);
            case REVUID_COL: {
               o = rds.get(row).rev.getUid();
            case DSETUID_COL: {
               o = rds.get(row).componentdataset.getUid();
      catch (Exception e) {
      return o;

Open in new window

Then I am parsing information from the table to create a XML String

public void getTableXML(StringBuffer sb) {
      for(int i = 0; i < SingletonSelectTable.getInstance().getRowCount(); i++) {
         Object item_id = SingletonSelectTable.getInstance().getValueAt(i, SingletonSelectTable.getInstance().ITEMID_COL);
         Object rev_id = SingletonSelectTable.getInstance().getValueAt(i, SingletonSelectTable.getInstance().REVID_COL);
         Object prl_id = SingletonSelectTable.getInstance().getValueAt(i, SingletonSelectTable.getInstance().PRL_COL);
         Object datasetName_id = SingletonSelectTable.getInstance().getValueAt(i, SingletonSelectTable.getInstance().DATASETNAME_COL);
         Object datasetType_id = SingletonSelectTable.getInstance().getValueAt(i, SingletonSelectTable.getInstance().DATASET_COL);
         Object comment_id = SingletonSelectTable.getInstance().getValueAt(i, SingletonSelectTable.getInstance().COMMENT_COL);
         Object revu_id = SingletonSelectTable.getInstance().getValueAt(i, SingletonSelectTable.getInstance().REVUID_COL);
         Object dsetu_id = SingletonSelectTable.getInstance().getValueAt(i, SingletonSelectTable.getInstance().DSETUID_COL);
         sb.append("   <ItemRevision itemId=\"" + item_id + "\"");
         sb.append(" revId=\"" + rev_id + "\"");
         sb.append(" prl=\"" + prl_id+ "\"");
         sb.append(" Uid=\"" + revu_id+ "\"");
         sb.append("      <Comment>" + comment_id + "</Comment>\n");
         sb.append("      <Dataset name=\"" + datasetName_id + "\"");
         sb.append(" type=\"" + datasetType_id + "\"");
         sb.append(" Uid=\"" + dsetu_id + "\"");
         sb.append(" />\n");
         sb.append("   </ItemRevision>\n");

Open in new window

What I am trying to do is look for a matching value.

say that I have 5 entries in my table and there are 2 that have the same item_id
I want to create the logic that parsing through the table and when finds a match it will print out found match.

I am not sure what is the best way to parse the table.  I am guessing we would have to get the first value for item_id and the check the rest of the table looking for a matching item_id.  The we would have to get the second value for item_id and parse the table again?

I really  do not know how to approach this.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

you may want to deal with the underlying tablemodel. override the tablemodel in such a way that it is aware of rows having the same item ids.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
yeah you need to use TableModel to set/retreive data to JTable.
you'll have more control over the data manipulating the JTable.
jkteaterAuthor Commented:
Can you show me an example of what you are suggesting?
jkteaterAuthor Commented:
I really need to figure out how to do this.  I am going to increase the points.  I could really use a example to help me understand.  

In my XML string, I need to know if the data in the table is a part or a drawing.  The only time I need to check for drawing or part is when I have a drawing for a part.  If that is the case they will share the same item_id, but could be on different rows in the table.  The table can have any where from 1 to 50 entries.
jkteaterAuthor Commented:
Ok lets assume that I have a arraylist - the list looks something like this

item          rev            type
1001         1001-1       part
1002         1002-1       part
1001         1001-1       drawing

so when I am writing out to my xml string - I need it to look something like this (not formatted)

<ItemRev item="1001" rev "1001-1">
          <Masterdata  Name="foo" type="part"/>
          <ExtraData Name="foo" type="drawing"\>
<ItemRev item="1002" rev "1002-1">
          <Masterdata  Name="foo1" type="part"/>

as you see above that 1001 has 2 entries in the table/arraylist - one being a part and one a drawing.

How would you parse that arraylist - I am going to use rev as my key to look for matches

Here is what I am was thinking about the logic

get first entry in array
get rev value
check the rest of the array looking for a matching value of rev
if no match
write xml string to buffer
if match
   get name value and and type value for the first entry and the matching entry
   if type value = part
       write xml buffer for masterdata
       write xml buffer for extradata

but then what happens - if you h ave to do each line and check every line, that could take a while logically.

I hope the above makes more since at what I am trying to do
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.