Package org.waveprotocol.wave.model.document.operation

Examples of org.waveprotocol.wave.model.document.operation.DocOp$IsDocOp


          b.elementEnd();
        }
      }
    }

    DocOp domOp = b.buildUnchecked();
    assert DocOpValidator.isWellFormed(null, domOp);
    return domOp;
  }
View Full Code Here


  //          assert value != null;
            b.endAnnotation(key);
          }
        });
    }
    DocOp annotationsOp = b.finish();
    assert DocOpValidator.isWellFormed(null, annotationsOp);
    return annotationsOp;
  }
View Full Code Here

    }
  }

  public void testOperationsOfDifferentSizes() throws Exception {
    String docId = "b+somedoc";
    DocOp docOp1 = new DocOpBuilder().characters("hi").build();
    WaveletDelta delta1 = createDelta(docId, docOp1, localVersion0);

    WaveServerTestUtil.applyDeltaToWavelet(localWavelet, delta1, 0L);
    try {
      DocOp docOp2 = new DocOpBuilder().characters("bye").build();
      WaveletDelta delta2 = createDelta(docId, docOp2, localWavelet.getCurrentVersion());

      WaveServerTestUtil.applyDeltaToWavelet(localWavelet, delta2, 0L);
      fail("Composition of \"hi\" and \"bye\" did not throw OperationException");
    } catch (OperationException expected) {
View Full Code Here

      return new CoreAddParticipant(participantId);
    } else if (op instanceof WaveletBlipOperation) {
      WaveletBlipOperation waveletBlipOp = (WaveletBlipOperation) op;
      BlipOperation blipOp = waveletBlipOp.getBlipOp();
      if (blipOp instanceof BlipContentOperation) {
        DocOp contentOp = ((BlipContentOperation) blipOp).getContentOp();
        return new CoreWaveletDocumentOperation(waveletBlipOp.getBlipId(), contentOp);
      } else if (blipOp instanceof SubmitBlip) {
        // There is no "core" submit operation, they are ignored by translating
        // them into no-ops
        return CoreNoOp.INSTANCE;
View Full Code Here

      }
    }

    <D extends ModifiableDocument> void run(D document, DocumentParser<D> parser) {
      String initialState = parser.asString(document);
      DocOp docOp = null;

      try {
        document.consume(mutation);
      } catch (OperationException e) {
        Assert.fail("An OperationException was thrown: " + e);
View Full Code Here

    this.participants = new ArrayList<ParticipantId>();
    this.documents = new HashMap<String, DocOp>();
  }

  private DocOp getOrCreateDocument(String documentId) {
    DocOp doc = documents.get(documentId);
    if (doc == null) {
      doc = EMPTY_DOC_OP;
      documents.put(documentId, doc);
    }
    return doc;
View Full Code Here

    return builder;
  }

  private static void addDocumentSnapshotToWavelet(
      DocumentSnapshot snapshot, WaveletData container) throws InvalidParticipantAddress {
    DocOp op = WaveletOperationSerializer.deserialize(snapshot.getDocumentOperation());
    DocInitialization docInit = DocOpUtil.asInitialization(op);

    Collection<ParticipantId> contributors = CollectionUtils.newArrayList();
    for (String p : snapshot.getContributor()) {
      contributors.add(ParticipantId.of(p));
View Full Code Here

  }

  @Override
  public boolean modifyDocument(String documentId, DocOp operation)
      throws OperationException {
    DocOp newDoc = Composer.compose(getOrCreateDocument(documentId), operation);
    if (OpComparators.SYNTACTIC_IDENTITY.equal(newDoc, EMPTY_DOC_OP)) {
      documents.remove(documentId);
    } else {
      documents.put(documentId, newDoc);
    }
View Full Code Here

      // sn0     sn1     sn2
      //     ci2     cn2
      //
      Pair<DocOp, DocOp> c = Decomposer.decompose(clientOp);
      Pair<DocOp, DocOp> s = Decomposer.decompose(serverOp);
      DocOp ci0 = c.first;
      DocOp cn0 = c.second;
      DocOp si0 = s.first;
      DocOp sn0 = s.second;
      OperationPair<DocOp> r1 = new InsertionTransformer().transformOperations(ci0, si0);
      DocOp ci1 = r1.clientOp();
      DocOp si1 = r1.serverOp();
      OperationPair<DocOp> r2 =
          new InsertionNoninsertionTransformer().transformOperations(ci1, sn0);
      DocOp ci2 = r2.clientOp();
      DocOp sn1 = r2.serverOp();
      OperationPair<DocOp> r3 =
          new InsertionNoninsertionTransformer().transformOperations(si1, cn0);
      DocOp si2 = r3.clientOp();
      DocOp cn1 = r3.serverOp();
      OperationPair<DocOp> r4 = new NoninsertionTransformer().transformOperations(cn1, sn1);
      DocOp cn2 = r4.clientOp();
      DocOp sn2 = r4.serverOp();
      return new OperationPair<DocOp>(
          Composer.compose(ci2, cn2),
          Composer.compose(si2, sn2));
    } catch (OperationException e) {
      throw new TransformException(e);
View Full Code Here

     * @param op mutation to apply
     */
    @Override
    public void consume(Nindo op) {
      try {
        DocOp docOp = sink.consumeAndReturnInvertible(op);
        if (outputSink != null) {
          outputSink.consume(docOp);
        }
      } catch (OperationException e) {
        throw new OperationRuntimeException(
View Full Code Here

TOP

Related Classes of org.waveprotocol.wave.model.document.operation.DocOp$IsDocOp

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.