01: /*
02: * Copyright (c) 1998 - 2005 Versant Corporation
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * Versant Corporation - initial API and implementation
10: */
11: package com.versant.core.metadata.parser;
12:
13: import com.versant.core.metadata.MDStaticUtils;
14: import com.versant.core.common.Debug;
15:
16: import java.io.PrintStream;
17: import java.util.Collections;
18:
19: /**
20: * Array element from a .jdo file.
21: */
22: public final class JdoArray extends JdoElement {
23:
24: public int embeddedElement;
25: public JdoExtension[] extensions;
26: public JdoField parent;
27:
28: public JdoElement getParent() {
29: return parent;
30: }
31:
32: /**
33: * Get information for this element to be used in building up a
34: * context string.
35: * @see #getContext
36: */
37: public String getSubContext() {
38: return "array";
39: }
40:
41: public String toString() {
42: StringBuffer s = new StringBuffer();
43: s.append("array embeddedElement=");
44: s.append(MDStaticUtils.toTriStateString(embeddedElement));
45: return s.toString();
46: }
47:
48: public void dump() {
49: dump(Debug.OUT, "");
50: }
51:
52: public void dump(PrintStream out, String indent) {
53: out.println(indent + this );
54: String is = indent + " ";
55: if (extensions != null) {
56: for (int i = 0; i < extensions.length; i++) {
57: extensions[i].dump(out, is);
58: }
59: }
60: }
61:
62: public void synchronizeForHorizontal(JdoArray array) {
63: if (array.extensions != null) {
64: JdoExtension[] copy = new JdoExtension[array.extensions.length];
65: for (int i = 0; i < array.extensions.length; i++) {
66: copy[i] = array.extensions[i].createCopy(this );
67: }
68: if (extensions != null) {
69: JdoExtension.synchronize3(extensions, copy,
70: Collections.EMPTY_SET, false);
71: } else {
72: extensions = copy;
73: }
74: }
75: }
76:
77: public JdoArray createCopy(JdoField jdoField) {
78: JdoArray tmp = new JdoArray();
79: tmp.parent = jdoField;
80: tmp.embeddedElement = embeddedElement;
81:
82: if (extensions != null) {
83: tmp.extensions = new JdoExtension[extensions.length];
84: for (int i = 0; i < extensions.length; i++) {
85: tmp.extensions[i] = extensions[i].createCopy(tmp);
86: }
87: }
88: return tmp;
89: }
90: }
|