1 11 package org.eclipse.core.runtime.internal.adaptor; 12 13 import java.util.Date ; 14 import org.eclipse.osgi.service.resolver.*; 15 import org.eclipse.osgi.util.NLS; 16 17 20 public class MessageHelper { 21 public static String getResolutionFailureMessage(VersionConstraint unsatisfied) { 22 if (unsatisfied.isResolved()) 23 throw new IllegalArgumentException (); 24 if (unsatisfied instanceof ImportPackageSpecification) 25 return NLS.bind(EclipseAdaptorMsg.ECLIPSE_MISSING_IMPORTED_PACKAGE, toString(unsatisfied)); 26 else if (unsatisfied instanceof BundleSpecification) 27 if (((BundleSpecification) unsatisfied).isOptional()) 28 return NLS.bind(EclipseAdaptorMsg.ECLIPSE_MISSING_OPTIONAL_REQUIRED_BUNDLE, toString(unsatisfied)); 29 else 30 return NLS.bind(EclipseAdaptorMsg.ECLIPSE_MISSING_REQUIRED_BUNDLE, toString(unsatisfied)); 31 else 32 return NLS.bind(EclipseAdaptorMsg.ECLIPSE_MISSING_HOST, toString(unsatisfied)); 33 } 34 35 39 public static void debug(String message) { 40 StringBuffer buffer = new StringBuffer (); 41 buffer.append(new Date (System.currentTimeMillis())); 42 buffer.append(" - ["); buffer.append(Thread.currentThread().getName()); 44 buffer.append("] "); buffer.append(message); 46 System.out.println(buffer.toString()); 47 } 48 49 private static String toString(VersionConstraint constraint) { 50 org.eclipse.osgi.service.resolver.VersionRange versionRange = constraint.getVersionRange(); 51 if (versionRange == null) 52 return constraint.getName(); 53 return constraint.getName() + '_' + versionRange; 54 } 55 56 } 57 | Popular Tags |