blob: ea4832ffc589021a33406c0e039d552dfc52e6bb (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
/*******************************************************************************
* Copyright (c) 2005, 2011 Intel Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Intel Corporation - initial API and implementation
* James Blackburn (Broadcom Corp.)
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.internal.core;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.eclipse.cdt.core.settings.model.ICStorageElement;
import org.eclipse.cdt.core.settings.model.WriteAccessException;
import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
import org.eclipse.core.runtime.CoreException;
public class ManagedConfigStorageElement implements ICStorageElement {
private IManagedConfigElement fElement;
private List<IManagedConfigElement> fChildList;
private ManagedConfigStorageElement fParent;
public ManagedConfigStorageElement(IManagedConfigElement el) {
this(el, null);
}
public ManagedConfigStorageElement(IManagedConfigElement el, ManagedConfigStorageElement parent) {
fElement = el;
fParent = parent;
}
@Override
public void clear() {
throw new WriteAccessException();
}
@Override
public ICStorageElement createChild(String name) {
throw new WriteAccessException();
}
@Override
public String getAttribute(String name) {
return fElement.getAttribute(name);
}
@Override
public boolean hasAttribute(String name) {
return fElement.getAttribute(name) != null;
}
@Override
public ICStorageElement[] getChildren() {
List<IManagedConfigElement> list = getChildList(true);
return list.toArray(new ManagedConfigStorageElement[list.size()]);
}
private List<IManagedConfigElement> getChildList(boolean create) {
if (fChildList == null && create) {
IManagedConfigElement children[] = fElement.getChildren();
fChildList = new ArrayList<IManagedConfigElement>(children.length);
fChildList.addAll(Arrays.asList(children));
}
return fChildList;
}
@Override
public ICStorageElement[] getChildrenByName(String name) {
List<ICStorageElement> children = new ArrayList<ICStorageElement>();
for (ICStorageElement child : getChildren())
if (name.equals(child.getName()))
children.add(child);
return children.toArray(new ICStorageElement[children.size()]);
}
@Override
public boolean hasChildren() {
return getChildList(true).isEmpty();
}
@Override
public String getName() {
return fElement.getName();
}
@Override
public ICStorageElement getParent() {
return fParent;
}
@Override
public String getValue() {
return null;
}
@Override
public ICStorageElement importChild(ICStorageElement el) throws UnsupportedOperationException {
throw new WriteAccessException();
}
@Override
public void removeAttribute(String name) {
throw new WriteAccessException();
}
@Override
public void removeChild(ICStorageElement el) {
throw new WriteAccessException();
}
@Override
public void setAttribute(String name, String value) {
throw new WriteAccessException();
}
@Override
public void setValue(String value) {
throw new WriteAccessException();
}
@Override
public String[] getAttributeNames() {
throw new UnsupportedOperationException();
}
@Override
public ICStorageElement createCopy() throws UnsupportedOperationException, CoreException {
throw new UnsupportedOperationException();
}
@Override
public boolean equals(ICStorageElement other) {
throw new UnsupportedOperationException();
}
}
|