KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > versant > core > metadata > parser > JdoArray


1
2 /*
3  * Copyright (c) 1998 - 2005 Versant Corporation
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  * Versant Corporation - initial API and implementation
11  */

12 package com.versant.core.metadata.parser;
13
14 import com.versant.core.metadata.MDStaticUtils;
15 import com.versant.core.common.Debug;
16
17 import java.io.PrintStream JavaDoc;
18 import java.util.Collections JavaDoc;
19
20 /**
21  * Array element from a .jdo file.
22  */

23 public final class JdoArray extends JdoElement {
24
25     public int embeddedElement;
26     public JdoExtension[] extensions;
27     public JdoField parent;
28
29     public JdoElement getParent() { return parent; }
30
31     /**
32      * Get information for this element to be used in building up a
33      * context string.
34      * @see #getContext
35      */

36     public String JavaDoc getSubContext() {
37         return "array";
38     }
39
40     public String JavaDoc toString() {
41         StringBuffer JavaDoc s = new StringBuffer JavaDoc();
42         s.append("array embeddedElement=");
43         s.append(MDStaticUtils.toTriStateString(embeddedElement));
44         return s.toString();
45     }
46
47     public void dump() {
48         dump(Debug.OUT, "");
49     }
50
51     public void dump(PrintStream JavaDoc out, String JavaDoc indent) {
52         out.println(indent + this);
53         String JavaDoc is = indent + " ";
54         if (extensions != null) {
55             for (int i = 0; i < extensions.length; i++) {
56                 extensions[i].dump(out, is);
57             }
58         }
59     }
60
61     public void synchronizeForHorizontal(JdoArray array) {
62         if (array.extensions != null) {
63             JdoExtension[] copy = new JdoExtension[array.extensions.length];
64             for (int i = 0; i < array.extensions.length; i++) {
65                 copy[i] = array.extensions[i].createCopy(this);
66             }
67             if (extensions != null) {
68                 JdoExtension.synchronize3(extensions, copy, Collections.EMPTY_SET, false);
69             } else {
70                 extensions = copy;
71             }
72         }
73     }
74
75     public JdoArray createCopy(JdoField jdoField) {
76         JdoArray tmp = new JdoArray();
77         tmp.parent = jdoField;
78         tmp.embeddedElement = embeddedElement;
79
80         if (extensions != null) {
81             tmp.extensions = new JdoExtension[extensions.length];
82             for (int i = 0; i < extensions.length; i++) {
83                 tmp.extensions[i] = extensions[i].createCopy(tmp);
84             }
85         }
86         return tmp;
87     }
88 }
89
90
Popular Tags