1 11 package org.eclipse.pde.internal.core.schema; 12 13 import java.io.IOException ; 14 import java.io.InputStream ; 15 import java.net.URL ; 16 17 import org.eclipse.core.resources.IStorage; 18 import org.eclipse.core.runtime.CoreException; 19 import org.eclipse.pde.internal.core.PDECore; 20 import org.eclipse.pde.internal.core.ischema.ISchema; 21 import org.eclipse.pde.internal.core.ischema.ISchemaDescriptor; 22 23 public class StorageSchemaDescriptor implements ISchemaDescriptor { 24 private IStorage fStorage; 25 private Schema fSchema; 26 27 public StorageSchemaDescriptor(IStorage storage) { 28 fStorage = storage; 29 } 30 31 public URL getSchemaURL() { 32 return fSchema != null ? fSchema.getURL() : null; 33 } 34 35 public String getPointId() { 36 return fSchema == null ? null : fSchema.getQualifiedPointId(); 37 } 38 39 protected void loadSchema(boolean abbreviated) { 40 fSchema = new Schema(this, null, false); 41 try { 42 InputStream stream = fStorage.getContents(); 43 fSchema.load(fStorage.getContents()); 44 stream.close(); 45 } 46 catch (CoreException e) { 47 PDECore.logException(e); 48 } 49 catch (IOException e) { 50 PDECore.logException(e); 51 } 52 } 53 54 public void reload() { 55 if (fSchema != null) { 56 fSchema.reload(); 57 } 58 } 59 60 public boolean isEnabled() { 61 return true; 62 } 63 64 67 public ISchema getSchema(boolean abbreviated) { 68 if (fSchema == null) 69 loadSchema(abbreviated); 70 return fSchema; 71 } 72 73 76 public boolean isStandalone() { 77 return true; 78 } 79 80 83 public long getLastModified() { 84 return 0; 85 } 86 87 } 88 | Popular Tags |