@Override
 public Object[] getChildren(final Object parentElement) {
   if (parentElement instanceof String) {
     final String nameSpace = (String) parentElement;
     if (!this.moduleHash.get(nameSpace).isEmpty()) {
       return this.moduleHash.get(nameSpace).toArray();
     } else {
       return Collections.EMPTY_LIST.toArray();
     }
   }
   return Collections.EMPTY_LIST.toArray();
 }
예제 #2
0
  public static <T> Iterator<T> iterator(Class<T> class1, final Object value) {

    if (value == null) {
      return Collections.EMPTY_LIST.iterator();
    }

    if (Boon.isArray(value)) {
      final int length = Arry.len(value);

      return new Iterator<T>() {
        int i = 0;

        @Override
        public boolean hasNext() {
          return i < length;
        }

        @Override
        public T next() {
          if (i >= length) throw new NoSuchElementException("No more properties");
          T next = (T) BeanUtils.idx(value, i);
          i++;
          return next;
        }

        @Override
        public void remove() {}
      };
    } else if (Typ.isCollection(value.getClass())) {
      return ((Collection<T>) value).iterator();
    } else {
      return (Iterator<T>) Collections.singleton(value).iterator();
    }
  }
  protected Iterator getMessageIter(
      FacesContext context, String forComponent, UIComponent component) {

    Iterator messageIter;
    // Attempt to use the "for" attribute to locate
    // messages.  Three possible scenarios here:
    // 1. valid "for" attribute - messages returned
    //    for valid component identified by "for" expression.
    // 2. zero length "for" expression - global errors
    //    not associated with any component returned
    // 3. no "for" expression - all messages returned.
    if (null != forComponent) {
      if (forComponent.length() == 0) {
        messageIter = context.getMessages(null);
      } else {
        UIComponent result = getForComponent(context, forComponent, component);
        if (result == null) {
          messageIter = Collections.EMPTY_LIST.iterator();
        } else {
          messageIter = context.getMessages(result.getClientId(context));
        }
      }
    } else {
      messageIter = context.getMessages();
    }
    return messageIter;
  }
예제 #4
0
  /** Initialize and register classes with kryo. */
  public void initialize() {
    // Register types we know about and do not require external configuration
    kryo.register(ArrayList.class);
    kryo.register(BasicCredentialMetaData.class);
    kryo.register(Class.class, new DefaultSerializers.ClassSerializer());
    kryo.register(ZonedDateTime.class, new ZonedDateTimeTranscoder());
    kryo.register(HardTimeoutExpirationPolicy.class);
    kryo.register(HashMap.class);
    kryo.register(LinkedHashMap.class);
    kryo.register(HashSet.class);
    kryo.register(DefaultHandlerResult.class);
    kryo.register(ImmutableAuthentication.class);
    kryo.register(MultiTimeUseOrTimeoutExpirationPolicy.class);
    kryo.register(NeverExpiresExpirationPolicy.class);
    kryo.register(RememberMeDelegatingExpirationPolicy.class);
    kryo.register(ServiceTicketImpl.class);
    kryo.register(
        SimpleWebApplicationServiceImpl.class, new SimpleWebApplicationServiceSerializer());
    kryo.register(ThrottledUseAndTimeoutExpirationPolicy.class);
    kryo.register(TicketGrantingTicketExpirationPolicy.class);
    kryo.register(TicketGrantingTicketImpl.class);
    kryo.register(TimeoutExpirationPolicy.class);
    kryo.register(UsernamePasswordCredential.class);
    kryo.register(SimplePrincipal.class);
    kryo.register(URL.class, new URLSerializer());
    kryo.register(URI.class, new URISerializer());
    kryo.register(Pattern.class, new RegexSerializer());
    kryo.register(UUID.class, new UUIDSerializer());
    kryo.register(EnumMap.class, new EnumMapSerializer());
    kryo.register(EnumSet.class, new EnumSetSerializer());

    // we add these ones for tests only
    kryo.register(RegisteredServiceImpl.class, new RegisteredServiceSerializer());
    kryo.register(RegexRegisteredService.class, new RegisteredServiceSerializer());

    kryo.register(CasDelegatingLogger.class, new DefaultSerializers.VoidSerializer());

    // from the kryo-serializers library (https://github.com/magro/kryo-serializers)
    UnmodifiableCollectionsSerializer.registerSerializers(kryo);
    ImmutableListSerializer.registerSerializers(kryo);
    ImmutableSetSerializer.registerSerializers(kryo);
    ImmutableMapSerializer.registerSerializers(kryo);
    ImmutableMultimapSerializer.registerSerializers(kryo);

    kryo.register(Collections.EMPTY_LIST.getClass(), new CollectionsEmptyListSerializer());
    kryo.register(Collections.EMPTY_MAP.getClass(), new CollectionsEmptyMapSerializer());
    kryo.register(Collections.EMPTY_SET.getClass(), new CollectionsEmptySetSerializer());

    // Register other types
    if (serializerMap != null) {
      serializerMap.forEach(kryo::register);
    }

    // don't reinit the registered classes after every write or read
    kryo.setAutoReset(false);
    // don't replace objects by references
    kryo.setReferences(false);
    // Catchall for any classes not explicitly registered
    kryo.setRegistrationRequired(false);
  }
