KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ws > jaxme > pm > generator > jdbc > TableDetails


1 /*
2  * Copyright 2003, 2004 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.ws.jaxme.pm.generator.jdbc;
18
19 import java.util.ArrayList JavaDoc;
20 import java.util.List JavaDoc;
21 import java.util.StringTokenizer JavaDoc;
22
23 import org.apache.ws.jaxme.xs.XSSchema;
24 import org.apache.ws.jaxme.xs.impl.XSUtil;
25 import org.apache.ws.jaxme.xs.parser.impl.LocSAXException;
26 import org.apache.ws.jaxme.xs.xml.XsObject;
27 import org.xml.sax.SAXException JavaDoc;
28
29 /**
30  * @author <a HREF="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
31  */

32 public class TableDetails extends ConnectionDetails {
33   protected TableDetails(JaxMeJdbcSG pJdbcSG, XsObject pParent) throws SAXException {
34     super(pJdbcSG, pParent);
35
36     XSSchema schema = pParent.getXsESchema().getContext().getXSSchema();
37     if (schema != null) {
38       ConnectionDetails details = (ConnectionDetails)
39         XSUtil.getSingleAppinfo(schema.getAnnotations(), ConnectionDetails.class);
40       if (details != null) {
41         cloneFrom(details);
42       }
43     }
44   }
45
46   private String JavaDoc name;
47   private List JavaDoc keys;
48   /** Sets the tables name.
49    */

50   public void setName(String JavaDoc pName) {
51     name = pName;
52   }
53   /** Returns the tables name.
54    */

55   public String JavaDoc getName() {
56     return name;
57   }
58   /** Sets the names of the primary key columns.
59    */

60   public void setKeys(String JavaDoc pKeys) {
61     if (keys == null) {
62       keys = new ArrayList JavaDoc();
63     }
64     for (StringTokenizer JavaDoc st = new StringTokenizer JavaDoc(pKeys, ", "); st.hasMoreTokens(); ) {
65       keys.add(st.nextToken());
66     }
67   }
68   /** Returns the names of the primary key columns.
69    */

70   public List JavaDoc getKeys() {
71     return keys;
72   }
73   /** Copies the current details from the given.
74    */

75   public void cloneFrom(TableDetails pFrom) {
76     super.cloneFrom(pFrom);
77     name = pFrom.name;
78   }
79
80   public void validate() throws SAXException {
81     super.validate();
82     if (name == null || name.length() == 0) {
83       throw new LocSAXException("Missing or empty 'table' attribute.", getLocator());
84     }
85   }
86 }
Popular Tags