Package com.webobjects.foundation

Examples of com.webobjects.foundation.NSRange


    // Add the reordered objects
    int listItemIDCount = listItemIDArray.count();
    for (int listItemIDIndex = 0; listItemIDIndex < listItemIDCount; listItemIDIndex++) {
      String itemID = (String) listItemIDArray.objectAtIndex(listItemIDIndex);
      NSRange itemPageRange;
      if (mutableList) {
        itemPageRange = new NSRange(startIndex + listItemIDIndex, listItemIDCount - listItemIDIndex);
      }
      else {
        itemPageRange = new NSRange(startIndex, listItemIDCount);
      }
      NSArray itemPageArray = list.subarrayWithRange(itemPageRange);
      EOQualifier itemIDQualifier = new EOKeyValueQualifier(listItemIDKeyPath, EOQualifier.QualifierOperatorEqual, itemID);
      NSArray matchingItems = EOQualifier.filteredArrayWithQualifier(itemPageArray, itemIDQualifier);
      if (matchingItems.count() == 0) {
        throw new NoSuchElementException("There was no item that matched the ID '" + itemID + "' in " + list + ".");
      }
      else if (matchingItems.count() > 1) {
        throw new IllegalStateException("There was more than one item that matched the ID '" + itemID + "' in " + list + ".");
      }
      Object replacingItem = matchingItems.objectAtIndex(0);
      if (mutableList) {
        int replacedItemIndex = itemPageRange.location();
        Object replacedItem = reorderedList.objectAtIndex(replacedItemIndex);
        if (replacedItem != replacingItem) {
          int replacingItemIndex = replacedItemIndex + itemPageArray.indexOfObject(replacingItem);
          reorderedList.replaceObjectAtIndex(replacingItem, replacedItemIndex);
          reorderedList.replaceObjectAtIndex(replacedItem, replacingItemIndex);
View Full Code Here


    return true;
  }

  @Override
  protected boolean traverseOrQualifier(EOOrQualifier q) {
    NSRange range = new NSRange(_qualifiers.count() - q.qualifiers().count(), q.qualifiers().count());
    ERXOrQualifier oq = new ERXOrQualifier(_qualifiers.subarrayWithRange(range));
    _qualifiers.removeObjectsInRange(range);
    _qualifiers.addObject(oq);
    return true;
  }
View Full Code Here

    return true;
  }

  @Override
  protected boolean traverseAndQualifier(EOAndQualifier q) {
    NSRange range = new NSRange(_qualifiers.count() - q.qualifiers().count(), q.qualifiers().count());
    ERXAndQualifier aq = new ERXAndQualifier(_qualifiers.subarrayWithRange(range));
    _qualifiers.removeObjectsInRange(range);
    _qualifiers.addObject(aq);
    return true;
  }
View Full Code Here

    public WOComponent toggleExpansion() {
        @SuppressWarnings("unchecked")
    NSArray<Object> selectionPath = (NSArray<Object>)_WOJExtensionsUtil.valueForBindingOrNull("selectionPath",this);

        selectionPath = selectionPath.subarrayWithRange(new NSRange(0, _nestingLevel));

        if (!isExpanded()) {
            Object currentItem = valueForBinding("item");
    //        NSLog(@"*** currentItem=%@", currentItem);
            selectionPath = selectionPath.arrayByAddingObject(currentItem);
View Full Code Here

    if (sortOrderings != null) {
      EOSortOrdering.sortArrayUsingKeyOrderArray(fetchedRows, sortOrderings);
    }

    if (fetchLimit > 0 && fetchedRows.count() > fetchLimit) {
      fetchedRows.removeObjectsInRange(new NSRange(fetchLimit, fetchedRows.count() - fetchLimit));
    }
    return fetchedRows;
  }
View Full Code Here

    public LuceneQualifierTraversal(EOEntity entity) {
      _entity = entity;
    }

    protected NSArray<Query> queriesForCurrent(int count) {
      NSRange range = new NSRange(_queries.count() - count, count);
      NSArray<Query> result = _queries.subarrayWithRange(range);
      _queries.removeObjectsInRange(range);
      return result;
    }
View Full Code Here

    int listItemIDCount = listItemIDArray.count();
    for(int listItemIDIndex = 0; listItemIDIndex < listItemIDCount; listItemIDIndex++) {

      String itemID = listItemIDArray.objectAtIndex(listItemIDIndex);
      NSRange itemPageRange;

      if(mutableList) {
        itemPageRange = new NSRange(startIndex + listItemIDIndex, listItemIDCount - listItemIDIndex);
      } else {
        itemPageRange = new NSRange(startIndex, listItemIDCount);
      }

      NSArray itemPageArray = list.subarrayWithRange(itemPageRange);
      EOQualifier itemIDQualifier = new EOKeyValueQualifier(listItemIDKeyPath, EOQualifier.QualifierOperatorEqual, itemID);
      NSArray matchingItems = EOQualifier.filteredArrayWithQualifier(itemPageArray, itemIDQualifier);

      if(matchingItems.count() == 0) {
        throw new NoSuchElementException("There was no item that matched the ID '" + itemID + "' in " + list + ".");
      } else if(matchingItems.count() > 1) {
        throw new IllegalStateException("There was more than one item that matched the ID '" + itemID + "' in " + list + ".");
      }

      Object replacingItem = matchingItems.objectAtIndex(0);

      if(mutableList) {
        int replacedItemIndex = itemPageRange.location();
        Object replacedItem = reorderedList.objectAtIndex(replacedItemIndex);
        if(replacedItem != replacingItem) {
          int replacingItemIndex = replacedItemIndex + itemPageArray.indexOfObject(replacingItem);
          reorderedList.replaceObjectAtIndex(replacingItem, replacedItemIndex);
          reorderedList.replaceObjectAtIndex(replacedItem, replacingItemIndex);
View Full Code Here

  public NSArray<Movie> movies() {
    return Movie.fetchAllMovies(ERXEC.newEditingContext(), Movie.TITLE.asc().array());
  }

  public NSArray<Movie> onlyFiveMovies() {
    NSRange range = new NSRange(0, 5);
    return movies().subarrayWithRange(range);
  }
View Full Code Here

   * @param options
   *            the current options
   * @return the effective batch number
   */
  public NSRange range(NSKeyValueCoding options) {
    NSRange range = null;
   
    String rangeStr = (String)options.valueForKey("Range");
    if (rangeStr != null) {
      Matcher rangeMatcher = _rangePattern.matcher(rangeStr);
      if (rangeMatcher.matches()) {
        int start = Integer.parseInt(rangeMatcher.group(1));
        int length = Integer.parseInt(rangeMatcher.group(2)) - start + 1;
        range = new NSRange(start, length);
      }
    }
    else {
      int batchNumber = batchNumber(options);
      int batchSize = batchSize(options);
      if (batchSize > 0) {
        range = new NSRange(batchNumber * batchSize, batchSize);
      }
    }
   
    return range;
  }
View Full Code Here

    EOFetchSpecification fetchSpec = new EOFetchSpecification(_entityName, qualifier, sortOrderings);
    fetchSpec.setIsDeep(true);

    NSArray<T> objects;
    NSRange range = range(options);
    if (range == null) {
      objects = editingContext.objectsWithFetchSpecification(fetchSpec);
      results = new Results<T>(objects, 0, -1, objects.count());
    }
    else {
      ERXFetchSpecificationBatchIterator batchIterator = new ERXFetchSpecificationBatchIterator(fetchSpec, editingContext, range.length());
      objects = batchIterator.batchWithRange(range);
      results = new Results<T>(objects, range.location(), range.length(), batchIterator.count());
    }
    return results;
  }
View Full Code Here

TOP

Related Classes of com.webobjects.foundation.NSRange

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.