1 package org.apache.commons.digester3.examples.api.dbinsert;
2
3 /*
4 * Licensed to the Apache Software Foundation (ASF) under one or more
5 * contributor license agreements. See the NOTICE file distributed with
6 * this work for additional information regarding copyright ownership.
7 * The ASF licenses this file to You under the Apache License, Version 2.0
8 * (the "License"); you may not use this file except in compliance with
9 * the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 */
19
20 import java.util.List;
21 import java.util.LinkedList;
22
23 /**
24 * See Main.java.
25 */
26 public class Row
27 {
28
29 /**
30 * Alas, we can't just use a Map to store the (name, value) pairs
31 * because the output will look weird if we don't preserve the column
32 * order. This wouldn't be a problem if we were really inserting into
33 * a database; it only matters because we are displaying the SQL statements
34 * via stdout instead. The LinkedHashMap class would be nice to use, but
35 * that would require java 1.4, so we'll use a list instead, and may as
36 * well call the entries in the list 'Column' objects.
37 */
38 public static class Column
39 {
40 private String name, value;
41
42 public Column( String name, String value )
43 {
44 this.name = name;
45 this.value = value;
46 }
47
48 public String getName()
49 {
50 return name;
51 }
52
53 public String getValue()
54 {
55 return value;
56 }
57 }
58
59 private LinkedList<Column> columns = new LinkedList<Column>();
60
61 public Row()
62 {
63 }
64
65 public void addColumn( String name, String value )
66 {
67 columns.add( new Column( name, value ) );
68 }
69
70 public List<Column> getColumns()
71 {
72 return columns;
73 }
74
75 }