Lines 58-63
Link Here
|
58 |
import java.util.Set; |
58 |
import java.util.Set; |
59 |
import java.util.SortedSet; |
59 |
import java.util.SortedSet; |
60 |
import java.util.TreeSet; |
60 |
import java.util.TreeSet; |
|
|
61 |
import java.util.concurrent.atomic.AtomicBoolean; |
61 |
import org.openide.util.SharedClassObject; |
62 |
import org.openide.util.SharedClassObject; |
62 |
import org.openide.util.Utilities; |
63 |
import org.openide.util.Utilities; |
63 |
import org.openide.util.io.NbMarshalledObject; |
64 |
import org.openide.util.io.NbMarshalledObject; |
Lines 146-151
Link Here
|
146 |
return new Attr(index, value); |
147 |
return new Attr(index, value); |
147 |
} |
148 |
} |
148 |
|
149 |
|
|
|
150 |
static Object getRawAttribute(FileObject fo, String name, AtomicBoolean ab) { |
151 |
Object raw = fo.getAttribute("raw:" + name); // NOI18N |
152 |
if (raw != null) { |
153 |
if (ab != null) { |
154 |
ab.set(true); |
155 |
} |
156 |
return raw; |
157 |
} |
158 |
if (ab != null) { |
159 |
ab.set(false); |
160 |
} |
161 |
return fo.getAttribute(name); |
162 |
} |
163 |
private static ThreadLocal<FileObject> ATTR_FOR = new ThreadLocal<FileObject>(); |
164 |
static Object readAttribute(FileObject forFO, AbstractFileSystem.Attr attr, String path, String attrName) { |
165 |
FileObject prev = ATTR_FOR.get(); |
166 |
try { |
167 |
ATTR_FOR.set(forFO); |
168 |
return attr.readAttribute(path, attrName); |
169 |
} finally { |
170 |
ATTR_FOR.set(prev); |
171 |
} |
172 |
} |
149 |
/** According to name of attribute returns attribute as object |
173 |
/** According to name of attribute returns attribute as object |
150 |
* @param p1 is name of attribute |
174 |
* @param p1 is name of attribute |
151 |
* @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 |
175 |
* @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 183-189
Link Here
|
183 |
/** implementation of Map.get. But fires Exception to have chance in |
207 |
/** implementation of Map.get. But fires Exception to have chance in |
184 |
* DefaultAttributes to catch and annotate*/ |
208 |
* DefaultAttributes to catch and annotate*/ |
185 |
Object getAttribute(Object attrName) throws Exception { |
209 |
Object getAttribute(Object attrName) throws Exception { |
186 |
return getAttribute(attrName, null); |
210 |
return getAttribute(attrName, new Object[] { ATTR_FOR.get(), attrName }); |
187 |
} |
211 |
} |
188 |
|
212 |
|
189 |
private Object getAttribute(Object attrName, Object[] params) |
213 |
private Object getAttribute(Object attrName, Object[] params) |
Lines 201-206
Link Here
|
201 |
if (attr == null && origAttrName.startsWith("class:")) { // NOI18N |
225 |
if (attr == null && origAttrName.startsWith("class:")) { // NOI18N |
202 |
attr = (Attr) map.get(origAttrName.substring(6)); |
226 |
attr = (Attr) map.get(origAttrName.substring(6)); |
203 |
retVal = attr != null ? attr.getType(params) : null; |
227 |
retVal = attr != null ? attr.getType(params) : null; |
|
|
228 |
} else if (attr == null && origAttrName.startsWith("raw:")) { // NOI18N |
229 |
attr = (Attr) map.get(origAttrName.substring(4)); |
230 |
if (attr != null && attr.keyIndex == 9) { |
231 |
return attr.methodValue(attr.value, params).getMethod(); |
232 |
} |
204 |
} else { |
233 |
} else { |
205 |
try { |
234 |
try { |
206 |
retVal = (attr == null) ? attr : attr.get(params); |
235 |
retVal = (attr == null) ? attr : attr.get(params); |
Lines 241-248
Link Here
|
241 |
Object[] keyValuePair = ModifiedAttribute.translateInto((String) p1, p2); |
270 |
Object[] keyValuePair = ModifiedAttribute.translateInto((String) p1, p2); |
242 |
String key = (String) keyValuePair[0]; |
271 |
String key = (String) keyValuePair[0]; |
243 |
Object value = keyValuePair[1]; |
272 |
Object value = keyValuePair[1]; |
244 |
Object toStore = ((value == null) || value instanceof Attr) ? value : new Attr(value); |
273 |
Object toStore; |
245 |
|
274 |
if (value == null) { |
|
|
275 |
toStore = null; |
276 |
} else if (value instanceof Attr) { |
277 |
toStore = value; |
278 |
} else if (value instanceof Method && key.startsWith("methodvalue:")) { // NOI18N |
279 |
Method m = (Method)value; |
280 |
key = key.substring("methodvalue:".length()); // NOI18N |
281 |
toStore = new Attr("methodvalue", m.getDeclaringClass().getName() + '.' + m.getName()); // NOI18N |
282 |
} else { |
283 |
toStore = new Attr(value); |
284 |
} |
246 |
if (decode) { |
285 |
if (decode) { |
247 |
key = Attr.decode(key).intern(); |
286 |
key = Attr.decode(key).intern(); |
248 |
} |
287 |
} |
Lines 618-636
Link Here
|
618 |
} |
657 |
} |
619 |
|
658 |
|
620 |
/** |
659 |
/** |
621 |
* Constructs new attribute as Object. Used for static creation from literal or serialValue. |
|
|
622 |
* @return new attribute as Object |
623 |
*/ |
624 |
private Object get() throws Exception { |
625 |
return getObject(null); //getObject is ready to aobtain null |
626 |
} |
627 |
|
628 |
/** |
629 |
* Constructs new attribute as Object. Used for dynamic creation: methodvalue . |
660 |
* Constructs new attribute as Object. Used for dynamic creation: methodvalue . |
630 |
* @param objs has sense only for methodvalue invocation; and only 2 parametres will be used |
661 |
* @param objs has sense only for methodvalue invocation; and only 2 parametres will be used |
631 |
*@return new attribute as Object |
662 |
*@return new attribute as Object |
632 |
*/ |
663 |
*/ |
633 |
private Object get(Object[] objs) throws Exception { |
664 |
final Object get(Object[] objs) throws Exception { |
634 |
return getObject(objs); |
665 |
return getObject(objs); |
635 |
} |
666 |
} |
636 |
|
667 |
|