Package org.waveprotocol.wave.model.util

Examples of org.waveprotocol.wave.model.util.StringSet


   *
   * @return a new string set each time, containing the class names of all
   *         registered update event listeners. it is safe to modify this set.
   */
  public StringSet debugGetAllUpdateEventNames() {
    StringSet events = CollectionUtils.createStringSet();
    for (EditorUpdateEvent.EditorUpdateListener l : updateListeners) {
      events.add(l.getClass().getName());
    }
    return events;
  }
View Full Code Here


   * whitelist.
   *
   * @param known
   */
  private ReadableStringSet filterContentAnnotations(ReadableStringSet known) {
    final StringSet interested = CollectionUtils.createStringSet();
    known.each(new Proc() {
      @Override
      public void apply(final String key) {
        AnnotationBehaviour behaviour = annotationLogic.getClosestBehaviour(key);
        if (behaviour != null && behaviour.getAnnotationFamily() == AnnotationFamily.CONTENT) {
          interested.add(key);
        }
      }
    });
    return interested;
  }
View Full Code Here

    // init to default state:
    leftSide.clear();
    rightSide.clear();
    final StringMap<String> leftValues = CollectionUtils.createStringMap();
    final StringMap<String> rightValues = CollectionUtils.createStringMap();
    final StringSet keysToCheck = CollectionUtils.createStringSet();

    // collection up non-null annotations on both sides
    if (location > 0) {
      doc.forEachAnnotationAt(location - 1, new ProcV<String>() {
        public void apply(String key, String value) {
          if (value != null) {
            leftValues.put(key, value);
            keysToCheck.add(key);
          }
        }
      });
    }
    if (location < doc.size()) {
      doc.forEachAnnotationAt(location, new ProcV<String>() {
        public void apply(String key, String value) {
          if (value != null) {
            rightValues.put(key, value);
            keysToCheck.add(key);
          }
        }
      });
    }

    // fill in values that change
    keysToCheck.each(new Proc() {
      public void apply(String key) {
        String left = leftValues.get(key);
        String right = rightValues.get(key);
        if (ValueUtils.notEqual(left, right)) {
          leftSide.put(key, left);
View Full Code Here

  public ReadableStringSet nextLocation() {
    if (!hasNext()) {
      throw new NoSuchElementException();
    }

    StringSet currentKeys = CollectionUtils.createStringSet();

    currentLocation = locations.peek().location;

    do {
      KeyLocation keyLocation = locations.remove();
      currentKeys.add(keyLocation.key);
      advance(keyLocation);
    } while (!locations.isEmpty() && locations.peek().location == currentLocation);

    return currentKeys;
  }
View Full Code Here

    return annotationsOp;
  }

  @Override
  public StringSet knownKeys() {
    final StringSet knownKeys = CollectionUtils.createStringSet();
    annotations.knownKeysLive().each(new Proc() {
      @Override
      public void apply(String key) {
        if (!Annotations.isLocal(key)) {
          knownKeys.add(key);
        }
      }
    });
    return knownKeys;
  }
View Full Code Here

        // and annoying way for now.

        final List<AnnotationEvent> events = new ArrayList<AnnotationEvent>();
        final Box<ReadableStringMap<String>> annotations = Box.create();
        int currentLocationBackup = currentLocation;
        final StringSet open = CollectionUtils.createStringSet();
        for (AnnotationInterval<String> i :
            annotationIntervals(currentLocation, finalLocation, requestedKeys)) {
          currentLocation = i.start();
          annotations.boxed = i.annotations();
          requestedValues.each(new ProcV<String>() {
            public void apply(String key, String value) {
              String oldVal = annotations.boxed.get(key, null);
              if (ValueUtils.notEqual(value, oldVal)) {
                events.add(new AnnotationStartEvent(currentLocation, key, oldVal));
                open.add(key);
              } else if (open.contains(key)) {
                events.add(new AnnotationEndEvent(currentLocation, key));
                //assert open.contains(key);
                open.remove(key);
              }
            }
          });
        }
        open.each(new Proc() {
          @Override
          public void apply(String key) {
            events.add(new AnnotationEndEvent(finalLocation, key));
          }
        });
View Full Code Here

     */
    // HACK(danilatos): This code is inefficient and does not belong in indexed document.
    private List<AnnotationEvent> deleteAnnotations(int size) {
      final List<AnnotationEvent> events = new ArrayList<AnnotationEvent>();

      final StringSet open = CollectionUtils.createStringSet();
      final StringMap<String> deletionInherit = CollectionUtils.createStringMap();
      deletionValues.each(new ReadableStringMap.ProcV<String>() {
        @Override
        public void apply(String key, String value) {
          deletionInherit.put(key, value);
        }
      });

      final int start = currentLocation;
      final int end = currentLocation + size;

      for (AnnotationInterval<String> i : annotationIntervals(start, end, null)) {
        assert i.end() > start;
        assert i.start() < end;
        final int realStart = Math.max(start, i.start());
        deletionInherit.each(new ReadableStringMap.ProcV<String>() {
          @Override
          public void apply(String key, String value) {
            events.add(
                new AnnotationStartEvent(realStart, key, getAnnotation(realStart, key)));
            open.add(key);
          }
        });
        i.annotations().each(new ReadableStringMap.ProcV<String>() {
          @Override
          public void apply(String key, String value) {
            if (!deletionInherit.containsKey(key)) {
              events.add(
                  new AnnotationStartEvent(realStart, key, value));
              open.add(key);
            }
          }
        });
      }

      // Produce endAnnotation calls for every annotation at the end.
      open.each(new StringSet.Proc() {
        @Override
        public void apply(String key) {
          events.add(new AnnotationEndEvent(end, key));
        }
      });
View Full Code Here

    // init to default state:
    leftSide.clear();
    rightSide.clear();
    final StringMap<String> leftValues = CollectionUtils.createStringMap();
    final StringMap<String> rightValues = CollectionUtils.createStringMap();
    final StringSet keysToCheck = CollectionUtils.createStringSet();

    // collection up non-null annotations on both sides
    if (location > 0) {
      doc.forEachAnnotationAt(location - 1, new ProcV<String>() {
        public void apply(String key, String value) {
          if (value != null) {
            leftValues.put(key, value);
            keysToCheck.add(key);
          }
        }
      });
    }
    if (location < doc.size()) {
      doc.forEachAnnotationAt(location, new ProcV<String>() {
        public void apply(String key, String value) {
          if (value != null) {
            rightValues.put(key, value);
            keysToCheck.add(key);
          }
        }
      });
    }

    // fill in values that change
    keysToCheck.each(new Proc() {
      public void apply(String key) {
        String left = leftValues.get(key);
        String right = rightValues.get(key);
        if (ValueUtils.notEqual(left, right)) {
          leftSide.put(key, left);
View Full Code Here

   *
   * @return a new string set each time, containing the class names of all
   *         registered update event listeners. it is safe to modify this set.
   */
  public StringSet debugGetAllUpdateEventNames() {
    StringSet events = CollectionUtils.createStringSet();
    for (EditorUpdateEvent.EditorUpdateListener l : updateListeners) {
      events.add(l.getClass().getName());
    }
    return events;
  }
View Full Code Here

   * whitelist.
   *
   * @param known
   */
  private ReadableStringSet filterContentAnnotations(ReadableStringSet known) {
    final StringSet interested = CollectionUtils.createStringSet();
    known.each(new Proc() {
      @Override
      public void apply(final String key) {
        AnnotationBehaviour behaviour = annotationLogic.getClosestBehaviour(key);
        if (behaviour != null && behaviour.getAnnotationFamily() == AnnotationFamily.CONTENT) {
          interested.add(key);
        }
      }
    });
    return interested;
  }
View Full Code Here

TOP

Related Classes of org.waveprotocol.wave.model.util.StringSet

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.