예제 #5
0
 @Override
 public Iterator iterator() {
   if (entries == null) {
     return Collections.EMPTY_LIST.iterator();
   }
   return new ResultIterator();
 }
예제 #6
0
 @SuppressWarnings("unchecked")
 public Iterator<Appender<ILoggingEvent>> iteratorForAppenders() {
   if (aai == null) {
     return Collections.EMPTY_LIST.iterator();
   }
   return aai.iteratorForAppenders();
 }
예제 #7
0
  public Iterator getMessages() {
    checkReleased();
    if (this.messages == null) {
      return Collections.EMPTY_LIST.iterator();
    }

    List messages = new ArrayList();
    for (Iterator i = this.messages.values().iterator(); i.hasNext(); ) {
      final List list = (List) i.next();
      messages.addAll(list);
    }

    if (messages.size() > 0) {
      return messages.iterator();
    }

    return Collections.EMPTY_LIST.iterator();
  }
예제 #8
0
  public Iterator getClientIdsWithMessages() {
    checkReleased();

    if (this.messages == null) {
      return Collections.EMPTY_LIST.iterator();
    } else {
      return this.messages.keySet().iterator();
    }
  }
예제 #9
0
 @SuppressWarnings("unchecked")
 public SpectrumIterator() {
   try {
     it = new Ms2QueryIterator();
   } catch (FileNotFoundException e) {
     // do nothing
     it = Collections.EMPTY_LIST.iterator();
   }
 }
예제 #10
0
 /**
  * Retrieves all the <CODE>AttachmentPart</CODE> objects that are part of this <CODE>SOAPMessage
  * </CODE> object.
  *
  * @return an iterator over all the attachments in this message
  */
 public Iterator getAttachments() {
   try {
     if (mAttachments != null && 0 != mAttachments.getAttachmentCount()) {
       return mAttachments.getAttachments().iterator();
     }
   } catch (AxisFault af) {
     log.error(Messages.getMessage("exception00"), af);
   }
   return Collections.EMPTY_LIST.iterator();
 }
예제 #11
0
 @SuppressWarnings("unchecked")
 public Iterator<String> iterateDeclaredSymbolNames() {
   Iterator<String> originalIterator;
   if (myOriginalSymTab != null) {
     originalIterator = myOriginalSymTab.iterateDeclaredSymbolNames();
   } else {
     originalIterator = Collections.EMPTY_LIST.iterator();
   }
   return new SymbolIterator(originalIterator);
 }
예제 #12
0
  public Iterator getMessages(String clientID) {
    checkReleased();
    if (this.messages != null) {
      final List list = (List) this.messages.get(clientID);
      if (list != null) {
        return list.iterator();
      }
    }

    return Collections.EMPTY_LIST.iterator();
  }
