/**
   * Retrieve the current textual label associated with this resolution. This will call back on the
   * given PackageManager to load the label from the application.
   *
   * @param pm A PackageManager from which the label can be loaded; usually the PackageManager from
   *     which you originally retrieved this item.
   * @return Returns a CharSequence containing the resolutions's label. If the item does not have a
   *     label, its name is returned.
   */
  public CharSequence loadLabel(PackageManager pm) {
    if (nonLocalizedLabel != null) {
      return nonLocalizedLabel;
    }
    CharSequence label;
    if (resolvePackageName != null && labelRes != 0) {
      label = pm.getText(resolvePackageName, labelRes, null);
      if (label != null) {
        return label.toString().trim();
      }
    }
    ComponentInfo ci = getComponentInfo();
    ApplicationInfo ai = ci.applicationInfo;
    if (labelRes != 0) {
      label = pm.getText(ci.packageName, labelRes, ai);
      if (label != null) {
        return label.toString().trim();
      }
    }

    CharSequence data = ci.loadLabel(pm);
    // Make the data safe
    if (data != null) data = data.toString().trim();
    return data;
  }
 /**
  * Finds ComponentInfo by component name
  *
  * @param componentName name of the component
  * @return ComponentInfo componentName or null
  */
 public ComponentInfo getComponentByName(String componentName) {
   for (ComponentInfo componentInfo : getComponents()) {
     if (componentInfo.getName().equals(componentName)) {
       return componentInfo;
     }
   }
   return null;
 }
 /**
  * Called whenever an instance is registered.
  *
  * @param info the key or info of the instance that was registered, null if not a component
  * @param registeredObject the instance that was registered, may be null
  */
 protected void registeredComponent(final ComponentInfo info, final Object registeredObject) {
   if (info.getAttributes().isEmpty()) {
     _logger.logDebug(" Registered component: " + info.toComponentKey());
   } else {
     _logger.logDebug(
         " Registered component: " + info.toComponentKey() + " " + info.getAttributes());
   }
 }
 public boolean isClientOnlyService() {
   if (components == null || components.isEmpty()) {
     return false;
   }
   for (ComponentInfo compInfo : components) {
     if (!compInfo.isClient()) {
       return false;
     }
   }
   return true;
 }
  public ComponentInfo getClientComponent() {
    ComponentInfo client = null;

    if (components != null) {
      for (ComponentInfo compInfo : components) {
        if (compInfo.isClient()) {
          client = compInfo;
          break;
        }
      }
    }
    return client;
  }
 public List<String> getConfigDependenciesWithComponents() {
   List<String> retVal = new ArrayList<String>();
   if (configDependencies != null) {
     retVal.addAll(configDependencies);
   }
   if (components != null) {
     for (ComponentInfo c : components) {
       if (c.getConfigDependencies() != null) {
         retVal.addAll(c.getConfigDependencies());
       }
     }
   }
   return retVal.size() == 0 ? (configDependencies == null ? null : configDependencies) : retVal;
 }
 /**
  * Retrieve the current graphical icon associated with this resolution. This will call back on the
  * given PackageManager to load the icon from the application.
  *
  * @param pm A PackageManager from which the icon can be loaded; usually the PackageManager from
  *     which you originally retrieved this item.
  * @return Returns a Drawable containing the resolution's icon. If the item does not have an icon,
  *     the default activity icon is returned.
  */
 public Drawable loadIcon(PackageManager pm) {
   Drawable dr;
   if (resolvePackageName != null && icon != 0) {
     dr = pm.getDrawable(resolvePackageName, icon, null);
     if (dr != null) {
       return dr;
     }
   }
   ComponentInfo ci = getComponentInfo();
   ApplicationInfo ai = ci.applicationInfo;
   if (icon != 0) {
     dr = pm.getDrawable(ci.packageName, icon, ai);
     if (dr != null) {
       return dr;
     }
   }
   return ci.loadIcon(pm);
 }
 /**
  * Gets an instance of a component.
  *
  * <p>This finds an instance that matches the specified information.
  *
  * @param info the component info, not null
  * @return the component instance, not null
  * @throws IllegalArgumentException if no component is available
  */
 public Object getInstance(final ComponentInfo info) {
   ArgumentChecker.notNull(info, "info");
   final ComponentKey key = info.toComponentKey();
   final Object result = _instanceMap.get(key);
   if (result == null) {
     throw new IllegalArgumentException("No component available: " + key);
   }
   return result;
 }
  /**
   * Registers the component specifying the info that describes it.
   *
   * <p>Certain interfaces are automatically detected. If the component implements {@code
   * Lifecycle}, it will be registered as though using {@link #registerLifecycle(Lifecycle)}. If it
   * implements {@code ServletContextAware}, then it will be registered as though using {@link
   * #registerServletContextAware(ServletContextAware)}. If it implements {@code InitializingBean},
   * then it will be initialized as though using {@link #initialize(InitializingBean)}.
   *
   * <p>If the component implements {@code FactoryBean}, it will be checked for the automatically
   * detected interfaces before the factory is evaluated. The evaluated factory will then be
   * registered, and the resulting object will again be checked for automatically detected
   * interfaces.
   *
   * @param info the component info to register, not null
   * @param instance the component instance to register, not null
   * @throws IllegalArgumentException if unable to register
   */
  public void registerComponent(final ComponentInfo info, Object instance) {
    ArgumentChecker.notNull(info, "info");
    ArgumentChecker.notNull(instance, "instance");
    checkStatus(Status.CREATING);

    final ComponentKey key = info.toComponentKey();
    try {
      // initialize
      initialize0(instance);
      registerInstanceInterfaces0(instance);

      // handle factories
      if (instance instanceof FactoryBean<?>) {
        try {
          instance = ((FactoryBean<?>) instance).getObject();
        } catch (final Exception ex) {
          throw new OpenGammaRuntimeException("FactoryBean threw exception", ex);
        }
        initialize0(instance);
        registerInstanceInterfaces0(instance);
      }

      // register into data structures
      final Object current = _instanceMap.putIfAbsent(key, instance);
      if (current != null) {
        throw new IllegalArgumentException(
            "Component already registered for specified information: " + key);
      }
      _infoMap.putIfAbsent(info.getType(), new ComponentTypeInfo(info.getType()));
      final ComponentTypeInfo typeInfo = getTypeInfo(info.getType());
      typeInfo.getInfoMap().put(info.getClassifier(), info);
      registeredComponent(info, instance);

      // If the component being registered is also an MBean, then register it as such
      if (JmxUtils.isMBean(instance.getClass())) {
        registerMBean(instance);
      }
    } catch (final RuntimeException ex) {
      _status.set(Status.FAILED);
      throw new RuntimeException("Failed during registration: " + key, ex);
    }
  }
 private void outputComponent(ComponentInfo component, StringBuilder sb) {
   sb.append("{ \"name\": \"");
   sb.append(component.name);
   sb.append("\",\n  \"version\": \"");
   sb.append(component.getVersion());
   sb.append("\",\n  \"categoryString\": \"");
   sb.append(component.getCategoryString());
   sb.append("\",\n  \"helpString\": ");
   sb.append(formatDescription(component.getHelpDescription()));
   sb.append(",\n  \"showOnPalette\": \"");
   sb.append(component.getShowOnPalette());
   sb.append("\",\n  \"nonVisible\": \"");
   sb.append(component.getNonVisible());
   sb.append("\",\n  \"iconName\": \"");
   sb.append(component.getIconName());
   sb.append("\",\n  \"properties\": [");
   String separator = "";
   for (Map.Entry<String, DesignerProperty> entry : component.designerProperties.entrySet()) {
     String propertyName = entry.getKey();
     DesignerProperty dp = entry.getValue();
     sb.append(separator);
     outputProperty(propertyName, dp, sb);
     separator = ",\n";
   }
   // We need additional information about properties in the blocks editor,
   // and we need all of them, not just the Designer properties. We output
   // the entire set separately for use by the blocks editor to keep things simple.
   sb.append("],\n  \"blockProperties\": [");
   separator = "";
   for (Property prop : component.properties.values()) {
     sb.append(separator);
     // Output properties that are not user-visible, but mark them as invisible
     // Note: carrying this over from the old Java blocks editor. I'm not sure
     // that we'll actually do anything with invisible properties in the blocks
     // editor. ([email protected])
     outputBlockProperty(prop.name, prop, sb);
     separator = ",\n    ";
   }
   sb.append("],\n  \"events\": [");
   separator = "";
   for (Event event : component.events.values()) {
     if (event.userVisible) {
       sb.append(separator);
       outputBlockEvent(event.name, event, sb);
       separator = ",\n    ";
     }
   }
   sb.append("],\n  \"methods\": [");
   separator = "";
   for (Method method : component.methods.values()) {
     if (method.userVisible) {
       sb.append(separator);
       outputBlockMethod(method.name, method, sb);
       separator = ",\n    ";
     }
   }
   sb.append("]}\n");
 }
  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("Service name:");
    sb.append(name);
    sb.append("\nversion:");
    sb.append(version);
    sb.append("\ncomment:");
    sb.append(comment);
    // for (PropertyInfo property : getProperties()) {
    //  sb.append("\tProperty name=" + property.getName() +
    // "\nproperty value=" + property.getValue() + "\ndescription=" + property.getDescription());
    // }
    for (ComponentInfo component : getComponents()) {
      sb.append("\n\n\nComponent:\n");
      sb.append("name=");
      sb.append(component.getName());
      sb.append("\tcategory=");
      sb.append(component.getCategory());
    }

    return sb.toString();
  }
 @DSSink({DSSinkKind.SENSITIVE_UNCATEGORIZED})
 @DSGenerator(
     tool_name = "Doppelganger",
     tool_version = "2.0",
     generated_on = "2013-12-30 12:34:48.941 -0500",
     hash_original_method = "45D9E31DA8DC0720E2897CA268CD8E20",
     hash_generated_method = "73D8B8C603E33D973013EB0774B0CFD7")
 @Override
 public void writeToParcel(Parcel out, int parcelableFlags) {
   super.writeToParcel(out, parcelableFlags);
   out.writeString(authority);
   out.writeString(readPermission);
   out.writeString(writePermission);
   out.writeInt(grantUriPermissions ? 1 : 0);
   out.writeTypedArray(uriPermissionPatterns, parcelableFlags);
   out.writeTypedArray(pathPermissions, parcelableFlags);
   out.writeInt(multiprocess ? 1 : 0);
   out.writeInt(initOrder);
   out.writeInt(isSyncable ? 1 : 0);
 }
 /**
  * Return the icon resource identifier to use for this match. If the match defines an icon, that
  * is used; else if the activity defines an icon, that is used; else, the application icon is
  * used.
  *
  * @return The icon associated with this match.
  */
 public final int getIconResource() {
   if (icon != 0) return icon;
   final ComponentInfo ci = getComponentInfo();
   if (ci != null) return ci.getIconResource();
   return 0;
 }