1 11 package org.eclipse.pde.internal.core.schema; 12 13 import java.io.File ; 14 import java.net.MalformedURLException ; 15 import java.net.URL ; 16 17 import org.eclipse.core.resources.IFile; 18 import org.eclipse.pde.internal.core.ischema.ISchema; 19 import org.eclipse.pde.internal.core.ischema.ISchemaDescriptor; 20 21 22 public class SchemaDescriptor implements ISchemaDescriptor { 23 24 private String fPoint; 25 private URL fSchemaURL; 26 private Schema fSchema; 27 private long fLastModified; 28 private boolean fEditable; 29 30 public SchemaDescriptor(String extPointID, URL schemaURL) { 31 fPoint = extPointID; 32 fSchemaURL = schemaURL; 33 if (fSchemaURL != null) { 34 File file = new File (fSchemaURL.getFile()); 35 if (file.exists()) 36 fLastModified = file.lastModified(); 37 } 38 } 39 40 public SchemaDescriptor(IFile file, boolean editable) { 41 this(new File (file.getLocation().toOSString())); 42 fEditable = editable; 43 } 44 45 public SchemaDescriptor(File file) { 46 try { 47 if (file.exists()) { 48 fSchemaURL = file.toURL(); 49 fLastModified = file.lastModified(); 50 } 51 } catch (MalformedURLException e) { 52 } 53 } 54 55 58 public String getPointId() { 59 if (fPoint != null) 60 return fPoint; 61 return (fSchema == null) ? null : fSchema.getQualifiedPointId(); 62 } 63 64 67 public ISchema getSchema(boolean abbreviated) { 68 if (fSchema == null && fSchemaURL != null) { 69 if (fEditable) 70 fSchema = new EditableSchema(this, fSchemaURL, abbreviated); 71 else 72 fSchema = new Schema(this, fSchemaURL, abbreviated); 73 fSchema.load(); 74 } 75 return fSchema; 76 } 77 78 81 public URL getSchemaURL() { 82 return fSchemaURL; 83 } 84 85 88 public boolean isStandalone() { 89 return true; 90 } 91 92 public long getLastModified() { 93 return fLastModified; 94 } 95 96 } 97 | Popular Tags |