예제 #13
0
  @Override
  public Iterator<Quad> find(Node graph, Node subject, Node predicate, Node object) {
    if (!isVar(subject) && !isVar(predicate) && !isVar(object) && !isVar(graph)) {
      if (contains(subject, predicate, object, graph)) {
        return new SingletonIterator(new Triple(subject, predicate, object));
      } else {
        return WrappedIterator.create(Collections.EMPTY_LIST.iterator());
      }
    }
    StringBuffer findQuery = new StringBuffer("SELECT * WHERE { \n");
    String graphURI = !isVar(graph) ? graph.getURI() : null;
    findQuery.append("  GRAPH ");
    if (graphURI != null) {
      findQuery.append("  <" + graphURI + ">");
    } else {
      findQuery.append("?g");
    }
    findQuery.append(" { ");
    findQuery
        .append(SparqlGraph.sparqlNode(subject, "?s"))
        .append(" ")
        .append(SparqlGraph.sparqlNode(predicate, "?p"))
        .append(" ")
        .append(SparqlGraph.sparqlNode(object, "?o"));
    findQuery.append("  } ");
    findQuery.append("\n}");

    // log.info(findQuery.toString());

    ResultSet rs = null;

    try {
      rs =
          JSONInput.fromJSON(
              rdfService.sparqlSelectQuery(findQuery.toString(), RDFService.ResultFormat.JSON));
    } catch (RDFServiceException rdfse) {
      throw new RuntimeException(rdfse);
    }

    List<Quad> quadlist = new ArrayList<Quad>();
    while (rs.hasNext()) {
      QuerySolution soln = rs.nextSolution();
      Quad q =
          new Quad(
              isVar(graph) ? soln.get("?g").asNode() : graph,
              isVar(subject) ? soln.get("?s").asNode() : subject,
              isVar(predicate) ? soln.get("?p").asNode() : predicate,
              isVar(object) ? soln.get("?o").asNode() : object);
      // log.info(t);
      quadlist.add(q);
    }
    // log.info(triplist.size() + " results");
    return WrappedIterator.create(quadlist.iterator());
  }
예제 #14
0
 @Override
 public Iterator<TopDatum> getData(Symbol symbol)
     throws DataNotAvailableException, UnsupportedSymbolException {
   try {
     List<TopDatum> rs = parse(exec(getUrl()));
     return rs.iterator();
   } catch (JSONException ex) {
     Logger.getLogger(TopFetcher.class.getName()).log(Level.SEVERE, null, ex);
   }
   return Collections.EMPTY_LIST.iterator();
 }
  /**
   * Return an Iterator over all children of this node that have the specified name. If there are no
   * such children, an empty Iterator is returned.
   *
   * @param name Name used to select children
   */
  public Iterator findChildren(String name) {

    if (children == null) return (Collections.EMPTY_LIST.iterator());

    ArrayList results = new ArrayList();
    Iterator items = children.iterator();
    while (items.hasNext()) {
      TreeNode item = (TreeNode) items.next();
      if (name.equals(item.getName())) results.add(item);
    }
    return (results.iterator());
  }
예제 #16
0
  public AbstractCustomDialog(
      Shell parentShell,
      String dialogTitle,
      String dialogMessage,
      Object initialInput,
      IInputValidator validator) {

    super(parentShell);

    this.title = dialogTitle;
    this.message = dialogMessage;
    this.input = (initialInput == null) ? Collections.EMPTY_LIST.toArray() : initialInput;
    this.validator = validator;
  }
예제 #17
0
/**
 * Iterator type that can combine multiple iterators into one logical iterator.
 *
 * @author Abe White
 */
public abstract class MultiIterator implements Iterator {
  private static final int PAST_END = -1;

  private Iterator _itr = Collections.EMPTY_LIST.iterator();
  private Iterator _last = null;
  private int _index = 0;

  public boolean hasNext() {
    setIterator();
    return _itr.hasNext();
  }

  public Object next() {
    setIterator();
    return _itr.next();
  }

  public void remove() {
    setIterator();
    _last.remove();
  }

  /**
   * Implement this method to return the iterator at the <code>index</code>th position in the list
   * of iterators to process. Indexing starts at 0 and will proceed upward linearly, never repeating
   * the same index. Return null to indicate that there are no more iterators to process. You may
   * return null to index 0, in which case this iterator will act like an iterator over an empty
   * collection.
   */
  protected abstract Iterator newIterator(int index);

  /** Sets internal iterator to the iterator to use for processing. */
  private void setIterator() {
    // if already iterated through all, nothing to do
    if (_index == PAST_END) return;

    // always remove from the last iterator used
    _last = _itr;

    // find next iterator with a value
    Iterator newItr = _itr;
    while (newItr != null && !newItr.hasNext()) newItr = newIterator(_index++);

    // switch current iter if needed
    if (newItr != null && _itr != newItr) _itr = newItr;
    else if (newItr == null) _index = PAST_END;
  }
}
예제 #18
0
 public static Iterator<?> toIterator(Object object) {
   if (object == null) {
     return Collections.EMPTY_LIST.iterator();
   } else if (object instanceof Iterator<?>) {
     return ((Iterator<?>) object);
   } else if (object instanceof Iterable<?>) {
     return ((Iterable<?>) object).iterator();
   } else if (object instanceof Map<?, ?>) {
     return ((Map<?, ?>) object).entrySet().iterator();
   } else if (object.getClass().isArray()) {
     return new ArrayIterator<Object>(object);
   } else {
     throw new UnsupportedOperationException(
         "Unsupported foreach type " + object.getClass().getName());
   }
 }
