Exemplo n.º 1
0
 /**
  * Returns the values in string format. If the type of this values is String, values are
  * returned as is. If the type of this values is byte[], values are base64 encoded. See {@link
  * #convertValuesToString(Collection)}.
  *
  * @return unmodifiable collection
  */
 @SuppressWarnings("unchecked")
 public Collection<String> getStringValues() {
   if (isType(String.class)) {
     return Collections.unmodifiableCollection((Collection<String>) values);
   }
   return Collections.unmodifiableCollection(convertValuesToString((Collection<byte[]>) values));
 }
  @Override
  public Collection<PyThreadInfo> getThreads() {
    cleanOtherDebuggers();

    List<PyThreadInfo> threads = collectAllThreads();

    if (myOtherDebuggers.size() > 0) {
      // here we add process id to thread name in case there are more then one process
      return Collections.unmodifiableCollection(
          Collections2.transform(
              threads,
              new Function<PyThreadInfo, PyThreadInfo>() {
                @Override
                public PyThreadInfo apply(PyThreadInfo t) {
                  String threadName = ThreadRegistry.threadName(t.getName(), t.getId());
                  PyThreadInfo newThread =
                      new PyThreadInfo(
                          t.getId(), threadName, t.getFrames(), t.getStopReason(), t.getMessage());
                  newThread.updateState(t.getState(), t.getFrames());
                  return newThread;
                }
              }));
    } else {
      return Collections.unmodifiableCollection(threads);
    }
  }
  /*
   * Gets the IDs of Items in the filesystem. Don't add a JavaDoc comment
   * here, we use the default documentation from implemented interface.
   */
  @Override
  public Collection<File> getItemIds() {

    if (recursive) {
      final Collection<File> col = new ArrayList<File>();
      for (int i = 0; i < roots.length; i++) {
        addItemIds(col, roots[i]);
      }
      return Collections.unmodifiableCollection(col);
    } else {
      File[] f;
      if (roots.length == 1) {
        if (filter != null) {
          f = roots[0].listFiles(filter);
        } else {
          f = roots[0].listFiles();
        }
      } else {
        f = roots;
      }

      if (f == null) {
        return Collections.unmodifiableCollection(new LinkedList<File>());
      }

      final List<File> l = Arrays.asList(f);
      Collections.sort(l);
      return Collections.unmodifiableCollection(l);
    }
  }
  /*
   * Gets the ID's of all root Items in the container. Don't add a JavaDoc
   * comment here, we use the default documentation from implemented
   * interface.
   */
  @Override
  public Collection<File> rootItemIds() {

    File[] f;

    // in single root case we use children
    if (roots.length == 1) {
      if (filter != null) {
        f = roots[0].listFiles(filter);
      } else {
        f = roots[0].listFiles();
      }
    } else {
      f = roots;
    }

    if (f == null) {
      return Collections.unmodifiableCollection(new LinkedList<File>());
    }

    final List<File> l = Arrays.asList(f);
    Collections.sort(l);

    return Collections.unmodifiableCollection(l);
  }
Exemplo n.º 5
0
 /**
  * Returns the values in binary format. If the type of this values is byte[], values are
  * returned as is. If the type of this values is String, values are UTF-8 encoded. See {@link
  * #convertValuesToByteArray(Collection)}.
  *
  * @return unmodifiable collection
  */
 @SuppressWarnings("unchecked")
 public Collection<byte[]> getBinaryValues() {
   if (isType(byte[].class)) {
     return Collections.unmodifiableCollection((Collection<byte[]>) values);
   }
   return Collections.unmodifiableCollection(
       convertValuesToByteArray((Collection<String>) values));
 }
 /*
  * Gets the IDs of the root elements in the container. Don't add a JavaDoc
  * comment here, we use the default documentation from implemented
  * interface.
  */
 @Override
 public Collection<?> rootItemIds() {
   if (filteredRoots != null) {
     return Collections.unmodifiableCollection(filteredRoots);
   } else {
     return Collections.unmodifiableCollection(roots);
   }
 }
  protected void getVelocityParamsForInput(Map<String, Object> velocityParams) {
    Collection issueLinkTypes = this.issueLinkTypeManager.getIssueLinkTypes();
    Collection issueTypes = this.constantsManager.getAllIssueTypeObjects();
    Collection statuses = this.constantsManager.getStatusObjects();

    velocityParams.put("issueLinkTypes", Collections.unmodifiableCollection(issueLinkTypes));
    velocityParams.put("issueTypes", Collections.unmodifiableCollection(issueTypes));
    velocityParams.put("statuses", Collections.unmodifiableCollection(statuses));
  }
