KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > triactive > jdo > model > ArrayMetaData


1 /*
2  * Copyright 2004 (C) TJDO.
3  * All rights reserved.
4  *
5  * This software is distributed under the terms of the TJDO License version 1.0.
6  * See the terms of the TJDO License in the documentation provided with this software.
7  *
8  * $Id: ArrayMetaData.java,v 1.1 2004/03/22 04:58:12 jackknifebarber Exp $
9  */

10
11 package com.triactive.jdo.model;
12
13 import java.util.List JavaDoc;
14 import java.util.Set JavaDoc;
15 import javax.jdo.JDOFatalInternalException;
16 import org.w3c.dom.Element JavaDoc;
17
18
19 public class ArrayMetaData extends MetaData
20 {
21     protected final Class JavaDoc elementType;
22     protected final boolean embeddedElement;
23
24     public ArrayMetaData(FieldMetaData fmd, Element JavaDoc elem)
25     {
26         super(fmd.getClassMetaData().getSourceURL(), elem);
27
28         elementType = fmd.getType().getComponentType();
29
30         String JavaDoc embeddedAttr = elem.getAttribute("embedded-element");
31
32         if (embeddedAttr.length() > 0)
33             embeddedElement = Boolean.valueOf(embeddedAttr).booleanValue();
34         else
35             embeddedElement = Types.isDefaultEmbeddedType(elementType);
36     }
37
38     public String JavaDoc getJavaName()
39     {
40         throw new JDOFatalInternalException("ArrayMetaData has no equivalent Java identifier");
41     }
42
43     public Class JavaDoc getElementType()
44     {
45         return elementType;
46     }
47
48     public boolean isEmbeddedElement()
49     {
50         return embeddedElement;
51     }
52
53     public ColumnOptions getElementColumnOptions()
54     {
55         return new ColumnOptions()
56         {
57             public String JavaDoc getLength()
58             {
59                 return getVendorExtension(MY_VENDOR, "length");
60             }
61
62             public String JavaDoc getPrecision()
63             {
64                 return getVendorExtension(MY_VENDOR, "precision");
65             }
66
67             public String JavaDoc getScale()
68             {
69                 return getVendorExtension(MY_VENDOR, "scale");
70             }
71         };
72     }
73
74     void getReferencedClasses(String JavaDoc vendorID, List JavaDoc ordered, Set JavaDoc referenced)
75     {
76         ClassMetaData cmd = ClassMetaData.forClass(elementType);
77
78         if (cmd != null)
79             cmd.getReferencedClasses(vendorID, ordered, referenced);
80     }
81 }
82
Popular Tags