예제 #19
0
  /**
   * Returns a <code>Command</code> that set both the sorting and filtering for this particular list
   * compartment.
   *
   * @return the command
   */
  public Command getApplyCommand() {
    Command cmd = UnexecutableCommand.INSTANCE;
    if (CHILD_PAGE.equals(pageType)) {
      List newSortedObjects = Collections.EMPTY_LIST;
      if (_sorting.equals(Sorting.MANUAL_LITERAL)) {
        newSortedObjects = new ArrayList();
        for (Iterator itr = elementCollection.iterator(); itr.hasNext(); ) {
          SortFilterElement element = (SortFilterElement) itr.next();
          newSortedObjects.add(element.getData());
        }
      }

      List newFilteredObjects = Collections.EMPTY_LIST;
      if (_filtering.equals(Filtering.MANUAL_LITERAL)) {
        newFilteredObjects = new ArrayList();
        for (Iterator itr = elementCollection.iterator(); itr.hasNext(); ) {
          SortFilterElement element = (SortFilterElement) itr.next();
          if (!element.isVisible()) {
            newFilteredObjects.add(element.getData());
          }
        }
        if (_filtering.equals(Filtering.MANUAL_LITERAL) && newFilteredObjects.size() == 0) {
          _filtering = Filtering.NONE_LITERAL;
        }
      }

      // Add the objects filtered otherwise.
      if (!_shownAsAlternateViewItems.isEmpty()
          && Collections.EMPTY_LIST.equals(newFilteredObjects)) {
        newFilteredObjects = new ArrayList();
      }
      newFilteredObjects.addAll(_shownAsAlternateViewItems);

      ChangeSortFilterRequest request =
          new ChangeSortFilterRequest(
              _filtering,
              newFilteredObjects,
              _filteringKeys,
              _sorting,
              newSortedObjects,
              _sortingKeys);

      cmd = editPart.getCommand(request);
    }
    return cmd;
  }
  /**
   * Assign the right TARGET if found.
   *
   * @param iArgs Parameters to bind
   * @return true if the target has been recognized, otherwise false
   */
  protected boolean assignTarget(final Map<Object, Object> iArgs) {
    parameters = iArgs;
    if (parsedTarget == null) return true;

    if (iArgs != null && iArgs.size() > 0 && compiledFilter != null)
      compiledFilter.bindParameters(iArgs);

    if (target == null) {
      if (parsedTarget.getTargetClasses() != null) searchInClasses();
      else if (parsedTarget.getTargetIndexValues() != null) {
        target =
            new IndexValuesIterator(
                parsedTarget.getTargetIndexValues(), parsedTarget.isTargetIndexValuesAsc());
      } else if (parsedTarget.getTargetClusters() != null) searchInClusters();
      else if (parsedTarget.getTargetRecords() != null) {
        if (!lazyIteration && parsedTarget.getTargetQuery() != null) {
          // EXECUTE THE QUERY TO ALLOW DISTRIB EXECUTION
          target =
              ((Iterable<? extends OIdentifiable>)
                      getDatabase()
                          .command(new OCommandSQL(parsedTarget.getTargetQuery()))
                          .execute(iArgs))
                  .iterator();
        } else if (parsedTarget.getTargetRecords() instanceof OIterableRecordSource) {
          target = ((OIterableRecordSource) parsedTarget.getTargetRecords()).iterator(iArgs);
        } else {
          target = parsedTarget.getTargetRecords().iterator();
        }
      } else if (parsedTarget.getTargetVariable() != null) {
        final Object var = getContext().getVariable(parsedTarget.getTargetVariable());
        if (var == null) {
          target = Collections.EMPTY_LIST.iterator();
          return true;
        } else if (var instanceof OIdentifiable) {
          final ArrayList<OIdentifiable> list = new ArrayList<OIdentifiable>();
          list.add((OIdentifiable) var);
          target = list.iterator();
        } else if (var instanceof Iterable<?>)
          target = ((Iterable<? extends OIdentifiable>) var).iterator();
      } else return false;
    }

    return true;
  }