Exemplo n.º 8
0
 @JsonCreator
 public Permission(
     @JsonProperty("source_ip") String sourceIp,
     @JsonProperty("access_methods") Collection<AccessMethod> accessMethods,
     @JsonProperty("resources") Collection<Resource> resources) {
   this.sourceIp = sourceIp;
   this.accessMethods =
       accessMethods == null ? null : Collections.unmodifiableCollection(accessMethods);
   this.resources = resources == null ? null : Collections.unmodifiableCollection(resources);
 }
Exemplo n.º 9
0
 /** @see Alignment#getCells(TypeDefinition, SchemaSpaceID) */
 @Override
 public Collection<? extends Cell> getCells(TypeDefinition type, SchemaSpaceID schemaSpace) {
   switch (schemaSpace) {
     case SOURCE:
       return Collections.unmodifiableCollection(cellsPerSourceType.get(type));
     case TARGET:
       return Collections.unmodifiableCollection(cellsPerTargetType.get(type));
     default:
       throw new IllegalArgumentException("Illegal schema space provided");
   }
 }
  /**
   * Creates node shadow adapter.
   *
   * @param node Node.
   */
  GridDiscoveryNodeShadowAdapter(GridNode node) {
    assert node != null;

    created = U.currentTimeMillis();
    id = node.id();
    attrs = Collections.unmodifiableMap(node.attributes());
    addrs = Collections.unmodifiableCollection(node.addresses());
    hostNames = Collections.unmodifiableCollection(node.hostNames());
    order = node.order();
    lastMetrics = node.metrics();
    daemon = "true".equalsIgnoreCase(this.<String>attribute(ATTR_DAEMON));
  }
Exemplo n.º 11
0
  /**
   * Return all the elements in this graph that have a specified weight. The elements are returned
   * in the form of an unmodifiable collection. If the specified weight is null, return all the
   * unweighted elements. If no elements have the specified weight (or if the argument is null and
   * there are no unweighted elements), return an empty collection. Each element in the returned
   * collection is an instance of {@link Element}.
   *
   * @param weight The specified weight.
   * @return The elements in this graph that have the specified weight.
   */
  public Collection elements(Object weight) {
    if (weight == null) {
      return Collections.unmodifiableCollection(_unweightedSet);
    } else {
      Collection sameWeightElements = (Collection) _weightMap.get(weight);

      if (sameWeightElements == null) {
        return _emptyCollection;
      } else {
        return Collections.unmodifiableCollection(sameWeightElements);
      }
    }
  }
Exemplo n.º 12
0
 @Override
 public int hashCode() {
   return LdapUtils.computeHashCode(
       HASH_CODE_SEED,
       type1,
       type2,
       type3,
       typeCol1 != null ? Collections.unmodifiableCollection(typeCol1) : null,
       typeCol2 != null ? Collections.unmodifiableCollection(typeCol2) : null,
       typeSet1,
       typeSet2,
       typeList1,
       typeList2);
 }
  public Collection<RuleRuntimeEventListener> getRuleRuntimeEventListeners() {
    if (this.cachedRuleRuntimeListeners == null) {
      this.cachedRuleRuntimeListeners = new HashSet<RuleRuntimeEventListener>();
    }

    return Collections.unmodifiableCollection(this.cachedRuleRuntimeListeners);
  }
