001package org.apache.commons.digester3.examples.api.dbinsert; 002 003/* 004 * Licensed to the Apache Software Foundation (ASF) under one or more 005 * contributor license agreements. See the NOTICE file distributed with 006 * this work for additional information regarding copyright ownership. 007 * The ASF licenses this file to You under the Apache License, Version 2.0 008 * (the "License"); you may not use this file except in compliance with 009 * the License. You may obtain a copy of the License at 010 * 011 * http://www.apache.org/licenses/LICENSE-2.0 012 * 013 * Unless required by applicable law or agreed to in writing, software 014 * distributed under the License is distributed on an "AS IS" BASIS, 015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 016 * See the License for the specific language governing permissions and 017 * limitations under the License. 018 */ 019 020import java.util.List; 021import java.util.LinkedList; 022 023/** 024 * See Main.java. 025 */ 026public class Row 027{ 028 029 /** 030 * Alas, we can't just use a Map to store the (name, value) pairs 031 * because the output will look weird if we don't preserve the column 032 * order. This wouldn't be a problem if we were really inserting into 033 * a database; it only matters because we are displaying the SQL statements 034 * via stdout instead. The LinkedHashMap class would be nice to use, but 035 * that would require java 1.4, so we'll use a list instead, and may as 036 * well call the entries in the list 'Column' objects. 037 */ 038 public static class Column 039 { 040 private String name, value; 041 042 public Column( String name, String value ) 043 { 044 this.name = name; 045 this.value = value; 046 } 047 048 public String getName() 049 { 050 return name; 051 } 052 053 public String getValue() 054 { 055 return value; 056 } 057 } 058 059 private LinkedList<Column> columns = new LinkedList<Column>(); 060 061 public Row() 062 { 063 } 064 065 public void addColumn( String name, String value ) 066 { 067 columns.add( new Column( name, value ) ); 068 } 069 070 public List<Column> getColumns() 071 { 072 return columns; 073 } 074 075}