예제 #21
0
    synchronized Iterator<Mutation> getFeatures(String trackKey, String chr, int start, int end)
        throws IOException {
      if (currentRange == null || !currentRange.contains(chr, start, end)) {
        Iterator<Feature> features = tribbleFeatureSource.getFeatures(chr, start, end);

        while (features.hasNext()) {
          Mutation feat = (Mutation) features.next();
          String thisKey = feat.getSampleId();
          List<Mutation> keyFeatures = featureMap.get(thisKey);
          if (keyFeatures == null) {
            keyFeatures = new ArrayList<Mutation>();
            featureMap.put(thisKey, keyFeatures);
          }
          keyFeatures.add(feat);
          currentRange = new Range(chr, start, end);
        }
      }
      List<Mutation> featureList = featureMap.get(trackKey);
      return featureList == null ? Collections.EMPTY_LIST.iterator() : featureList.iterator();
    }
  @Test
  public void testClassNamesToString() {
    List ifcs = new LinkedList();
    ifcs.add(Serializable.class);
    ifcs.add(Runnable.class);
    assertEquals("[interface java.io.Serializable, interface java.lang.Runnable]", ifcs.toString());
    assertEquals("[java.io.Serializable, java.lang.Runnable]", ClassUtils.classNamesToString(ifcs));

    List classes = new LinkedList();
    classes.add(LinkedList.class);
    classes.add(Integer.class);
    assertEquals("[class java.util.LinkedList, class java.lang.Integer]", classes.toString());
    assertEquals(
        "[java.util.LinkedList, java.lang.Integer]", ClassUtils.classNamesToString(classes));

    assertEquals("[interface java.util.List]", Collections.singletonList(List.class).toString());
    assertEquals("[java.util.List]", ClassUtils.classNamesToString(List.class));

    assertEquals("[]", Collections.EMPTY_LIST.toString());
    assertEquals("[]", ClassUtils.classNamesToString(Collections.EMPTY_LIST));
  }
  /** getCandidates method comment. */
  protected Iterator getCandidates() {
    List candidates = new ArrayList();

    checkSemiColon(); // check should add semi-colon or not

    String name = getPropertyName();
    if (name != null) {
      CSSMetaModelUtil util = new CSSMetaModelUtil(fContext.getMetaModel());
      Iterator i = Collections.EMPTY_LIST.iterator();
      if (isFontFaceRule()) {
        CSSMMDescriptor desc = util.getDescriptor(name);
        if (desc != null) {
          i = desc.getValues();
        }
      } else {
        CSSMMProperty prop = util.getProperty(name);
        if (prop != null) {
          i = prop.getValues();
        }
      }
      while (i.hasNext()) {
        CSSMMNode val = (CSSMMNode) i.next();
        String valueType = val.getType();
        if (valueType == CSSMMNode.TYPE_KEYWORD) {
          addString(candidates, val.toString());
        } else if (valueType == CSSMMNode.TYPE_NUMBER) {
          addNumber(candidates, (CSSMMNumber) val);
        } else if (valueType == CSSMMNode.TYPE_FUNCTION) {
          addFunction(candidates, (CSSMMFunction) val);
        }
      }
    }

    addImportant(candidates);
    addSemiColon(candidates);

    return candidates.iterator();
  }
예제 #24
0
 public Iterator getAllUserGroups(boolean validOnly) {
   return Collections.EMPTY_LIST.iterator();
 }
예제 #25
0
 public Iterator getAllParticipants() {
   return Collections.EMPTY_LIST.iterator();
 }
예제 #26
0
 public Iterator<UserUserGroupLink> getAllUserGroupLinks() {
   return Collections.EMPTY_LIST.iterator();
 }
예제 #27
0
 public Iterator<UserParticipantLink> getAllParticipantLinks() {
   return Collections.EMPTY_LIST.iterator();
 }
예제 #28
0
 public Iterator<IOrganization> getAllOrganizations() {
   return Collections.EMPTY_LIST.iterator();
 }
예제 #29
0
 public Iterator<IRole> getAllRoles() {
   return Collections.EMPTY_LIST.iterator();
 }
예제 #30
0
 @NotNull
 @Override
 public Object[] getVariants() {
   return Collections.EMPTY_LIST.toArray();
 }