Exemplo n.º 14
0
/**
 * Created with IntelliJ IDEA. User: mmounirou Date: 11/04/12 Time: 19:39 To change this template
 * use File | Settings | File Templates.
 */
public class GitProvider extends AbstractOriginatingFileProvider {

  static final Collection<Capability> CAPABILITIES =
      Collections.unmodifiableCollection(
          Arrays.asList(
              new Capability[] {
                Capability.CREATE,
                Capability.DELETE,
                Capability.RENAME,
                Capability.GET_TYPE,
                Capability.LIST_CHILDREN,
                Capability.READ_CONTENT,
                Capability.GET_LAST_MODIFIED,
                Capability.URI,
                Capability.WRITE_CONTENT,
                Capability.APPEND_CONTENT,
                Capability.RANDOM_ACCESS_READ,
              }));

  @Override
  protected FileSystem doCreateFileSystem(FileName name, FileSystemOptions fileSystemOptions)
      throws FileSystemException {
    final GenericFileName rootName = (GenericFileName) name;
    return new GitFileSystem(rootName, fileSystemOptions);
  }

  @Override
  public Collection<Capability> getCapabilities() {
    return CAPABILITIES;
  }
}
  static {
    _propertyNames = new ArrayList<String>(1);

    _propertyNames.add("url");

    _propertyNames = Collections.unmodifiableCollection(_propertyNames);
  }
Exemplo n.º 16
0
 @Override
 public Collection<Cookie> getCookies() {
   if (cookies == null) {
     cookies = Collections.unmodifiableCollection(Collections.<Cookie>emptyList());
   }
   return cookies;
 }
  @Override
  public Collection<BrowserCapabilities> getAllBrowserCapabilities() {

    Assert.assertEquals("There is only one BrowserCapability defined", 1, cache.size());

    return Collections.unmodifiableCollection(cache.values());
  }
Exemplo n.º 18
0
 /** Returns an (unordered, possibly immutable) set of the nodes that link to this node. */
 public Collection<Node<T>> getPredecessors() {
   if (preds == null) {
     return Collections.emptyList();
   } else {
     return Collections.unmodifiableCollection(preds);
   }
 }
Exemplo n.º 19
0
  public synchronized Collection<V> values() {
    // First, clear all entries that have been in cache longer than the
    // maximum defined age.
    deleteExpiredEntries();

    return Collections.unmodifiableCollection(
        new AbstractCollection<V>() {
          Collection<CacheObject<V>> values = map.values();

          public Iterator<V> iterator() {
            return new Iterator<V>() {
              Iterator<CacheObject<V>> it = values.iterator();

              public boolean hasNext() {
                return it.hasNext();
              }

              public V next() {
                return it.next().object;
              }

              public void remove() {
                it.remove();
              }
            };
          }

          public int size() {
            return values.size();
          }
        });
  }
Exemplo n.º 20
0
 static {
   List<String> temp = new ArrayList<String>();
   temp.add(SUPPORTED_TRIGGER);
   temp.add(SUPPORTED_CONDITION);
   temp.add(SUPPORTED_ACTION);
   types = Collections.unmodifiableCollection(temp);
 }
Exemplo n.º 21
0
 public Collection<Rule> getRules() {
   List<Rule> list = new ArrayList<Rule>(rules.size());
   for (RuleImpl rule : rules.values()) {
     list.add(rule);
   }
   return Collections.unmodifiableCollection(list);
 }
Exemplo n.º 22
0
public class HDFSFileProvider extends AbstractOriginatingFileProvider {
  /** The scheme this provider was designed to support */
  public static final String SCHEME = "hdfs";

  /** User Information. */
  public static final String ATTR_USER_INFO = "UI";

