1 19 20 package org.netbeans.modules.projectimport.eclipse; 21 22 import java.io.File ; 23 import org.openide.ErrorManager; 24 25 30 public final class ClassPathEntry { 31 32 33 static class Type { 34 String desc; 35 private Type(String desc) { 36 this.desc = desc; 37 } 38 public String toString() { 39 return desc; 40 } 41 } 42 43 static final Type TYPE_OUTPUT = new Type("output"); static final Type TYPE_LIBRARY = new Type("lib"); static final Type TYPE_EXTERNAL_LIBRARY = new Type("lib-ext"); static final Type TYPE_CONTAINER = new Type("con"); static final Type TYPE_VARIABLE= new Type("var"); static final Type TYPE_SOURCE = new Type("src"); static final Type TYPE_PROJECT = new Type("src-prj"); static final Type TYPE_LINK = new Type("src-link"); static final Type TYPE_UNKNOWN = new Type("unkown"); 53 private Type type; 54 private String rawPath; 55 private String absolutePath; 56 57 ClassPathEntry(String type, String rawPath) { 58 this.rawPath = rawPath; 59 setTypeFromRawtype(type); 60 } 61 62 void setType(ClassPathEntry.Type type) { 63 this.type = type; 64 } 65 66 private void setTypeFromRawtype(String rawType) { 67 if ("output".equals(rawType)) { this.type = TYPE_OUTPUT; 69 } else if ("src".equals(rawType)) { if (rawPath.startsWith("/")) { this.type = TYPE_PROJECT; 73 } else { 74 this.type = TYPE_SOURCE; 75 } 76 } else if ("lib".equals(rawType)) { if (isRawPathRelative()) { 78 this.type = TYPE_LIBRARY; 79 } else { 80 this.type = TYPE_EXTERNAL_LIBRARY; 81 } 82 } else if ("con".equals(rawType)) { this.type = TYPE_CONTAINER; 84 } else if ("var".equals(rawType)) { this.type = TYPE_VARIABLE; 86 } else { 87 ErrorManager.getDefault().log(ErrorManager.WARNING, 88 "Unkown type encountered in " + "ClassPathEntry.setTypeFromRawtype(): " + rawType); this.type = TYPE_UNKNOWN; 91 } 92 } 93 94 Type getType() { 95 return type; 96 } 97 98 public String getRawPath() { 99 return rawPath; 100 } 101 102 public String getAbsolutePath() { 103 return absolutePath; 104 } 105 106 void setAbsolutePath(String absolutePath) { 107 this.absolutePath = absolutePath; 108 } 109 110 boolean isRawPathRelative() { 111 return !(new File (rawPath).isAbsolute()); 112 } 113 114 public String toString() { 115 return type + " = \"" + rawPath + "\"" + " (absolutePath: " + absolutePath + ")"; } 118 } 119 120 | Popular Tags |