# This patch file was generated by NetBeans IDE
# Following Index: paths are relative to: /doma/jarda/netbeans-src/openide/fs
# This patch can be applied using context Tools: Patch action on respective folder.
# It uses platform neutral UTF-8 encoding and \n newlines.
# Above lines and this line are ignored by the patching process.
Index: src/org/openide/filesystems/XMLFileSystem.java
*** /doma/jarda/netbeans-src/openide/fs/src/org/openide/filesystems/XMLFileSystem.java Base (1.9)
--- /doma/jarda/netbeans-src/openide/fs/src/org/openide/filesystems/XMLFileSystem.java Locally Modified (Based On 1.9)
***************
*** 100,105 ****
--- 100,122 ----
* < !ATTLIST attr serialvalue CDATA #IMPLIED>
* < !ATTLIST attr urlvalue CDATA #IMPLIED>
*
+ *
+ *
+ * The methodvalue attribute can be in form of pgk1.pkg2.ClassName.methodName
+ * which should point to existing class with static method usually having no, one
+ * or two arguments. This method does not need to be public or in public class, if
+ * the filesystem has premitions to call the method. The method can take one
+ * of following signatures:
+ *
+ * static Value methodName();
+ * static Value methodName(FileObject fo);
+ * static Value methodName(FileObject fo, String attrName);
+ * static Value methodName(Map attrs); // since 7.0
+ * static Value methodName(Map attrs, String attrName); // since 7.0
+ *
+ * where Value
can be any java type.
+ *
+ *
* @author Radek Matous
*/
public final class XMLFileSystem extends AbstractFileSystem {
Index: manifest.mf
*** /doma/jarda/netbeans-src/openide/fs/manifest.mf Base (1.7)
--- /doma/jarda/netbeans-src/openide/fs/manifest.mf Locally Modified (Based On 1.7)
***************
*** 1,5 ****
Manifest-Version: 1.0
OpenIDE-Module: org.openide.filesystems
! OpenIDE-Module-Specification-Version: 6.6
OpenIDE-Module-Localizing-Bundle: org/openide/filesystems/Bundle.properties
--- 1,5 ----
Manifest-Version: 1.0
OpenIDE-Module: org.openide.filesystems
! OpenIDE-Module-Specification-Version: 7.0
OpenIDE-Module-Localizing-Bundle: org/openide/filesystems/Bundle.properties
Index: test/unit/src/org/openide/filesystems/data/Attributes.xml
*** /doma/jarda/netbeans-src/openide/fs/test/unit/src/org/openide/filesystems/data/Attributes.xml Base (1.1)
--- /doma/jarda/netbeans-src/openide/fs/test/unit/src/org/openide/filesystems/data/Attributes.xml Locally Modified (Based On 1.1)
***************
*** 16,21 ****
--- 16,24 ----
+
+
+
+
Index: test/unit/src/org/openide/filesystems/AttributesTestHidden.java
*** /doma/jarda/netbeans-src/openide/fs/test/unit/src/org/openide/filesystems/AttributesTestHidden.java Base (1.3)
--- /doma/jarda/netbeans-src/openide/fs/test/unit/src/org/openide/filesystems/AttributesTestHidden.java Locally Modified (Based On 1.3)
***************
*** 254,259 ****
--- 254,269 ----
assertTrue ("methodValue failed", obj != null);
assertTrue ("methodValue doesn't keep order ",
obj.equals(getObjectViaMethodValue5 ()));
+
+ testName = "test6";
+ obj = fo.getAttribute(testName);
+ assertTrue ("methodValue failed", obj != null);
+ assertEquals("even works for java.util.Map", "Ahoj1", obj);
+
+ testName = "test7";
+ obj = fo.getAttribute(testName);
+ assertTrue ("methodValue failed", obj != null);
+ assertEquals("works for map and string", "Ahoj1test7", obj);
}
public void testAttribute09 () throws IOException {
***************
*** 344,349 ****
--- 354,395 ----
return "";
}
+ private static Object getObjectViaMethodValue6 (Map attrs) {
+ try {
+ attrs.keySet().iterator().remove();
+ return "UnsupportedOperationException";
+ } catch (UnsupportedOperationException ex) {
+ // ok
+ }
+ try {
+ attrs.put("value1", "nothing");
+ return "UnsupportedOperationException";
+ } catch (UnsupportedOperationException ex) {
+ // ok
+ }
+ try {
+ attrs.remove("value1");
+ return "UnsupportedOperationException";
+ } catch (UnsupportedOperationException ex) {
+ // ok
+ }
+
+
+ return attrs.get("value1");
+ }
+ private static Object getObjectViaMethodValue7 (Map attrs, String attrName) {
+ assertEquals(8, attrs.keySet().size());
+ try {
+ attrs.entrySet().remove(null);
+ return "UnsupportedOperationException";
+ } catch (UnsupportedOperationException ex) {
+ // ok
+ }
+
+
+ return attrs.get("value1") + attrName;
+ }
+
private String basicAttributeTest (String attrName, String attrValue) throws IOException {
FileObject foTested = testedFS.getRoot ();
foTested.setAttribute (attrName, attrValue);
Index: src/org/openide/filesystems/XMLMapAttr.java
*** /doma/jarda/netbeans-src/openide/fs/src/org/openide/filesystems/XMLMapAttr.java Base (1.3)
--- /doma/jarda/netbeans-src/openide/fs/src/org/openide/filesystems/XMLMapAttr.java Locally Modified (Based On 1.3)
***************
*** 872,891 ****
Object[] paramArray = new Object[] {
new Class[] { FileObject.class, String.class }, new Class[] { String.class, FileObject.class },
! new Class[] { FileObject.class }, new Class[] { String.class }, new Class[] { }
};
boolean both = ((fo != null) && (attrName != null));
! Object[] objectsList = new Object[5];
objectsList[0] = (both) ? new Object[] { fo, attrName } : null;
objectsList[1] = (both) ? new Object[] { attrName, fo } : null;
objectsList[2] = (fo != null) ? new Object[] { fo } : null;
objectsList[3] = (attrName != null) ? new Object[] { attrName } : null;
objectsList[4] = new Object[] { };
for (int i = 0; i < paramArray.length; i++) {
Object[] objArray = (Object[]) objectsList[i];
--- 872,893 ----
Object[] paramArray = new Object[] {
new Class[] { FileObject.class, String.class }, new Class[] { String.class, FileObject.class },
! new Class[] { FileObject.class }, new Class[] { String.class }, new Class[] { },
! new Class[] { Map.class, String.class }, new Class[] { Map.class },
};
boolean both = ((fo != null) && (attrName != null));
! Object[] objectsList = new Object[7];
objectsList[0] = (both) ? new Object[] { fo, attrName } : null;
objectsList[1] = (both) ? new Object[] { attrName, fo } : null;
objectsList[2] = (fo != null) ? new Object[] { fo } : null;
objectsList[3] = (attrName != null) ? new Object[] { attrName } : null;
objectsList[4] = new Object[] { };
+ Map fileMap = wrapToMap(fo);
+ objectsList[5] = attrName != null ? new Object[] { fileMap, attrName } : null;
+ objectsList[6] = new Object[] { fileMap };
+
for (int i = 0; i < paramArray.length; i++) {
Object[] objArray = (Object[]) objectsList[i];
***************
*** 907,912 ****
--- 912,921 ----
throw new InstantiationException(value);
}
+ static final Map wrapToMap(FileObject fo) {
+ return fo == null ? Collections.EMPTY_MAP : new FileMap(fo);
+ }
+
/**
* Checks if key is valid
* @return Index to array of allowed keys or -1 which means error.
***************
*** 1088,1094 ****
--- 1097,1192 ----
return false;
}
}
+
+ private static final class FileMap extends AbstractMap {
+ private FileObject fo;
+
+ private FileMap (FileObject fo) {
+ this.fo = fo;
}
+
+ public Set> entrySet() {
+ return new AttrFileSet(fo);
+ }
+
+ public Object get(String key) {
+ return fo.getAttribute(key);
+ }
+
+ public Object remove(Object key) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Object put(String key, Object value) {
+ throw new UnsupportedOperationException();
+ }
+
+ }
+ private static final class AttrFileSet extends AbstractSet> {
+ private FileObject fo;
+
+ private AttrFileSet(FileObject fo) {
+ this.fo = fo;
+ }
+
+ public Iterator> iterator() {
+ class Iter implements Iterator> {
+ Enumeration attrs = (Enumeration)fo.getAttributes();
+
+ public boolean hasNext() {
+ return attrs.hasMoreElements();
+ }
+
+ public Map.Entry next() {
+ String s = attrs.nextElement();
+ return new FOEntry(fo, s);
+ }
+
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+ }
+ return new Iter();
+ }
+
+ public int size() {
+ Enumeration> all = fo.getAttributes();
+ int cnt = 0;
+ while (all.hasMoreElements()) {
+ cnt++;
+ all.nextElement();
+ }
+ return cnt;
+ }
+
+ public boolean remove(Object o) {
+ throw new UnsupportedOperationException();
+ }
+ } // end of AttrFileSet
+
+ private static final class FOEntry implements Map.Entry {
+ private FileObject fo;
+ private String attr;
+
+ private FOEntry(FileObject fo, String attr) {
+ this.fo = fo;
+ this.attr = attr;
+ }
+
+ public String getKey() {
+ return attr;
+ }
+
+ public Object getValue() {
+ return fo.getAttribute(attr);
+ }
+
+ public Object setValue(Object value) {
+ throw new UnsupportedOperationException();
+ }
+ } // end of FOEntry
+ }
Index: apichanges.xml
*** /doma/jarda/netbeans-src/openide/fs/apichanges.xml Base (1.7)
--- /doma/jarda/netbeans-src/openide/fs/apichanges.xml Locally Modified (Based On 1.7)
***************
*** 17,22 ****
--- 17,45 ----
Filesystems API
+
+
+ Semantics of XMLFileSystem's methodvalue extended to
+ also support methods that do not depend on FileSystems API
+ at all
+
+
+
+
+
+
+
+ XMLFileSystem's
+ methodvalue now supports also Map
+ attribute, so one can write factory methods that are completely
+ independent on filesystems by creating methods like
+ static Object methodName(Map attrs)
or
+ static Object methodName(Map attrs, String s)
.
+
+
+
+
Added additional method FileObject.getOutpuStream