Java Collections.unmodifiableCollection Examples

Java Collections.unmodifiableCollection - 30 examples found. These are the top rated real world Java examples of java.util.Collections.unmodifiableCollection extracted from open source projects. You can rate examples to help us improve the quality of examples.
 /**
  * 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);
  }
 /**
  * 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);
   }
 }