1 50 51 package org.apache.avalon.meta.info; 52 53 import java.util.Properties ; 54 55 import org.apache.avalon.framework.Version; 56 57 64 public class Service extends Descriptor 65 { 66 70 73 private final ReferenceDescriptor m_reference; 74 75 78 private final EntryDescriptor[] m_entries; 79 80 84 90 public Service( final ReferenceDescriptor reference ) 91 { 92 this( reference, null, null ); 93 } 94 95 102 public Service( 103 final ReferenceDescriptor reference, 104 final EntryDescriptor[] entries ) 105 { 106 this( reference, entries, null ); 107 } 108 109 116 public Service( 117 final ReferenceDescriptor reference, 118 final Properties attributes ) 119 { 120 this( reference, null, attributes ); 121 } 122 123 131 public Service( 132 final ReferenceDescriptor reference, 133 final EntryDescriptor[] entries, 134 final Properties attributes ) 135 { 136 super( attributes ); 137 if ( reference == null ) 138 { 139 throw new NullPointerException ( "reference" ); 140 } 141 m_reference = reference; 142 if ( entries == null ) 143 { 144 m_entries = new EntryDescriptor[0]; 145 } 146 else 147 { 148 m_entries = entries; 149 } 150 } 151 152 156 160 public String getClassname() 161 { 162 return m_reference.getClassname(); 163 } 164 165 169 public Version getVersion() 170 { 171 return m_reference.getVersion(); 172 } 173 174 178 public ReferenceDescriptor getReference() 179 { 180 return m_reference; 181 } 182 183 188 public EntryDescriptor[] getEntries() 189 { 190 return m_entries; 191 } 192 193 200 public boolean matches( final ReferenceDescriptor reference ) 201 { 202 return m_reference.matches( reference ); 203 } 204 205 209 public int hashCode() 210 { 211 return m_reference.hashCode(); 212 } 213 214 220 public boolean equals( Object other ) 221 { 222 boolean match = false; 223 224 if ( other instanceof ReferenceDescriptor ) 225 { 226 match = matches( (ReferenceDescriptor) other ); 227 } 228 else if ( other instanceof Service ) 229 { 230 Service ref = (Service) other; 231 match = ref.getClassname().equals( getClassname() ) 232 && ref.getVersion().complies( getVersion() ); 233 } 234 235 return match; 236 } 237 238 242 public String toString() 243 { 244 return getReference().toString(); 245 } 246 247 } 248 | Popular Tags |