01: /*
02: * Copyright 2004 (C) TJDO.
03: * All rights reserved.
04: *
05: * This software is distributed under the terms of the TJDO License version 1.0.
06: * See the terms of the TJDO License in the documentation provided with this software.
07: *
08: * $Id: ArrayMetaData.java,v 1.1 2004/03/22 04:58:12 jackknifebarber Exp $
09: */
10:
11: package com.triactive.jdo.model;
12:
13: import java.util.List;
14: import java.util.Set;
15: import javax.jdo.JDOFatalInternalException;
16: import org.w3c.dom.Element;
17:
18: public class ArrayMetaData extends MetaData {
19: protected final Class elementType;
20: protected final boolean embeddedElement;
21:
22: public ArrayMetaData(FieldMetaData fmd, Element elem) {
23: super (fmd.getClassMetaData().getSourceURL(), elem);
24:
25: elementType = fmd.getType().getComponentType();
26:
27: String embeddedAttr = elem.getAttribute("embedded-element");
28:
29: if (embeddedAttr.length() > 0)
30: embeddedElement = Boolean.valueOf(embeddedAttr)
31: .booleanValue();
32: else
33: embeddedElement = Types.isDefaultEmbeddedType(elementType);
34: }
35:
36: public String getJavaName() {
37: throw new JDOFatalInternalException(
38: "ArrayMetaData has no equivalent Java identifier");
39: }
40:
41: public Class getElementType() {
42: return elementType;
43: }
44:
45: public boolean isEmbeddedElement() {
46: return embeddedElement;
47: }
48:
49: public ColumnOptions getElementColumnOptions() {
50: return new ColumnOptions() {
51: public String getLength() {
52: return getVendorExtension(MY_VENDOR, "length");
53: }
54:
55: public String getPrecision() {
56: return getVendorExtension(MY_VENDOR, "precision");
57: }
58:
59: public String getScale() {
60: return getVendorExtension(MY_VENDOR, "scale");
61: }
62: };
63: }
64:
65: void getReferencedClasses(String vendorID, List ordered,
66: Set referenced) {
67: ClassMetaData cmd = ClassMetaData.forClass(elementType);
68:
69: if (cmd != null)
70: cmd.getReferencedClasses(vendorID, ordered, referenced);
71: }
72: }
|