org.eclipse.equinox.p2.director_2.1.1.v20111126-0211

rComponent
  implements IAgentServiceFactory
{
  public Object createService(IProvisioningAgent agent)
  {
    return new SimplePlanner(agent);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.p2.director.PlannerComponent
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.p2.director;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.eclipse.equinox.internal.p2.core.helpers.CollectionUtils;
import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.eclipse.equinox.p2.engine.IProfile;
import org.eclipse.equinox.p2.engine.IProfileRegistry;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.metadata.IRequirement;
import org.eclipse.equinox.p2.planner.IProfileChangeRequest;

public class ProfileChangeRequest
  implements Cloneable, IProfileChangeRequest
{
  private final IProfile profile;
  private ArrayList<IInstallableUnit> iusToRemove = null;
  private ArrayList<IInstallableUnit> iusToAdd = null;
  private ArrayList<String> propertiesToRemove = null;
  private HashMap<String, String> propertiesToAdd = null;
  private HashMap<IInstallableUnit, Map<String, String>> iuPropertiesToAdd = null;
  private HashMap<IInstallableUnit, List<String>> iuPropertiesToRemove = null;
  private ArrayList<IRequirement> additionalRequirements;
  
  public static ProfileChangeRequest createByProfileId(IProvisioningAgent agent, String profileId)
  {
    IProfileRegistry profileRegistry = (IProfileRegistry)agent.getService(IProfileRegistry.SERVICE_NAME);
    if (profileRegistry == null) {
      throw new IllegalStateException(Messages.Planner_no_profile_registry);
    }
    IProfile profile = profileRegistry.getProfile(profileId);
    if (profile == null) {
      throw new IllegalArgumentException("Profile id " + profileId + " is not registered.");
    }
    return new ProfileChangeRequest(profile);
  }
  
  public ProfileChangeRequest(IProfile profile)
  {
    this.profile = profile;
  }
  
  public void setProfile(IProfile profile)
  {
    if (profile == null) {
      throw new IllegalArgumentException("Profile cannot be null.");
    }
  }
  
  public IProfile getProfile()
  {
    return profile;
  }
  
  public Map<String, String> getProfileProperties()
  {
    Map<String, String> result = new HashMap(profile.getProperties());
    if (propertiesToRemove != null) {
      for (Iterator localIterator = propertiesToRemove.iterator(); localIterator.hasNext();)
      {
        String key = (String)localIterator.next();
        result.remove(key);
      }
    }
    if (propertiesToAdd != null) {
      result.putAll(propertiesToAdd);
    }
    return result;
  }
  
  public void add(IInstallableUnit toInstall)
  {
    if (iusToAdd == null) {
      iusToAdd = new ArrayList();
    }
    iusToAdd.add(toInstall);
  }
  
  public void addAll(Collection<IInstallableUnit> toInstall)
  {
    for (Iterator localIterator = toInstall.iterator(); localIterator.hasNext();)
    {
      IInstallableUnit iu = (IInstallableUnit)localIterator.next();
      add(iu);
    }
  }
  
  public void addInstallableUnits(IInstallableUnit[] toInstall)
  {
    for (int i = 0; i < toInstall.length; i++) {
      add(toInstall[i]);
    }
  }
  
  public void remove(IInstallableUnit toUninstall)
  {
    if (iusToRemove == null) {
      iusToRemove = new ArrayList();
    }
    iusToRemove.add(toUninstall);
  }
  
  public void removeInstallableUnits(IInstallableUnit[] toUninstall)
  {
    for (int i = 0; i < toUninstall.length; i++) {
      remove(toUninstall[i]);
    }
  }
  
  public void removeAll(Collection<IInstallableUnit> toUninstall)
  {
    for (Iterator localIterator = toUninstall.iterator(); localIterator.hasNext();)
    {
      IInstallableUnit iu = (IInstallableUnit)localIterator.next();
      remove(iu);
    }
  }
  
  public void setProfileProperty(String key, String value)
  {
    if (propertiesToAdd == null) {
      propertiesToAdd = new HashMap();
    }
    propertiesToAdd.put(key, value);
  }
  
  public void removeProfileProperty(String key)
  {
    if (propertiesToRemove == null) {
      propertiesToRemove = new ArrayList(1);
    }
    propertiesToRemove.add(key);
  }
  
  public void setInstallableUnitProfileProperty(IInstallableUnit iu, String key, String value)
  {
    if (iuPropertiesToAdd == null) {
      iuPropertiesToAdd = new HashMap();
    }
    Map<String, String> properties = (Map)iuPropertiesToAdd.get(iu);
    if (properties == null)
    {
      properties = new HashMap();
      iuPropertiesToAdd.put(iu, properties);
    }
    properties.put(key, value);
  }
  
  public void removeInstallableUnitProfileProperty(IInstallableUnit iu, String key)
  {
    if (iuPropertiesToRemove == null) {
      iuPropertiesToRemove = new HashMap();
    }
    List<String> keys = (List)iuPropertiesToRemove.get(iu);
    if (keys == null)
    {
      keys = new ArrayList();
      iuPropertiesToRemove.put(iu, keys);
    }
    if (!keys.contains(key)) {
      keys.add(key);
    }
  }
  
  public Collection<IInstallableUnit> getRemovals()
  {
    if (iusToRemove == null) {
      return CollectionUtils.emptyList();
    }
    return Collections.unmodifiableList(iusToRemove);
  }
  
  public Collection<IInstallableUnit> getAdditions()
  {
    if (iusToAdd == null) {
      return CollectionUtils.emptyList();
    }
    return Collections.unmodifiableList(iusToAdd);
  }
  
  public String[] getPropertiesToRemove()
  {
    if (propertiesToRemove == null) {
      return new String[0];
    }
    return (String[])propertiesToRemove.toArray(new String[propertiesToRemove.size()]);
  }
  
  public Map<String, String> getPropertiesToAdd()
  {
    if (propertiesToAdd == null) {
      return CollectionUtils.emptyMap();
    }
    return propertiesToAdd;
  }
  
  public Map<IInstallableUnit, List<String>> getInstallableUnitProfilePropertiesToRemove()
  {
    if (iuPropertiesToRemove == null) {
      return CollectionUtils.emptyMap();
    }
    return iuPropertiesToRemove;
  }
  
  public Map<IInstallableUnit, Map<String, String>> getInstallableUnitProfilePropertiesToAdd()
  {
    if (iuPropertiesToAdd == null) {
      return CollectionUtils.emptyMap();
    }
    return iuPropertiesToAdd;
  }
  
  public void setInstallableUnitInclusionRules(IInstallableUnit iu, String value)
  {
    setInstallableUnitProfileProperty(iu, "org.eclipse.equinox.p2.internal.inclusion.rules", value);
  }
  
  public void removeInstallableUnitInclusionRules(IInstallableUnit iu)
  {
    removeInstallableUnitProfileProperty(iu, "org.eclipse.equinox.p2.internal.inclusion.rules");
  }
  
  public Object clone()
  {
    ProfileChangeRequest result = new ProfileChangeRequest(profile);
    iusToRemove = (iusToRemove == null ? null : (ArrayList)iusToRemove.clone());
    iusToAdd = (iusToAdd == null ? null : (ArrayList)iusToAdd.clone());
    propertiesToRemove = (propertiesToRemove == null ? null : (ArrayList)propertiesToRemove.clone());
    propertiesToAdd = (propertiesToAdd == null ? null : (HashMap)propertiesToAdd.clone());
    iuPropertiesToAdd = (iuPropertiesToAdd == null ? null : (HashMap)iuPropertiesToAdd.clone());
    iuPropertiesToRemove = (iuPropertiesToRemove == null ? null : (HashMap)iuPropertiesToRemove.clone());
    additionalRequirements = (additionalRequirements == null ? null : (ArrayList)additionalRequirements.clone());
    return result;
  }
  
  public String toString()
  {
    StringBuffer result = new StringBuffer(1000);
    result.append("==Profile change request for ");
    result.append(profile.getProfileId());
    result.append('\n');
    Iterator localIterator;
    if (iusToAdd != null)
    {
      result.append("==Additions==");
      result.append('\n');
      for (localIterator = iusToAdd.iterator(); localIterator.hasNext();)
      {
        IInstallableUnit iu = (IInstallableUnit)localIterator.next();
        result.append('\t');
        result.append(iu);
        result.append('\n');
      }
    }
    if (iusToRemove != null)
    {
      result.append("==Removals==");
      result.append('\n');
      for (localIterator = iusToRemove.iterator(); localIterator.hasNext();)
      {
        IInstallableUnit iu = (IInstallableUnit)localIterator.next();
        result.append('\t');
        result.append(iu);
        result.append('\n');
      }
    }
    return result.toString();
  }
  
  public void addExtraRequirements(Collection<IRequirement> requirements)
  {
    if (additionalRequirements == null) {
      additionalRequirements = new ArrayList(requirements.size());
    }
    additionalRequirements.addAll(requirements);
  }
  
  public Collection<IRequirement> getExtraRequirements()
  {
    return additionalRequirements;
  }
  
  public void clearExtraRequirements()
  {
    additionalRequirements = null;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.p2.director.ProfileChangeRequest
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.p2.director;

class Projector$AbstractVariable
{
  public Projector$AbstractVariable(String name) {}
  
  public Projector$AbstractVariable() {}
  
  public String toString()
  {
    return "AbstractVariable: " + hashCode();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.p2.director.Projector.AbstractVariable
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.p2.director;

import java.util.Set;
import org.eclipse.core.runtime.jobs.Job;
import org.sat4j.pb.tools.DependencyHelper;

class Projector$ExplanationJob
  extends Job
{
  private Set<Explanation> explanation;
  final Projector this$0;
  
  public Projector$ExplanationJob(Projector paramProjector)
  {
    super(Messages.Planner_NoSolution);
    
    setSystem(true);
  }
  
  public boolean belongsTo(Object family)
  {
    return family == this;
  }
  
  protected void canceling()
  {
    super.canceling();
    this$0.dependencyHelper.stopExplanation();
  }
  
  public Set<Explanation> getExplanationResult()
  {
    return explanation;
  }
  
  /* Error */
  protected org.eclipse.core.runtime.IStatus run(org.eclipse.core.runtime.IProgressMonitor monitor)
  {
    // Byte code:
    //   0: lconst_0
    //   1: lstore_2
    //   2: getstatic 117	org/eclipse/equinox/internal/p2/director/Projector:DEBUG	Z
    //   5: ifeq +26 -> 31
    //   8: invokestatic 126	java/lang/System:currentTimeMillis	()J
    //   11: lstore_2
    //   12: new 61	java/lang/StringBuffer
    //   15: dup
    //   16: ldc 1
    //   18: invokespecial 124	java/lang/StringBuffer:<init>	(Ljava/lang/String;)V
    //   21: lload_2
    //   22: invokevirtual 125	java/lang/StringBuffer:append	(J)Ljava/lang/StringBuffer;
    //   25: invokevirtual 123	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   28: invokestatic 130	org/eclipse/equinox/internal/p2/core/helpers/Tracing:debug	(Ljava/lang/String;)V
    //   31: aload_0
    //   32: aload_0
    //   33: getfield 120	org/eclipse/equinox/internal/p2/director/Projector$ExplanationJob:this$0	Lorg/eclipse/equinox/internal/p2/director/Projector;
    //   36: getfield 118	org/eclipse/equinox/internal/p2/director/Projector:dependencyHelper	Lorg/sat4j/pb/tools/DependencyHelper;
    //   39: invokevirtual 133	org/sat4j/pb/tools/DependencyHelper:why	()Ljava/util/Set;
    //   42: putfield 119	org/eclipse/equinox/internal/p2/director/Projector$ExplanationJob:explanation	Ljava/util/Set;
    //   45: getstatic 117	org/eclipse/equinox/internal/p2/director/Projector:DEBUG	Z
    //   48: ifeq +130 -> 178
    //   51: invokestatic 126	java/lang/System:currentTimeMillis	()J
    //   54: lstore 4
    //   56: new 61	java/lang/StringBuffer
    //   59: dup
    //   60: ldc 2
    //   62: invokespecial 124	java/lang/StringBuffer:<init>	(Ljava/lang/String;)V
    //   65: lload 4
    //   67: lload_2
    //   68: lsub
    //   69: invokevirtual 125	java/lang/StringBuffer:append	(J)Ljava/lang/StringBuffer;
    //   72: invokevirtual 123	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   75: invokestatic 130	org/eclipse/equinox/internal/p2/core/helpers/Tracing:debug	(Ljava/lang/String;)V
    //   78: ldc 3
    //   80: invokestatic 130	org/eclipse/equinox/internal/p2/core/helpers/Tracing:debug	(Ljava/lang/String;)V
    //   83: aload_0
    //   84: getfield 119	org/eclipse/equinox/internal/p2/director/Projector$ExplanationJob:explanation	Ljava/util/Set;
    //   87: invokeinterface 136 1 0
    //   92: astore 7
    //   94: goto +23 -> 117
    //   97: aload 7
    //   99: invokeinterface 135 1 0
    //   104: checkcast 69	org/eclipse/equinox/internal/p2/director/Explanation
    //   107: astore 6
    //   109: aload 6
    //   111: invokevirtual 122	java/lang/Object:toString	()Ljava/lang/String;
    //   114: invokestatic 130	org/eclipse/equinox/internal/p2/core/helpers/Tracing:debug	(Ljava/lang/String;)V
    //   117: aload 7
    //   119: invokeinterface 134 1 0
    //   124: ifne -27 -> 97
    //   127: goto +51 -> 178
    //   130: pop
    //   131: getstatic 117	org/eclipse/equinox/internal/p2/director/Projector:DEBUG	Z
    //   134: ifeq +8 -> 142
    //   137: ldc 4
    //   139: invokestatic 130	org/eclipse/equinox/internal/p2/core/helpers/Tracing:debug	(Ljava/lang/String;)V
    //   142: aload_0
    //   143: getfield 119	org/eclipse/equinox/internal/p2/director/Projector$ExplanationJob:explanation	Ljava/util/Set;
    //   146: ifnonnull +46 -> 192
    //   149: aload_0
    //   150: invokestatic 129	org/eclipse/equinox/internal/p2/core/helpers/CollectionUtils:emptySet	()Ljava/util/Set;
    //   153: putfield 119	org/eclipse/equinox/internal/p2/director/Projector$ExplanationJob:explanation	Ljava/util/Set;
    //   156: goto +36 -> 192
    //   159: astore 8
    //   161: aload_0
    //   162: getfield 119	org/eclipse/equinox/internal/p2/director/Projector$ExplanationJob:explanation	Ljava/util/Set;
    //   165: ifnonnull +10 -> 175
    //   168: aload_0
    //   169: invokestatic 129	org/eclipse/equinox/internal/p2/core/helpers/CollectionUtils:emptySet	()Ljava/util/Set;
    //   172: putfield 119	org/eclipse/equinox/internal/p2/director/Projector$ExplanationJob:explanation	Ljava/util/Set;
    //   175: aload 8
    //   177: athrow
    //   178: aload_0
    //   179: getfield 119	org/eclipse/equinox/internal/p2/director/Projector$ExplanationJob:explanation	Ljava/util/Set;
    //   182: ifnonnull +10 -> 192
    //   185: aload_0
    //   186: invokestatic 129	org/eclipse/equinox/internal/p2/core/helpers/CollectionUtils:emptySet	()Ljava/util/Set;
    //   189: putfield 119	org/eclipse/equinox/internal/p2/director/Projector$ExplanationJob:explanation	Ljava/util/Set;
    //   192: aload_0
    //   193: dup
    //   194: astore 4
    //   196: monitorenter
    //   197: aload_0
    //   198: invokevirtual 121	java/lang/Object:notify	()V
    //   201: aload 4
    //   203: monitorexit
    //   204: goto +7 -> 211
    //   207: aload 4
    //   209: monitorexit
    //   210: athrow
    //   211: getstatic 115	org/eclipse/core/runtime/Status:OK_STATUS	Lorg/eclipse/core/runtime/IStatus;
    //   214: areturn
    // Line number table:
    //   Java source line #116	-> byte code offset #0
    //   Java source line #117	-> byte code offset #2
    //   Java source line #118	-> byte code offset #8
    //   Java source line #119	-> byte code offset #12
    //   Java source line #122	-> byte code offset #31
    //   Java source line #123	-> byte code offset #45
    //   Java source line #124	-> byte code offset #51
    //   Java source line #125	-> byte code offset #56
    //   Java source line #126	-> byte code offset #78
    //   Java source line #127	-> byte code offset #83
    //   Java source line #128	-> byte code offset #109
    //   Java source line #127	-> byte code offset #117
    //   Java source line #131	-> byte code offset #130
    //   Java source line #132	-> byte code offset #131
    //   Java source line #133	-> byte code offset #137
    //   Java source line #136	-> byte code offset #142
    //   Java source line #137	-> byte code offset #149
    //   Java source line #134	-> byte code offset #159
    //   Java source line #136	-> byte code offset #161
    //   Java source line #137	-> byte code offset #168
    //   Java source line #138	-> byte code offset #175
    //   Java source line #136	-> byte code offset #178
    //   Java source line #137	-> byte code offset #185
    //   Java source line #139	-> byte code offset #192
    //   Java source line #140	-> byte code offset #197
    //   Java source line #139	-> byte code offset #201
    //   Java source line #142	-> byte code offset #211
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	215	0	this	ExplanationJob
    //   0	215	1	monitor	org.eclipse.core.runtime.IProgressMonitor
    //   1	67	2	start	long
    //   54	12	4	stop	long
    //   194	14	4	Ljava/lang/Object;	Object
    //   107	3	6	ex	Explanation
    //   92	26	7	localIterator	java.util.Iterator
    //   130	1	8	localTimeoutException	org.sat4j.specs.TimeoutException
    //   159	17	8	localObject1	Object
    // Exception table:
    //   from	to	target	type
    //   31	127	130	org/sat4j/specs/TimeoutException
    //   31	142	159	finally
    //   197	204	207	finally
    //   207	210	207	finally
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.p2.director.Projector.ExplanationJob
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.p2.director;

import java.util.List;
import org.eclipse.equinox.p2.metadata.IInstallableUnitPatch;

final class Projector$Pending
{
  List<? super IInstallableUnitPatch> matches;
  Explanation explanation;
  Object left;
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.p2.director.Projector.Pending
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.p2.director;

import java.io.PrintStream;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.equinox.internal.p2.core.helpers.CollectionUtils;
import org.eclipse.equinox.internal.p2.core.helpers.Tracing;
import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability;
import org.eclipse.equinox.internal.p2.metadata.InstallableUnit;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.metadata.IInstallableUnitFragment;
import org.eclipse.equinox.p2.metadata.IInstallableUnitPatch;
import org.eclipse.equinox.p2.metadata.IRequirement;
import org.eclipse.equinox.p2.metadata.IRequirementChange;
import org.eclipse.equinox.p2.metadata.Version;
import org.eclipse.equinox.p2.metadata.expression.IMatchExpression;
import org.eclipse.equinox.p2.query.Collector;
import org.eclipse.equinox.p2.query.IQueryResult;
import org.eclipse.equinox.p2.query.IQueryable;
import org.eclipse.equinox.p2.query.QueryUtil;
import org.eclipse.osgi.util.NLS;
import org.osgi.framework.BundleContext;
import org.sat4j.pb.IPBSolver;
import org.sat4j.pb.SolverFactory;
import org.sat4j.pb.UserFriendlyPBStringSolver;
import org.sat4j.pb.tools.DependencyHelper;
import org.sat4j.pb.tools.ImplicationAnd;
import org.sat4j.pb.tools.ImplicationNamer;
import org.sat4j.pb.tools.ImplicationRHS;
import org.sat4j.pb.tools.WeightedObject;
import org.sat4j.specs.ContradictionException;
import org.sat4j.specs.IVec;
import org.sat4j.specs.TimeoutException;

public class Projector
{
  static boolean DEBUG = Tracing.DEBUG_PLANNER_PROJECTOR;
  private static boolean DEBUG_ENCODING = false;
  private IQueryable<IInstallableUnit> picker;
  private QueryableArray patches;
  private Map<IInstallableUnit, AbstractVariable> noopVariables;
  private List<AbstractVariable> abstractVariables;
  private Map<String, Map<Version, IInstallableUnit>> slice;
  private IInstallableUnit selectionContext;
  DependencyHelper<Object, Explanation> dependencyHelper;
  private Collection<IInstallableUnit> solution;
  private Collection<Object> assumptions;
  private MultiStatus result;
  private Collection<IInstallableUnit> alreadyInstalledIUs;
  private IQueryable<IInstallableUnit> lastState;
  private boolean considerMetaRequirements;
  private IInstallableUnit entryPoint;
  private Map<IInstallableUnitFragment, Set<IInstallableUnit>> fragments = new HashMap();
  private int numberOfInstalledIUs;
  private Set<IInstallableUnit> nonGreedyIUs;
  private Map<IInstallableUnit, AbstractVariable> nonGreedyVariables = new HashMap();
  private Map<AbstractVariable, List<Object>> nonGreedyProvider = new HashMap();
  private boolean emptyBecauseFiltered;
  
  static class AbstractVariable
  {
    public AbstractVariable(String name) {}
    
    public AbstractVariable() {}
    
    public String toString()
    {
      return "AbstractVariable: " + hashCode();
    }
  }
  
  class ExplanationJob
    extends Job
  {
    private Set<Explanation> explanation;
    
    public ExplanationJob()
    {
      super();
      
      setSystem(true);
    }
    
    public boolean belongsTo(Object family)
    {
      return family == this;
    }
    
    protected void canceling()
    {
      super.canceling();
      dependencyHelper.stopExplanation();
    }
    
    public Set<Explanation> getExplanationResult()
    {
      return explanation;
    }
    
    /* Error */
    protected IStatus run(IProgressMonitor monitor)
    {
      // Byte code:
      //   0: lconst_0
      //   1: lstore_2
      //   2: getstatic 117	org/eclipse/equinox/internal/p2/director/Projector:DEBUG	Z
      //   5: ifeq +26 -> 31
      //   8: invokestatic 126	java/lang/System:currentTimeMillis	()J
      //   11: lstore_2
      //   12: new 61	java/lang/StringBuffer
      //   15: dup
      //   16: ldc 1
      //   18: invokespecial 124	java/lang/StringBuffer:<init>	(Ljava/lang/String;)V
      //   21: lload_2
      //   22: invokevirtual 125	java/lang/StringBuffer:append	(J)Ljava/lang/StringBuffer;
      //   25: invokevirtual 123	java/lang/StringBuffer:toString	()Ljava/lang/String;
      //   28: invokestatic 130	org/eclipse/equinox/internal/p2/core/helpers/Tracing:debug	(Ljava/lang/String;)V
      //   31: aload_0
      //   32: aload_0
      //   33: getfield 120	org/eclipse/equinox/internal/p2/director/Projector$ExplanationJob:this$0	Lorg/eclipse/equinox/internal/p2/director/Projector;
      //   36: getfield 118	org/eclipse/equinox/internal/p2/director/Projector:dependencyHelper	Lorg/sat4j/pb/tools/DependencyHelper;
      //   39: invokevirtual 133	org/sat4j/pb/tools/DependencyHelper:why	()Ljava/util/Set;
      //   42: putfield 119	org/eclipse/equinox/internal/p2/director/Projector$ExplanationJob:explanation	Ljava/util/Set;
      //   45: getstatic 117	org/eclipse/equinox/internal/p2/director/Projector:DEBUG	Z
      //   48: ifeq +130 -> 178
      //   51: invokestatic 126	java/lang/System:currentTimeMillis	()J
      //   54: lstore 4
      //   56: new 61	java/lang/StringBuffer
      //   59: dup
      //   60: ldc 2
      //   62: invokespecial 124	java/lang/StringBuffer:<init>	(Ljava/lang/String;)V
      //   65: lload 4
      //   67: lload_2
      //   68: lsub
      //   69: invokevirtual 125	java/lang/StringBuffer:append	(J)Ljava/lang/StringBuffer;
      //   72: invokevirtual 123	java/lang/StringBuffer:toString	()Ljava/lang/String;
      //   75: invokestatic 130	org/eclipse/equinox/internal/p2/core/helpers/Tracing:debug	(Ljava/lang/String;)V
      //   78: ldc 3
      //   80: invokestatic 130	org/eclipse/equinox/internal/p2/core/helpers/Tracing:debug	(Ljava/lang/String;)V
      //   83: aload_0
      //   84: getfield 119	org/eclipse/equinox/internal/p2/director/Projector$ExplanationJob:explanation	Ljava/util/Set;
      //   87: invokeinterface 136 1 0
      //   92: astore 7
      //   94: goto +23 -> 117
      //   97: aload 7
      //   99: invokeinterface 135 1 0
      //   104: checkcast 69	org/eclipse/equinox/internal/p2/director/Explanation
      //   107: astore 6
      //   109: aload 6
      //   111: invokevirtual 122	java/lang/Object:toString	()Ljava/lang/String;
      //   114: invokestatic 130	org/eclipse/equinox/internal/p2/core/helpers/Tracing:debug	(Ljava/lang/String;)V
      //   117: aload 7
      //   119: invokeinterface 134 1 0
      //   124: ifne -27 -> 97
      //   127: goto +51 -> 178
      //   130: pop
      //   131: getstatic 117	org/eclipse/equinox/internal/p2/director/Projector:DEBUG	Z
      //   134: ifeq +8 -> 142
      //   137: ldc 4
      //   139: invokestatic 130	org/eclipse/equinox/internal/p2/core/helpers/Tracing:debug	(Ljava/lang/String;)V
      //   142: aload_0
      //   143: getfield 119	org/eclipse/equinox/internal/p2/director/Projector$ExplanationJob:explanation	Ljava/util/Set;
      //   146: ifnonnull +46 -> 192
      //   149: aload_0
      //   150: invokestatic 129	org/eclipse/equinox/internal/p2/core/helpers/CollectionUtils:emptySet	()Ljava/util/Set;
      //   153: putfield 119	org/eclipse/equinox/internal/p2/director/Projector$ExplanationJob:explanation	Ljava/util/Set;
      //   156: goto +36 -> 192
      //   159: astore 8
      //   161: aload_0
      //   162: getfield 119	org/eclipse/equinox/internal/p2/director/Projector$ExplanationJob:explanation	Ljava/util/Set;
      //   165: ifnonnull +10 -> 175
      //   168: aload_0
      //   169: invokestatic 129	org/eclipse/equinox/internal/p2/core/helpers/CollectionUtils:emptySet	()Ljava/util/Set;
      //   172: putfield 119	org/eclipse/equinox/internal/p2/director/Projector$ExplanationJob:explanation	Ljava/util/Set;
      //   175: aload 8
      //   177: athrow
      //   178: aload_0
      //   179: getfield 119	org/eclipse/equinox/internal/p2/director/Projector$ExplanationJob:explanation	Ljava/util/Set;
      //   182: ifnonnull +10 -> 192
      //   185: aload_0
      //   186: invokestatic 129	org/eclipse/equinox/internal/p2/core/helpers/CollectionUtils:emptySet	()Ljava/util/Set;
      //   189: putfield 119	org/eclipse/equinox/internal/p2/director/Projector$ExplanationJob:explanation	Ljava/util/Set;
      //   192: aload_0
      //   193: dup
      //   194: astore 4
      //   196: monitorenter
      //   197: aload_0
      //   198: invokevirtual 121	java/lang/Object:notify	()V
      //   201: aload 4
      //   203: monitorexit
      //   204: goto +7 -> 211
      //   207: aload 4
      //   209: monitorexit
      //   210: athrow
      //   211: getstatic 115	org/eclipse/core/runtime/Status:OK_STATUS	Lorg/eclipse/core/runtime/IStatus;
      //   214: areturn
      // Line number table:
      //   Java source line #116	-> byte code offset #0
      //   Java source line #117	-> byte code offset #2
      //   Java source line #118	-> byte code offset #8
      //   Java source line #119	-> byte code offset #12
      //   Java source line #122	-> byte code offset #31
      //   Java source line #123	-> byte code offset #45
      //   Java source line #124	-> byte code offset #51
      //   Java source line #125	-> byte code offset #56
      //   Java source line #126	-> byte code offset #78
      //   Java source line #127	-> byte code offset #83
      //   Java source line #128	-> byte code offset #109
      //   Java source line #127	-> byte code offset #117
      //   Java source line #131	-> byte code offset #130
      //   Java source line #132	-> byte code offset #131
      //   Java source line #133	-> byte code offset #137
      //   Java source line #136	-> byte code offset #142
      //   Java source line #137	-> byte code offset #149
      //   Java source line #134	-> byte code offset #159
      //   Java source line #136	-> byte code offset #161
      //   Java source line #137	-> byte code offset #168
      //   Java source line #138	-> byte code offset #175
      //   Java source line #136	-> byte code offset #178
      //   Java source line #137	-> byte code offset #185
      //   Java source line #139	-> byte code offset #192
      //   Java source line #140	-> byte code offset #197
      //   Java source line #139	-> byte code offset #201
      //   Java source line #142	-> byte code offset #211
      // Local variable table:
      //   start	length	slot	name	signature
      //   0	215	0	this	ExplanationJob
      //   0	215	1	monitor	IProgressMonitor
      //   1	67	2	start	long
      //   54	12	4	stop	long
      //   194	14	4	Ljava/lang/Object;	Object
      //   107	3	6	ex	Explanation
      //   92	26	7	localIterator	Iterator
      //   130	1	8	localTimeoutException	TimeoutException
      //   159	17	8	localObject1	Object
      // Exception table:
      //   from	to	target	type
      //   31	127	130	org/sat4j/specs/TimeoutException
      //   31	142	159	finally
      //   197	204	207	finally
      //   207	210	207	finally
    }
  }
  
  public Projector(IQueryable<IInstallableUnit> q, Map<String, String> context, Set<IInstallableUnit> nonGreedyIUs, boolean considerMetaRequirements)
  {
    picker = q;
    noopVariables = new HashMap();
    slice = new HashMap();
    selectionContext = InstallableUnit.contextIU(context);
    abstractVariables = new ArrayList();
    result = new MultiStatus("org.eclipse.equinox.p2.director", 0, Messages.Planner_Problems_resolving_plan, null);
    assumptions = new ArrayList();
    this.nonGreedyIUs = nonGreedyIUs;
    this.considerMetaRequirements = considerMetaRequirements;
  }
  
  protected boolean isInstalled(IInstallableUnit iu)
  {
    return !lastState.query(QueryUtil.createIUQuery(iu), null).isEmpty();
  }
  
  public void encode(IInstallableUnit entryPointIU, IInstallableUnit[] alreadyExistingRoots, IQueryable<IInstallableUnit> installedIUs, Collection<IInstallableUnit> newRoots, IProgressMonitor monitor)
  {
    alreadyInstalledIUs = Arrays.asList(alreadyExistingRoots);
    numberOfInstalledIUs = sizeOf(installedIUs);
    lastState = installedIUs;
    entryPoint = entryPointIU;
    try
    {
      long start = 0L;
      if (DEBUG)
      {
        start = System.currentTimeMillis();
        Tracing.debug("Start projection: " + start);
      }
      IPBSolver solver;
      IPBSolver solver;
      if (DEBUG_ENCODING) {
        solver = new UserFriendlyPBStringSolver();
      } else {
        solver = SolverFactory.newEclipseP2();
      }
      int timeout = 1000;
      String timeoutString = null;
      try
      {
        timeoutString = DirectorActivator.context.getProperty("eclipse.p2.projector.timeout");
        if (timeoutString != null) {
          timeout = Math.max(timeout, Integer.parseInt(timeoutString));
        }
      }
      catch (Exception e)
      {
        System.err.println("Ignoring user-specified 'eclipse.p2.projector.timeout' value of: " + timeoutString);
        e.printStackTrace();
      }
      solver.setTimeoutOnConflicts(timeout);
      IQueryResult<IInstallableUnit> queryResult = picker.query(QueryUtil.createIUAnyQuery(), null);
      if (DEBUG_ENCODING)
      {
        dependencyHelper = new DependencyHelper(solver, false);
        ((UserFriendlyPBStringSolver)solver).setMapping(dependencyHelper.getMappingToDomain());
      }
      else
      {
        dependencyHelper = new DependencyHelper(solver);
      }
      Iterator<IInstallableUnit> iusToEncode = queryResult.iterator();
      List<IInstallableUnit> iusToOrder = new ArrayList();
      while (iusToEncode.hasNext()) {
        iusToOrder.add((IInstallableUnit)iusToEncode.next());
      }
      Collections.sort(iusToOrder);
      iusToEncode = iusToOrder.iterator();
      while (iusToEncode.hasNext())
      {
        if (monitor.isCanceled())
        {
          result.merge(Status.CANCEL_STATUS);
          throw new OperationCanceledException();
        }
        IInstallableUnit iuToEncode = (IInstallableUnit)iusToEncode.next();
        if (iuToEncode != entryPointIU) {
          processIU(iuToEncode, false);
        }
      }
      createMustHave(entryPointIU, alreadyExistingRoots);
      
      createConstraintsForSingleton();
      
      createConstraintsForNonGreedy();
      
      createOptimizationFunction(entryPointIU, newRoots);
      if (DEBUG)
      {
        long stop = System.currentTimeMillis();
        Tracing.debug("Projection complete: " + (stop - start));
      }
      if (DEBUG_ENCODING) {
        System.out.println(solver.toString());
      }
    }
    catch (IllegalStateException e)
    {
      result.add(new Status(4, "org.eclipse.equinox.p2.director", e.getMessage(), e));
    }
    catch (ContradictionException localContradictionException)
    {
      result.add(new Status(4, "org.eclipse.equinox.p2.director", Messages.Planner_Unsatisfiable_problem));
    }
  }
  
  private void createConstraintsForNonGreedy()
    throws ContradictionException
  {
    for (Iterator localIterator = nonGreedyIUs.iterator(); localIterator.hasNext();)
    {
      IInstallableUnit iu = (IInstallableUnit)localIterator.next();
      AbstractVariable var = getNonGreedyVariable(iu);
      List<Object> providers = (List)nonGreedyProvider.get(var);
      if ((providers == null) || (providers.size() == 0)) {
        dependencyHelper.setFalse(var, new Explanation.MissingGreedyIU(iu));
      } else {
        createImplication(var, providers, Explanation.OPTIONAL_REQUIREMENT);
      }
    }
  }
  
  private int sizeOf(IQueryable<IInstallableUnit> installedIUs)
  {
    IQueryResult<IInstallableUnit> qr = installedIUs.query(QueryUtil.createIUAnyQuery(), null);
    if ((qr instanceof Collector)) {
      return ((Collector)qr).size();
    }
    return qr.toUnmodifiableSet().size();
  }
  
  private void createOptimizationFunction(IInstallableUnit metaIu, Collection<IInstallableUnit> newRoots)
  {
    List<WeightedObject<? extends Object>> weightedObjects = new ArrayList();
    Set<IInstallableUnit> transitiveClosure;
    Set<IInstallableUnit> transitiveClosure;
    if (newRoots.isEmpty())
    {
      transitiveClosure = CollectionUtils.emptySet();
    }
    else
    {
      IQueryable<IInstallableUnit> queryable = new Slicer(picker, selectionContext, false).slice((IInstallableUnit[])newRoots.toArray(new IInstallableUnit[newRoots.size()]), new NullProgressMonitor());
      Set<IInstallableUnit> transitiveClosure;
      if (queryable == null) {
        transitiveClosure = CollectionUtils.emptySet();
      } else {
        transitiveClosure = queryable.query(QueryUtil.ALL_UNITS, new NullProgressMonitor()).toSet();
      }
    }
    Set<Map.Entry<String, Map<Version, IInstallableUnit>>> s = slice.entrySet();
    BigInteger POWER = BigInteger.valueOf(numberOfInstalledIUs > 0 ? numberOfInstalledIUs + 1 : 2);
    
    BigInteger maxWeight = POWER;
    for (Iterator localIterator1 = s.iterator(); localIterator1.hasNext();)
    {
      Map.Entry<String, Map<Version, IInstallableUnit>> entry = (Map.Entry)localIterator1.next();
      conflictingEntries = new ArrayList(((Map)entry.getValue()).values());
      if (conflictingEntries.size() == 1)
      {
        IInstallableUnit iu = (IInstallableUnit)conflictingEntries.get(0);
        if (iu != metaIu) {
          weightedObjects.add(WeightedObject.newWO(iu, POWER));
        }
      }
      else
      {
        Collections.sort(conflictingEntries, Collections.reverseOrder());
        BigInteger weight = POWER;
        boolean installedIuMet = false;
        boolean rootedMet = false;
        for (localIterator2 = conflictingEntries.iterator(); localIterator2.hasNext();)
        {
          IInstallableUnit iu = (IInstallableUnit)localIterator2.next();
          if ((!rootedMet) && (isInstalled(iu)) && (!transitiveClosure.contains(iu)))
          {
            installedIuMet = true;
            weightedObjects.add(WeightedObject.newWO(iu, BigInteger.ONE));
          }
          else if ((!installedIuMet) && (!rootedMet) && (isRoot(iu, newRoots)))
          {
            rootedMet = true;
            weightedObjects.add(WeightedObject.newWO(iu, BigInteger.ONE));
          }
          else
          {
            weightedObjects.add(WeightedObject.newWO(iu, weight));
          }
          weight = weight.multiply(POWER);
        }
        if (weight.compareTo(maxWeight) > 0) {
          maxWeight = weight;
        }
      }
    }
    maxWeight = maxWeight.multiply(POWER).multiply(BigInteger.valueOf(s.size()));
    
    BigInteger abstractWeight = maxWeight.negate();
    for (List<IInstallableUnit> conflictingEntries = abstractVariables.iterator(); conflictingEntries.hasNext();)
    {
      AbstractVariable var = (AbstractVariable)conflictingEntries.next();
      weightedObjects.add(WeightedObject.newWO(var, abstractWeight));
    }
    maxWeight = maxWeight.multiply(POWER).add(BigInteger.ONE);
    
    BigInteger optionalWeight = maxWeight.negate();
    long countOptional = 1L;
    List<IInstallableUnit> requestedPatches = new ArrayList();
    Collection<IRequirement> reqs = metaIu.getRequirements();
    Iterator<IInstallableUnit> iterator;
    label698:
    for (Iterator localIterator2 = reqs.iterator(); localIterator2.hasNext(); iterator.hasNext())
    {
      IRequirement req = (IRequirement)localIterator2.next();
      if ((req.getMin() > 0) || (!req.isGreedy())) {
        break label698;
      }
      IQueryResult<IInstallableUnit> matches = picker.query(QueryUtil.createMatchQuery(req.getMatches(), new Object[0]), null);
      iterator = matches.iterator(); continue;
      IInstallableUnit match = (IInstallableUnit)iterator.next();
      if ((match instanceof IInstallableUnitPatch))
      {
        requestedPatches.add(match);
        countOptional += 1L;
      }
      else
      {
        weightedObjects.add(WeightedObject.newWO(match, optionalWeight));
      }
    }
    BigInteger patchWeight = maxWeight.multiply(POWER).multiply(BigInteger.valueOf(countOptional)).negate();
    for (Object iterator = requestedPatches.iterator(); ((Iterator)iterator).hasNext();) {
      weightedObjects.add(WeightedObject.newWO((IInstallableUnit)((Iterator)iterator).next(), patchWeight));
    }
    if (!weightedObjects.isEmpty()) {
      createObjectiveFunction(weightedObjects);
    }
  }
  
  private boolean isRoot(IInstallableUnit iu, Collection<IInstallableUnit> newRoots)
  {
    return newRoots.contains(iu);
  }
  
  private void createObjectiveFunction(List<WeightedObject<? extends Object>> weightedObjects)
  {
    if (DEBUG)
    {
      StringBuffer b = new StringBuffer();
      for (Iterator localIterator = weightedObjects.iterator(); localIterator.hasNext();)
      {
        WeightedObject<? extends Object> object = (WeightedObject)localIterator.next();
        if (b.length() > 0) {
          b.append(", ");
        }
        b.append(object.getWeight());
        b.append(' ');
        b.append(thing);
      }
      Tracing.debug("objective function: " + b);
    }
    WeightedObject[] array = (WeightedObject[])weightedObjects.toArray(new WeightedObject[weightedObjects.size()]);
    dependencyHelper.setObjectiveFunction(array);
  }
  
  private void createMustHave(IInstallableUnit iu, IInstallableUnit[] alreadyExistingRoots)
    throws ContradictionException
  {
    processIU(iu, true);
    if (DEBUG) {
      Tracing.debug(iu + "=1");
    }
    assumptions.add(iu);
  }
  
  private void createNegation(IInstallableUnit iu, I
1 2 3 4 5

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2019. Infinite Loop Ltd