  /** Authentication types. */
  public static final UserAuthenticationData.Type[] AUTHENTICATOR_TYPES =
      new UserAuthenticationData.Type[] {
        UserAuthenticationData.USERNAME, UserAuthenticationData.PASSWORD
      };

  /** The provider's capabilities. */
  protected static final Collection<Capability> capabilities =
      Collections.unmodifiableCollection(
          Arrays.asList(
              new Capability[] {
                Capability.CREATE,
                Capability.DELETE,
                Capability.RENAME,
                Capability.GET_TYPE,
                Capability.LIST_CHILDREN,
                Capability.READ_CONTENT,
                Capability.URI,
                Capability.WRITE_CONTENT,
                Capability.APPEND_CONTENT,
                Capability.GET_LAST_MODIFIED,
                Capability.SET_LAST_MODIFIED_FILE,
                Capability.RANDOM_ACCESS_READ
              }));

  public HDFSFileProvider() {
    super();
    setFileNameParser(HDFSFileNameParser.getInstance());
  }

  protected FileSystem doCreateFileSystem(
      final FileName name, final FileSystemOptions fileSystemOptions) throws FileSystemException {
    // Create the file system
    // UserAuthenticationData authData = null;
    // try {
    // //authData = UserAuthenticatorUtils.authenticate(fileSystemOptions, AUTHENTICATOR_TYPES);
    // // UserAuthenticatorUtils.getData(authData, UserAuthenticationData.USERNAME,
    // UserAuthenticatorUtils.toChar(rootName.getUserName())),
    // // UserAuthenticatorUtils.getData(authData, UserAuthenticationData.PASSWORD,
    // UserAuthenticatorUtils.toChar(rootName.getPassword())), fileSystemOptions);
    // } catch (final Exception e) {
    // throw new FileSystemException("vfs.provider.sftp/connect.error", name, e);
    // } finally {
    // UserAuthenticatorUtils.cleanup(authData);
    // }
    //
    return new HDFSFileSystem(name, fileSystemOptions);
  }

  public Collection<Capability> getCapabilities() {
    return capabilities;
  }
}
Exemplo n.º 23
0
 /** @see com.vaadin.data.Validatable#getValidators() */
 @Override
 public Collection<Validator> getValidators() {
   if (validators == null || validators.isEmpty()) {
     return null;
   }
   return Collections.unmodifiableCollection(validators);
 }
Exemplo n.º 24
0
 /** @see Alignment#getCells(EntityDefinition, boolean) */
 @Override
 public Collection<? extends Cell> getCells(
     EntityDefinition entityDefinition, boolean includeInherited) {
   if (!includeInherited)
     return Collections.unmodifiableCollection(cellsPerEntity.get(entityDefinition));
   else {
     // Set for safety to return each cell only once.
     // Duplicates shouldn't happen in usual cases, though.
     Collection<Cell> cells = new HashSet<Cell>();
     EntityDefinition e = entityDefinition;
     do {
       cells.addAll(cellsPerEntity.get(e));
       if (e.getFilter() != null) {
         cells.addAll(
             cellsPerEntity.get(
                 AlignmentUtil.createEntity(
                     e.getType(), e.getPropertyPath(), e.getSchemaSpace(), null)));
       }
       TypeDefinition superType = e.getType().getSuperType();
       e =
           superType == null
               ? null
               : AlignmentUtil.createEntity(
                   superType, e.getPropertyPath(), e.getSchemaSpace(), e.getFilter());
     } while (e != null);
     return cells;
   }
 }
Exemplo n.º 25
0
/** @author <a href="mailto:[email protected]">Tomaz Cerar</a> (c) 2013 Red Hat Inc. */
public class ErrorPageDefinition extends AbstractHandlerDefinition {

