1 19 20 package org.openide.loaders; 21 22 import java.io.IOException ; 23 24 import org.openide.*; 25 import org.openide.filesystems.*; 26 import org.openide.util.io.SafeException; 27 28 34 public abstract class UniFileLoader extends MultiFileLoader { 35 36 static final long serialVersionUID=-6190649471408985837L; 37 38 39 public static final String PROP_EXTENSIONS = "extensions"; 41 45 @Deprecated 46 protected UniFileLoader(Class <? extends DataObject> representationClass) { 47 super (representationClass); 48 } 49 50 56 protected UniFileLoader (String representationClassName) { 57 super (representationClassName); 58 } 59 60 66 protected FileObject findPrimaryFile (FileObject fo) { 67 if (fo.isFolder()) return null; 69 70 return getExtensions().isRegistered(fo) ? fo : null; 71 } 72 73 81 protected abstract MultiDataObject createMultiObject (FileObject primaryFile) 82 throws DataObjectExistsException, java.io.IOException ; 83 84 90 protected MultiDataObject.Entry createPrimaryEntry (MultiDataObject obj, FileObject primaryFile) { 91 return new FileEntry (obj, primaryFile); 92 } 93 94 101 protected MultiDataObject.Entry createSecondaryEntry (MultiDataObject obj, FileObject secondaryFile) { 102 103 StringBuffer buf = new StringBuffer ("Error in data system. Please reopen the bug #17014 with the following message: "); buf.append("\n DataLoader:"); buf.append(getClass().getName()); 107 buf.append("\n DataObject:"); buf.append(obj); 109 buf.append("\n PrimaryEntry:"); buf.append(obj.getPrimaryEntry()); 111 buf.append("\n PrimaryFile:"); buf.append(obj.getPrimaryFile()); 113 buf.append("\n SecondaryFile:"); buf.append(secondaryFile); 115 buf.append("\n"); 116 117 throw new UnsupportedOperationException (buf.toString()); } 119 120 128 final DataObject checkCollision (DataObject obj, FileObject file) { 129 return null; 130 } 131 132 138 final void checkConsistency (MultiDataObject obj) { 139 } 140 141 147 final void checkFiles (MultiDataObject obj) { 148 } 149 150 153 public void setExtensions(ExtensionList ext) { 154 putProperty (PROP_EXTENSIONS, ext, true); 155 } 156 157 160 public ExtensionList getExtensions() { 161 ExtensionList l = (ExtensionList)getProperty (PROP_EXTENSIONS); 162 if (l == null) { 163 l = new ExtensionList (); 164 putProperty (PROP_EXTENSIONS, l, false); 165 } 166 return l; 167 } 168 169 172 public void writeExternal (java.io.ObjectOutput oo) throws IOException { 173 super.writeExternal (oo); 174 175 oo.writeObject (getProperty (PROP_EXTENSIONS)); 176 } 177 178 181 public void readExternal (java.io.ObjectInput oi) 182 throws IOException , ClassNotFoundException { 183 SafeException se; 184 try { 185 super.readExternal (oi); 186 se = null; 187 } catch (SafeException se2) { 188 se = se2; 189 } 190 191 setExtensions ((ExtensionList)oi.readObject ()); 192 if (se != null) throw se; 193 } 194 195 } 196 | Popular Tags |