Lines 61-66
Link Here
|
61 |
import java.util.Set; |
61 |
import java.util.Set; |
62 |
import java.util.SortedSet; |
62 |
import java.util.SortedSet; |
63 |
import java.util.TreeSet; |
63 |
import java.util.TreeSet; |
|
|
64 |
import java.util.concurrent.atomic.AtomicBoolean; |
64 |
import org.openide.util.SharedClassObject; |
65 |
import org.openide.util.SharedClassObject; |
65 |
import org.openide.util.Utilities; |
66 |
import org.openide.util.Utilities; |
66 |
import org.openide.util.io.NbMarshalledObject; |
67 |
import org.openide.util.io.NbMarshalledObject; |
Lines 149-154
Link Here
|
149 |
return new Attr(index, value); |
150 |
return new Attr(index, value); |
150 |
} |
151 |
} |
151 |
|
152 |
|
|
|
153 |
static Object getRawAttribute(FileObject fo, String name, AtomicBoolean ab) { |
154 |
Object raw = fo.getAttribute("raw:" + name); // NOI18N |
155 |
if (raw != null) { |
156 |
if (ab != null) { |
157 |
ab.set(true); |
158 |
} |
159 |
return raw; |
160 |
} |
161 |
if (ab != null) { |
162 |
ab.set(false); |
163 |
} |
164 |
return fo.getAttribute(name); |
165 |
} |
166 |
private static ThreadLocal<FileObject> ATTR_FOR = new ThreadLocal<FileObject>(); |
167 |
static Object readAttribute(FileObject forFO, AbstractFileSystem.Attr attr, String path, String attrName) { |
168 |
FileObject prev = ATTR_FOR.get(); |
169 |
try { |
170 |
ATTR_FOR.set(forFO); |
171 |
return attr.readAttribute(path, attrName); |
172 |
} finally { |
173 |
ATTR_FOR.set(prev); |
174 |
} |
175 |
} |
152 |
/** According to name of attribute returns attribute as object |
176 |
/** According to name of attribute returns attribute as object |
153 |
* @param p1 is name of attribute |
177 |
* @param p1 is name of attribute |
154 |
* @return attribute, which is hold in XMLMapAttr.Attr or null if such attribute doesn`t exist or isn`t able to construct form String representation |
178 |
* @return attribute, which is hold in XMLMapAttr.Attr or null if such attribute doesn`t exist or isn`t able to construct form String representation |
Lines 186-192
Link Here
|
186 |
/** implementation of Map.get. But fires Exception to have chance in |
210 |
/** implementation of Map.get. But fires Exception to have chance in |
187 |
* DefaultAttributes to catch and annotate*/ |
211 |
* DefaultAttributes to catch and annotate*/ |
188 |
Object getAttribute(Object attrName) throws Exception { |
212 |
Object getAttribute(Object attrName) throws Exception { |
189 |
return getAttribute(attrName, null); |
213 |
return getAttribute(attrName, new Object[] { ATTR_FOR.get(), attrName }); |
190 |
} |
214 |
} |
191 |
|
215 |
|
192 |
private Object getAttribute(Object attrName, Object[] params) |
216 |
private Object getAttribute(Object attrName, Object[] params) |
Lines 204-215
Link Here
|
204 |
if (attr == null && origAttrName.startsWith("class:")) { // NOI18N |
228 |
if (attr == null && origAttrName.startsWith("class:")) { // NOI18N |
205 |
attr = (Attr) map.get(origAttrName.substring(6)); |
229 |
attr = (Attr) map.get(origAttrName.substring(6)); |
206 |
retVal = attr != null ? attr.getType(params) : null; |
230 |
retVal = attr != null ? attr.getType(params) : null; |
|
|
231 |
} else if (attr == null && origAttrName.startsWith("raw:")) { // NOI18N |
232 |
attr = (Attr) map.get(origAttrName.substring(4)); |
233 |
if (attr != null && attr.keyIndex == 9) { |
234 |
return attr.methodValue(attr.value, params).getMethod(); |
235 |
} |
236 |
if (attr != null && attr.keyIndex == 12) { |
237 |
return attr.getType(params); |
238 |
} |
207 |
} else { |
239 |
} else { |
208 |
try { |
240 |
if (keyValuePair[1] instanceof ModifiedAttribute) { |
209 |
retVal = (attr == null) ? attr : attr.get(params); |
241 |
return attr; |
210 |
} catch (Exception e) { |
242 |
} else { |
211 |
ExternalUtil.annotate(e, "attrName = " + attrName); //NOI18N |
243 |
try { |
212 |
throw e; |
244 |
retVal = (attr == null) ? attr : attr.get(params); |
|
|
245 |
} catch (Exception e) { |
246 |
ExternalUtil.annotate(e, "attrName = " + attrName); //NOI18N |
247 |
throw e; |
248 |
} |
213 |
} |
249 |
} |
214 |
} |
250 |
} |
215 |
|
251 |
|
Lines 244-251
Link Here
|
244 |
Object[] keyValuePair = ModifiedAttribute.translateInto((String) p1, p2); |
280 |
Object[] keyValuePair = ModifiedAttribute.translateInto((String) p1, p2); |
245 |
String key = (String) keyValuePair[0]; |
281 |
String key = (String) keyValuePair[0]; |
246 |
Object value = keyValuePair[1]; |
282 |
Object value = keyValuePair[1]; |
247 |
Object toStore = ((value == null) || value instanceof Attr) ? value : new Attr(value); |
283 |
Object toStore; |
248 |
|
284 |
if (value == null) { |
|
|
285 |
toStore = null; |
286 |
} else if (value instanceof Attr) { |
287 |
toStore = value; |
288 |
} else if (value instanceof Method && key.startsWith("methodvalue:")) { // NOI18N |
289 |
Method m = (Method)value; |
290 |
key = key.substring("methodvalue:".length()); // NOI18N |
291 |
toStore = new Attr("methodvalue", m.getDeclaringClass().getName() + '.' + m.getName()); // NOI18N |
292 |
} else if (value instanceof Class && key.startsWith("newvalue:")) { // NOI18N |
293 |
Class<?> c = (Class<?>)value; |
294 |
key = key.substring("newvalue:".length()); // NOI18N |
295 |
toStore = new Attr("newvalue", c.getName()); // NOI18N |
296 |
} else { |
297 |
toStore = new Attr(value); |
298 |
} |
249 |
if (decode) { |
299 |
if (decode) { |
250 |
key = Attr.decode(key).intern(); |
300 |
key = Attr.decode(key).intern(); |
251 |
} |
301 |
} |
Lines 621-639
Link Here
|
621 |
} |
671 |
} |
622 |
|
672 |
|
623 |
/** |
673 |
/** |
624 |
* Constructs new attribute as Object. Used for static creation from literal or serialValue. |
|
|
625 |
* @return new attribute as Object |
626 |
*/ |
627 |
private Object get() throws Exception { |
628 |
return getObject(null); //getObject is ready to aobtain null |
629 |
} |
630 |
|
631 |
/** |
632 |
* Constructs new attribute as Object. Used for dynamic creation: methodvalue . |
674 |
* Constructs new attribute as Object. Used for dynamic creation: methodvalue . |
633 |
* @param objs has sense only for methodvalue invocation; and only 2 parametres will be used |
675 |
* @param objs has sense only for methodvalue invocation; and only 2 parametres will be used |
634 |
*@return new attribute as Object |
676 |
*@return new attribute as Object |
635 |
*/ |
677 |
*/ |
636 |
private Object get(Object[] objs) throws Exception { |
678 |
final Object get(Object[] objs) throws Exception { |
637 |
return getObject(objs); |
679 |
return getObject(objs); |
638 |
} |
680 |
} |
639 |
|
681 |
|