  public static final ErrorPageDefinition INSTANCE = new ErrorPageDefinition();
  public static final AttributeDefinition CODE =
      new SimpleAttributeDefinitionBuilder("code", ModelType.INT)
          .setAllowExpression(true)
          .setAllowNull(true)
          .build();
  public static final AttributeDefinition PATH =
      new SimpleAttributeDefinitionBuilder("path", ModelType.STRING)
          .setAllowExpression(true)
          .setAllowNull(true)
          .build();
  public static final Collection<AttributeDefinition> ATTRIBUTES =
      Collections.unmodifiableCollection(Arrays.asList(CODE, PATH));

  private ErrorPageDefinition() {
    super(Constants.ERROR_PAGE);
  }

  @Override
  public Collection<AttributeDefinition> getAttributes() {
    return ATTRIBUTES;
  }

  @Override
  public Class getHandlerClass() {
    return FileErrorPageHandler.class;
  }
}
 public Collection<ServiceInfo<AuthenticatorDescription>> getAllServices() {
   Collection<ServiceInfo<AuthenticatorDescription>> unmodifiableCollection;
   synchronized (this.mServicesLock) {
     unmodifiableCollection = Collections.unmodifiableCollection(this.mServices.values());
   }
   return unmodifiableCollection;
 }
Exemplo n.º 27
0
 public Collection<Global> getGlobalVariables() {
   List<Global> list = new ArrayList<Global>(getGlobals().size());
   for (Map.Entry<String, String> global : getGlobals().entrySet()) {
     list.add(new GlobalImpl(global.getKey(), global.getValue()));
   }
   return Collections.unmodifiableCollection(list);
 }
  static {
    _propertyNames = new ArrayList<String>(1);

    _propertyNames.add("layoutTemplateId");

    _propertyNames = Collections.unmodifiableCollection(_propertyNames);
  }
Exemplo n.º 29
0
  /**
   * Returns a new graph with the same structure as the one wrapped here, and with vertices
   * generated by the given {@link Function1}. Edges are copied in direction and weight.
   *
   * @param factory the vertex factory used to instantiate new vertices in the new graph
   * @param function the function used to set values of a new vertex in the new graph, from the
   *     matching spot
   * @param mappings a map that will receive mappings from {@link Spot} to the new vertices. Can be
   *     <code>null</code> if you do not want to get the mappings
   * @return a new {@link SimpleDirectedWeightedGraph}.
   */
  public <V> SimpleDirectedWeightedGraph<V, DefaultWeightedEdge> copy(
      final VertexFactory<V> factory,
      final Function1<Spot, V> function,
      final Map<Spot, V> mappings) {
    final SimpleDirectedWeightedGraph<V, DefaultWeightedEdge> copy =
        new SimpleDirectedWeightedGraph<V, DefaultWeightedEdge>(DefaultWeightedEdge.class);
    final Set<Spot> spots = graph.vertexSet();
    // To store mapping of old graph vs new graph
    Map<Spot, V> map;
    if (null == mappings) {
      map = new HashMap<Spot, V>(spots.size());
    } else {
      map = mappings;
    }

    // Generate new vertices
    for (final Spot spot : Collections.unmodifiableCollection(spots)) {
      final V vertex = factory.createVertex();
      function.compute(spot, vertex);
      map.put(spot, vertex);
      copy.addVertex(vertex);
    }

    // Generate new edges
    for (final DefaultWeightedEdge edge : graph.edgeSet()) {
      final DefaultWeightedEdge newEdge =
          copy.addEdge(map.get(graph.getEdgeSource(edge)), map.get(graph.getEdgeTarget(edge)));
      copy.setEdgeWeight(newEdge, graph.getEdgeWeight(edge));
    }

    return copy;
  }
Exemplo n.º 30
0
 /** Returns a duplicate-free collection of the nodes that this node links to. */
 public Collection<Node<T>> getSuccessors() {
   if (succs == null) {
     return Collections.emptyList();
   } else {
     return Collections.unmodifiableCollection(succs);
   }
 }