1 5 package SOFA.SOFAnode.TR.Impl; 6 7 import java.io.Serializable ; 8 9 import SOFA.SOFAnode.TR.ComponentInfo; 10 11 16 public class ComponentInfoImpl implements ComponentInfo, Serializable { 17 18 22 private String name; 23 24 28 private String specificationVersion; 29 30 33 private String implementationVersion; 34 35 41 private String location; 42 43 47 private ComponentInfo[] subComponents; 48 49 54 public ComponentInfoImpl (String name, String implementationVersion) { 55 this.name = name; 56 this.implementationVersion = implementationVersion; 57 } 58 59 65 public ComponentInfoImpl (String name, String implementationVersion, String location) { 66 this(name, implementationVersion); 67 this.location = location; 68 } 69 70 74 public String getName () { 75 return name; 76 } 77 78 82 public String getSpecificationVersion () { 83 return specificationVersion; 84 } 85 86 90 public String getImplementationVersion () { 91 return implementationVersion; 92 } 93 94 98 public String getLocation () { 99 return location; 100 } 101 102 106 public ComponentInfo[] getSubComponents () { 107 return subComponents; 108 } 109 110 115 void setLocation (String location) { 116 this.location = location; 117 } 118 119 void setSubComponents (ComponentInfoImpl[] subComponents) { 120 this.subComponents = subComponents; 121 } 122 123 129 public boolean equals (Object o) { 130 if (this == o) return true; 131 if (!(o instanceof ComponentInfoImpl)) return false; 132 133 final ComponentInfoImpl componentInfo = (ComponentInfoImpl) o; 134 135 if (!implementationVersion.equals(componentInfo.implementationVersion)) return false; 136 if (!name.equals(componentInfo.name)) return false; 137 138 return true; 139 } 140 141 public int hashCode () { 142 int result; 143 result = name.hashCode(); 144 result = 29 * result + implementationVersion.hashCode(); 145 return result; 146 } 147 148 153 public String toString () { 154 return name + "[" + implementationVersion + "]"; 155 } 156 157 164 public static ComponentInfoImpl fromString (String fullName) { 165 int delimiter = fullName.lastIndexOf('['); 166 String name = fullName.substring(0, delimiter); 167 String version = fullName.substring(delimiter + 1, fullName.length() - 1); 168 return new ComponentInfoImpl(name, version); 169 } 170 } 171 | Popular Tags |