Package org.jamesii.gui.syntaxeditor

Examples of org.jamesii.gui.syntaxeditor.DocumentReader


    assertEquals(original, output.toString());

    PlainDocument doc = new PlainDocument();
    doc.insertString(0, original, null);

    input = new DocumentReader(doc);
    output = new StringWriter();

    action.run(input, output);

    assertEquals(original, output.toString());
View Full Code Here


              generator);
      Document doc = new PlainDocument();
      try {
        doc.remove(0, doc.getLength());
        doc.insertString(0, testString, null);
        DocumentReader reader = new DocumentReader(doc);
        ReaderCharSequence rcs = new ReaderCharSequence(reader);
        reader.close();

        assertTrue(testString.contentEquals(rcs));

        reader = new DocumentReader(doc);
        StringWriter writer = new StringWriter();

        int read;
        while ((read = reader.read()) >= 0) {
          writer.write(read);
        }
        writer.flush();

        assertEquals(testString, writer.toString());
View Full Code Here

      };
      try {
        doc.remove(0, doc.getLength());
        doc.insertString(0, testString, null);
        ReaderCharSequence rcs;
        try (DocumentReader reader = new DocumentReader(doc)) {
          for (int i = 0; i < 10; i++) {
            int r = (generator.nextInt(doc.getLength()));
            int l = (generator.nextInt(doc.getLength() - r));
            if (i % 2 == 0) {
              doc.remove(r, l);
View Full Code Here

      Document doc = new PlainDocument();
      try {
        doc.remove(0, doc.getLength());
        doc.insertString(0, testString, null);
        ReaderCharSequence rcs;
        try (DocumentReader reader = new DocumentReader(doc)) {
          for (int i = 0; i < 10; i++) {
            int r = generator.nextInt(doc.getLength());
            int l = generator.nextInt((doc.getLength() - r));
            if (i % 2 == 0) {
              doc.remove(r, l);
View Full Code Here

      Document doc = new PlainDocument();
      try {
        doc.remove(0, doc.getLength());
        doc.insertString(0, testString, null);
        StringBuilder result;
        try (DocumentReader reader = new DocumentReader(doc)) {
          result = new StringBuilder(testString.length());
          {
            int l = (int) (testString.length() * generator.nextDouble() / 2f);
            char[] cbuf = new char[l];
            int read = reader.read(cbuf, 0, cbuf.length);
            if (read > 0) {
              result.append(cbuf, 0, read);
            }
          }
          for (int i = 0; i < 10; i++) {
            int r = (generator.nextInt(doc.getLength()));
            int l = (generator.nextInt(doc.getLength() - r));
            if (i % 2 == 0) {
              doc.remove(r, l);
            } else {
              String s =
                  Strings.generateRandomString(generator.nextInt(100),
                      generator);
              doc.insertString(r, s, null);
            }
          }
          while (true) {
            char[] cbuf = new char[1024];
            int read = reader.read(cbuf, 0, cbuf.length);
            if (read < 0) {
              break;
            }
            result.append(cbuf, 0, read);
          }
View Full Code Here

      Document doc = new PlainDocument();
      try {
        doc.remove(0, doc.getLength());
        doc.insertString(0, testString, null);
        StringBuilder result;
        try (DocumentReader reader = new DocumentReader(doc)) {
          result = new StringBuilder(testString.length());
          for (int i = 0; i < 10; i++) {
            int r = generator.nextInt(doc.getLength());
            int l = generator.nextInt(doc.getLength() - r);
            if (i % 2 == 0) {
              doc.remove(r, l);
            } else {
              String s =
                  Strings.generateRandomString(generator.nextInt(100),
                      generator);
              doc.insertString(r, s, null);
            }
          }
          {
            int l = (int) (testString.length() * generator.nextDouble() / 2f);
            char[] cbuf = new char[l];
            int read = reader.read(cbuf, 0, cbuf.length);
            if (read > 0) {
              result.append(cbuf, 0, read);
            }
          }
          for (int i = 0; i < 10; i++) {
            int r = generator.nextInt(doc.getLength());
            int l = generator.nextInt(doc.getLength() - r);
            if (i % 2 == 0) {
              doc.remove(r, l);
            } else {
              String s =
                  Strings.generateRandomString(generator.nextInt(100),
                      generator);
              doc.insertString(r, s, null);
            }
          }
          while (true) {
            char[] cbuf = new char[1024];
            int read = reader.read(cbuf, 0, cbuf.length);
            if (read < 0) {
              break;
            }
            result.append(cbuf, 0, read);
          }
View Full Code Here

TOP

Related Classes of org.jamesii.gui.syntaxeditor.DocumentReader

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.